scummvm random work
[patches.git] / gdb-lookup-internal-first.patch
CommitLineData
5e993f12 12006-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@@ -486,6 +486,17 @@ write_dollar_variable (struct stoken str
64 if (i >= 0)
65 goto handle_register;
66
67+ /* Any names starting with $ are probably debugger internal variables. */
68+
69+ if (str.ptr[0] == '$' && lookup_only_internalvar (copy_name (str) + 1))
70+ {
71+internal_lookup:
72+ write_exp_elt_opcode (OP_INTERNALVAR);
73+ write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1));
74+ write_exp_elt_opcode (OP_INTERNALVAR);
75+ return;
76+ }
77+
78 /* On some systems, such as HP-UX and hppa-linux, certain system routines
79 have names beginning with $ or $$. Check for those, first. */
80
81@@ -508,12 +519,9 @@ write_dollar_variable (struct stoken str
82 return;
83 }
84
85- /* Any other names starting in $ are debugger internal variables. */
86-
87- write_exp_elt_opcode (OP_INTERNALVAR);
88- write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1));
89- write_exp_elt_opcode (OP_INTERNALVAR);
90- return;
91+ /* Any other names are assumed to be debugger internal variables. */
92+
93+ goto internal_lookup;
94 handle_last:
95 write_exp_elt_opcode (OP_LAST);
96 write_exp_elt_longcst ((LONGEST) i);