This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa] linespec.c: decode_variable
- From: Elena Zannoni <ezannoni at redhat dot com>
- To: David Carlton <carlton at math dot stanford dot edu>
- Cc: gdb-patches at sources dot redhat dot com, Elena Zannoni <ezannoni at redhat dot com>
- Date: Wed, 8 Jan 2003 09:27:24 -0500
- Subject: Re: [rfa] linespec.c: decode_variable
- References: <ro1adicfwcx.fsf@jackfruit.Stanford.EDU>
David Carlton writes:
> This is another simple patch: it collects the code at the end of
> decode_line_1 after the call to decode_dollar and moves it into a
> function decode_variable. No tricks anywhere.
>
> This is the last of the first round of patches to linespec.c; I'll
> send a separate e-mail saying what else remains to do (quite a lot),
> and in what order I'm suggesting to do it.
>
> Tested on i686-pc-linux-gnu/GCC 3.1/DWARF-2. OK to commit?
>
> David Carlton
> carlton@math.stanford.edu
>
> 2003-01-07 David Carlton <carlton@math.stanford.edu>
>
> * linespec.c (decode_line_1): Move code into decode_variable.
> (decode_variable): New function.
OK
Elena
>
> Index: linespec.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/linespec.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 linespec.c
> --- linespec.c 7 Jan 2003 17:05:49 -0000 1.33
> +++ linespec.c 7 Jan 2003 21:39:19 -0000
> @@ -87,6 +87,11 @@ static struct symtabs_and_lines decode_d
> char ***canonical,
> struct symtab *s);
>
> +static struct symtabs_and_lines decode_variable (char *copy,
> + int funfirstline,
> + char ***canonical,
> + struct symtab *s);
> +
> static struct
> symtabs_and_lines symbol_found (int funfirstline,
> char ***canonical,
> @@ -558,11 +563,6 @@ decode_line_1 (char **argptr, int funfir
> char *q;
> struct symtab *s = NULL;
>
> - struct symbol *sym;
> - /* The symtab that SYM was found in. */
> - struct symtab *sym_symtab;
> -
> - 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. */
> @@ -713,24 +713,7 @@ decode_line_1 (char **argptr, int funfir
> /* Look up that token as a variable.
> If file specified, use that file's per-file block to start with. */
>
> - sym = lookup_symbol (copy,
> - (s ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)
> - : get_selected_block (0)),
> - VAR_NAMESPACE, 0, &sym_symtab);
> -
> - if (sym != NULL)
> - return symbol_found (funfirstline, canonical, copy, sym, s, sym_symtab);
> -
> - msymbol = lookup_minimal_symbol (copy, NULL, NULL);
> -
> - if (msymbol != NULL)
> - return minsym_found (funfirstline, msymbol);
> -
> - if (!have_full_symbols () &&
> - !have_partial_symbols () && !have_minimal_symbols ())
> - error ("No symbol table is loaded. Use the \"file\" command.");
> -
> - error ("Function \"%s\" not defined.", copy);
> + return decode_variable (copy, funfirstline, canonical, s);
> }
>
>
> @@ -1386,6 +1369,42 @@ decode_dollar (char *copy, int funfirstl
>
> return values;
> }
> +
> +
> +
> +/* Decode a linespec that's a variable. If S is non-NULL,
> + look in that symtab's static variables first. */
> +
> +static struct symtabs_and_lines
> +decode_variable (char *copy, int funfirstline, char ***canonical,
> + struct symtab *s)
> +{
> + struct symbol *sym;
> + /* The symtab that SYM was found in. */
> + struct symtab *sym_symtab;
> +
> + struct minimal_symbol *msymbol;
> +
> + sym = lookup_symbol (copy,
> + (s ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)
> + : get_selected_block (0)),
> + VAR_NAMESPACE, 0, &sym_symtab);
> +
> + if (sym != NULL)
> + return symbol_found (funfirstline, canonical, copy, sym, s, sym_symtab);
> +
> + msymbol = lookup_minimal_symbol (copy, NULL, NULL);
> +
> + if (msymbol != NULL)
> + return minsym_found (funfirstline, msymbol);
> +
> + if (!have_full_symbols () &&
> + !have_partial_symbols () && !have_minimal_symbols ())
> + error ("No symbol table is loaded. Use the \"file\" command.");
> +
> + error ("Function \"%s\" not defined.", copy);
> +}
> +
>
>
>