Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] Fix bug report 11479
@ 2010-04-08 20:40 Pierre Muller
  2010-04-12 15:55 ` Joel Brobecker
  0 siblings, 1 reply; 12+ messages in thread
From: Pierre Muller @ 2010-04-08 20:40 UTC (permalink / raw)
  To: gdb-patches

  I finally for once decide to use the bug database.
I reported bug 11479, with a simple test case.
http://sourceware.org/bugzilla/show_bug.cgi?id=11479

  Here is the patch that fixes the problem for me.

  This is not a direct RFA for two reasons:
 1) I don't remember how the ChangeLog should reflect the fact
that the commit is related to this bug.
 2) concerning  the fix in stabsread.c,
this chain of different types that all point to the same main type
could apparently be something else than just
a simple 'const' or 'volatile' modifier.
  But I don't think that I know enough
about the other possibilities to know if I should exclude them
from my patch by checking if only TYPE_CONST and TYPE_VOLATILE are
different.

Pierre


2010-04-08  Pierre Muller  <muller@ics.u-strasbg.fr>

	* stabsread.c (read_struct_type): Also set length of
	other types in the chain.
	
Testsuite ChangeLog entry:

2010-04-08  Pierre Muller  <muller@ics.u-strasbg.fr>
	Test for bug 11479.
	* gdb.stabs/gdb11479.exp: New file.
	* gdb.stabs/gdb11479.c: New file.

Index: src/gdb/stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.124
diff -u -p -r1.124 stabsread.c
--- src/gdb/stabsread.c	5 Apr 2010 22:43:47 -0000	1.124
+++ src/gdb/stabsread.c	8 Apr 2010 16:35:24 -0000
@@ -3448,9 +3448,17 @@ read_struct_type (char **pp, struct type
 
   {
     int nbits;
+    struct type *ntype;
     TYPE_LENGTH (type) = read_huge_number (pp, 0, &nbits, 0);
     if (nbits != 0)
       return error_type (pp, objfile);
+    ntype = TYPE_CHAIN (type);
+    while (ntype != type)
+      {
+	if (TYPE_LENGTH(ntype) == 0)
+	  TYPE_LENGTH (ntype) = TYPE_LENGTH (type);
+	ntype = TYPE_CHAIN (ntype);
+      }
   }
 
   /* Now read the baseclasses, if any, read the regular C struct or C++
Index: src/gdb/testsuite/gdb.stabs/gdb11479.exp
===================================================================
RCS file: testsuite/gdb.stabs/gdb11479.exp
diff -N testsuite/gdb.stabs/gdb11479.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/gdb/testsuite/gdb.stabs/gdb11479.exp	8 Apr 2010 16:35:24 -0000
@@ -0,0 +1,51 @@
+# 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/>.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@gnu.org
+
+# Test GDB stabs problem with qualified parameter of forward types.
+
+if $tracelevel then {
+	strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+set testfile "gdb11479"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable
{debug}] != "" } {
+    untested "couldn't compile ${srcdir}/${subdir}/${srcfile}"
+    return -1
+}
+
+# Start with a fresh gdb.
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Regression test for a cleanup bug in the charset code.
+gdb_test "rb test" "" "Set breakpoints"
+gdb_test "run" "Breakpoint .* test2 .*" "Stop at first breakpoint"
+gdb_test "print *t" ".*\{x = 5, y = 25, b = 2.5\}.*" "Inspect t in test2"
+gdb_test "continue" "Breakpoint .* test .*" "Stop at first breakpoint"
+gdb_test "print *t" ".*\{x = 5, y = 25, b = 2.5\}.*" "Inspect t in test"
+
+gdb_exit 
Index: src/gdb/testsuite/gdb.stabs/gdb11479.c
===================================================================
RCS file: testsuite/gdb.stabs/gdb11479.c
diff -N testsuite/gdb.stabs/gdb11479.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/gdb/testsuite/gdb.stabs/gdb11479.c	8 Apr 2010 16:35:24 -0000
@@ -0,0 +1,61 @@
+/* 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/>.
+
+   Please email any bugs, comments, and/or additions to this file to:
+   bug-gdb@gnu.org  */
+
+/* Qualifiers of forward types are not resolved correctly with stabs.  */
+
+struct dummy;
+
+const void *
+test (const struct dummy *t)
+{
+  const struct dummy *tt;
+  tt = t;
+  return t;
+}
+
+void *
+test2 (struct dummy *t)
+{
+  struct dummy *tt;
+  tt = t;
+  return t;
+}
+
+
+struct dummy {
+ int x;
+ int y;
+ double b;
+} tag_dummy;
+
+
+int
+main ()
+{
+  struct dummy tt;
+  tt.x = 5;
+  tt.y = 25;
+  tt.b = 2.5;
+  test2 (&tt);
+  test (&tt);
+  return 0;
+}


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-04-22 13:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-08 20:40 [RFC] Fix bug report 11479 Pierre Muller
2010-04-12 15:55 ` Joel Brobecker
2010-04-12 16:22   ` Pierre Muller
2010-04-13 15:28     ` Joel Brobecker
2010-04-21 15:11       ` Joel Brobecker
2010-04-21 21:11         ` Pierre Muller
2010-04-22  1:11           ` Joel Brobecker
2010-04-22 10:20             ` [RFA-v2] " Pierre Muller
2010-04-22 12:20               ` Joel Brobecker
2010-04-22 13:03                 ` Pierre Muller
2010-04-22 13:26                   ` Joel Brobecker
2010-04-22 13:39                     ` Pierre Muller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox