From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19945 invoked by alias); 13 Jun 2006 06:37:17 -0000 Received: (qmail 19937 invoked by uid 22791); 13 Jun 2006 06:37:16 -0000 X-Spam-Check-By: sourceware.org Received: from ausmtp04.au.ibm.com (HELO ausmtp04.au.ibm.com) (202.81.18.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 13 Jun 2006 06:37:13 +0000 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp04.au.ibm.com (8.13.6/8.13.5) with ESMTP id k5D6egFJ238692 for ; Tue, 13 Jun 2006 16:40:42 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.250.237]) by sd0208e0.au.ibm.com (8.12.10/NCO/VER6.8) with ESMTP id k5D6eTcJ245312 for ; Tue, 13 Jun 2006 16:40:29 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k5D6b8wq021712 for ; Tue, 13 Jun 2006 16:37:08 +1000 Received: from [9.181.133.20] ([9.181.133.20]) by d23av04.au.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k5D6b6Et021673 for ; Tue, 13 Jun 2006 16:37:06 +1000 Date: Tue, 13 Jun 2006 06:37:00 -0000 From: Wu Zhou To: gdb-patches@sourceware.org Subject: [RFC]: New testcase for hw watchpoint, covering watch/rwatch/awatch Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00169.txt.bz2 Hello all, I see that the current watchpoint testcases don't differentiate too much on software watchpoints and hardware ones. And rwatch and awatch is not covered in any testcase. I ever proposed to have a specific testcase for h/w watchpoint. OK. Here it is. I am look it as a strawman. So if you are interested, you will have something to shot. :-) The testcase will first use "rwatch" command to detect if hardware watchpoint is supported. If not, it skip and quit. Otherwise, it will test watch (set can-use-hardware-watchpoint 1), rwatch and awatch respectively. I had tested it on i386, ppc64 with kernel-2.6.15 (support hw watchpoint) and ppc64 with kernel-2.6.9 (don't support hw watchpoint). On the first two configuration, it will report 44 pass. On the third configuatrion, it will report one fail and quit. Here is the code: ============== gdb.base/hw-watch.exp ======================== # Copyright 2006 # 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # This file was written by Wu Zhou (woodzltc@cn.ibm.com). Some of the code # is got from recurse.exp. if $tracelevel then { strace $tracelevel } set prms_id 0 set bug_id 0 set testfile "recurse" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } # Start with a fresh gdb. gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} proc watch_tests {} { if [runto recurse] then { # To test if target support hardware watchpoint gdb_test "set can-use-hw-watchpoints 1" "" "" if [gdb_test "rwatch b" ".*Hardware read watchpoint.*" "rwatch b"] then { unsupported "No hardware watchpoint support from target, skip this case." exit } gdb_test "delete 2" "" "" gdb_test "next" "if \\(a == 1\\)" "watch_tests: next over b = 0" # To verify that "set can-use-hw-watchpoints 0" will disable h/w watchpoint gdb_test "set can-use-hw-watchpoints 0" "" "" if [gdb_test "watch b" ".*Watchpoint \[0-9]*: b" \ "watch_tests: set write watchpoint on b, this is a software one"] then { gdb_suppress_tests; } # To verify that "set can-use-hw-watchpoints 1" will enable h/w watchpoint gdb_test "delete 3" "" "" if [gdb_test "set can-use-hw-watchpoints 1" "" ""] then { gdb_suppress_tests; } if [gdb_test "watch b" ".*Hardware watchpoint \[0-9]*: b" \ "watch_tests: reset write watchpoint on b, this is a hardware one"] then { gdb_suppress_tests; } gdb_test "info watchpoints" "1\[ \]*breakpoint.*recurse.*\r\n4\[ \]*hw watchpoint.*b.*" \ "watch_tests: info watchpoints" # Continue until the first set of b if [gdb_test "continue" \ "Continuing.*Hardware watchpoint.*: b.*Old value = 0.*New value = 10.*" \ "watch_tests: continue to the h/w write watchpoint, first time"] then { gdb_suppress_tests; } # Continue inward for a few iterations gdb_test "continue" "Breakpoint.* recurse \\(a=9\\).*" \ "watch_tests: continue to recurse (a = 9)" gdb_test "continue" "Breakpoint.* recurse \\(a=8\\).*" \ "watch_tests: continue to recurse (a = 8)" gdb_test "continue" "Breakpoint.* recurse \\(a=7\\).*" \ "watch_tests: continue to recurse (a = 7)" gdb_test "continue" "Breakpoint.* recurse \\(a=6\\).*" \ "watch_tests: continue to recurse (a = 6)" gdb_test "continue" "Breakpoint.* recurse \\(a=5\\).*" \ "watch_tests: continue to recurse (a = 5)" gdb_test "continue" "Breakpoint.* recurse \\(a=4\\).*" \ "watch_tests: continue to recurse (a = 4)" gdb_test "continue" "Breakpoint.* recurse \\(a=3\\).*" \ "watch_tests: continue to recurse (a = 3)" gdb_test "continue" "Breakpoint.* recurse \\(a=2\\).*" \ "watch_tests: continue to recurse (a = 2)" gdb_test "continue" "Breakpoint.* recurse \\(a=1\\).*" \ "watch_tests: continue to recurse (a = 1)" if [gdb_test "continue" \ "Continuing.*\[Ww\]atchpoint.*b.*Old value = 10.*New value = 3628800.*return.*" \ "watch_tests: continue to the h/w write watchpoint, second time"] then { gdb_suppress_tests } # watchpoint is automatically deleted when the process is out of its scope if [gdb_test "continue" \ "Continuing.*\[Ww\]atchpoint.*deleted.*\(main \\(\\) \|21.*\}\).*" \ "watch_tests: hardware write watchpoint deleted when leaving scope"] then { gdb_suppress_tests; } } gdb_stop_suppressing_tests; } proc rwatch_tests {} { if [runto recurse] then { if [gdb_test "rwatch b" ".*Hardware read watchpoint \[0-9]*: b" \ "rwatch_tests: set read watchpoint, this is a hardware one"] then { gdb_suppress_tests; } # Continue inward for a few iterations gdb_test "continue" "Breakpoint.* recurse \\(a=9\\).*" \ "rwatch_tests: continue to recurse (a = 9)" gdb_test "continue" "Breakpoint.* recurse \\(a=8\\).*" \ "rwatch_tests: continue to recurse (a = 8)" gdb_test "continue" "Breakpoint.* recurse \\(a=7\\).*" \ "rwatch_tests: continue to recurse (a = 7)" gdb_test "continue" "Breakpoint.* recurse \\(a=6\\).*" \ "rwatch_tests: continue to recurse (a = 6)" gdb_test "continue" "Breakpoint.* recurse \\(a=5\\).*" \ "rwatch_tests: continue to recurse (a = 5)" gdb_test "continue" "Breakpoint.* recurse \\(a=4\\).*" \ "rwatch_tests: continue to recurse (a = 4)" gdb_test "continue" "Breakpoint.* recurse \\(a=3\\).*" \ "rwatch_tests: continue to recurse (a = 3)" gdb_test "continue" "Breakpoint.* recurse \\(a=2\\).*" \ "rwatch_tests: continue to recurse (a = 2)" gdb_test "continue" "Breakpoint.* recurse \\(a=1\\).*" \ "rwatch_tests: continue to recurse (a = 1)" gdb_test "continue" \ "Continuing.*Hardware read watchpoint.*b.*Value = 10.*recurse \\(a=10\\).*" \ "rwatch_tests: the hardware read watchpoint hit, first time" if [gdb_test "continue" \ "Continuing.*Hardware read watchpoint.*b.*Value = 3628800.*return.*" \ "rwatch_tests: the hardware read watchpoint hit, second time"] then { gdb_suppress_tests } # watchpoint is automatically deleted when the process is out of its scope # if [gdb_test "continue" \ # "Continuing.*\[Ww\]atchpoint.*deleted because the program has left the block.*" \ # "Hardware read watchpoint deleted when leaving scope"] then { # gdb_suppress_tests; # } } gdb_stop_suppressing_tests; } proc awatch_tests {} { if [runto recurse] then { gdb_test "next" "if \\(a == 1\\)" "awatch: next over b = 0" if [gdb_test "awatch b" "Hardware access.*watchpoint .*: b" \ "awatch_tests: set access watchpoint on b, this is a hardware one"] then { gdb_suppress_tests; } # Continue until the first set of b. if [gdb_test "continue" \ "Continuing.*\[Ww\]atchpoint.*: b.*Old value = 0.*New value = 10.*" \ "awatch_tests: the h/w access watchpoint is hit by write operation, first time"] then { gdb_suppress_tests; } # Continue inward for a few iterations gdb_test "continue" "Breakpoint.* recurse \\(a=9\\).*" \ "awatch_tests: continue to recurse (a = 9)" gdb_test "continue" "Breakpoint.* recurse \\(a=8\\).*" \ "awatch_tests: continue to recurse (a = 8)" gdb_test "continue" "Breakpoint.* recurse \\(a=7\\).*" \ "awatch_tests: continue to recurse (a = 7)" gdb_test "continue" "Breakpoint.* recurse \\(a=6\\).*" \ "awatch_tests: continue to recurse (a = 6)" gdb_test "continue" "Breakpoint.* recurse \\(a=5\\).*" \ "awatch_tests: continue to recurse (a = 5)" gdb_test "continue" "Breakpoint.* recurse \\(a=4\\).*" \ "awatch_tests: continue to recurse (a = 4)" gdb_test "continue" "Breakpoint.* recurse \\(a=3\\).*" \ "awatch_tests: continue to recurse (a = 3)" gdb_test "continue" "Breakpoint.* recurse \\(a=2\\).*" \ "awatch_tests: continue to recurse (a = 2)" gdb_test "continue" "Breakpoint.* recurse \\(a=1\\).*" \ "awatch_tests: continue to recurse (a = 1)" if [gdb_test "continue" \ "Continuing.*Hardware access.*watchpoint.*b.*Value = 10.*recurse \\(a=10\\).*" \ "awatch_tests: the access watchpoint is hit by read operation, first time"] then { gdb_suppress_tests } if [gdb_test "continue" \ "Continuing.*\[Ww\]atchpoint.*b.*Old value = 10.*New value = 3628800.*return.*" \ "awatch_tests: the access watchpoint is hit by write operation, second time"] then { gdb_suppress_tests } if [gdb_test "continue" \ "Continuing.*Hardware access.*watchpoint.*b.*Value = 3628800.*return.*" \ "awatch_tests: the access watchpoint is hit by read operation, second time"] then { gdb_suppress_tests } # watchpoint is automatically deleted when the process is out of its scope # if [gdb_test "continue" \ # "Continuing.*\[Ww\]atchpoint.*deleted because the program has left the block.*" \ # "Hardware access watchpoint deleted when leaving scope"] then { # gdb_suppress_tests; # } } gdb_stop_suppressing_tests; } # Preserve the old timeout, and set a new one that should be # sufficient to avoid timing out during this test. set oldtimeout $timeout set timeout [expr "$timeout + 60"] verbose "Timeout is now $timeout seconds" 2 watch_tests rwatch_tests awatch_tests # Restore the preserved old timeout value. set timeout $oldtimeout verbose "Timeout is now $timeout seconds" 2 Any comments? Thanks a lot! Regards - Wu Zhou