diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 16 | ||||
-rw-r--r-- | gdb/ada-lang.c | 18 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 19 | ||||
-rw-r--r-- | gdb/symtab.c | 36 | ||||
-rw-r--r-- | gdb/symtab.h | 4 |
5 files changed, 62 insertions, 31 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0302842..7474370 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +2008-05-05 Aleksandar Ristovski <aristovski@qnx.com> + Joel Brobecker <brobecker@adacore.com> + + * ada-lang.c: Update throughout to use symbol_matches_domain + instead of matching the symbol domain explictly. + * dwarf2read.c (add_partial_symbol): Do not add new psym for + STRUCT_DOMAIN. Make sure you recognize c++ struct and java and ada + class as typedefs. See lookup_partial_symbol function. + (new_symbol): Similar to add_partial_symbol, do not create + symbol for the typedef. See lookup_block_symbol. + * symtab.c (symbol_matches_domain): New function, takes care + of dual meaning of STRUCT_DOMAIN symbol for c++, ada and java. + (lookup_partial_symbol): Use symbol_matches_domain to see if the + found psym domain matches the given domain. + (lookup_block_symbol): Likewise. + 2008-05-05 Vladimir Prus <vladimir@codesourcery.com> * top.c (command_line_handler_continuation): Remove. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3508a62..8206f94 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4177,7 +4177,8 @@ ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name, { struct partial_symbol *psym = start[i]; - if (SYMBOL_DOMAIN (psym) == namespace + if (symbol_matches_domain (SYMBOL_LANGUAGE (psym), + SYMBOL_DOMAIN (psym), namespace) && wild_match (name, name_len, SYMBOL_LINKAGE_NAME (psym))) return psym; } @@ -4211,7 +4212,8 @@ ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name, { struct partial_symbol *psym = start[i]; - if (SYMBOL_DOMAIN (psym) == namespace) + if (symbol_matches_domain (SYMBOL_LANGUAGE (psym), + SYMBOL_DOMAIN (psym), namespace)) { int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym), name_len); @@ -4254,7 +4256,8 @@ ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name, { struct partial_symbol *psym = start[i]; - if (SYMBOL_DOMAIN (psym) == namespace) + if (symbol_matches_domain (SYMBOL_LANGUAGE (psym), + SYMBOL_DOMAIN (psym), namespace)) { int cmp; @@ -5254,7 +5257,8 @@ ada_add_block_symbols (struct obstack *obstackp, struct symbol *sym; ALL_BLOCK_SYMBOLS (block, iter, sym) { - if (SYMBOL_DOMAIN (sym) == domain + if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), + SYMBOL_DOMAIN (sym), domain) && wild_match (name, name_len, SYMBOL_LINKAGE_NAME (sym))) { switch (SYMBOL_CLASS (sym)) @@ -5284,7 +5288,8 @@ ada_add_block_symbols (struct obstack *obstackp, { ALL_BLOCK_SYMBOLS (block, iter, sym) { - if (SYMBOL_DOMAIN (sym) == domain) + if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), + SYMBOL_DOMAIN (sym), domain)) { int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym), name_len); if (cmp == 0 @@ -5329,7 +5334,8 @@ ada_add_block_symbols (struct obstack *obstackp, ALL_BLOCK_SYMBOLS (block, iter, sym) { - if (SYMBOL_DOMAIN (sym) == domain) + if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), + SYMBOL_DOMAIN (sym), domain)) { int cmp; diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 1357178..4f1cb1e 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2066,16 +2066,6 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) : &objfile->static_psymbols, 0, (CORE_ADDR) 0, cu->language, objfile); - if (cu->language == language_cplus - || cu->language == language_java - || cu->language == language_ada) - { - /* For C++ and Java, these implicitly act as typedefs as well. */ - add_psymbol_to_list (actual_name, strlen (actual_name), - VAR_DOMAIN, LOC_TYPEDEF, - &objfile->global_psymbols, - 0, (CORE_ADDR) 0, cu->language, objfile); - } break; case DW_TAG_enumerator: add_psymbol_to_list (actual_name, strlen (actual_name), @@ -7565,23 +7555,16 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) /* The semantics of C++ state that "struct foo { ... }" also defines a typedef for "foo". A Java class declaration also - defines a typedef for the class. Synthesize a typedef symbol - so that "ptype foo" works as expected. */ + defines a typedef for the class. */ if (cu->language == language_cplus || cu->language == language_java || cu->language == language_ada) { - struct symbol *typedef_sym = (struct symbol *) - obstack_alloc (&objfile->objfile_obstack, - sizeof (struct symbol)); - *typedef_sym = *sym; - SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN; /* The symbol's name is already allocated along with this objfile, so we don't need to duplicate it for the type. */ if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_SEARCH_NAME (sym); - add_symbol_to_list (typedef_sym, list_to_add); } } break; diff --git a/gdb/symtab.c b/gdb/symtab.c index 6c16b95..3d4389e 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1650,6 +1650,26 @@ lookup_symbol_global (const char *name, domain, symtab); } +int +symbol_matches_domain (enum language symbol_language, + domain_enum symbol_domain, + domain_enum domain) +{ + /* For C++ "struct foo { ... }" also defines a typedef for "foo". + A Java class declaration also defines a typedef for the class. + Similarly, any Ada type declaration implicitly defines a typedef. */ + if (symbol_language == language_cplus + || symbol_language == language_java + || symbol_language == language_ada) + { + if ((domain == VAR_DOMAIN || domain == STRUCT_DOMAIN) + && symbol_domain == STRUCT_DOMAIN) + return 1; + } + /* For all other languages, strict match is required. */ + return (symbol_domain == domain); +} + /* Look, in partial_symtab PST, for symbol whose natural name is NAME. If LINKAGE_NAME is non-NULL, check in addition that the symbol's linkage name matches it. Check the global symbols if GLOBAL, the @@ -1714,10 +1734,9 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, ? strcmp (SYMBOL_LINKAGE_NAME (*top), linkage_name) == 0 : SYMBOL_MATCHES_SEARCH_NAME (*top,name))) { - if (SYMBOL_DOMAIN (*top) == domain) - { - return (*top); - } + if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), + SYMBOL_DOMAIN (*top), domain)) + return (*top); top++; } } @@ -1729,7 +1748,8 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, { for (psym = start; psym < start + length; psym++) { - if (domain == SYMBOL_DOMAIN (*psym)) + if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym), + SYMBOL_DOMAIN (*psym), domain)) { if (linkage_name != NULL ? strcmp (SYMBOL_LINKAGE_NAME (*psym), linkage_name) == 0 @@ -1914,7 +1934,8 @@ lookup_block_symbol (const struct block *block, const char *name, sym != NULL; sym = dict_iter_name_next (name, &iter)) { - if (SYMBOL_DOMAIN (sym) == domain + if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), + SYMBOL_DOMAIN (sym), domain) && (linkage_name != NULL ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1)) return sym; @@ -1935,7 +1956,8 @@ lookup_block_symbol (const struct block *block, const char *name, sym != NULL; sym = dict_iter_name_next (name, &iter)) { - if (SYMBOL_DOMAIN (sym) == domain + if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), + SYMBOL_DOMAIN (sym), domain) && (linkage_name != NULL ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1)) { diff --git a/gdb/symtab.h b/gdb/symtab.h index cfdd2a4..ef8cade 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -998,6 +998,10 @@ extern const char multiple_symbols_cancel[]; const char *multiple_symbols_select_mode (void); +int symbol_matches_domain (enum language symbol_language, + domain_enum symbol_domain, + domain_enum domain); + /* lookup a symbol table by source file name */ extern struct symtab *lookup_symtab (const char *); |