Partial fix for PR c++/1465.
Fix for PR c++/1377.
* cp-support.h (cp_lookup_rtti_type): New function.
* cp-support.c (cp_lookup_rtti_type): New function.
* gnu-v2-abi.c: Update copyright years.
(gnuv2_rtti_type): Call cp_lookup_rtti_type.
* gnu-v3-abi.c: Update copyright years.
(gnuv3_rtti_type): Call cp_lookup_rtti_type.
+2003-12-04 Michael Chastain <mec.gnu@mindspring.com>
+
+ Partial fix for PR c++/1465.
+ Fix for PR c++/1377.
+ * cp-support.h (cp_lookup_rtti_type): New function.
+ * cp-support.c (cp_lookup_rtti_type): New function.
+ * gnu-v2-abi.c: Update copyright years.
+ (gnuv2_rtti_type): Call cp_lookup_rtti_type.
+ * gnu-v3-abi.c: Update copyright years.
+ (gnuv3_rtti_type): Call cp_lookup_rtti_type.
+
2003-12-04 J. Brobecker <brobecker@gnat.com>
* stabsread.c (read_type): Save a reference to types that are defined
#include "symtab.h"
#include "block.h"
#include "complaints.h"
+#include "gdbtypes.h"
/* Functions related to demangled name parsing. */
return (sym_return_val);
}
+/* Lookup the rtti type for a class name. */
+
+struct type *
+cp_lookup_rtti_type (const char *name, struct block *block)
+{
+ struct symbol * rtti_sym;
+ struct type * rtti_type;
+
+ rtti_sym = lookup_symbol (name, block, STRUCT_DOMAIN, NULL, NULL);
+
+ if (rtti_sym == NULL)
+ {
+ warning ("RTTI symbol not found for class '%s'", name);
+ return NULL;
+ }
+
+ if (SYMBOL_CLASS (rtti_sym) != LOC_TYPEDEF)
+ {
+ warning ("RTTI symbol for class '%s' is not a type", name);
+ return NULL;
+ }
+
+ rtti_type = SYMBOL_TYPE (rtti_sym);
+
+ switch (TYPE_CODE (rtti_type))
+ {
+ case TYPE_CODE_CLASS:
+ break;
+ case TYPE_CODE_NAMESPACE:
+ /* chastain/2003-11-26: the symbol tables often contain fake
+ symbols for namespaces with the same name as the struct.
+ This warning is an indication of a bug in the lookup order
+ or a bug in the way that the symbol tables are populated. */
+ warning ("RTTI symbol for class '%s' is a namespace", name);
+ return NULL;
+ default:
+ warning ("RTTI symbol for class '%s' has bad type", name);
+ return NULL;
+ }
+
+ return rtti_type;
+}
/* Don't allow just "maintenance cplus". */
struct obstack;
struct block;
struct objfile;
+struct type;
/* This struct is designed to store data from using directives. It
says that names from namespace INNER should be visible within
extern struct symbol **make_symbol_overload_list (struct symbol *);
+extern struct type *cp_lookup_rtti_type (const char *name,
+ struct block *block);
+
/* Functions/variables from cp-namespace.c. */
extern unsigned char processing_has_namespace_info;
/* Abstraction of GNU v2 abi.
- Copyright 2001, 2003 Free Software Foundation, Inc.
+ Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dberlin@redhat.com>
#include "value.h"
#include "demangle.h"
#include "cp-abi.h"
+#include "cp-support.h"
#include <ctype.h>
*(strchr(demangled_name,' '))=0;
/* Lookup the type for the name */
- rtti_type=lookup_typename(demangled_name, (struct block *)0,1);
-
- if (rtti_type==NULL)
+ /* FIXME: chastain/2003-11-26: block=NULL is bogus. See pr gdb/1465. */
+ rtti_type = cp_lookup_rtti_type (demangled_name, NULL);
+ if (rtti_type == NULL)
return NULL;
if (TYPE_N_BASECLASSES(rtti_type) > 1 && full && (*full) != 1)
/* Abstraction of GNU v3 abi.
Contributed by Jim Blandy <jimb@redhat.com>
- Copyright 2001, 2002 Free Software Foundation, Inc.
+ Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GDB.
#include "defs.h"
#include "value.h"
#include "cp-abi.h"
+#include "cp-support.h"
#include "demangle.h"
#include "gdb_assert.h"
#include "gdb_string.h"
struct minimal_symbol *vtable_symbol;
const char *vtable_symbol_name;
const char *class_name;
- struct symbol *class_symbol;
struct type *run_time_type;
struct type *base_type;
LONGEST offset_to_top;
class_name = vtable_symbol_name + 11;
/* Try to look up the class name as a type name. */
- class_symbol = lookup_symbol (class_name, 0, STRUCT_DOMAIN, 0, 0);
- if (! class_symbol)
- {
- warning ("can't find class named `%s', as given by C++ RTTI", class_name);
- return NULL;
- }
-
- /* Make sure the type symbol is sane. (An earlier version of this
- code would find constructor functions, who have the same name as
- the class.) */
- if (SYMBOL_CLASS (class_symbol) != LOC_TYPEDEF
- || TYPE_CODE (SYMBOL_TYPE (class_symbol)) != TYPE_CODE_CLASS)
- {
- warning ("C++ RTTI gives a class name of `%s', but that isn't a type name",
- class_name);
- return NULL;
- }
-
- /* This is the object's run-time type! */
- run_time_type = SYMBOL_TYPE (class_symbol);
+ /* FIXME: chastain/2003-11-26: block=NULL is bogus. See pr gdb/1465. */
+ run_time_type = cp_lookup_rtti_type (class_name, NULL);
+ if (run_time_type == NULL)
+ return NULL;
/* Get the offset from VALUE to the top of the complete object.
NOTE: this is the reverse of the meaning of *TOP_P. */