2004-01-23 David Carlton <carlton@kealia.com>

Partial workaround for PR c++/1511:
	* cp-namespace.c: Include frame.h.
	(cp_lookup_transparent_type): New
	(cp_lookup_transparent_type_loop): New.
	* cp-support.h: Declare cp_lookup_transparent_type.
	* symtab.c (basic_lookup_transparent_type): Renamed from
	lookup_transparent_type.
	(lookup_transparent_type): Replace old body by a call to
	current_language->la_lookup_transparent_type.
	* symtab.h: Update copyright.  Declare
	basic_lookup_transparent_type.
	* language.h: Update copyright.
	(struct language_defn): Add la_lookup_transparent_type.
	* language.c: Update copyright.
	(unknown_language_defn): Add basic_lookup_transparent_type.
	(auto_language_defn): Add basic_lookup_transparent_type.
	(local_language_defn): Add basic_lookup_transparent_type.
	* ada-lang.c: Update copyright.
	(ada_language_defn): Add basic_lookup_transparent_type.
	* c-lang.c: Update copyright.
	(c_language_defn): Add basic_lookup_transparent_type.
	(cplus_language_defn): Add basic_lookup_transparent_type.
	(asm_language_defn): Add basic_lookup_transparent_type.
	(minimal_language_defn): Add basic_lookup_transparent_type.
	* f-lang.c: Update copyright.
	(f_language_defn): Add basic_lookup_transparent_type.
	* jv-lang.c: Update copyright.
	(java_language_defn): Add basic_lookup_transparent_type.
	* m2-lang.c: Update copyright.
	(m2_language_defn): Add basic_lookup_transparent_type.
	* objc-lang.c: Update copyright.
	(objc_language_defn): Add basic_lookup_transparent_type.
	* p-lang.c: Update copyright.
	(p_language_defn): Add basic_lookup_transparent_type.
	* scm-lang.c: Update copyright.
	(scm_language_defn): Add basic_lookup_transparent_type.
	* Makefile.in (cp-namespace.o): Depend on frame.h.

2004-01-23  David Carlton  <carlton@kealia.com>

	* gdb.cp/rtti.exp: Don't include full path in ${srcfile}.  Add
	test for cp_lookup_transparent_type.
	* gdb.cp/rtti1.cc: Update copyright.  Add n2::func and refer_to;
	call them.
This commit is contained in:
David Carlton 2004-01-23 23:03:31 +00:00
parent 3835ff9bee
commit b368761e45
19 changed files with 205 additions and 26 deletions

View File

@ -1,3 +1,43 @@
2004-01-23 David Carlton <carlton@kealia.com>
Partial workaround for PR c++/1511:
* cp-namespace.c: Include frame.h.
(cp_lookup_transparent_type): New
(cp_lookup_transparent_type_loop): New.
* cp-support.h: Declare cp_lookup_transparent_type.
* symtab.c (basic_lookup_transparent_type): Renamed from
lookup_transparent_type.
(lookup_transparent_type): Replace old body by a call to
current_language->la_lookup_transparent_type.
* symtab.h: Update copyright. Declare
basic_lookup_transparent_type.
* language.h: Update copyright.
(struct language_defn): Add la_lookup_transparent_type.
* language.c: Update copyright.
(unknown_language_defn): Add basic_lookup_transparent_type.
(auto_language_defn): Add basic_lookup_transparent_type.
(local_language_defn): Add basic_lookup_transparent_type.
* ada-lang.c: Update copyright.
(ada_language_defn): Add basic_lookup_transparent_type.
* c-lang.c: Update copyright.
(c_language_defn): Add basic_lookup_transparent_type.
(cplus_language_defn): Add basic_lookup_transparent_type.
(asm_language_defn): Add basic_lookup_transparent_type.
(minimal_language_defn): Add basic_lookup_transparent_type.
* f-lang.c: Update copyright.
(f_language_defn): Add basic_lookup_transparent_type.
* jv-lang.c: Update copyright.
(java_language_defn): Add basic_lookup_transparent_type.
* m2-lang.c: Update copyright.
(m2_language_defn): Add basic_lookup_transparent_type.
* objc-lang.c: Update copyright.
(objc_language_defn): Add basic_lookup_transparent_type.
* p-lang.c: Update copyright.
(p_language_defn): Add basic_lookup_transparent_type.
* scm-lang.c: Update copyright.
(scm_language_defn): Add basic_lookup_transparent_type.
* Makefile.in (cp-namespace.o): Depend on frame.h.
2004-01-23 David Carlton <carlton@kealia.com>
Patch for PR c++/1520:

