public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Bug 10645: small additions to existing testcase
@ 2010-07-30 21:13 Dragos Tatulea
  2010-08-03  8:11 ` Dragos Tatulea
  0 siblings, 1 reply; 3+ messages in thread
From: Dragos Tatulea @ 2010-07-30 21:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: jan.kratochvil

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.

Thanks,
Dragos Tatulea

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

* Re: [PATCH] Bug 10645: small additions to existing testcase
  2010-07-30 21:13 [PATCH] Bug 10645: small additions to existing testcase Dragos Tatulea
@ 2010-08-03  8:11 ` Dragos Tatulea
  2010-08-04 22:57   ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Dragos Tatulea @ 2010-08-03  8:11 UTC (permalink / raw)
  To: gdb-patches

[-- 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


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

* Re: [PATCH] Bug 10645: small additions to existing testcase
  2010-08-03  8:11 ` Dragos Tatulea
@ 2010-08-04 22:57   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2010-08-04 22:57 UTC (permalink / raw)
  To: Dragos Tatulea; +Cc: gdb-patches

On Tue, 03 Aug 2010 10:11:09 +0200, Dragos Tatulea wrote:
> ---
>  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
> 

A GNU ChangeLog entry is missing.


> 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.
                ^^^^ The date should include also 2010.


[...]
> 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.
               ^^^^ The date should include also 2010.


[...]
> +# 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
> +        }

I do not see why you could not use simple gdb_test here instead of
gdb_test_multiple.


[...]
> +    || [target_info exists gdb,no_hardware_watchpoints]} then {
> +    verbose "Skipping watchpoint-hw test."
                         ^^^^^^^^^^^^^ This testfile is named differently.

[...]
> +gdb_test "set debug infrun 1"
   ^^^^^^^^ -> gdb_test_no_output nowadays.

Not an issue for this patch:
gdb_test could sanity check it must be given some expect string.


> +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"

All the testcases generate:

PASS: gdb.base/watchpoint-hw-unreadable.exp: catch *p
PASS: gdb.base/watchpoint-hw-unreadable.exp: catch *p
PASS: gdb.base/watchpoint-hw-unreadable.exp: catch *p

The testcase names should be unique.


> +set c(0) [list *p 2 9 10]
> +set c(1) [list **pp 3 9 10]
> +gdb_watch_test c
> +unset c

Just such a qustion, maybe to simplify all the upvar, unset, set lines etc.
using just some?

gdb_watch_test {{*p 2 9 10} {**pp 3 9 10}}



Thanks,
Jan

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-30 21:13 [PATCH] Bug 10645: small additions to existing testcase Dragos Tatulea
2010-08-03  8:11 ` Dragos Tatulea
2010-08-04 22:57   ` Jan Kratochvil

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).