scummvm random work
[patches.git] / gdb-lookup-internal-first-2.patch
1 2006-08-21 Mike Frysinger <vapier@gentoo.org>
2
3 * value.h (lookup_only_internalvar): New prototype.
4 * value.c (lookup_only_internalvar): New function.
5 (lookup_internalvar): Use lookup_only_internalvar.
6 * parse.c (write_dollar_variable): Look up $ symbols in internal
7 table first rather than last.
8
9 --- gdb/value.h
10 +++ gdb/value.h
11 @@ -419,6 +419,8 @@ extern void set_internalvar_component (s
12 int bitpos, int bitsize,
13 struct value *newvalue);
14
15 +extern struct internalvar *lookup_only_internalvar (char *name);
16 +
17 extern struct internalvar *lookup_internalvar (char *name);
18
19 extern int value_equal (struct value *arg1, struct value *arg2);
20 --- gdb/value.c
21 +++ gdb/value.c
22 @@ -741,10 +741,10 @@ init_if_undefined_command (char* args, i
23 normally include a dollar sign.
24
25 If the specified internal variable does not exist,
26 - one is created, with a void value. */
27 + the return value is NULL. */
28
29 struct internalvar *
30 -lookup_internalvar (char *name)
31 +lookup_only_internalvar (char *name)
32 {
33 struct internalvar *var;
34
35 @@ -752,6 +752,25 @@ lookup_internalvar (char *name)
36 if (strcmp (var->name, name) == 0)
37 return var;
38
39 + return NULL;
40 +}
41 +
42 +
43 +/* Look up an internal variable with name NAME. NAME should not
44 + normally include a dollar sign.
45 +
46 + If the specified internal variable does not exist,
47 + one is created, with a void value. */
48 +
49 +struct internalvar *
50 +lookup_internalvar (char *name)
51 +{
52 + struct internalvar *var;
53 +
54 + var = lookup_only_internalvar (name);
55 + if (var)
56 + return var;
57 +
58 var = (struct internalvar *) xmalloc (sizeof (struct internalvar));
59 var->name = concat (name, (char *)NULL);
60 var->value = allocate_value (builtin_type_void);
61 --- gdb/parse.c
62 +++ gdb/parse.c
63 @@ -448,6 +448,7 @@ write_dollar_variable (struct stoken str
64 {
65 struct symbol *sym = NULL;
66 struct minimal_symbol *msym = NULL;
67 + struct internalvar *isym = NULL;
68
69 /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
70 and $$digits (equivalent to $<-digits> if you could type that). */
71 @@ -486,6 +487,17 @@ write_dollar_variable (struct stoken str
72 if (i >= 0)
73 goto handle_register;
74
75 + /* Any names starting with $ are probably debugger internal variables. */
76 +
77 + isym = lookup_only_internalvar (copy_name (str) + 1);
78 + if (isym)
79 + {
80 + write_exp_elt_opcode (OP_INTERNALVAR);
81 + write_exp_elt_intern (isym);
82 + write_exp_elt_opcode (OP_INTERNALVAR);
83 + return;
84 + }
85 +
86 /* On some systems, such as HP-UX and hppa-linux, certain system routines
87 have names beginning with $ or $$. Check for those, first. */
88
89 @@ -508,7 +520,7 @@ write_dollar_variable (struct stoken str
90 return;
91 }
92
93 - /* Any other names starting in $ are debugger internal variables. */
94 + /* Any other names are assumed to be debugger internal variables. */
95
96 write_exp_elt_opcode (OP_INTERNALVAR);
97 write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1));