View File

@ -1691,7 +1691,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) $(command_h)
$(gdbtypes_h) $(dictionary_h) $(command_h) $(frame_h)
cp-support.o: cp-support.c $(defs_h) $(cp_support_h) $(gdb_string_h) \
$(demangle_h) $(gdb_assert_h) $(gdbcmd_h) $(dictionary_h) \
$(objfiles_h) $(frame_h) $(symtab_h) $(block_h) $(complaints_h) \

View File

@ -1,5 +1,5 @@
/* Ada language support routines for GDB, the GNU debugger. Copyright
1992, 1993, 1994, 1997, 1998, 1999, 2000, 2003
1992, 1993, 1994, 1997, 1998, 1999, 2000, 2003, 2004
Free Software Foundation, Inc.
This file is part of GDB.
@ -8019,6 +8019,7 @@ const struct language_defn ada_language_defn = {
NULL, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
#if 0

View File

@ -1,5 +1,5 @@
/* C language support routines for GDB, the GNU debugger.
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GDB.
@ -556,6 +556,7 @@ const struct language_defn c_language_defn =
NULL, /* Language specific skip_trampoline */
NULL, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
@ -613,6 +614,7 @@ const struct language_defn cplus_language_defn =
NULL, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
cp_lookup_transparent_type, /* lookup_transparent_type */
cplus_demangle, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
@ -647,6 +649,7 @@ const struct language_defn asm_language_defn =
NULL, /* Language specific skip_trampoline */
NULL, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
@ -686,6 +689,7 @@ const struct language_defn minimal_language_defn =
NULL, /* Language specific skip_trampoline */
NULL, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */

View File

@ -31,6 +31,7 @@
#include "gdbtypes.h"
#include "dictionary.h"
#include "command.h"
#include "frame.h"
/* When set, the file that we're processing is known to have debugging
info for C++ namespaces. */
@ -85,6 +86,10 @@ static struct symbol *lookup_symbol_file (const char *name,
struct symtab **symtab,
int anonymous_namespace);
static struct type *cp_lookup_transparent_type_loop (const char *name,
const char *scope,
int scope_len);
static void initialize_namespace_symtab (struct objfile *objfile);
static struct block *get_possible_namespace_block (struct objfile *objfile);
@ -551,6 +556,74 @@ cp_lookup_nested_type (struct type *parent_type,
}
}
/* The C++-version of lookup_transparent_type. */
/* FIXME: carlton/2004-01-16: The problem that this is trying to
address is that, unfortunately, sometimes NAME is wrong: it may not
include the name of namespaces enclosing the type in question.
lookup_transparent_type gets called when the the type in question
is a declaration, and we're trying to find its definition; but, for
declarations, our type name deduction mechanism doesn't work.
There's nothing we can do to fix this in general, I think, in the
absence of debug information about namespaces (I've filed PR
gdb/1511 about this); until such debug information becomes more
prevalent, one heuristic which sometimes looks is to search for the
definition in namespaces containing the current namespace.
We should delete this functions once the appropriate debug
information becomes more widespread. (GCC 3.4 will be the first
released version of GCC with such information.) */
struct type *
cp_lookup_transparent_type (const char *name)
{
/* First, try the honest way of looking up the definition. */
struct type *t = basic_lookup_transparent_type (name);
const char *scope;
if (t != NULL)
return t;
/* If that doesn't work and we're within a namespace, look there
instead. */
scope = block_scope (get_selected_block (0));
if (scope[0] == '\0')
return NULL;
return cp_lookup_transparent_type_loop (name, scope, 0);
}
/* Lookup the the type definition associated to NAME in
namespaces/classes containing SCOPE whose name is strictly longer
than LENGTH. LENGTH must be the index of the start of a
component of SCOPE. */
static struct type *
cp_lookup_transparent_type_loop (const char *name, const char *scope,
int length)
{
int scope_length = cp_find_first_component (scope + length);
char *full_name;
/* If the current scope is followed by "::", look in the next
component. */
if (scope[scope_length] == ':')
{
struct type *retval
= cp_lookup_transparent_type_loop (name, scope, scope_length + 2);
if (retval != NULL)
return retval;
}
full_name = alloca (scope_length + 2 + strlen (name) + 1);
strncpy (full_name, scope, scope_length);
strncpy (full_name + scope_length, "::", 2);
strcpy (full_name + scope_length + 2, name);
return basic_lookup_transparent_type (full_name);
}
/* Now come functions for dealing with symbols associated to
namespaces. (They're used to store the namespaces themselves, not
objects that live in the namespaces.) These symbols come in two

View File

@ -108,6 +108,8 @@ extern struct type *cp_lookup_nested_type (struct type *parent_type,
extern void cp_check_possible_namespace_symbols (const char *name,
struct objfile *objfile);
struct type *cp_lookup_transparent_type (const char *name);
/* The list of "maint cplus" commands. */
extern struct cmd_list_element *maint_cplus_cmd_list;

View File

@ -1,5 +1,5 @@
/* Fortran language support routines for GDB, the GNU debugger.
Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
Contributed by Motorola. Adapted from the C parser by Farooq Butt
(fmbutt@engage.sps.mot.com).
@ -475,6 +475,7 @@ const struct language_defn f_language_defn =
NULL, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%o", "0", "o", ""}, /* Octal format info */

View File

@ -1,5 +1,5 @@
/* Java language support routines for GDB, the GNU debugger.
Copyright 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
Copyright 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
This file is part of GDB.
@ -1046,6 +1046,7 @@ const struct language_defn java_language_defn =
NULL, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
java_demangle, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */

View File

@ -1,7 +1,7 @@
/* Multiple source language support for GDB.
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
2001, 2002, 2003 Free Software Foundation, Inc.
2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by the Department of Computer Science at the State University
of New York at Buffalo.
@ -1289,6 +1289,7 @@ const struct language_defn unknown_language_defn =
unk_lang_trampoline, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
unk_lang_demangle, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
@ -1324,6 +1325,7 @@ const struct language_defn auto_language_defn =
unk_lang_trampoline, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
unk_lang_demangle, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
@ -1358,6 +1360,7 @@ const struct language_defn local_language_defn =
unk_lang_trampoline, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
unk_lang_demangle, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */

View File

@ -1,7 +1,7 @@
/* Source-language-related definitions for GDB.
Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2003 Free
Software Foundation, Inc.
Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2003,
2004 Free Software Foundation, Inc.
Contributed by the Department of Computer Science at the State University
of New York at Buffalo.
@ -233,6 +233,9 @@ struct language_defn
const domain_enum,
struct symtab **);
/* Find the definition of the type with the given name. */
struct type *(*la_lookup_transparent_type) (const char *);
/* Return demangled language symbol, or NULL. */
char *(*la_demangle) (const char *mangled, int options);

View File

@ -1,5 +1,5 @@
/* Modula 2 language support routines for GDB, the GNU debugger.
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2002
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GDB.
@ -428,6 +428,7 @@ const struct language_defn m2_language_defn =
NULL, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"%loB", "", "o", "B"}, /* Octal format info */

View File

@ -1,6 +1,6 @@
/* Objective-C language support routines for GDB, the GNU debugger.
Copyright 2002, 2003 Free Software Foundation, Inc.
Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Apple Computer, Inc.
Written by Michael Snyder.
@ -672,6 +672,7 @@ const struct language_defn objc_language_defn = {
objc_skip_trampoline, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
objc_demangle, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */

View File

@ -1,5 +1,5 @@
/* Pascal language support routines for GDB, the GNU debugger.
Copyright 2000, 2002 Free Software Foundation, Inc.
Copyright 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GDB.
@ -464,6 +464,7 @@ const struct language_defn pascal_language_defn =
NULL, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
{"", "%", "b", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */

View File

@ -1,6 +1,6 @@
/* Scheme/Guile language support routines for GDB, the GNU debugger.
Copyright 1995, 1996, 1998, 2000, 2001, 2002, 2003 Free Software
Copyright 1995, 1996, 1998, 2000, 2001, 2002, 2003, 2004 Free Software
Foundation, Inc.
This file is part of GDB.
@ -263,6 +263,7 @@ const struct language_defn scm_language_defn =
NULL, /* Language specific skip_trampoline */
value_of_this, /* value_of_this */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
{"", "", "", ""}, /* Binary format info */
{"#o%lo", "#o", "o", ""}, /* Octal format info */

