From: Sterling Augustine <saugustine@google.com>
To: gdb-patches@sourceware.org
Subject: Make DW_TAG_enumerator's consistent, regardless of containing scope
Date: Fri, 07 Oct 2011 21:27:00 -0000 [thread overview]
Message-ID: <CAEG7qUxckuOJJzDza6fHrajeNyr9bdd-jT22oQL85Dh0p-BN5w@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1426 bytes --]
This patch fixes the issue described in
http://sourceware.org/ml/gdb/2011-09/msg00119.html. To recap, consider
the testcase below. Dividing the namespace definition into two
compilation units and their order on the command-line is essential to
see the problem.
enum0_main.cc:
namespace foo { }
int main() { return 0; }
enum0.cc:
namespace foo {
enum B { B_B };
enum B b = B_B;
};
saugustine@sterling$ g++ -g enum0_main.cc enum0.cc -o enum-namespace
saugustine@sterling$ gdb ./enum-namespace
GNU gdb (GDB) 7.3.50.20111007-cvs
...
(gdb) p foo::B_B
No symbol "B_B" in namespace "foo".
(gdb) p foo::B::B_B
`foo::B' is not defined as an aggregate type.
GDB puts this definition into the partial symbol table as foo::B::B_B,
but it should be foo::B_B.
After partial symbols have been converted to full symbols, the
enum-type is not be included as part of the enumerator's scope.
The enclosed patch fixes the situation dropping the enum-type name for
all enumerators. The original code was commented that it should do
that, but didn't work because it was looking at the enumerator die's
parent die, rather than the enumerator die itself.
The file split in the test case is required to avoid reading all of
namespace foo's symbols in the intermediate symbol lookup.
OK to commit?
Sterling
2011-10-07 Sterling Augustine <saugustine@google.com>
* dwarf2read.c (partial_die_parent_scope): Rearrange conditional logic.
[-- Attachment #2: enumerator-patch --]
[-- Type: application/octet-stream, Size: 1030 bytes --]
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.561
diff -d -u -r1.561 dwarf2read.c
--- dwarf2read.c 13 Sep 2011 21:44:27 -0000 1.561
+++ dwarf2read.c 7 Oct 2011 17:51:52 -0000
@@ -3878,7 +3878,10 @@
return NULL;
}
- if (parent->tag == DW_TAG_namespace
+ if (pdi->tag == DW_TAG_enumerator)
+ /* Enumerators should not get the name of the enumeration as a prefix. */
+ parent->scope = grandparent_scope;
+ else if (parent->tag == DW_TAG_namespace
|| parent->tag == DW_TAG_module
|| parent->tag == DW_TAG_structure_type
|| parent->tag == DW_TAG_class_type
@@ -3893,9 +3896,6 @@
grandparent_scope,
parent->name, 0, cu);
}
- else if (parent->tag == DW_TAG_enumerator)
- /* Enumerators should not get the name of the enumeration as a prefix. */
- parent->scope = grandparent_scope;
else
{
/* FIXME drow/2004-04-01: What should we be doing with
next reply other threads:[~2011-10-07 21:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-07 21:27 Sterling Augustine [this message]
2011-10-07 23:43 ` Keith Seitz
2011-10-08 0:46 ` Sterling Augustine
2011-10-10 22:21 ` Sterling Augustine
2011-10-11 17:07 ` Tom Tromey
2011-10-11 18:27 ` Sterling Augustine
2011-10-11 19:04 ` Tom Tromey
2011-10-12 9:21 ` [obv] Fix gdb.cp/namespace-enum.exp compilation [Re: Make DW_TAG_enumerator's consistent, regardless of containing scope] Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAEG7qUxckuOJJzDza6fHrajeNyr9bdd-jT22oQL85Dh0p-BN5w@mail.gmail.com \
--to=saugustine@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox