Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Elena Zannoni <ezannoni@redhat.com>
To: David Carlton <carlton@math.stanford.edu>
Cc: gdb-patches@sources.redhat.com, Elena Zannoni <ezannoni@redhat.com>
Subject: Re: [rfa] linespec.c: lookup_prefix_sym
Date: Tue, 04 Feb 2003 17:46:00 -0000	[thread overview]
Message-ID: <15935.64848.617116.327755@localhost.redhat.com> (raw)
In-Reply-To: <ro1bs2i6od8.fsf@jackfruit.Stanford.EDU>

David Carlton writes:
 > Now I'm starting to decompose decode_compound into pieces.  Here's the
 > first one: this creates a new function lookup_prefix_sym.
 > 
 > It's pretty straightforward: it doesn't change the code at all.  The
 > only delicate issue is to make sure that decode_compound doesn't need
 > the values of 'p' and 'copy' after the call, since lookup_prefix_sym
 > changes them.  The other uses of both variables lie in two situations:
 > if the big "if (sym_class && ...)" branch is taken, and if it isn't.
 > 
 > If the branch is taken, then p is reset immediately (to either
 > skip_quoted (*argptr) or *argptr).  And 'copy' is reset right after
 > that, in the code that follows the commented-out bit.  (Despite the
 > presence of braces, that code is commented out: those braces are there
 > because it was originally the else clause of a commented-out
 > conditional.)
 > 
 > And if the branch isn't taken, then p is reset immediately as well.
 > And the only use of copy outside the branch is right at the end of the
 > function, and copy is reset there as well.
 > 
 > Tested on i686-pc-linux-gnu/GCC3.1/DWARF-2; OK to commit?
 > 

OK.

elena


 > David Carlton
 > carlton@math.stanford.edu
 > 
 > 2003-01-15  David Carlton  <carlton@math.stanford.edu>
 > 
 > 	* linespec.c (decode_compound): Extract code into
 > 	lookup_prefix_sym.
 > 	(lookup_prefix_sym): New function.
 > 
 > Index: linespec.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/linespec.c,v
 > retrieving revision 1.38
 > diff -u -p -r1.38 linespec.c
 > --- linespec.c	14 Jan 2003 20:48:50 -0000	1.38
 > +++ linespec.c	15 Jan 2003 22:16:07 -0000
 > @@ -54,6 +54,8 @@ static struct symtabs_and_lines decode_c
 >  						 char *saved_arg,
 >  						 char *p);
 >  
 > +static struct symbol *lookup_prefix_sym (char **argptr, char *p);
 > +
 >  static NORETURN void cplusplus_error (const char *name,
 >  				      const char *fmt, ...)
 >       ATTR_NORETURN ATTR_FORMAT (printf, 2, 3);
 > @@ -930,7 +932,7 @@ decode_compound (char **argptr, int funf
 >  		 char *saved_arg, char *p)
 >  {
 >    struct symtabs_and_lines values;
 > -  char *p1, *p2;
 > +  char *p2;
 >  #if 0
 >    char *q, *q1;
 >  #endif
 > @@ -975,22 +977,7 @@ decode_compound (char **argptr, int funf
 >    p2 = p;		/* Save for restart.  */
 >    while (1)
 >      {
 > -      /* Extract the class name.  */
 > -      p1 = p;
 > -      while (p != *argptr && p[-1] == ' ')
 > -	--p;
 > -      copy = (char *) alloca (p - *argptr + 1);
 > -      memcpy (copy, *argptr, p - *argptr);
 > -      copy[p - *argptr] = 0;
 > -
 > -      /* Discard the class name from the arg.  */
 > -      p = p1 + (p1[0] == ':' ? 2 : 1);
 > -      while (*p == ' ' || *p == '\t')
 > -	p++;
 > -      *argptr = p;
 > -
 > -      sym_class = lookup_symbol (copy, 0, STRUCT_NAMESPACE, 0,
 > -				 (struct symtab **) NULL);
 > +      sym_class = lookup_prefix_sym (argptr, p);
 >  
 >        if (sym_class &&
 >  	  (t = check_typedef (SYMBOL_TYPE (sym_class)),
 > @@ -1166,6 +1153,37 @@ decode_compound (char **argptr, int funf
 >    cplusplus_error (saved_arg,
 >  		   "Can't find member of namespace, class, struct, or union named \"%s\"\n",
 >  		   copy);
 > +}
 > +
 > +/* Next come some helper functions for decode_compound.  */
 > +
 > +/* Return the symbol corresponding to the substring of *ARGPTR ending
 > +   at P, allowing whitespace.  Also, advance *ARGPTR past the symbol
 > +   name in question, the compound object separator ("::" or "."), and
 > +   whitespace.  */
 > +
 > +static struct symbol *
 > +lookup_prefix_sym (char **argptr, char *p)
 > +{
 > +  char *p1;
 > +  char *copy;
 > +
 > +  /* Extract the class name.  */
 > +  p1 = p;
 > +  while (p != *argptr && p[-1] == ' ')
 > +    --p;
 > +  copy = (char *) alloca (p - *argptr + 1);
 > +  memcpy (copy, *argptr, p - *argptr);
 > +  copy[p - *argptr] = 0;
 > +
 > +  /* Discard the class name from the arg.  */
 > +  p = p1 + (p1[0] == ':' ? 2 : 1);
 > +  while (*p == ' ' || *p == '\t')
 > +    p++;
 > +  *argptr = p;
 > +
 > +  return lookup_symbol (copy, 0, STRUCT_NAMESPACE, 0,
 > +			(struct symtab **) NULL);
 >  }
 >  
 >  \f


  reply	other threads:[~2003-02-04 17:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-15 22:26 David Carlton
2003-02-04 17:46 ` Elena Zannoni [this message]
2003-02-04 21:25   ` David Carlton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15935.64848.617116.327755@localhost.redhat.com \
    --to=ezannoni@redhat.com \
    --cc=carlton@math.stanford.edu \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox