mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-19 00:59:15 +08:00
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.
This commit is contained in:
@ -1,3 +1,14 @@
|
|||||||
|
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>
|
2003-12-04 J. Brobecker <brobecker@gnat.com>
|
||||||
|
|
||||||
* stabsread.c (read_type): Save a reference to types that are defined
|
* stabsread.c (read_type): Save a reference to types that are defined
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
#include "complaints.h"
|
#include "complaints.h"
|
||||||
|
#include "gdbtypes.h"
|
||||||
|
|
||||||
/* Functions related to demangled name parsing. */
|
/* Functions related to demangled name parsing. */
|
||||||
|
|
||||||
@ -582,6 +583,48 @@ make_symbol_overload_list (struct symbol *fsym)
|
|||||||
return (sym_return_val);
|
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". */
|
/* Don't allow just "maintenance cplus". */
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ struct symbol;
|
|||||||
struct obstack;
|
struct obstack;
|
||||||
struct block;
|
struct block;
|
||||||
struct objfile;
|
struct objfile;
|
||||||
|
struct type;
|
||||||
|
|
||||||
/* This struct is designed to store data from using directives. It
|
/* This struct is designed to store data from using directives. It
|
||||||
says that names from namespace INNER should be visible within
|
says that names from namespace INNER should be visible within
|
||||||
@ -61,6 +62,9 @@ extern unsigned int cp_entire_prefix_len (const char *name);
|
|||||||
|
|
||||||
extern struct symbol **make_symbol_overload_list (struct symbol *);
|
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. */
|
/* Functions/variables from cp-namespace.c. */
|
||||||
|
|
||||||
extern unsigned char processing_has_namespace_info;
|
extern unsigned char processing_has_namespace_info;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* Abstraction of GNU v2 abi.
|
/* 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>
|
Contributed by Daniel Berlin <dberlin@redhat.com>
|
||||||
|
|
||||||
@ -30,6 +30,7 @@
|
|||||||
#include "value.h"
|
#include "value.h"
|
||||||
#include "demangle.h"
|
#include "demangle.h"
|
||||||
#include "cp-abi.h"
|
#include "cp-abi.h"
|
||||||
|
#include "cp-support.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@ -259,8 +260,8 @@ gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
|
|||||||
*(strchr(demangled_name,' '))=0;
|
*(strchr(demangled_name,' '))=0;
|
||||||
|
|
||||||
/* Lookup the type for the name */
|
/* Lookup the type for the name */
|
||||||
rtti_type=lookup_typename(demangled_name, (struct block *)0,1);
|
/* 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)
|
if (rtti_type == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* Abstraction of GNU v3 abi.
|
/* Abstraction of GNU v3 abi.
|
||||||
Contributed by Jim Blandy <jimb@redhat.com>
|
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.
|
This file is part of GDB.
|
||||||
|
|
||||||
@ -23,6 +23,7 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
#include "cp-abi.h"
|
#include "cp-abi.h"
|
||||||
|
#include "cp-support.h"
|
||||||
#include "demangle.h"
|
#include "demangle.h"
|
||||||
#include "gdb_assert.h"
|
#include "gdb_assert.h"
|
||||||
#include "gdb_string.h"
|
#include "gdb_string.h"
|
||||||
@ -196,7 +197,6 @@ gnuv3_rtti_type (struct value *value,
|
|||||||
struct minimal_symbol *vtable_symbol;
|
struct minimal_symbol *vtable_symbol;
|
||||||
const char *vtable_symbol_name;
|
const char *vtable_symbol_name;
|
||||||
const char *class_name;
|
const char *class_name;
|
||||||
struct symbol *class_symbol;
|
|
||||||
struct type *run_time_type;
|
struct type *run_time_type;
|
||||||
struct type *base_type;
|
struct type *base_type;
|
||||||
LONGEST offset_to_top;
|
LONGEST offset_to_top;
|
||||||
@ -255,26 +255,10 @@ gnuv3_rtti_type (struct value *value,
|
|||||||
class_name = vtable_symbol_name + 11;
|
class_name = vtable_symbol_name + 11;
|
||||||
|
|
||||||
/* Try to look up the class name as a type name. */
|
/* Try to look up the class name as a type name. */
|
||||||
class_symbol = lookup_symbol (class_name, 0, STRUCT_DOMAIN, 0, 0);
|
/* FIXME: chastain/2003-11-26: block=NULL is bogus. See pr gdb/1465. */
|
||||||
if (! class_symbol)
|
run_time_type = cp_lookup_rtti_type (class_name, NULL);
|
||||||
{
|
if (run_time_type == NULL)
|
||||||
warning ("can't find class named `%s', as given by C++ RTTI", class_name);
|
|
||||||
return NULL;
|
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);
|
|
||||||
|
|
||||||
/* Get the offset from VALUE to the top of the complete object.
|
/* Get the offset from VALUE to the top of the complete object.
|
||||||
NOTE: this is the reverse of the meaning of *TOP_P. */
|
NOTE: this is the reverse of the meaning of *TOP_P. */
|
||||||
|
Reference in New Issue
Block a user