]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2003-05-23 David Carlton <carlton@bactrian.org>
authorDavid Carlton <carlton@bactrian.org>
Fri, 23 May 2003 22:28:54 +0000 (22:28 +0000)
committerDavid Carlton <carlton@bactrian.org>
Fri, 23 May 2003 22:28:54 +0000 (22:28 +0000)
* 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.

gdb/ChangeLog
gdb/Makefile.in
gdb/cp-namespace.c
gdb/cp-support.h
gdb/symtab.c
gdb/symtab.h

index c03b17444b72708b3a12ab3d09403879ae6c51bf..840d98270e4bb89572f2c1d3435a78506cf148b8 100644 (file)
@@ -1,3 +1,17 @@
+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.
index 47113a2d0c360cb6e322d87034d9db759b11785c..ca721d783b482df75c505e70f1b0952e52aeb73b 100644 (file)
@@ -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) \
index 63af14af5c252376ba86fca7ca8b9c1210a06d76..0f04f14d3d7db6b6fa4af14323a681a9b3780a6d 100644 (file)
@@ -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.  */
 
index 3401828bcc3f94c7ee919c5c5bc4ef6ea929e103..7423872ebfdb0b51fc7b7c8da29ce39c31f9d850 100644 (file)
@@ -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;
index 42bd140b301cc4fc6b66dd218bed457951914be3..d8eed3517d28fd8bb885d00db92eb5eb67dc6ee8 100644 (file)
@@ -1604,8 +1604,28 @@ 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;
@@ -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() ? */
index d83add3e84218a2a24bf6f8796642ea322663e1c..42d42f2204fc4fb56fbcdca4a0bad8481fbffdf3 100644 (file)
@@ -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