This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Monday 21 August 2006 21:35, Daniel Jacobowitz wrote: > On Mon, Aug 21, 2006 at 09:32:29PM -0400, Mike Frysinger wrote: > > On Sunday 20 August 2006 09:57, Daniel Jacobowitz wrote: > > > As a followup, there are several better options: > > > > hmm, is there a spec somewhere that says what order symbols need to be > > resolved ? how about an alternative option: > > - in write_dollar_variable(), if the symbol starts with a '$', we first > > try to look it up via lookup_internalvar() ... if that fails, we fall > > back to lookup_symbol() and lookup_minimal_symbol() and then jump back to > > the lookup_internalvar() ... > > Hmm... that's also an interesting option. I have no opinion. here's a stab at it then ... i'm sure others have better ideas :) -mike
Attachment:
pgp00000.pgp
Description: PGP signature
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. --- gdb/value.h +++ gdb/value.h @@ -419,6 +419,8 @@ extern void set_internalvar_component (s int bitpos, int bitsize, struct value *newvalue); +extern struct internalvar *lookup_only_internalvar (char *name); + extern struct internalvar *lookup_internalvar (char *name); extern int value_equal (struct value *arg1, struct value *arg2); --- gdb/value.c +++ gdb/value.c @@ -741,10 +741,10 @@ init_if_undefined_command (char* args, i normally include a dollar sign. If the specified internal variable does not exist, - one is created, with a void value. */ + the return value is NULL. */ struct internalvar * -lookup_internalvar (char *name) +lookup_only_internalvar (char *name) { struct internalvar *var; @@ -752,6 +752,25 @@ lookup_internalvar (char *name) if (strcmp (var->name, name) == 0) return var; + return NULL; +} + + +/* Look up an internal variable with name NAME. NAME should not + normally include a dollar sign. + + If the specified internal variable does not exist, + one is created, with a void value. */ + +struct internalvar * +lookup_internalvar (char *name) +{ + struct internalvar *var; + + var = lookup_only_internalvar (name); + if (var) + return var; + var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); var->name = concat (name, (char *)NULL); var->value = allocate_value (builtin_type_void); --- 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; + } + /* On some systems, such as HP-UX and hppa-linux, certain system routines have names beginning with $ or $$. Check for those, first. */ @@ -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; handle_last: write_exp_elt_opcode (OP_LAST); write_exp_elt_longcst ((LONGEST) i);
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |