summaryrefslogtreecommitdiff
path: root/gdb/cp-support.c
diff options
context:
space:
mode:
authorMichael Chastain <mec.gnu@mindspring.com>2003-12-05 04:25:09 +0000
committerMichael Chastain <mec.gnu@mindspring.com>2003-12-05 04:25:09 +0000
commitf394fc52a3da6d651c1361863e1c9700c31103f8 (patch)
tree8746afee29bc9b248734a133e7ee02714a82d9b4 /gdb/cp-support.c
parent9b8eb889214f5de4cdaa6396da2e1266d212cc8a (diff)
downloadgdb-f394fc52a3da6d651c1361863e1c9700c31103f8.tar.gz
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.
Diffstat (limited to 'gdb/cp-support.c')
-rw-r--r--gdb/cp-support.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 9e6d44b119c..9b447fcadf3 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -33,6 +33,7 @@
#include "symtab.h"
#include "block.h"
#include "complaints.h"
+#include "gdbtypes.h"
/* Functions related to demangled name parsing. */
@@ -582,6 +583,48 @@ make_symbol_overload_list (struct symbol *fsym)
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". */