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, part 6
Date: Mon, 09 Dec 2002 10:26:00 -0000	[thread overview]
Message-ID: <15860.52905.66816.48498@localhost.redhat.com> (raw)
In-Reply-To: <ro1ptsg0zj0.fsf@jackfruit.Stanford.EDU>

David Carlton writes:
 > Here's the next part of the exciting linespec series of patches.  This
 > one factors out the code dealing with filenames into a function
 > symtab_from_filename.  (And it gets rid of a few register
 > declarations, but never mind that.)
 > 
 > I didn't change the code when I extracted it, so the only thing to be
 > careful about is uses of variables.  The code that I extracted does
 > modify 'p', but 'p' isn't referenced again in decode_line_1 until the
 > code following the comment starting with "Arg token is not digits";
 > and every branch of the conditional following that comment resets 'p'
 > from scratch.  Similarly, the code that I extracted modifies 'copy',
 > but one can easily check that the value of 'copy' is reset later.
 > 

Ok.

Elena


 > David Carlton
 > carlton@math.stanford.edu
 > 
 > 2002-12-05  David Carlton  <carlton@math.stanford.edu>
 > 
 > 	* linespec.c (symtab_from_filename): New function.
 > 	(decode_line_1): Move code into symtab_from_filename.
 > 
 > Index: linespec.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/linespec.c,v
 > retrieving revision 1.30
 > diff -u -p -r1.30 linespec.c
 > --- linespec.c	5 Dec 2002 22:25:49 -0000	1.30
 > +++ linespec.c	6 Dec 2002 00:15:06 -0000
 > @@ -70,6 +70,9 @@ static char *find_toplevel_char (char *s
 >  static struct symtabs_and_lines decode_line_2 (struct symbol *[],
 >  					       int, int, char ***);
 >  
 > +static struct symtab *symtab_from_filename (char **argptr,
 > +					    char *p, int is_quote_enclosed);
 > +
 >  static struct
 >  symtabs_and_lines symbol_found (int funfirstline,
 >  				char ***canonical,
 > @@ -539,15 +542,15 @@ decode_line_1 (char **argptr, int funfir
 >  {
 >    struct symtabs_and_lines values;
 >    struct symtab_and_line val;
 > -  register char *p, *p1;
 > +  char *p;
 >    char *q;
 > -  register struct symtab *s = NULL;
 > +  struct symtab *s = NULL;
 >  
 > -  register struct symbol *sym;
 > +  struct symbol *sym;
 >    /* The symtab that SYM was found in.  */
 >    struct symtab *sym_symtab;
 >  
 > -  register struct minimal_symbol *msymbol;
 > +  struct minimal_symbol *msymbol;
 >    char *copy;
 >    /* This is NULL if there are no parens in *ARGPTR, or a pointer to
 >       the closing parenthesis if there are parens.  */
 > @@ -591,40 +594,17 @@ decode_line_1 (char **argptr, int funfir
 >      {
 >        if (is_quoted)
 >  	*argptr = *argptr + 1;
 > +      
 > +      /* Is it a C++ or Java compound data structure?  */
 > +
 >        if (p[0] == '.' || p[1] == ':')
 > -	/*  C++ */
 > -	/*  ... or Java */
 >  	return decode_compound (argptr, funfirstline, canonical,
 >  				saved_arg, p);
 >  
 > -      /* Extract the file name.  */
 > -      p1 = p;
 > -      while (p != *argptr && p[-1] == ' ')
 > -	--p;
 > -      if ((*p == '"') && is_quote_enclosed)
 > -	--p;
 > -      copy = (char *) alloca (p - *argptr + 1);
 > -      memcpy (copy, *argptr, p - *argptr);
 > -      /* It may have the ending quote right after the file name */
 > -      if (is_quote_enclosed && copy[p - *argptr - 1] == '"')
 > -	copy[p - *argptr - 1] = 0;
 > -      else
 > -	copy[p - *argptr] = 0;
 > -
 > -      /* Find that file's data.  */
 > -      s = lookup_symtab (copy);
 > -      if (s == 0)
 > -	{
 > -	  if (!have_full_symbols () && !have_partial_symbols ())
 > -	    error ("No symbol table is loaded.  Use the \"file\" command.");
 > -	  error ("No source file named %s.", copy);
 > -	}
 > +      /* No, the first part is a filename; set s to be that file's
 > +	 symtab.  Also, move argptr past the filename.  */
 >  
 > -      /* Discard the file name from the arg.  */
 > -      p = p1 + 1;
 > -      while (*p == ' ' || *p == '\t')
 > -	p++;
 > -      *argptr = p;
 > +      s = symtab_from_filename (argptr, p, is_quote_enclosed);
 >      }
 >  #if 0
 >    /* No one really seems to know why this was added. It certainly
 > @@ -1317,6 +1297,50 @@ decode_compound (char **argptr, int funf
 >  		   "Can't find member of namespace, class, struct, or union named \"%s\"\n",
 >  		   copy);
 >  }
 > +
 > +\f
 > +
 > +/* Return the symtab associated to the filename given by the substring
 > +   of *ARGPTR ending at P, and advance ARGPTR past that filename.  */
 > +
 > +static struct symtab *
 > +symtab_from_filename (char **argptr, char *p, int is_quote_enclosed)
 > +{
 > +  char *p1;
 > +  char *copy;
 > +  struct symtab *s;
 > +  
 > +  p1 = p;
 > +  while (p != *argptr && p[-1] == ' ')
 > +    --p;
 > +  if ((*p == '"') && is_quote_enclosed)
 > +    --p;
 > +  copy = (char *) alloca (p - *argptr + 1);
 > +  memcpy (copy, *argptr, p - *argptr);
 > +  /* It may have the ending quote right after the file name */
 > +  if (is_quote_enclosed && copy[p - *argptr - 1] == '"')
 > +    copy[p - *argptr - 1] = 0;
 > +  else
 > +    copy[p - *argptr] = 0;
 > +
 > +  /* Find that file's data.  */
 > +  s = lookup_symtab (copy);
 > +  if (s == 0)
 > +    {
 > +      if (!have_full_symbols () && !have_partial_symbols ())
 > +	error ("No symbol table is loaded.  Use the \"file\" command.");
 > +      error ("No source file named %s.", copy);
 > +    }
 > +
 > +  /* Discard the file name from the arg.  */
 > +  p = p1 + 1;
 > +  while (*p == ' ' || *p == '\t')
 > +    p++;
 > +  *argptr = p;
 > +
 > +  return s;
 > +}
 > +
 >  
 >  \f
 >  


  reply	other threads:[~2002-12-09 18:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-05 16:26 David Carlton
2002-12-09 10:26 ` Elena Zannoni [this message]
2002-12-09 11:59   ` 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=15860.52905.66816.48498@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