This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [RFA-v2] Fix bug report 11479



> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Joel Brobecker
> Envoyé?: Thursday, April 22, 2010 2:20 PM
> À?: Pierre Muller
> Cc?: gdb-patches@sourceware.org
> Objet?: Re: [RFA-v2] Fix bug report 11479
> 
> > 2010-04-22  Pierre Muller  <muller@ics.u-strasbg.fr>
> >
> > 	PR stabs/11479.
> > 	* stabsread.c (set_length_in_type_chain): New function.
> > 	(read_struct_type): Call set_length_in_type_chain function.
> > 	(read_enum_type): Idem.
> 
> The code portion is pre-approved with the comments below. Just go ahead
> and check it in.

  Thanks, I did commit this part with your
detailed comment.
 
> > 2010-04-22  Pierre Muller  <muller@ics.u-strasbg.fr>
> >
> > 	PR stabs/11479.
> > 	* gdb.stabs/gdb11479.exp: New file.
> > 	* gdb.stabs/gdb11479.c: New file.
> 
> This portion can be checked in separately after we answer the few
> questions
> I have (see below).
> > +   Please email any bugs, comments, and/or additions to this file
> to:
> > +   bug-gdb@gnu.org  */
> 
> Can you remove this bit?
Done. 
> > +# Please email any bugs, comments, and/or additions to this file to:
> > +# bug-gdb@gnu.org
> 
> Same for this one...
OK. 
> > +set testfile "gdb11479"
> > +set srcfile ${testfile}.c
> > +set binfile ${objdir}/${subdir}/${testfile}
> > +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}"
> executable
> > {debug additional_flags=-gstabs}] != "" } {
> > +    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}
> 
> Can you actually use "prepare_for_testing" here? The only thing that
> is a bit out of the ordinary is request the -gstabs debug flag.  I am
> actually wondering if we really want that, since this may not work on
> certain platforms while we might still want to use the test with the
> default debug format.  
  This is a stabs specific bug,
when I first tried to test it on gcc16 from the compile farm,
I got no difference in the output.
  This was due to the fact that gcc16 is a 64-bit linux machine
and as such uses dwarf debug format by default.
  So I thought, why not try to force using stabs debugging,
and fall back to normal compilation if this fails.

>On the other hand, you probably want to make sure
> that your test gets run with -gstabs on Windows, so we have two
> incompatible objectives...
> 
> How's about we do 2 builds? One with standard debug, and another with
> -gstabs? We can repeat the testing by putting the gdb_test calls inside
> a proc and then call it twice? I think that prepare_for_testing should
> be able to handle the case where you need to add additional_flags as
> well. In fact:
> 
>     gdb.base/commands.exp:if { [prepare_for_testing commands.exp
> commands run.c {debug additional_flags=-DFAKEARGV}] } {
> 
> > +# Regression test for a cleanup bug in the charset code.
> 
> ?
  You probably guessed now which file I used to
create those new ones...
Removed. 
> > +gdb_exit
> 
> Harmless, but unnecessary. Let's toss it.
Removed at the end, but reintroduced below...

 I am not convinced that a second round using
default compiler debug settings is really useful,
unless the same bug reappears once in another debug format,
which is pretty unlikely.

 But I still wrote a new version with two builds.

Is this OK for you?

Pierre

Testsuite ChangeLog entry:

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

	PR stabs/11479.
	* gdb.stabs/gdb11479.exp: New file.
	* gdb.stabs/gdb11479.c: New file.

Index: 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
+++ testsuite/gdb.stabs/gdb11479.c	22 Apr 2010 13:02:08 -0000
@@ -0,0 +1,66 @@
+/* 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/>.
+
+   Qualifiers of forward types are not resolved correctly with stabs.  */
+
+struct dummy;
+
+enum dummy_enum;
+
+const void *
+test (const struct dummy *t)
+{
+  const struct dummy *tt;
+  enum dummy_enum *e;
+  tt = t;
+  return t;
+}
+
+void *
+test2 (struct dummy *t)
+{
+  struct dummy *tt;
+  const enum dummy_enum *e;
+  tt = t;
+  return t;
+}
+
+
+struct dummy {
+ int x;
+ int y;
+ double b;
+} tag_dummy;
+
+enum dummy_enum {
+  enum1,
+  enum2
+};
+
+int
+main ()
+{
+  struct dummy tt;
+  tt.x = 5;
+  tt.y = 25;
+  tt.b = 2.5;
+  test2 (&tt);
+  test (&tt);
+  return 0;
+}
Index: 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
+++ testsuite/gdb.stabs/gdb11479.exp	22 Apr 2010 13:02:08 -0000
@@ -0,0 +1,56 @@
+# 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 stabs problem with qualified parameter of forward types.
+
+if $tracelevel then {
+	strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+set testfile "gdb11479"
+
+proc do_test {version} {
+    gdb_test "rb test" "" "Set breakpoints $version"
+    gdb_test "run" "Breakpoint .* test2 .*" "Stop at first breakpoint
$version"
+    # Check that the struct is read in correctly
+    gdb_test "print *t" ".*\{x = 5, y = 25, b = 2.5\}.*" \
+	"Inspect t in test2 $version"
+    # Check that the enum type length has been set to a non-zero value
+    gdb_test "print sizeof (*e)" "= \[1-9\]*" "sizeof (e) in test2
$version"
+    gdb_test "continue" "Breakpoint .* test .*" \
+	"Stop at first breakpoint $version"
+    gdb_test "print *t" ".*\{x = 5, y = 25, b = 2.5\}.*" \
+	"Inspect t in test $version"
+    # Check that the enum type length has been set to a non-zero value
+    gdb_test "print sizeof (*e)" "= \[1-9\]*" "sizeof (e) in test $version"
+}
+
+if { [prepare_for_testing $testfile.exp $testfile $testfile.c {debug
additional_flags=-gstabs}] == 0 } {
+    do_test forced_stabs
+}
+
+# Without this gdb_exit the executable is still opened
+# by GDB which can generate a compilation failure. 
+gdb_exit
+
+if { [prepare_for_testing $testfile.exp $testfile $testfile.c {debug}] == 0
} {
+    do_test natural_debug_format
+}
+



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]