[patch ping] change lookup order of $localvars to happen before symbol tables
Daniel Jacobowitz
drow@false.org
Sat Sep 16 04:02:00 GMT 2006
Sorry, I'm way behind on patches, and it seems others don't have
much time for review either.
On Thu, Sep 14, 2006 at 01:00:54AM -0400, Mike Frysinger wrote:
> 2006-08-21 Mike Frysinger <vapier@gentoo.org>
>
> * value.h (lookup_only_internalvar): New prototype.
> * value.c (lookup_only_internalvar): New function.
> (lookup_internalvar): Use lookup_only_internalvar.
> * parse.c (write_dollar_variable): Look up $ symbols in internal
> table first rather than last.
I think this approach is basically OK. Minor comments on the
patch:
> --- gdb/parse.c
> +++ gdb/parse.c
> @@ -486,6 +486,17 @@ write_dollar_variable (struct stoken str
> if (i >= 0)
> goto handle_register;
>
> + /* Any names starting with $ are probably debugger internal variables. */
> +
> + if (str.ptr[0] == '$' && lookup_only_internalvar (copy_name (str) + 1))
> + {
> +internal_lookup:
> + write_exp_elt_opcode (OP_INTERNALVAR);
> + write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1));
> + write_exp_elt_opcode (OP_INTERNALVAR);
> + return;
> + }
You don't need to check ptr[0]; this is write_dollar_variable, if it
didn't start with a dollar sign we wouldn't be here :-)
Scanning the list of internal variables is linear. Let's not be
wasteful with it; please save the result the first time you do it.
> @@ -508,12 +519,9 @@ write_dollar_variable (struct stoken str
> return;
> }
>
> - /* Any other names starting in $ are debugger internal variables. */
> -
> - write_exp_elt_opcode (OP_INTERNALVAR);
> - write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1));
> - write_exp_elt_opcode (OP_INTERNALVAR);
> - return;
> + /* Any other names are assumed to be debugger internal variables. */
> +
> + goto internal_lookup;
Let's avoid goto, please, since it's only three lines. We're going
to rescan the internal variable list here, but we don't much care.
Would you mind resubmitting with those changes?
--
Daniel Jacobowitz
CodeSourcery
More information about the Gdb-patches
mailing list