diff options
author | David Carlton <carlton@bactrian.org> | 2003-03-07 00:31:46 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2003-03-07 00:31:46 +0000 |
commit | 0d4719c89d07c794b40714b03747f9685de97447 (patch) | |
tree | 5e32517c41180a30969d1c2cff66be2fca26464f | |
parent | ea00b6ec6bf5ed83e0c0310feaa6c6559ee7e84a (diff) | |
download | gdb-0d4719c89d07c794b40714b03747f9685de97447.zip gdb-0d4719c89d07c794b40714b03747f9685de97447.tar.gz gdb-0d4719c89d07c794b40714b03747f9685de97447.tar.bz2 |
2003-03-06 David Carlton <carlton@math.stanford.edu>
* minsyms.c (add_minsym_to_hash_table): Use SYMBOL_LINKAGE_NAME.
(add_minsym_to_demangled_hash_table): Use SYMBOL_NATURAL_NAME.
(build_minimal_symbol_hash_tables): Add all minsyms to demangled
hash table.
(install_minimal_symbols): Use SYMBOL_LINKAGE_NAME.
(find_solib_trampoline_target): Ditto.
(compare_minimal_symbols): Ditto.
(compact_minimal_symbols): Ditto.
* symtab.h (DEPRECATED_SYMBOL_MATCHES_NAME): Delete.
* minsyms.c (lookup_minimal_symbol_text): Replace use of
DEPRECATED_SYMBOL_MATCHES_NAME by strcmp on linkage name.
(lookup_minimal_symbol_solib_trampoline): Ditto.
* symtab.h: Declare lookup_minimal_symbol_linkage,
lookup_minimal_symbol_natural.
* minsyms.c (lookup_minimal_symbol_aux): New function.
(lookup_minimal_symbol_linkage): Ditto.
(lookup_minimal_symbol_natural): Ditto.
(lookup_minimal_symbol): Move body into
lookup_minimal_symbol_aux.
2003-03-06 David Carlton <carlton@math.stanford.edu>
* gdb.c++/templates.exp (do_tests): Make expressions for 'ptype
Bar' and 'ptype Qux' more generous.
-rw-r--r-- | gdb/ChangeLog | 22 | ||||
-rw-r--r-- | gdb/minsyms.c | 184 | ||||
-rw-r--r-- | gdb/symtab.h | 25 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.c++/templates.exp | 4 |
5 files changed, 154 insertions, 86 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5528bbd..2d29a27 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,25 @@ +2003-03-06 David Carlton <carlton@math.stanford.edu> + + * minsyms.c (add_minsym_to_hash_table): Use SYMBOL_LINKAGE_NAME. + (add_minsym_to_demangled_hash_table): Use SYMBOL_NATURAL_NAME. + (build_minimal_symbol_hash_tables): Add all minsyms to demangled + hash table. + (install_minimal_symbols): Use SYMBOL_LINKAGE_NAME. + (find_solib_trampoline_target): Ditto. + (compare_minimal_symbols): Ditto. + (compact_minimal_symbols): Ditto. + * symtab.h (DEPRECATED_SYMBOL_MATCHES_NAME): Delete. + * minsyms.c (lookup_minimal_symbol_text): Replace use of + DEPRECATED_SYMBOL_MATCHES_NAME by strcmp on linkage name. + (lookup_minimal_symbol_solib_trampoline): Ditto. + * symtab.h: Declare lookup_minimal_symbol_linkage, + lookup_minimal_symbol_natural. + * minsyms.c (lookup_minimal_symbol_aux): New function. + (lookup_minimal_symbol_linkage): Ditto. + (lookup_minimal_symbol_natural): Ditto. + (lookup_minimal_symbol): Move body into + lookup_minimal_symbol_aux. + 2003-03-05 Andrew Cagney <cagney@redhat.com> * d10v-tdep.c (struct frame_extra_info): Delete unused structure. diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 9216d86..cf35c0e 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -76,6 +76,11 @@ static int msym_bunch_index; static int msym_count; +static struct minimal_symbol *lookup_minimal_symbol_aux (const char *name, + int linkage, + const char *sfile, + struct objfile *objf); + /* Compute a hash code based using the same criteria as `strcmp_iw'. */ unsigned int @@ -113,7 +118,8 @@ add_minsym_to_hash_table (struct minimal_symbol *sym, { if (sym->hash_next == NULL) { - unsigned int hash = msymbol_hash (DEPRECATED_SYMBOL_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE; + unsigned int hash + = msymbol_hash (SYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE; sym->hash_next = table[hash]; table[hash] = sym; } @@ -123,11 +129,13 @@ add_minsym_to_hash_table (struct minimal_symbol *sym, TABLE. */ static void add_minsym_to_demangled_hash_table (struct minimal_symbol *sym, - struct minimal_symbol **table) + struct minimal_symbol **table) { if (sym->demangled_hash_next == NULL) { - unsigned int hash = msymbol_hash_iw (SYMBOL_DEMANGLED_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE; + unsigned int hash + = (msymbol_hash_iw (SYMBOL_NATURAL_NAME (sym)) + % MINIMAL_SYMBOL_HASH_SIZE); sym->demangled_hash_next = table[hash]; table[hash] = sym; } @@ -144,20 +152,66 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym, Note: One instance where there may be duplicate minimal symbols with the same name is when the symbol tables for a shared library and the symbol tables for an executable contain global symbols with the same - names (the dynamic linker deals with the duplication). */ + names (the dynamic linker deals with the duplication). + + This function first searches for matches via linkage names; if it + doesn't find a match there, it then searches via natural names. */ struct minimal_symbol * lookup_minimal_symbol (register const char *name, const char *sfile, struct objfile *objf) { + struct minimal_symbol *msymbol; + + msymbol = lookup_minimal_symbol_linkage (name, sfile, objf); + + if (msymbol != NULL) + return msymbol; + else + return lookup_minimal_symbol_natural (name, sfile, objf); +} + +/* Search for a minimal symbol via linkage names; args are as in + lookup_minimal_symbol. */ + +struct minimal_symbol * +lookup_minimal_symbol_linkage (const char *name, const char *sfile, + struct objfile *objf) +{ + return lookup_minimal_symbol_aux (name, 1, sfile, objf); +} + +/* Search for a minimal symbol via natural names; args are as in + lookup_minimal_symbol. */ + +struct minimal_symbol * +lookup_minimal_symbol_natural (const char *name, const char *sfile, + struct objfile *objf) +{ + return lookup_minimal_symbol_aux (name, 0, sfile, objf); +} + +/* Helper function for lookup_minimal_symbol and friends, which only + searches for matches via linkage names or natural names but not + both. Args are in lookup_minimal_symbol; if LINKAGE is non-zero, + search in linkage names, if zero, search in natural names. */ + +static struct minimal_symbol * +lookup_minimal_symbol_aux (const char *name, int linkage, + const char *sfile, struct objfile *objf) +{ struct objfile *objfile; struct minimal_symbol *msymbol; struct minimal_symbol *found_symbol = NULL; struct minimal_symbol *found_file_symbol = NULL; struct minimal_symbol *trampoline_symbol = NULL; - unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; - unsigned int dem_hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE; + unsigned int hash; + + if (linkage) + hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; + else + hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE; #ifdef SOFUN_ADDRESS_MAYBE_MISSING if (sfile != NULL) @@ -174,66 +228,61 @@ lookup_minimal_symbol (register const char *name, const char *sfile, { if (objf == NULL || objf == objfile) { - /* Do two passes: the first over the ordinary hash table, - and the second over the demangled hash table. */ - int pass; + if (linkage) + msymbol = objfile->msymbol_hash[hash]; + else + msymbol = objfile->msymbol_demangled_hash[hash]; - for (pass = 1; pass <= 2 && found_symbol == NULL; pass++) + while (msymbol != NULL && found_symbol == NULL) { - /* Select hash list according to pass. */ - if (pass == 1) - msymbol = objfile->msymbol_hash[hash]; - else - msymbol = objfile->msymbol_demangled_hash[dem_hash]; - - while (msymbol != NULL && found_symbol == NULL) + if (linkage + ? strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0 + : SYMBOL_MATCHES_NATURAL_NAME (msymbol, name)) { - if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name)) + switch (MSYMBOL_TYPE (msymbol)) { - switch (MSYMBOL_TYPE (msymbol)) - { - case mst_file_text: - case mst_file_data: - case mst_file_bss: + case mst_file_text: + case mst_file_data: + case mst_file_bss: #ifdef SOFUN_ADDRESS_MAYBE_MISSING - if (sfile == NULL || STREQ (msymbol->filename, sfile)) - found_file_symbol = msymbol; + if (sfile == NULL || STREQ (msymbol->filename, sfile)) + found_file_symbol = msymbol; #else - /* We have neither the ability nor the need to - deal with the SFILE parameter. If we find - more than one symbol, just return the latest - one (the user can't expect useful behavior in - that case). */ - found_file_symbol = msymbol; + /* We have neither the ability nor the need to + deal with the SFILE parameter. If we find + more than one symbol, just return the latest + one (the user can't expect useful behavior in + that case). */ + found_file_symbol = msymbol; #endif - break; - - case mst_solib_trampoline: - - /* If a trampoline symbol is found, we prefer to - keep looking for the *real* symbol. If the - actual symbol is not found, then we'll use the - trampoline entry. */ - if (trampoline_symbol == NULL) - trampoline_symbol = msymbol; - break; - - case mst_unknown: - default: - found_symbol = msymbol; - break; - } - } + break; + + case mst_solib_trampoline: - /* Find the next symbol on the hash chain. */ - if (pass == 1) - msymbol = msymbol->hash_next; - else - msymbol = msymbol->demangled_hash_next; + /* If a trampoline symbol is found, we prefer to + keep looking for the *real* symbol. If the + actual symbol is not found, then we'll use the + trampoline entry. */ + if (trampoline_symbol == NULL) + trampoline_symbol = msymbol; + break; + + case mst_unknown: + default: + found_symbol = msymbol; + break; + } } + + /* Find the next symbol on the hash chain. */ + if (linkage) + msymbol = msymbol->hash_next; + else + msymbol = msymbol->demangled_hash_next; } } } + /* External symbols are best. */ if (found_symbol) return found_symbol; @@ -288,7 +337,7 @@ lookup_minimal_symbol_text (register const char *name, const char *sfile, msymbol != NULL && found_symbol == NULL; msymbol = msymbol->hash_next) { - if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name) && + if (strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0 && (MSYMBOL_TYPE (msymbol) == mst_text || MSYMBOL_TYPE (msymbol) == mst_file_text)) { @@ -364,7 +413,7 @@ lookup_minimal_symbol_solib_trampoline (register const char *name, msymbol != NULL && found_symbol == NULL; msymbol = msymbol->hash_next) { - if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name) && + if (strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0 && MSYMBOL_TYPE (msymbol) == mst_solib_trampoline) return msymbol; } @@ -659,8 +708,8 @@ compare_minimal_symbols (const void *fn1p, const void *fn2p) else /* addrs are equal: sort by name */ { - char *name1 = DEPRECATED_SYMBOL_NAME (fn1); - char *name2 = DEPRECATED_SYMBOL_NAME (fn2); + char *name1 = SYMBOL_LINKAGE_NAME (fn1); + char *name2 = SYMBOL_LINKAGE_NAME (fn2); if (name1 && name2) /* both have names */ return strcmp (name1, name2); @@ -752,7 +801,8 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount, { if (SYMBOL_VALUE_ADDRESS (copyfrom) == SYMBOL_VALUE_ADDRESS ((copyfrom + 1)) && - (STREQ (DEPRECATED_SYMBOL_NAME (copyfrom), DEPRECATED_SYMBOL_NAME ((copyfrom + 1))))) + (STREQ (SYMBOL_LINKAGE_NAME (copyfrom), + SYMBOL_LINKAGE_NAME ((copyfrom + 1))))) { if (MSYMBOL_TYPE ((copyfrom + 1)) == mst_unknown) { @@ -795,9 +845,8 @@ build_minimal_symbol_hash_tables (struct objfile *objfile) add_minsym_to_hash_table (msym, objfile->msymbol_hash); msym->demangled_hash_next = 0; - if (SYMBOL_DEMANGLED_NAME (msym) != NULL) - add_minsym_to_demangled_hash_table (msym, - objfile->msymbol_demangled_hash); + add_minsym_to_demangled_hash_table (msym, + objfile->msymbol_demangled_hash); } } @@ -867,9 +916,9 @@ install_minimal_symbols (struct objfile *objfile) for (bindex = 0; bindex < msym_bunch_index; bindex++, mcount++) { msymbols[mcount] = bunch->contents[bindex]; - if (DEPRECATED_SYMBOL_NAME (&msymbols[mcount])[0] == leading_char) + if (SYMBOL_LINKAGE_NAME (&msymbols[mcount])[0] == leading_char) { - DEPRECATED_SYMBOL_NAME (&msymbols[mcount])++; + SYMBOL_LINKAGE_NAME (&msymbols[mcount])++; } } msym_bunch_index = BUNCH_SIZE; @@ -898,7 +947,7 @@ install_minimal_symbols (struct objfile *objfile) symbol count does *not* include this null symbol, which is why it is indexed by mcount and not mcount-1. */ - DEPRECATED_SYMBOL_NAME (&msymbols[mcount]) = NULL; + SYMBOL_LINKAGE_NAME (&msymbols[mcount]) = NULL; SYMBOL_VALUE_ADDRESS (&msymbols[mcount]) = 0; MSYMBOL_INFO (&msymbols[mcount]) = NULL; MSYMBOL_TYPE (&msymbols[mcount]) = mst_unknown; @@ -918,7 +967,7 @@ install_minimal_symbols (struct objfile *objfile) for (i = 0; i < mcount; i++) { - const char *name = DEPRECATED_SYMBOL_NAME (&objfile->msymbols[i]); + const char *name = SYMBOL_LINKAGE_NAME (&objfile->msymbols[i]); if (name[0] == '_' && name[1] == 'Z') { set_cp_abi_as_auto_default ("gnu-v3"); @@ -981,7 +1030,8 @@ find_solib_trampoline_target (CORE_ADDR pc) ALL_MSYMBOLS (objfile, msymbol) { if (MSYMBOL_TYPE (msymbol) == mst_text - && STREQ (DEPRECATED_SYMBOL_NAME (msymbol), DEPRECATED_SYMBOL_NAME (tsymbol))) + && STREQ (SYMBOL_LINKAGE_NAME (msymbol), + SYMBOL_LINKAGE_NAME (tsymbol))) return SYMBOL_VALUE_ADDRESS (msymbol); } } diff --git a/gdb/symtab.h b/gdb/symtab.h index ace4f34..9c784a7 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -211,23 +211,6 @@ extern const char *symbol_demangled_name (const struct general_symbol_info #define SYMBOL_PRINT_NAME(symbol) \ (demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol)) -/* Macro that tests a symbol for a match against a specified name string. - First test the unencoded name, then looks for and test a C++ encoded - name if it exists. Note that whitespace is ignored while attempting to - match a C++ encoded name, so that "foo::bar(int,long)" is the same as - "foo :: bar (int, long)". - Evaluates to zero if the match fails, or nonzero if it succeeds. */ - -/* FIXME: carlton/2003-02-27: This is an unholy mixture of linkage - names and natural names. If you want to test the linkage names - with strcmp, do that. If you want to test the natural names with - strcmp_iw, use SYMBOL_MATCHES_NATURAL_NAME. */ - -#define DEPRECATED_SYMBOL_MATCHES_NAME(symbol, name) \ - (STREQ (DEPRECATED_SYMBOL_NAME (symbol), (name)) \ - || (SYMBOL_DEMANGLED_NAME (symbol) != NULL \ - && strcmp_iw (SYMBOL_DEMANGLED_NAME (symbol), (name)) == 0)) - /* Macro that tests a symbol for a match against a specified name string. It tests against SYMBOL_NATURAL_NAME, and it ignores whitespace and trailing parentheses. (See strcmp_iw for details @@ -1141,6 +1124,14 @@ extern struct minimal_symbol *lookup_minimal_symbol (const char *, const char *, struct objfile *); +extern struct minimal_symbol *lookup_minimal_symbol_linkage (const char *, + const char *, + struct objfile *); + +extern struct minimal_symbol *lookup_minimal_symbol_natural (const char *, + const char *, + struct objfile *); + extern struct minimal_symbol *lookup_minimal_symbol_text (const char *, const char *, struct objfile *); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4c46ecb..1bc95db 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-03-06 David Carlton <carlton@math.stanford.edu> + + * gdb.c++/templates.exp (do_tests): Make expressions for 'ptype + Bar' and 'ptype Qux' more generous. + 2003-03-04 David Carlton <carlton@math.stanford.edu> * gdb.c++/templates.exp (do_tests): Accept valid const in "print diff --git a/gdb/testsuite/gdb.c++/templates.exp b/gdb/testsuite/gdb.c++/templates.exp index bee78a9..9bef50c 100644 --- a/gdb/testsuite/gdb.c++/templates.exp +++ b/gdb/testsuite/gdb.c++/templates.exp @@ -353,7 +353,7 @@ send_gdb "ptype Bar\n" gdb_expect { -re "type = template <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)1>\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)33>\r\n$gdb_prompt $" { pass "ptype Bar" } -re "type = <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Bar" } - -re "ptype Bar\r\ntype = class Bar<int,33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $" + -re "ptype Bar\r\ntype = class Bar<int, ?33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $" { # GCC 3.1, DWARF-2 output. kfail "gdb/57" "ptype Bar" } -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $" @@ -461,7 +461,7 @@ send_gdb "ptype Spec\n" gdb_expect { -re "type = template <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Spec<int,int \\*>\r\n\[ \t\]*(class |)Spec<int,char>\r\n$gdb_prompt $" { pass "ptype Spec" } -re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Spec" } - -re "type = class Spec<int,char> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(char\\);\r\n}\r\n$gdb_prompt $" + -re "type = class Spec<int, ?char> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(char\\);\r\n}\r\n$gdb_prompt $" { # GCC 3.1, DWARF-2 output. kfail "gdb/57" "ptype Spec" } -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $" |