diff options
author | David Carlton <carlton@bactrian.org> | 2003-02-04 21:24:21 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2003-02-04 21:24:21 +0000 |
commit | 93d91629613637c599e9fd7e0d8f7f541af74ea1 (patch) | |
tree | 10dc64e43bae54d3045e3e20d3b8ecfacba921db /gdb/linespec.c | |
parent | 1c5cb38e90bd8955f5027f152b832675c2aa7922 (diff) | |
download | gdb-93d91629613637c599e9fd7e0d8f7f541af74ea1.zip gdb-93d91629613637c599e9fd7e0d8f7f541af74ea1.tar.gz gdb-93d91629613637c599e9fd7e0d8f7f541af74ea1.tar.bz2 |
2003-02-04 David Carlton <carlton@math.stanford.edu>
* linespec.c (decode_compound): Extract code into
lookup_prefix_sym.
(lookup_prefix_sym): New function.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r-- | gdb/linespec.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c index 37633cc..4b36d86 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -54,6 +54,8 @@ static struct symtabs_and_lines decode_compound (char **argptr, char *saved_arg, char *p); +static struct symbol *lookup_prefix_sym (char **argptr, char *p); + static NORETURN void cplusplus_error (const char *name, const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 2, 3); @@ -930,7 +932,7 @@ decode_compound (char **argptr, int funfirstline, char ***canonical, char *saved_arg, char *p) { struct symtabs_and_lines values; - char *p1, *p2; + char *p2; #if 0 char *q, *q1; #endif @@ -975,22 +977,7 @@ decode_compound (char **argptr, int funfirstline, char ***canonical, p2 = p; /* Save for restart. */ while (1) { - /* Extract the class name. */ - p1 = p; - while (p != *argptr && p[-1] == ' ') - --p; - copy = (char *) alloca (p - *argptr + 1); - memcpy (copy, *argptr, p - *argptr); - copy[p - *argptr] = 0; - - /* Discard the class name from the arg. */ - p = p1 + (p1[0] == ':' ? 2 : 1); - while (*p == ' ' || *p == '\t') - p++; - *argptr = p; - - sym_class = lookup_symbol (copy, 0, STRUCT_NAMESPACE, 0, - (struct symtab **) NULL); + sym_class = lookup_prefix_sym (argptr, p); if (sym_class && (t = check_typedef (SYMBOL_TYPE (sym_class)), @@ -1168,6 +1155,37 @@ decode_compound (char **argptr, int funfirstline, char ***canonical, copy); } +/* Next come some helper functions for decode_compound. */ + +/* Return the symbol corresponding to the substring of *ARGPTR ending + at P, allowing whitespace. Also, advance *ARGPTR past the symbol + name in question, the compound object separator ("::" or "."), and + whitespace. */ + +static struct symbol * +lookup_prefix_sym (char **argptr, char *p) +{ + char *p1; + char *copy; + + /* Extract the class name. */ + p1 = p; + while (p != *argptr && p[-1] == ' ') + --p; + copy = (char *) alloca (p - *argptr + 1); + memcpy (copy, *argptr, p - *argptr); + copy[p - *argptr] = 0; + + /* Discard the class name from the arg. */ + p = p1 + (p1[0] == ':' ? 2 : 1); + while (*p == ' ' || *p == '\t') + p++; + *argptr = p; + + return lookup_symbol (copy, 0, STRUCT_NAMESPACE, 0, + (struct symtab **) NULL); +} + /* Return the symtab associated to the filename given by the substring |