Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sterling Augustine <saugustine@google.com>
To: gdb-patches@sourceware.org
Subject: Re: Make DW_TAG_enumerator's consistent, regardless of containing scope
Date: Mon, 10 Oct 2011 22:21:00 -0000	[thread overview]
Message-ID: <CAEG7qUyjapfjgBhYOVBxGmm04zrKfddtKk7Q34ob=W+z+Zoj_A@mail.gmail.com> (raw)
In-Reply-To: <CAEG7qUxckuOJJzDza6fHrajeNyr9bdd-jT22oQL85Dh0p-BN5w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1230 bytes --]

On Fri, Oct 7, 2011 at 4:42 PM, Keith Seitz <keiths@redhat.com> wrote:
> On 10/07/2011 02:26 PM, Sterling Augustine wrote:
>>
>> 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.
>
> First things first: this is going to need a test case.

Enclosed please find the same patch, only this time with a test case.

> I've tried to reproduce this, but I cannot seem to replicate using your
> instructions:
>

To recap: be sure to compile it like so:

g++ namespace-enum-main.cc namespace-enum.cc -g

The order of the source files matters.

OK to commit?

Sterling

gdb/ChangeLog
2011-10-07  Sterling Augustine  <saugustine@google.com>

       * dwarf2read.c (partial_die_parent_scope): Rearrange conditional logic.

gdb/testsuite/gdb.cp/ChangeLog
2011-10-10  Sterling Augustine  <saugustine@google.com>

       * gdb.cp/Makefile.in: Add namespace-enum test.
       * gdb.cp/namespace-enum.exp: New file.
       * gdb.cp/namespace-enum.c: New file.
       * gdb.cp/namespace-enum-main.c: New file.

[-- Attachment #2: enumerator-patch --]
[-- Type: application/octet-stream, Size: 5156 bytes --]

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.568
diff -u -p -r1.568 dwarf2read.c
--- dwarf2read.c	9 Oct 2011 19:34:18 -0000	1.568
+++ dwarf2read.c	10 Oct 2011 21:33:09 -0000
@@ -3897,7 +3897,10 @@ partial_die_parent_scope (struct partial
       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
@@ -3912,9 +3915,6 @@ partial_die_parent_scope (struct partial
 					 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
Index: testsuite/gdb.cp/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/Makefile.in,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile.in
--- testsuite/gdb.cp/Makefile.in	22 Feb 2011 20:52:46 -0000	1.13
+++ testsuite/gdb.cp/Makefile.in	10 Oct 2011 21:33:14 -0000
@@ -7,9 +7,9 @@ EXECUTABLES = abstract-origin ambiguous 
 	exception expand-sals extern-c formatted-ref fpointer gdb1355 \
 	gdb2384 hang infcall-dlopen inherit koenig local m-data m-static \
 	mb-ctor mb-inline mb-templates member-ptr method misc namespace \
-	namespace-nested-import nextoverthrow noparam nsdecl nsimport \
-	nsnested nsnoimports nsrecurs nsstress nsusing operator oranking \
-	overload overload-const ovldbreak pass-by-ref pr-1023 pr-1210 \
+	namespace-enum namespace-nested-import nextoverthrow noparam nsdecl \
+	nsimport nsnested nsnoimports nsrecurs nsstress nsusing operator \
+	oranking overload overload-const ovldbreak pass-by-ref pr-1023 pr-1210 \
 	pr-574 pr10728 pr12028 pr9631 printmethod psmang ptype-cv-cp \
 	re-set-overloaded ref-typ ref-typ2 rtti shadow smartp temargs \
 	templates try_catch typedef-operator userdef virtbase virtfunc \
Index: testsuite/gdb.cp/namespace-enum-main.cc
===================================================================
RCS file: testsuite/gdb.cp/namespace-enum-main.cc
diff -N testsuite/gdb.cp/namespace-enum-main.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/namespace-enum-main.cc	10 Oct 2011 21:33:14 -0000
@@ -0,0 +1,5 @@
+namespace foo {
+int aglobal = 0;
+}
+
+int main() {return 0;}
Index: testsuite/gdb.cp/namespace-enum.cc
===================================================================
RCS file: testsuite/gdb.cp/namespace-enum.cc
diff -N testsuite/gdb.cp/namespace-enum.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/namespace-enum.cc	10 Oct 2011 21:33:14 -0000
@@ -0,0 +1,8 @@
+enum A { A_A };
+enum A a = A_A;
+
+namespace foo
+{
+enum B { B_B };
+enum B b = B_B;
+};
Index: testsuite/gdb.cp/namespace-enum.exp
===================================================================
RCS file: testsuite/gdb.cp/namespace-enum.exp
diff -N testsuite/gdb.cp/namespace-enum.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/namespace-enum.exp	10 Oct 2011 21:33:14 -0000
@@ -0,0 +1,49 @@
+# Copyright 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set testfile namespace-enum
+set srcfile0 ${testfile}.cc
+set objfile0 ${testfile}.o
+set srcfile1 ${testfile}-main.cc
+set objfile1 ${testfile}-main.o
+set binfile ${objdir}/${subdir}/${testfile}
+
+if  { [gdb_compile "$srcdir/$subdir/$srcfile0" "$objdir/$subdir/$objfile0" object {debug c++}] != "" } {
+     untested namespace-enum.exp
+     return -1
+}
+
+if  { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
+     untested namespace-enum.exp
+     return -1
+}
+
+if  { [gdb_compile "$objdir/$subdir/$objfile0 $objdir/$subdir/$objfile1" "${binfile}" executable {debug c++}] != "" } {
+     untested namespace-enum.exp
+     return -1
+}
+
+if [get_compiler_info ${binfile} "c++"] {
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+gdb_test "print foo::B::B_B" "`foo::B' is not defined as an aggregate type."
+gdb_test "print foo::B_B" "foo::B_B"
+gdb_test "print A_A" "A_A"
+

  parent reply	other threads:[~2011-10-10 22:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-07 21:27 Sterling Augustine
2011-10-07 23:43 ` Keith Seitz
2011-10-08  0:46   ` Sterling Augustine
2011-10-10 22:21 ` Sterling Augustine [this message]
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='CAEG7qUyjapfjgBhYOVBxGmm04zrKfddtKk7Q34ob=W+z+Zoj_A@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