Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: <tromey@redhat.com>
Cc: <gdb-patches@sourceware.org>
Subject: [RFA-v2] PR 11530: Fix and test case
Date: Sat, 08 May 2010 15:33:00 -0000	[thread overview]
Message-ID: <000001caeec3$b4068500$1c138f00$@muller@ics-cnrs.unistra.fr> (raw)
In-Reply-To: <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"
+



  reply	other threads:[~2010-05-08 15:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <36245.8778698512$1272577829@news.gmane.org>
2010-04-30 17:26 ` [RFA] " Tom Tromey
2010-05-05 22:11   ` Pierre Muller
     [not found]   ` <1723.54181199825$1273097500@news.gmane.org>
2010-05-07 17:45     ` Tom Tromey
2010-05-08 15:33       ` Pierre Muller [this message]
2010-05-11 16:57         ` [RFA-v2] " Tom Tromey
2010-05-11 22:05           ` Pierre Muller

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='000001caeec3$b4068500$1c138f00$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /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