diff options
-rw-r--r-- | gdb/ChangeLog | 14 | ||||
-rw-r--r-- | gdb/Makefile.in | 2 | ||||
-rw-r--r-- | gdb/cp-namespace.c | 57 | ||||
-rw-r--r-- | gdb/cp-support.h | 2 | ||||
-rw-r--r-- | gdb/symtab.c | 29 | ||||
-rw-r--r-- | gdb/symtab.h | 2 |
6 files changed, 98 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c03b174..840d982 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,19 @@ 2003-05-23 David Carlton <carlton@bactrian.org> + * Makefile.in (cp-namespace.o): Depend on frame_h. + * cp-support.h: Declare lookup_transparent_type_namespace, + lookup_transparent_type_namespace_loop. + * cp-namespace.c: Include frame.h. + (lookup_transparent_type_namespace): New. + (lookup_transparent_type_namespace_loop): New. + * symtab.h: Declare lookup_transparent_type_aux. + * symtab.c (lookup_transparent_type): Add FIXME, fork off code + into lookup_transparent_type_aux, do backup strategy of trying to + look in namespaces. + (lookup_transparent_type_aux): New. + +2003-05-23 David Carlton <carlton@bactrian.org> + * Merge with mainline; tag is carlton_dictionary-20030523-merge. 2003-05-22 Ian Lance Taylor <ian@airs.com> diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 47113a2..ca721d7 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1625,7 +1625,7 @@ cp-abi.o: cp-abi.c $(defs_h) $(value_h) $(cp_abi_h) $(command_h) \ $(gdbcmd_h) $(ui_out_h) $(gdb_string_h) cp-namespace.o: cp-namespace.c $(defs_h) $(cp_support_h) $(gdb_obstack_h) \ $(symtab_h) $(symfile_h) $(gdb_assert_h) $(block_h) $(objfiles_h) \ - $(gdbtypes_h) $(dictionary_h) $(gdbcmd_h) + $(gdbtypes_h) $(dictionary_h) $(gdbcmd_h) $(frame_h) cp-support.o: cp-support.c $(defs_h) $(cp_support_h) $(gdb_string_h) \ $(demangle_h) $(gdb_assert_h) $(symtab_h) $(gdbcmd_h) cp-valprint.o: cp-valprint.c $(defs_h) $(gdb_obstack_h) $(symtab_h) \ diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 63af14a..0f04f14 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -31,6 +31,7 @@ #include "gdbtypes.h" #include "dictionary.h" #include "gdbcmd.h" +#include "frame.h" /* When set, the file that we're processing seems to have debugging info for C++ namespaces, so cp-namespace.c shouldn't try to guess @@ -71,6 +72,10 @@ static struct symbol *lookup_symbol_file (const char *name, struct symtab **symtab, int anonymous_namespace); +static struct type *lookup_transparent_type_namespace_loop (const char *name, + const char *scope, + int scope_len); + /* This block exists only to store symbols associated to namespaces. Normally, try to avoid accessing it directly: instead, use get_namespace_block if you can. Similarly with @@ -521,6 +526,58 @@ lookup_symbol_file (const char *name, return NULL; } +/* Try to look up the type definition associated to NAME if honest + methods don't work: look for NAME in the classes/namespaces that + are currently active, on the off chance that it might be there. */ + +struct type * +lookup_transparent_type_namespace (const char *name) +{ + const char *scope = block_scope (get_selected_block (0)); + + if (strstr (scope, "::") == NULL) + return NULL; + + return lookup_transparent_type_namespace_loop (name, scope, 0); +} + +/* Lookup the the type definition associated to NAME in + namespaces/classes containing SCOPE other than the global + namespace. */ + +static struct type * +lookup_transparent_type_namespace_loop (const char *name, const char *scope, + int scope_len) +{ + int new_scope_len = scope_len; + char *full_name; + + /* If the current scope is followed by "::", skip past that. */ + if (new_scope_len != 0) + new_scope_len += 2; + new_scope_len += cp_find_first_component (scope + new_scope_len); + + if (scope[new_scope_len] == ':') + { + struct type *retval + = lookup_transparent_type_namespace_loop (name, scope, new_scope_len); + if (retval != NULL) + return retval; + } + + /* If there's no enclosing scope, lookup_transparent_type would have + found it. */ + if (scope_len == 0) + return NULL; + + full_name = alloca (scope_len + 2 + strlen (name) + 1); + strncpy (full_name, scope, scope_len); + strncpy (full_name + scope_len, "::", 2); + strcpy (full_name + scope_len + 2, name); + + return lookup_transparent_type_aux (full_name); +} + /* Allocate everything necessary for namespace_block and possible_namespace_block. */ diff --git a/gdb/cp-support.h b/gdb/cp-support.h index 3401828..7423872 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -104,6 +104,8 @@ extern struct symbol *cp_lookup_symbol_namespace (const char *namespace, const domain_enum domain, struct symtab **symtab); +struct type *lookup_transparent_type_namespace (const char *name); + /* The list of "maint cplus" commands. */ extern struct cmd_list_element *maint_cplus_cmd_list; diff --git a/gdb/symtab.c b/gdb/symtab.c index 42bd140..d8eed35 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1604,9 +1604,29 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, name of the type in question, so this doesn't have to get any smarter about namespace stuff. */ +/* FIXME: carlton/2003-05-23: No, sometimes, unfortunately, the name + is wrong. This function gets called when the the type in question + is a declaration; in that situation, our type name deduction + machinery doesn't work, so if the type is declared in a namespace + and GCC isn't giving us namespace debug info, we're screwed. Sigh. + There's nothing we can do to fix this in general, I think. */ + struct type * lookup_transparent_type (const char *name) { + struct type *retval = lookup_transparent_type_aux (name); + + if (retval != NULL) + return retval; + else + /* See above FIXME comment: with proper debug info, this should + never be necessary (or even desirable). */ + return lookup_transparent_type_namespace (name); +} + +struct type * +lookup_transparent_type_aux (const char *name) +{ register struct symbol *sym; register struct symtab *s = NULL; register struct partial_symtab *ps; @@ -1649,9 +1669,7 @@ lookup_transparent_type (const char *name) block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN); if (!sym) - error ("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\ -%s may be an inlined function, or may be a template function\n\ -(if a template, try specifying an instantiation: %s<type>).", + error ("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s<type>).", name, ps->filename, name, name); } if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym))) @@ -1696,9 +1714,7 @@ lookup_transparent_type (const char *name) block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN); if (!sym) - error ("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\ -%s may be an inlined function, or may be a template function\n\ -(if a template, try specifying an instantiation: %s<type>).", + error ("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s<type>).", name, ps->filename, name, name); } if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym))) @@ -1708,7 +1724,6 @@ lookup_transparent_type (const char *name) return (struct type *) 0; } - /* Find the psymtab containing main(). */ /* FIXME: What about languages without main() or specially linked executables that have no main() ? */ diff --git a/gdb/symtab.h b/gdb/symtab.h index d83add3..42d42f2 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1123,6 +1123,8 @@ extern void reread_symbols (void); extern struct type *lookup_transparent_type (const char *); +extern struct type *lookup_transparent_type_aux (const char *name); + /* Macro for name of symbol to indicate a file compiled with gcc. */ #ifndef GCC_COMPILED_FLAG_SYMBOL |