* [rfa] lookup_transparent_type hack
@ 2004-01-16 23:58 David Carlton
2004-01-18 23:48 ` Elena Zannoni
2004-01-19 4:25 ` Daniel Jacobowitz
0 siblings, 2 replies; 7+ messages in thread
From: David Carlton @ 2004-01-16 23:58 UTC (permalink / raw)
To: gdb-patches; +Cc: Daniel Jacobowitz, Elena Zannoni, Jim Blandy
This is a hack for lookup_transparent_type, as a partial workaround
for PR gdb/1511. The problem there is, if the compiler doesn't
generate DW_TAG_namespace, then, if we have a class C defined inside a
namespace N, then when GDB sees an abstract declaration for N::C, it
will think it's called "C" instead of "N::C". Then
lookup_transparent_type will get passed "C", and it won't find the
full definition for the class (which is called "N::C").
I don't see what we can do about this without full debugging info -
GDB can't very well look in all the namespaces out there. One
heuristic which has proved useful, however, is to try looking in the
namespaces associated to the function we're currently within (if any),
on the theory that we're a bit more likely to be dealing with types in
those namespaces than types in other namespaces. It's a hack, but it
does seem to help.
Here's a patch to do that. It needs C++ approval, and it would be
nice if a symtab person would confirm that it's okay to make
lookup_transparent_type language-dependent. Tested on
i686-pc-linux-gnu, DWARF-2, GCC 3.2 both with and without
DW_AT_namespace; no regressions, and the new test passes in both
cases. (It shouldn't affect stabs, though I'm running the testsuite
now just to double-check.)
Okay to commit?
David Carlton
carlton@kealia.com
2004-01-16 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-16 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 call to it.
Index: cp-namespace.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-namespace.c,v
retrieving revision 1.9
diff -u -p -r1.9 cp-namespace.c
--- cp-namespace.c 14 Jan 2004 16:54:41 -0000 1.9
+++ cp-namespace.c 16 Jan 2004 23:36:18 -0000
@@ -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
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);
@@ -549,6 +554,74 @@ cp_lookup_nested_type (struct type *pare
internal_error (__FILE__, __LINE__,
"cp_lookup_nested_type called on a non-aggregate 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
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.124
diff -u -p -r1.124 symtab.c
--- symtab.c 17 Dec 2003 22:21:02 -0000 1.124
+++ symtab.c 16 Jan 2004 23:36:20 -0000
@@ -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_sy
}
/* 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
+ 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. */
+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 *
-lookup_transparent_type (const char *name)
+basic_lookup_transparent_type (const char *name)
{
struct symbol *sym;
struct symtab *s = NULL;
Index: language.h
===================================================================
RCS file: /cvs/src/src/gdb/language.h,v
retrieving revision 1.24
diff -u -p -r1.24 language.h
--- language.h 6 Oct 2003 22:37:37 -0000 1.24
+++ language.h 16 Jan 2004 23:36:18 -0000
@@ -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.
@@ -232,6 +232,9 @@ struct language_defn
const struct block *,
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);
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.475
diff -u -p -r1.475 Makefile.in
--- Makefile.in 3 Jan 2004 10:08:44 -0000 1.475
+++ Makefile.in 16 Jan 2004 23:36:15 -0000
@@ -1674,7 +1674,7 @@ cp-abi.o: cp-abi.c $(defs_h) $(value_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)
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.34
diff -u -p -r1.34 ada-lang.c
--- ada-lang.c 23 Nov 2003 20:41:16 -0000 1.34
+++ ada-lang.c 16 Jan 2004 23:36:17 -0000
@@ -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_
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
Index: c-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/c-lang.c,v
retrieving revision 1.25
diff -u -p -r1.25 c-lang.c
--- c-lang.c 6 Oct 2003 22:37:38 -0000 1.25
+++ c-lang.c 16 Jan 2004 23:36:17 -0000
@@ -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_de
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_languag
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_
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_langu
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 */
Index: cp-support.h
===================================================================
RCS file: /cvs/src/src/gdb/cp-support.h,v
retrieving revision 1.11
diff -u -p -r1.11 cp-support.h
--- cp-support.h 9 Jan 2004 22:22:07 -0000 1.11
+++ cp-support.h 16 Jan 2004 23:36:18 -0000
@@ -108,6 +108,8 @@ extern struct type *cp_lookup_nested_typ
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;
Index: f-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/f-lang.c,v
retrieving revision 1.20
diff -u -p -r1.20 f-lang.c
--- f-lang.c 23 Nov 2003 20:41:16 -0000 1.20
+++ f-lang.c 16 Jan 2004 23:36:18 -0000
@@ -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_de
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 */
Index: jv-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-lang.c,v
retrieving revision 1.25
diff -u -p -r1.25 jv-lang.c
--- jv-lang.c 6 Oct 2003 22:37:38 -0000 1.25
+++ jv-lang.c 16 Jan 2004 23:36:18 -0000
@@ -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.
@@ -1060,6 +1060,7 @@ const struct language_defn java_language
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 */
Index: language.c
===================================================================
RCS file: /cvs/src/src/gdb/language.c,v
retrieving revision 1.42
diff -u -p -r1.42 language.c
--- language.c 23 Nov 2003 20:41:17 -0000 1.42
+++ language.c 16 Jan 2004 23:36:18 -0000
@@ -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_langu
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
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_languag
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 */
Index: m2-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/m2-lang.c,v
retrieving revision 1.14
diff -u -p -r1.14 m2-lang.c
--- m2-lang.c 6 Oct 2003 22:37:38 -0000 1.14
+++ m2-lang.c 16 Jan 2004 23:36:19 -0000
@@ -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_d
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 */
Index: objc-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/objc-lang.c,v
retrieving revision 1.32
diff -u -p -r1.32 objc-lang.c
--- objc-lang.c 6 Oct 2003 22:37:38 -0000 1.32
+++ objc-lang.c 16 Jan 2004 23:36:19 -0000
@@ -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
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 */
Index: p-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/p-lang.c,v
retrieving revision 1.16
diff -u -p -r1.16 p-lang.c
--- p-lang.c 6 Oct 2003 22:37:38 -0000 1.16
+++ p-lang.c 16 Jan 2004 23:36:19 -0000
@@ -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_langua
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 */
Index: scm-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/scm-lang.c,v
retrieving revision 1.21
diff -u -p -r1.21 scm-lang.c
--- scm-lang.c 6 Oct 2003 22:37:38 -0000 1.21
+++ scm-lang.c 16 Jan 2004 23:36:19 -0000
@@ -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_
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 */
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.83
diff -u -p -r1.83 symtab.h
--- symtab.h 11 Nov 2003 20:04:52 -0000 1.83
+++ symtab.h 16 Jan 2004 23:36:20 -0000
@@ -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_A
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. */
Index: testsuite/gdb.cp/rtti.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti.exp,v
retrieving revision 1.3
diff -u -p -r1.3 rtti.exp
--- testsuite/gdb.cp/rtti.exp 14 Jan 2004 19:03:32 -0000 1.3
+++ testsuite/gdb.cp/rtti.exp 16 Jan 2004 23:36:24 -0000
@@ -46,8 +46,9 @@ set srcfile2 "${srcdir}/${subdir}/${test
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 $" {
@@ -130,6 +131,14 @@ gdb_test_multiple "print *e2" "print *e2
kfail "gdb/57" "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
Index: testsuite/gdb.cp/rtti1.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti1.cc,v
retrieving revision 1.1
diff -u -p -r1.1 rtti1.cc
--- testsuite/gdb.cp/rtti1.cc 23 Aug 2003 03:55:59 -0000 1.1
+++ testsuite/gdb.cp/rtti1.cc 16 Jan 2004 23:36:24 -0000
@@ -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,16 @@ namespace n1 {
} // n1
+namespace n2
+{
+ void func ()
+ {
+ C2 *obj = create2 ();
+
+ return; // func-constructs-done
+ }
+}
+
int main()
{
using namespace n1;
@@ -63,5 +73,7 @@ int main()
C1 *e1 = create1();
C2 *e2 = create2();
- return 0; // constructs-done
+ n2::func(); // main-constructs-done
+
+ return 0;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [rfa] lookup_transparent_type hack
2004-01-16 23:58 [rfa] lookup_transparent_type hack David Carlton
@ 2004-01-18 23:48 ` Elena Zannoni
2004-01-19 4:25 ` Daniel Jacobowitz
1 sibling, 0 replies; 7+ messages in thread
From: Elena Zannoni @ 2004-01-18 23:48 UTC (permalink / raw)
To: David Carlton; +Cc: gdb-patches, Daniel Jacobowitz
David Carlton writes:
> This is a hack for lookup_transparent_type, as a partial workaround
> for PR gdb/1511. The problem there is, if the compiler doesn't
> generate DW_TAG_namespace, then, if we have a class C defined inside a
> namespace N, then when GDB sees an abstract declaration for N::C, it
> will think it's called "C" instead of "N::C". Then
> lookup_transparent_type will get passed "C", and it won't find the
> full definition for the class (which is called "N::C").
>
> I don't see what we can do about this without full debugging info -
> GDB can't very well look in all the namespaces out there. One
> heuristic which has proved useful, however, is to try looking in the
> namespaces associated to the function we're currently within (if any),
> on the theory that we're a bit more likely to be dealing with types in
> those namespaces than types in other namespaces. It's a hack, but it
> does seem to help.
>
> Here's a patch to do that. It needs C++ approval, and it would be
> nice if a symtab person would confirm that it's okay to make
> lookup_transparent_type language-dependent. Tested on
> i686-pc-linux-gnu, DWARF-2, GCC 3.2 both with and without
> DW_AT_namespace; no regressions, and the new test passes in both
> cases. (It shouldn't affect stabs, though I'm running the testsuite
> now just to double-check.)
>
> Okay to commit?
>
I have no objections, but I think it should be tested with gcc2.95.3 and
-gdwarf-2, since MichaelC is doing that, and turning out interesting
regressions.
elena
> David Carlton
> carlton@kealia.com
>
> 2004-01-16 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-16 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 call to it.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [rfa] lookup_transparent_type hack
2004-01-16 23:58 [rfa] lookup_transparent_type hack David Carlton
2004-01-18 23:48 ` Elena Zannoni
@ 2004-01-19 4:25 ` Daniel Jacobowitz
2004-01-22 22:00 ` David Carlton
1 sibling, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2004-01-19 4:25 UTC (permalink / raw)
To: gdb-patches
On Fri, Jan 16, 2004 at 03:58:04PM -0800, David Carlton wrote:
> This is a hack for lookup_transparent_type, as a partial workaround
> for PR gdb/1511. The problem there is, if the compiler doesn't
> generate DW_TAG_namespace, then, if we have a class C defined inside a
> namespace N, then when GDB sees an abstract declaration for N::C, it
> will think it's called "C" instead of "N::C". Then
> lookup_transparent_type will get passed "C", and it won't find the
> full definition for the class (which is called "N::C").
>
> I don't see what we can do about this without full debugging info -
> GDB can't very well look in all the namespaces out there. One
Well, we can. I'm thinking about sorting the symbol tables by
basename, as I mentioned earlier. That would make this search easy.
But the only cases where it would be really interesting, it would still
be ambiguous...
> heuristic which has proved useful, however, is to try looking in the
> namespaces associated to the function we're currently within (if any),
> on the theory that we're a bit more likely to be dealing with types in
> those namespaces than types in other namespaces. It's a hack, but it
> does seem to help.
>
> Here's a patch to do that. It needs C++ approval, and it would be
> nice if a symtab person would confirm that it's okay to make
> lookup_transparent_type language-dependent. Tested on
> i686-pc-linux-gnu, DWARF-2, GCC 3.2 both with and without
> DW_AT_namespace; no regressions, and the new test passes in both
> cases. (It shouldn't affect stabs, though I'm running the testsuite
> now just to double-check.)
>
> Okay to commit?
This is OK. I'd also like to see results with 2.95, though I expect no
difficulties. It's a terrible hack, but you're right that it probably
works often enough to bother.
It doesn't work for the case that has been reported twice now:
namespace bar {
class Foo { };
namespace baz {
class Foo : public bar::Foo { };
}
}
There's nothing clear we can do, although bonus points would definitely
be had for making sure we don't resolve the derived type's reference
to the base type to the derived type itself. Again, a hack, won't
catch larger cycles, but would eliminate some infinite loops.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [rfa] lookup_transparent_type hack
2004-01-19 4:25 ` Daniel Jacobowitz
@ 2004-01-22 22:00 ` David Carlton
2004-01-22 22:30 ` Daniel Jacobowitz
2004-01-23 23:06 ` David Carlton
0 siblings, 2 replies; 7+ messages in thread
From: David Carlton @ 2004-01-22 22:00 UTC (permalink / raw)
To: gdb-patches
On Sun, 18 Jan 2004 23:25:35 -0500, Daniel Jacobowitz <drow@mvista.com> said:
> This is OK. I'd also like to see results with 2.95, though I expect
> no difficulties.
No problems with 2.95. Unfortunately, there are issues with mainline
GCC. (As of last Thursday's GCC, at least.) The new test in rtti.exp
(print *obj) fails there, and in fact the earlier test in rtti.exp
(print *e2), which I would expect to pass, is KFAILing.
These failures aren't caused by my patch to GDB - they happen with or
without the patch - but I want to look into the reason for the
behavior first before committing the patch. There are also some
(non-regression) FAILs in namespace.exp that are probably related to
this. (I have a patch waiting for approval that takes care of most of
the FAILs in namespace.exp, but not all of them.)
Am I correct in remembering that GCC has recently changed its rules
for when it emits debug info for classes? Something about only
emitting them in the same place where it emits the vtable (which it
does following the CFront rule)? If so, that might be relevant. Or
am I thinking of something else?
David Carlton
carlton@kealia.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [rfa] lookup_transparent_type hack
2004-01-22 22:00 ` David Carlton
@ 2004-01-22 22:30 ` Daniel Jacobowitz
2004-01-23 23:06 ` David Carlton
1 sibling, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2004-01-22 22:30 UTC (permalink / raw)
To: gdb-patches
On Thu, Jan 22, 2004 at 02:00:08PM -0800, David Carlton wrote:
> On Sun, 18 Jan 2004 23:25:35 -0500, Daniel Jacobowitz <drow@mvista.com> said:
>
> > This is OK. I'd also like to see results with 2.95, though I expect
> > no difficulties.
>
> No problems with 2.95. Unfortunately, there are issues with mainline
> GCC. (As of last Thursday's GCC, at least.) The new test in rtti.exp
> (print *obj) fails there, and in fact the earlier test in rtti.exp
> (print *e2), which I would expect to pass, is KFAILing.
>
> These failures aren't caused by my patch to GDB - they happen with or
> without the patch - but I want to look into the reason for the
> behavior first before committing the patch. There are also some
> (non-regression) FAILs in namespace.exp that are probably related to
> this. (I have a patch waiting for approval that takes care of most of
> the FAILs in namespace.exp, but not all of them.)
OK.
> Am I correct in remembering that GCC has recently changed its rules
> for when it emits debug info for classes? Something about only
> emitting them in the same place where it emits the vtable (which it
> does following the CFront rule)? If so, that might be relevant. Or
> am I thinking of something else?
Well, I recently had an argument about it, but the behavior is not new
- it's done that for years. The only 'recent' change is not to emit
debug info for unused types.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [rfa] lookup_transparent_type hack
2004-01-22 22:00 ` David Carlton
2004-01-22 22:30 ` Daniel Jacobowitz
@ 2004-01-23 23:06 ` David Carlton
2004-01-23 23:08 ` Daniel Jacobowitz
1 sibling, 1 reply; 7+ messages in thread
From: David Carlton @ 2004-01-23 23:06 UTC (permalink / raw)
To: gdb-patches
On Thu, 22 Jan 2004 14:00:08 -0800, David Carlton <carlton@kealia.com> said:
> These failures aren't caused by my patch to GDB - they happen with or
> without the patch - but I want to look into the reason for the
> behavior first before committing the patch.
I've looked into them; as I suspected, they didn't really have
anything to do with this patch. There is a bug in the way I handle
the debug output that GCC 3.4 generates for classes in namespaces;
I'll submit a patch for that later this afternoon. And, once I fixed
that bug, I discovered that, if you do:
void func ()
{
C2 *obj = create2 ();
return;
}
and set a breakpoint on the 'return' line then, if it's compiled with
GCC 3.4, 'print *obj' claims that there isn't a variable named 'obj'.
Sigh.
So I tweaked rtti1.cc to avoid this issue. With that change, I
committed the patch; the rtti1.cc part of the patch is below.
David Carlton
carlton@kealia.com
Index: testsuite/gdb.cp/rtti1.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti1.cc,v
retrieving revision 1.1
diff -u -p -r1.1 rtti1.cc
--- testsuite/gdb.cp/rtti1.cc 23 Aug 2003 03:55:59 -0000 1.1
+++ testsuite/gdb.cp/rtti1.cc 23 Jan 2004 22:54:25 -0000
@@ -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;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [rfa] lookup_transparent_type hack
2004-01-23 23:06 ` David Carlton
@ 2004-01-23 23:08 ` Daniel Jacobowitz
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2004-01-23 23:08 UTC (permalink / raw)
To: gdb-patches
On Fri, Jan 23, 2004 at 03:06:45PM -0800, David Carlton wrote:
> On Thu, 22 Jan 2004 14:00:08 -0800, David Carlton <carlton@kealia.com> said:
>
> > These failures aren't caused by my patch to GDB - they happen with or
> > without the patch - but I want to look into the reason for the
> > behavior first before committing the patch.
>
> I've looked into them; as I suspected, they didn't really have
> anything to do with this patch. There is a bug in the way I handle
> the debug output that GCC 3.4 generates for classes in namespaces;
> I'll submit a patch for that later this afternoon. And, once I fixed
> that bug, I discovered that, if you do:
>
>
> void func ()
> {
> C2 *obj = create2 ();
>
> return;
> }
>
> and set a breakpoint on the 'return' line then, if it's compiled with
> GCC 3.4, 'print *obj' claims that there isn't a variable named 'obj'.
> Sigh.
Yes, there are a number of these in our testsuite - and I think that
GCC is not at fault.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-01-23 23:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-16 23:58 [rfa] lookup_transparent_type hack David Carlton
2004-01-18 23:48 ` Elena Zannoni
2004-01-19 4:25 ` Daniel Jacobowitz
2004-01-22 22:00 ` David Carlton
2004-01-22 22:30 ` Daniel Jacobowitz
2004-01-23 23:06 ` David Carlton
2004-01-23 23:08 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox