aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2002-12-01 22:07:56 +0000
committerDavid Carlton <carlton@bactrian.org>2002-12-01 22:07:56 +0000
commit1d9ae06b28c95a6cba96007f3028e9028baed6fe (patch)
tree6e710e55731ca140bccf5569c36caaaf2cf8766f
parentb48a215cc08178f8b2c7a444a26420596293dd8d (diff)
downloadgdb-1d9ae06b28c95a6cba96007f3028e9028baed6fe.zip
gdb-1d9ae06b28c95a6cba96007f3028e9028baed6fe.tar.gz
gdb-1d9ae06b28c95a6cba96007f3028e9028baed6fe.tar.bz2
2002-11-29 David Carlton <carlton@bactrian.org>
* dwarf2read.c (add_partial_symbol): Add partial symbols corresponding to classes, etc. to global list. (new_symbol): Ditto, mutatis mutandem. 2002-11-29 David Carlton <carlton@bactrian.org> * gdb.c++/namespace.exp: Add OtherFileClass tests. * gdb.c++/namespace1.cc (C): New file.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/dwarf2read.c75
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.c++/namespace.exp11
-rw-r--r--gdb/testsuite/gdb.c++/namespace1.cc7
5 files changed, 79 insertions, 25 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a925f63..a93161a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2002-11-29 David Carlton <carlton@bactrian.org>
+
+ * dwarf2read.c (add_partial_symbol): Add partial symbols
+ corresponding to classes, etc. to global list.
+ (new_symbol): Ditto, mutatis mutandem.
+
2002-11-27 David Carlton <carlton@math.stanford.edu>
* dwarf2read.c (add_partial_enumeration): New function.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 0c5bb17..2c64f59 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1553,11 +1553,13 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
case DW_TAG_enumeration_type:
/* Skip aggregate types without children, these are external
references. */
+ /* NOTE: carlton/2002-11-29: See comment in new_symbol about
+ static vs. global. */
if (pdi->has_children == 0)
return;
add_psymbol_to_list (actual_name, strlen (actual_name),
STRUCT_NAMESPACE, LOC_TYPEDEF,
- &objfile->static_psymbols,
+ &objfile->global_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
if (cu_language == language_cplus)
@@ -1565,14 +1567,14 @@ add_partial_symbol (struct partial_die_info *pdi, struct objfile *objfile,
/* For C++, these implicitly act as typedefs as well. */
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_NAMESPACE, LOC_TYPEDEF,
- &objfile->static_psymbols,
+ &objfile->global_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
}
break;
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_NAMESPACE, LOC_CONST,
- &objfile->static_psymbols,
+ &objfile->global_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
break;
default:
@@ -5239,26 +5241,43 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
gdb_assert (SYMBOL_DEMANGLED_NAME (sym) == NULL);
}
}
-
- add_symbol_to_list (sym, list_in_scope);
- /* The semantics of C++ state that "struct foo { ... }" also
- defines a typedef for "foo". Synthesize a typedef symbol so
- that "ptype foo" works as expected. */
- if (cu_language == language_cplus)
- {
- struct symbol *typedef_sym = (struct symbol *)
- obstack_alloc (&objfile->symbol_obstack,
- sizeof (struct symbol));
- *typedef_sym = *sym;
- SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
- if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
- TYPE_NAME (SYMBOL_TYPE (sym)) =
- obsavestring (SYMBOL_NAME (sym),
- strlen (SYMBOL_NAME (sym)),
- &objfile->type_obstack);
- add_symbol_to_list (typedef_sym, list_in_scope);
- }
+ {
+ /* NOTE: carlton/2002-11-29: Class symbols shouldn't
+ really ever be static objects: otherwise, if you try
+ to, say, break of a class's method and you're in a file
+ which doesn't mention that class, it won't work unless
+ the check for all static symbols in lookup_symbol_aux
+ saves you. Though perhaps C allows different files to
+ define different structs with the same name; if so,
+ this should be conditional on C++. See the
+ OtherFileClass tests in gdb.c++/namespace.exp. */
+
+ struct pending **list_to_add;
+
+ list_to_add = (list_in_scope == &file_symbols
+ ? &global_symbols : list_in_scope);
+
+ add_symbol_to_list (sym, list_to_add);
+
+ /* The semantics of C++ state that "struct foo { ... }" also
+ defines a typedef for "foo". Synthesize a typedef symbol so
+ that "ptype foo" works as expected. */
+ if (cu_language == language_cplus)
+ {
+ struct symbol *typedef_sym = (struct symbol *)
+ obstack_alloc (&objfile->symbol_obstack,
+ sizeof (struct symbol));
+ *typedef_sym = *sym;
+ SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
+ if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
+ TYPE_NAME (SYMBOL_TYPE (sym)) =
+ obsavestring (SYMBOL_NAME (sym),
+ strlen (SYMBOL_NAME (sym)),
+ &objfile->type_obstack);
+ add_symbol_to_list (typedef_sym, list_to_add);
+ }
+ }
break;
case DW_TAG_typedef:
if (processing_has_namespace_info
@@ -5292,7 +5311,17 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile,
{
dwarf2_const_value (attr, sym, objfile, cu_header);
}
- add_symbol_to_list (sym, list_in_scope);
+ {
+ /* NOTE: carlton/2002-11-29: See comment above in the
+ DW_TAG_class_type, etc. block. */
+
+ struct pending **list_to_add;
+
+ list_to_add = (list_in_scope == &file_symbols
+ ? &global_symbols : list_in_scope);
+
+ add_symbol_to_list (sym, list_to_add);
+ }
break;
default:
/* Not a tag we recognize. Hopefully we aren't processing
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 6fa5e95..0886e86 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2002-11-29 David Carlton <carlton@bactrian.org>
+
+ * gdb.c++/namespace.exp: Add OtherFileClass tests.
+ * gdb.c++/namespace1.cc (C): New file.
+
2002-11-27 David Carlton <carlton@math.stanford.edu>
* gdb.c++/m-data.cc (main): Add marker comment.
diff --git a/gdb/testsuite/gdb.c++/namespace.exp b/gdb/testsuite/gdb.c++/namespace.exp
index d8fa938..fa38f2e 100644
--- a/gdb/testsuite/gdb.c++/namespace.exp
+++ b/gdb/testsuite/gdb.c++/namespace.exp
@@ -39,6 +39,7 @@ if { [skip_cplus_tests] } { continue }
set testfile "namespace"
set srcfile ${testfile}.cc
+set srcfile1 ${testfile}1.cc
set binfile ${objdir}/${subdir}/${testfile}
if [get_compiler_info ${binfile}] {
@@ -47,7 +48,7 @@ if [get_compiler_info ${binfile}] {
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1}" "${binfile}" executable {debug c++}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will a
utomatically fail."
}
@@ -251,13 +252,19 @@ gdb_test "ptype E" "type = namespace C::D::E" "ptype C::D::E"
gdb_test "ptype CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}" "ptype CClass"
gdb_test "ptype CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}" "ptype CClass::NestedClass"
gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context." "ptype NestedClass"
-gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n inty;\r\n\}" "ptype ::C::CClass"
+gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}" "ptype ::C::CClass"
gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}" "ptype ::C::CClass::NestedClass"
gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"." "ptype ::C::NestedClass"
gdb_test "ptype C::CClass" "No symbol \"Class\" in namespace \"C::C\"" "ptype C::CClass"
gdb_test "ptype C::CClass::NestedClass" "No symbol \"Class\" in namespace \"C::C\"" "ptype C::CClass::NestedClass"
gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"." "ptype C::NestedClass"
+# Tests involving multiple files
+
+gdb_test "ptype OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}" "ptype OtherFileClass"
+gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}" "ptype ::C::OtherFileClass"
+gdb_test "ptype C::OtherFileClass" "No symbol \"Class\" in namespace \"C::C\"" "ptype C::OtherFileClass"
+
# Some anonymous namespace tests.
gdb_test "print cX" "\\$\[0-9\].* = 6" "print cX"
diff --git a/gdb/testsuite/gdb.c++/namespace1.cc b/gdb/testsuite/gdb.c++/namespace1.cc
new file mode 100644
index 0000000..ac4703c
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/namespace1.cc
@@ -0,0 +1,7 @@
+namespace C
+{
+ class OtherFileClass {
+ public:
+ int z;
+ };
+}