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