This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA- v2] Testcase for bug report 11531 and fix for Solaris
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Pedro Alves'" <pedro at codesourcery dot com>, <gdb-patches at sourceware dot org>
- Cc: "'Joel Brobecker'" <brobecker at adacore dot com>
- Date: Sat, 24 Apr 2010 17:13:06 +0200
- Subject: [RFA- v2] Testcase for bug report 11531 and fix for Solaris
- References: <000301cae303$d6d068b0$84713a10$@muller@ics-cnrs.unistra.fr> <20100423172933.GO19194@adacore.com> <201004231915.49375.pedro@codesourcery.com>
> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Pedro Alves
> Envoyé?: Friday, April 23, 2010 8:16 PM
> À?: gdb-patches@sourceware.org
> Cc?: Joel Brobecker; Pierre Muller
> Objet?: Re: [RFA] Testcase for bug report 11531
>
> On Friday 23 April 2010 18:29:33, Joel Brobecker wrote:
> > > +gdb_test "start" ".*Temporary breakpoint.*"
> >
> > Unfortunately, this does not work when testing with the remote
> protocol.
> > Do use "runto", but use "*main" instead of "main", or something like
> > that. That way, you should always stop before the instruction that
> > causes the watchpoint to trigger.
> >
>
> Or avoid those tricks, and simply put another statement before
> the one that triggers the watchpoint:
>
> int
> main ()
> {
> + myrec.y = 1; <<<<<< runto main stops here instead.
I found another way:
simply remove all breakpoints before
setting the watchpoint.
Tested with cygwin GDB and GDBserver,
both give 6 PASS.
On a i386 solaris 32-bit GDB executable,
I get two failures that disappear
once I remove the macro from nm-i386-sol2.h.
Pierre Muller
PS1: Once this macro is removed, I
will submit a RFA for the complete removal
of nm-i386-sol2.h.
PS2: The code inside infrun.c ought to
be changed as well. If it is now non-functional
I propose to generate a compilation error
if the macro is still defined, this way
third party users will not be surprised that
it does not work...
ChangeLog entry:
2010-04-24 Pierre Muller <muller@ics.u-strasbg.fr>
* config/i386/nm-i386-sol2.h (CANNOT_STEP_HW_WATCHPOINTS):
Remove macro.
testsuite/ChangeLog entry:
PR breakpoints/11531.
* testsuite/gdb.base/gdb11531.c: New file.
* testsuite/gdb.base/gdb11531.exp: New file.
Index: config/i386/nm-i386sol2.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386sol2.h,v
retrieving revision 1.19
diff -u -p -r1.19 nm-i386sol2.h
--- config/i386/nm-i386sol2.h 1 Jan 2010 07:31:48 -0000 1.19
+++ config/i386/nm-i386sol2.h 24 Apr 2010 15:07:54 -0000
@@ -27,6 +27,8 @@
Work around the problem by removing hardware watchpoints if a step is
requested, GDB will check for a hardware watchpoint trigger after the
step anyway. */
-#define CANNOT_STEP_HW_WATCHPOINTS
+/* The code related to this macro does not work
+ anymore. Thus we remove this macro definition. */
+/* #define CANNOT_STEP_HW_WATCHPOINTS */
#endif /* NEW_PROC_API */
Index: testsuite/gdb.base/gdb11531.c
===================================================================
RCS file: testsuite/gdb.base/gdb11531.c
diff -N testsuite/gdb.base/gdb11531.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/gdb11531.c 24 Apr 2010 13:20:02 -0000
@@ -0,0 +1,40 @@
+/* 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 Solaris specific watchpoint problem. */
+
+struct rec
+{
+ int x;
+ double y;
+ int z;
+};
+
+static struct rec myrec;
+
+int
+main ()
+{
+ myrec.x = 5;
+ myrec.y = 3.4;
+ myrec.z = 56;
+ myrec.x = 78;
+ return myrec.x;
+}
+
Index: testsuite/gdb.base/gdb11531.exp
===================================================================
RCS file: testsuite/gdb.base/gdb11531.exp
diff -N testsuite/gdb.base/gdb11531.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/gdb11531.exp 24 Apr 2010 13:20:02 -0000
@@ -0,0 +1,63 @@
+# 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 "gdb11531"
+
+if { [prepare_for_testing $testfile.exp $testfile $testfile.c {debug}] } {
+ return -1;
+}
+
+
+if { ![runto main] } then {
+ fail "run to main"
+ return
+}
+
+# If the breakpoint is at the same instruction as the
+# watchpoint value assignment
+# you can fall into the problem of the stepping over the breakpoint
+# location that can also trigger a watchpoint miss
+# This is not the problem reported here.
+# Thus we remove all breakpoints first.
+
+delete_breakpoints
+
+gdb_test "watch myrec.x" ".*atchpoint \[0-9\]+: myrec\.x" "Set watchpoint "
+
+gdb_test "stepi" \
+ "Old value = 0.*New value = 5.*" \
+ "watchpoint variable triggers at next"
+
+gdb_test "continue" \
+ "Old value = .*New value = 78.*" \
+ "watchpoint variable triggers at continue"
+
+gdb_test "continue" ".*Program exited.*" "Continue to program exit"
+
+gdb_test "start" "" "restart"
+
+gdb_test "next" "Old value = 0.*New value = 5.*" "watchpoint triggers after
second start"
+