+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:
$(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) \
/* 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.
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
/* 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.
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 */
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 */
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 */
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 */
#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. */
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);
}
}
+/* 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
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;
/* 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).
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 */
/* 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.
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 */
/* 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.
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 */
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 */
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 */
/* 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.
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);
/* 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.
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 */
/* 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.
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 */
/* 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.
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 */
/* 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.
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 */
/* 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.
}
/* 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;
/* 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.
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. */
+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
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."
# 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 $" {
}
}
+# 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
/* 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.
} // 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;
C1 *e1 = create1();
C2 *e2 = create2();
- return 0; // constructs-done
+ n2::func(); // main-constructs-done
+
+ return 0;
}