This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA-v2] PR 11530: Fix and test case
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: <tromey at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Sat, 8 May 2010 17:32:43 +0200
- Subject: [RFA-v2] PR 11530: Fix and test case
- References: <36245.8778698512$1272577829@news.gmane.org> <m3mxwkzwb4.fsf@fleche.redhat.com> <1723.54181199825$1273097500@news.gmane.org> <m3ocgrfvw5.fsf@fleche.redhat.com>
> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Tom Tromey
> Envoyé?: Friday, May 07, 2010 7:46 PM
> À?: Pierre Muller
> Cc?: gdb-patches@sourceware.org
> Objet?: Re: [RFA] PR 11530: Fix and test case
>
> >>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
> writes:
>
> Pierre> If the compiler is not gcc we should skip the test,
> Pierre> is that what you want?
>
> Pierre> if {![test_compiler_info gcc-*]} {
> Pierre> return 0
> Pierre> }
>
> Pierre> Would this fit?
>
> Yes, thanks.
It turned out that test_compiler_info needs
a call to get_compiler_info before otherwise
it returns unknown...
Here is a new version of the patch.
Tested on gcc16, adds 3 PASS (while current CVS
gives two failures on gdb11530.exp test).
Pierre
2010-05-08 Pierre Muller <muller@ics.u-strasbg.fr>
PR exp/11530.
* gdbtypes.c (lookup_struct_elt_type): Also lookup
names of unnamed structures or unions.
testsuite ChangeLog entry:
2010-05-08 Pierre Muller <muller@ics.u-strasbg.fr>
PR exp/11530.
* testsuite/gdb.base/gdb11530.c: New file.
* testsuite/gdb.base/gdb11530.exp: New file.
Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.190
diff -u -p -r1.190 gdbtypes.c
--- gdbtypes.c 6 May 2010 19:41:12 -0000 1.190
+++ gdbtypes.c 8 May 2010 14:01:26 -0000
@@ -1244,6 +1244,13 @@ lookup_struct_elt_type (struct type *typ
{
return TYPE_FIELD_TYPE (type, i);
}
+ else if (!t_field_name || *t_field_name == '\0')
+ {
+ struct type *subtype = lookup_struct_elt_type (
+ TYPE_FIELD_TYPE (type, i), name, 1);
+ if (subtype != NULL)
+ return subtype;
+ }
}
/* OK, it's not in this class. Recursively check the baseclasses. */
Index: testsuite/gdb.base/gdb11530.c
===================================================================
RCS file: testsuite/gdb.base/gdb11530.c
diff -N testsuite/gdb.base/gdb11530.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/gdb11530.c 8 May 2010 14:01:26 -0000
@@ -0,0 +1,35 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 Free Software Foundation, Inc.
+
+ Contributed by Pierre Muller.
+
+ 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/>.
+
+ Test for problem related to unnamed unions. */
+
+struct a
+ {
+ union
+ {
+ int i;
+ };
+ } a;
+
+int
+main (void)
+{
+ return sizeof (a.i);
+}
+
Index: testsuite/gdb.base/gdb11530.exp
===================================================================
RCS file: testsuite/gdb.base/gdb11530.exp
diff -N testsuite/gdb.base/gdb11530.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/gdb11530.exp 8 May 2010 14:01:26 -0000
@@ -0,0 +1,55 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2010 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/>.
+
+# Test GDB bug report 11530.
+# This is a problem related unnamed unions.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+set testfile "gdb11530"
+set binfile ${testfile}${EXEEXT}
+
+# Unnamed union is a GNU extension, thus we restrict the test
+# to gcc compiler.
+
+if [get_compiler_info ${binfile}] {
+ return -1;
+}
+
+if { ![test_compiler_info gcc*] } {
+ return 0;
+}
+
+if { [prepare_for_testing $testfile.exp $testfile $testfile.c {debug}] } {
+ return -1;
+}
+
+
+if { ![runto main] } then {
+ fail "run to main"
+ return
+}
+
+gdb_test "print a.i" " = 0"
+gdb_test "print sizeof (a.i)" " = \[0-9\]+"
+gdb_test "print sizeof (a.i) == sizeof (int)" " = 1"
+