View File

@ -1,7 +1,7 @@
/* Symbol table lookup for the GNU debugger, GDB.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GDB.
@ -1480,15 +1480,23 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
}
/* Look up a type named NAME in the struct_domain. The type returned
must not be opaque -- i.e., must have at least one field defined
This code was modelled on lookup_symbol -- the parts not relevant to looking
up types were just left out. In particular it's assumed here that types
are available in struct_domain and only at file-static or global blocks. */
must not be opaque -- i.e., must have at least one field
defined. */
struct type *
lookup_transparent_type (const char *name)
{
return current_language->la_lookup_transparent_type (name);
}
/* The standard implementation of lookup_transparent_type. This code
was modeled on lookup_symbol -- the parts not relevant to looking
up types were just left out. In particular it's assumed here that
types are available in struct_domain and only at file-static or
global blocks. */
struct type *
basic_lookup_transparent_type (const char *name)
{
struct symbol *sym;
struct symtab *s = NULL;

View File

@ -1,7 +1,7 @@
/* Symbol table definitions for GDB.
Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
Foundation, Inc.
This file is part of GDB.
@ -1107,6 +1107,7 @@ extern int find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *);
extern void reread_symbols (void);
extern struct type *lookup_transparent_type (const char *);
extern struct type *basic_lookup_transparent_type (const char *);
/* Macro for name of symbol to indicate a file compiled with gcc. */

View File

@ -1,3 +1,10 @@
2004-01-23 David Carlton <carlton@kealia.com>
* gdb.cp/rtti.exp: Don't include full path in ${srcfile}. Add
test for cp_lookup_transparent_type.
* gdb.cp/rtti1.cc: Update copyright. Add n2::func and refer_to;
call them.
2004-01-23 Daniel Jacobowitz <drow@mvista.com>
* gdb.mi/mi-var-child.exp: Update copyright year. Move new test

View File

@ -46,8 +46,9 @@ set srcfile2 "${srcdir}/${subdir}/${testfile}2.cc"
set objfile2 "${objdir}/${subdir}/${testfile}2.o"
set binfile ${objdir}/${subdir}/${testfile}
# gdb_get_line_number needs this to be called srcfile.
set srcfile "${srcfile1}"
# gdb_get_line_number needs this to be called srcfile. Except that it
# gets confused if the directories are included. :-(
set srcfile "${testfile}1.cc"
if { [gdb_compile "${srcfile1}" "${objfile1}" object {debug c++}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
@ -78,8 +79,8 @@ if ![runto_main] then {
# First, run to after we've constructed the object:
gdb_breakpoint [gdb_get_line_number "constructs-done"]
gdb_continue_to_breakpoint "end of constructors"
gdb_breakpoint [gdb_get_line_number "main-constructs-done"]
gdb_continue_to_breakpoint "end of constructors in main"
gdb_test_multiple "print *e1" "print *e1" {
-re "warning: RTTI symbol not found for class 'n1::D1'.*$gdb_prompt $" {
@ -131,5 +132,13 @@ gdb_test_multiple "print *e2" "print *e2" {
}
}
# Now we test the hack that's been implemented to get around some
# instances of PR gdb/1511.
gdb_breakpoint [gdb_get_line_number "func-constructs-done"]
gdb_continue_to_breakpoint "end of constructors in func"
gdb_test "print *obj" "\\$\[0-9\]* = {<n2::Base2> = .*}"
gdb_exit
return 0

View File

@ -1,6 +1,6 @@
/* Code to go along with tests in rtti.exp.
Copyright 2003 Free Software Foundation, Inc.
Copyright 2003, 2004 Free Software Foundation, Inc.
Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
Inc.
@ -55,6 +55,26 @@ namespace n1 {
} // n1
// NOTE: carlton/2004-01-23: This call exists only to convince GCC to
// keep around a reference to 'obj' in n2::func - GCC 3.4 had been
// optimizing it away.
void refer_to (n2::C2 *obj)
{
// Do nothing.
}
namespace n2
{
void func ()
{
C2 *obj = create2 ();
refer_to (obj); // func-constructs-done
return;
}
}
int main()
{
using namespace n1;
@ -63,5 +83,7 @@ int main()
C1 *e1 = create1();
C2 *e2 = create2();
return 0; // constructs-done
n2::func(); // main-constructs-done
return 0;
}