This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: fix PR c++/8000
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 19 Jan 2010 11:11:00 -0700
- Subject: FYI: fix PR c++/8000
- Reply-to: tromey at redhat dot com
I'm checking this in.
This patch fixes PR c++/8000, a bug involving enums in namespaces.
Here is a simple test:
namespace ns {
enum x { A, B, C };
};
int main()
{
ns::x a = ns::A;
return a;
}
Currently gdb will do this:
(gdb) p ns::A
Internal: static symbol `A' found in ../../../../libstdc++-v3/src/concept-inst.cc psymtab but not in symtab.
A may be an inlined function, or may be a template function
(if a template, try specifying an instantiation: A<type>).
The fix is to make sure that the enumerators are namespace-qualified in
all cases.
Regression tested on x86-64 (compile farm). New test case included.
Tom
2010-01-19 Tom Tromey <tromey@redhat.com>
PR c++/8000:
* dwarf2read.c (partial_die_parent_scope): Put enumeration type
into parent scope, and enumerator into grandparent scope.
2010-01-19 Tom Tromey <tromey@redhat.com>
PR c++/8000:
* gdb.cp/namespace.exp: Use new enum. Fix line numbers in
existing tests.
* gdb.cp/namespace.cc (AAA::SomeEnum): New enum.
(main): Use AAA::SomeEnum.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.348
diff -u -r1.348 dwarf2read.c
--- dwarf2read.c 19 Jan 2010 09:47:47 -0000 1.348
+++ dwarf2read.c 19 Jan 2010 18:09:26 -0000
@@ -2386,7 +2386,8 @@
|| parent->tag == DW_TAG_structure_type
|| parent->tag == DW_TAG_class_type
|| parent->tag == DW_TAG_interface_type
- || parent->tag == DW_TAG_union_type)
+ || parent->tag == DW_TAG_union_type
+ || parent->tag == DW_TAG_enumeration_type)
{
if (grandparent_scope == NULL)
parent->scope = parent->name;
@@ -2394,7 +2395,7 @@
parent->scope = typename_concat (&cu->comp_unit_obstack, grandparent_scope,
parent->name, cu);
}
- else if (parent->tag == DW_TAG_enumeration_type)
+ else if (parent->tag == DW_TAG_enumerator)
/* Enumerators should not get the name of the enumeration as a prefix. */
parent->scope = grandparent_scope;
else
Index: testsuite/gdb.cp/namespace.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/namespace.cc,v
retrieving revision 1.5
diff -u -r1.5 namespace.cc
--- testsuite/gdb.cp/namespace.cc 28 Dec 2009 21:45:24 -0000 1.5
+++ testsuite/gdb.cp/namespace.cc 19 Jan 2010 18:09:28 -0000
@@ -8,6 +8,11 @@
int xx;
int fum (int);
};
+ enum SomeEnum {
+ ALPHA,
+ BETA,
+ DELTA
+ };
};
int AAA::inA::fum (int i)
@@ -174,6 +179,7 @@
{
using AAA::inA;
char c1;
+ AAA::SomeEnum var = AAA::ALPHA;
using namespace BBB;
Index: testsuite/gdb.cp/namespace.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/namespace.exp,v
retrieving revision 1.15
diff -u -r1.15 namespace.exp
--- testsuite/gdb.cp/namespace.exp 1 Jan 2010 07:32:01 -0000 1.15
+++ testsuite/gdb.cp/namespace.exp 19 Jan 2010 18:09:28 -0000
@@ -164,7 +164,7 @@
# Break on a function in a namespace
gdb_test "break AAA::xyzq" \
- "Breakpoint.*at $hex: file.*namespace.cc, line 42\\."
+ "Breakpoint.*at $hex: file.*namespace.cc, line 47\\."
# Call a function in a nested namespace
@@ -189,7 +189,7 @@
# Break on a function in a nested namespace
gdb_test "break BBB::CCC::xyzq" \
- "Breakpoint.*at $hex: file.*namespace.cc, line 58\\."
+ "Breakpoint.*at $hex: file.*namespace.cc, line 63\\."
# Print address of a function in a class in a namespace
@@ -214,7 +214,7 @@
# Break on a function in a class in a namespace
gdb_test "break BBB::Class::xyzq" \
- "Breakpoint.*at $hex: file.*namespace.cc, line 63\\."
+ "Breakpoint.*at $hex: file.*namespace.cc, line 68\\."
# Test to see if the appropriate namespaces are in scope when trying
# to print out stuff from within a function defined within a
@@ -271,3 +271,6 @@
gdb_test "print G::XgX" "\\$\[0-9\].* = 11"
gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context."
gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context."
+
+# Enum tests.
+gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA"