diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 20 | ||||
-rw-r--r-- | gdb/symfile.c | 13 | ||||
-rw-r--r-- | gdb/symtab.c | 90 |
3 files changed, 86 insertions, 37 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 340bc0e..dd1f8aa 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,23 @@ +2000-10-12 Elena Zannoni <ezannoni@kwikemart.cygnus.com> + + From Daniel Berlin <dberlin@redhat.com> : + + * symtab.c (lookup_symbol_aux): New function. Renamed from + lookup_symbol. Move code to do demangling/case sensitivity to + lookup_symbol(). + (lookup_symbol): Now wrapper for lookup_symbol_aux, so we can + perform case sensitivity/demangling without leaking memory. Move + code to do demangling/case sensitivity from old_lookup_symbol to + here. + (lookup_partial_symbol): Use SYMBOL_SOURCE_NAME instead of + SYMBOL_NAME. + (lookup_block_symbol): Use SYMBOL_SOURCE_NAME instead of + SYMBOL_NAME. Don't do linear search in case of C++. + + * symfile.c (compare_symbols): Use SYMBOL_SOURCE_NAME instead of + SYMBOL_NAME. + (compare_psymbols): Same here. + 2000-10-09 Kevin Buettner <kevinb@redhat.com> * remote-nindy.c (non_dle, nindy_xfer_inferior_memory): Protoize. diff --git a/gdb/symfile.c b/gdb/symfile.c index 5fc516b..02f0404 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -212,8 +212,7 @@ compare_symbols (const PTR s1p, const PTR s2p) s1 = (struct symbol **) s1p; s2 = (struct symbol **) s2p; - - return (STRCMP (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2))); + return (STRCMP (SYMBOL_SOURCE_NAME (*s1), SYMBOL_SOURCE_NAME (*s2))); } /* @@ -241,8 +240,14 @@ compare_symbols (const PTR s1p, const PTR s2p) static int compare_psymbols (const PTR s1p, const PTR s2p) { - register char *st1 = SYMBOL_NAME (*(struct partial_symbol **) s1p); - register char *st2 = SYMBOL_NAME (*(struct partial_symbol **) s2p); + register struct partial_symbol **s1, **s2; + register char *st1, *st2; + + s1 = (struct partial_symbol **) s1p; + s2 = (struct partial_symbol **) s2p; + st1 = SYMBOL_SOURCE_NAME (*s1); + st2 = SYMBOL_SOURCE_NAME (*s2); + if ((st1[0] - st2[0]) || !st1[0]) { diff --git a/gdb/symtab.c b/gdb/symtab.c index 4068fd0..3a97e10 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -83,6 +83,13 @@ static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *, static struct symtab *lookup_symtab_1 (char *); +static struct symbol *lookup_symbol_aux (const char *name, const + struct block *block, const + namespace_enum namespace, int + *is_a_field_of_this, struct + symtab **symtab); + + static void cplusplus_hint (char *); static struct symbol *find_active_alias (struct symbol *sym, CORE_ADDR addr); @@ -572,17 +579,14 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile) can probably assume it will never hit the C++ code). */ struct symbol * -lookup_symbol (const char *name, register const struct block *block, +lookup_symbol (const char *name, const struct block *block, const namespace_enum namespace, int *is_a_field_of_this, struct symtab **symtab) { - register struct symbol *sym; - register struct symtab *s = NULL; - register struct partial_symtab *ps; - struct blockvector *bv; - register struct objfile *objfile = NULL; - register struct block *b; - register struct minimal_symbol *msymbol; + char *modified_name = NULL; + char *modified_name2 = NULL; + int needtofreename = 0; + struct symbol *returnval; if (case_sensitivity == case_sensitive_off) { @@ -594,8 +598,44 @@ lookup_symbol (const char *name, register const struct block *block, for (i= 0; i < len; i++) copy[i] = tolower (name[i]); copy[len] = 0; - name = copy; + modified_name = copy; } + else + modified_name = (char *) name; + + /* If we are using C++ language, demangle the name before doing a lookup, so + we can always binary search. */ + if (current_language->la_language == language_cplus) + { + modified_name2 = cplus_demangle (modified_name, DMGL_ANSI | DMGL_PARAMS); + if (modified_name2) + { + modified_name = modified_name2; + needtofreename = 1; + } + } + + returnval = lookup_symbol_aux (modified_name, block, namespace, + is_a_field_of_this, symtab); + if (needtofreename) + free (modified_name2); + + return returnval; +} + +static struct symbol * +lookup_symbol_aux (const char *name, const struct block *block, + const namespace_enum namespace, int *is_a_field_of_this, + struct symtab **symtab) +{ + register struct symbol *sym; + register struct symtab *s = NULL; + register struct partial_symtab *ps; + register struct blockvector *bv; + register struct objfile *objfile = NULL; + register struct block *b; + register struct minimal_symbol *msymbol; + /* Search specified block and its superiors. */ @@ -987,7 +1027,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global, { do_linear_search = 1; } - if (STRCMP (SYMBOL_NAME (*center), name) >= 0) + if (STRCMP (SYMBOL_SOURCE_NAME (*center), name) >= 0) { top = center; } @@ -1190,9 +1230,7 @@ lookup_block_symbol (register const struct block *block, const char *name, { /* Reset the linear search flag so if the binary search fails, we won't do the linear search once unless we find some reason to - do so, such as finding a C++ symbol during the binary search. - Note that for C++ modules, ALL the symbols in a block should - end up marked as C++ symbols. */ + do so */ do_linear_search = 0; top = BLOCK_NSYMS (block); @@ -1210,22 +1248,19 @@ lookup_block_symbol (register const struct block *block, const char *name, } inc = (inc >> 1) + bot; sym = BLOCK_SYM (block, inc); - if (!do_linear_search - && (SYMBOL_LANGUAGE (sym) == language_cplus - || SYMBOL_LANGUAGE (sym) == language_java - )) + if (!do_linear_search && (SYMBOL_LANGUAGE (sym) == language_java)) { do_linear_search = 1; } - if (SYMBOL_NAME (sym)[0] < name[0]) + if (SYMBOL_SOURCE_NAME (sym)[0] < name[0]) { bot = inc; } - else if (SYMBOL_NAME (sym)[0] > name[0]) + else if (SYMBOL_SOURCE_NAME (sym)[0] > name[0]) { top = inc; } - else if (STRCMP (SYMBOL_NAME (sym), name) < 0) + else if (STRCMP (SYMBOL_SOURCE_NAME (sym), name) < 0) { bot = inc; } @@ -1247,19 +1282,8 @@ lookup_block_symbol (register const struct block *block, const char *name, while (bot < top) { sym = BLOCK_SYM (block, bot); - inc = SYMBOL_NAME (sym)[0] - name[0]; - if (inc == 0) - { - inc = STRCMP (SYMBOL_NAME (sym), name); - } - if (inc == 0 && SYMBOL_NAMESPACE (sym) == namespace) - { - return (sym); - } - if (inc > 0) - { - break; - } + if (SYMBOL_MATCHES_NAME (sym, name)) + return sym; bot++; } } |