From: Dragos Tatulea <dragos.tatulea@gmail.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH] Bug 10645: small additions to existing testcase
Date: Tue, 03 Aug 2010 08:11:00 -0000 [thread overview]
Message-ID: <AANLkTimgPBkpneh78XQwhboJHU7iPksTVeB=us4N8w2S@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikTv6zVVix6AHpX77x51_2p-CGuihY95VZf3-nk@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 533 bytes --]
On Fri, Jul 30, 2010 at 11:13 PM, Dragos Tatulea
<dragos.tatulea@gmail.com> wrote:
> Hi,
>
> The original testcase has been done by Jan Kratochvil, added in
> the bug details. I just added a few extra lines.
> This bug has been partially fixed by another change (please check
> bug description for more details). After the commit mentioned in the
> bug, the test is passing. That's because invalid watchpoints are
> catched on access instead of mmap/munmap.
>
Forgot to attach the patch.
Thanks,
Dragos Tatulea
[-- Attachment #2: hwwatch_test.patch.txt --]
[-- Type: text/plain, Size: 5412 bytes --]
---
gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c | 45 +++++++
.../gdb.base/watchpoint-hw-unreadable.exp | 127 ++++++++++++++++++++
2 files changed, 172 insertions(+), 0 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c
create mode 100644 gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp
diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c
new file mode 100644
index 0000000..887c293
--- /dev/null
+++ b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.c
@@ -0,0 +1,45 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2009 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/>. */
+
+#include <stdio.h>
+
+static int dummy, *p, **pp;
+
+int
+main (void)
+{
+ dummy = 1;
+ dummy = 2;
+ p = &dummy;
+ dummy = 3;
+ dummy = 4;
+ pp = &p;
+ dummy = 5;
+ pp = NULL;
+ dummy = 6;
+ p = NULL;
+ dummy = 7;
+ p = &dummy;
+ dummy = 8;
+ dummy = 9;
+ pp = &p;
+ dummy = 10;
+ p = *pp;
+ dummy = 11;
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp
new file mode 100644
index 0000000..034972f
--- /dev/null
+++ b/gdb/testsuite/gdb.base/watchpoint-hw-unreadable.exp
@@ -0,0 +1,127 @@
+# Copyright 2009 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/>.
+
+# Tests watchpoints.
+# Input: Array of list containing the folowing elements:
+# 1: W_NAME - watched var name
+# 2: W_ID - watched var id
+# 3: OLD_VAL - expected old val
+# 4: NEW_VAL - expected new val
+proc gdb_watch_test {arg_array} {
+ upvar $arg_array arg_arr
+ global test
+ global gdb_prompt
+
+ set expect_output "\r\ninfrun: stopped by watchpoint\r\n.*"
+ foreach {k v} [array get arg_arr] {
+ set w_name [lindex $v 0]
+ set w_id [lindex $v 1]
+ set old_val [lindex $v 2]
+ set new_val [lindex $v 3]
+
+ set expect_output "$expect_output\r\nHardware watchpoint $w_id: \\$w_name\[\r\n\]+Old value = $old_val\r\nNew value = $new_val"
+ }
+
+ gdb_test_multiple "continue" $test {
+ -re "$expect_output.*$gdb_prompt $" {
+ #puts "PASS"
+ pass $test
+ }
+ default {
+ #puts "FAIL"
+ fail $test
+ return 0
+ }
+ }
+
+ return 1
+}
+
+# Arch not supporting hw watchpoints does not imply no_hardware_watchpoints set.
+if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"]
+ && ![istarget "ia64-*-*"] && ![istarget "s390*-*-*"])
+ || [target_info exists gdb,no_hardware_watchpoints]} then {
+ verbose "Skipping watchpoint-hw test."
+ return
+}
+
+set testfile watchpoint-hw-unreadable
+if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+# The test below would get false FAIL as the first breakpoint left by
+# runto_main must be singlestepped over while this testfile tries to ensure no
+# singlestepping occurs for the watchpoints.
+delete_breakpoints
+
+gdb_test "set debug infrun 1"
+gdb_test "show debug infrun" "Inferior debugging is 1\\."
+
+gdb_test "watch *p" "ardware watchpoint 2: \\\*p"
+gdb_test "watch **pp" "ardware watchpoint 3: \\\*\\\*pp"
+set test "catch *p"
+
+set c(0) [list *p 2 <unreadable> 2]
+gdb_watch_test c
+
+set c(0) [list *p 2 2 3]
+gdb_watch_test c
+
+set c(0) [list *p 2 3 4]
+gdb_watch_test c
+
+set c(0) [list **pp 3 <unreadable> 4]
+gdb_watch_test c
+
+set c(0) [list *p 2 4 5]
+set c(1) [list **pp 3 4 5]
+gdb_watch_test c
+unset c
+
+set c(0) [list **pp 3 5 <unreadable>]
+gdb_watch_test c
+
+set c(0) [list *p 2 5 6]
+gdb_watch_test c
+
+set c(0) [list *p 2 6 <unreadable>]
+gdb_watch_test c
+
+set c(0) [list *p 2 <unreadable> 7]
+gdb_watch_test c
+
+set c(0) [list *p 2 7 8]
+gdb_watch_test c
+
+set c(0) [list *p 2 8 9]
+gdb_watch_test c
+
+set c(0) [list **pp 3 <unreadable> 9]
+gdb_watch_test c
+
+set c(0) [list *p 2 9 10]
+set c(1) [list **pp 3 9 10]
+gdb_watch_test c
+unset c
+
+set c(0) [list *p 2 10 11]
+set c(1) [list **pp 3 10 11]
+gdb_watch_test c
+unset c
--
1.6.5.2
next prev parent reply other threads:[~2010-08-03 8:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-30 21:13 Dragos Tatulea
2010-08-03 8:11 ` Dragos Tatulea [this message]
2010-08-04 22:57 ` Jan Kratochvil
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='AANLkTimgPBkpneh78XQwhboJHU7iPksTVeB=us4N8w2S@mail.gmail.com' \
--to=dragos.tatulea@gmail.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).