From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18502 invoked by alias); 27 Jul 2004 18:56:21 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 18494 invoked from network); 27 Jul 2004 18:56:20 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 27 Jul 2004 18:56:20 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i6RIuKe1018419 for ; Tue, 27 Jul 2004 14:56:20 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i6RIuKa23765 for ; Tue, 27 Jul 2004 14:56:20 -0400 Received: from touchme.toronto.redhat.com (IDENT:postfix@touchme.toronto.redhat.com [172.16.14.9]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id i6RIuKXP025008 for ; Tue, 27 Jul 2004 14:56:20 -0400 Received: from redhat.com (toocool.toronto.redhat.com [172.16.14.72]) by touchme.toronto.redhat.com (Postfix) with ESMTP id 8616F800497 for ; Tue, 27 Jul 2004 14:56:19 -0400 (EDT) Message-ID: <4106A553.7010202@redhat.com> Date: Tue, 27 Jul 2004 18:56:00 -0000 From: Jeff Johnston User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [RFA]: threaded watchpoint test Content-Type: multipart/mixed; boundary="------------020508020605010805090400" X-SW-Source: 2004-07/txt/msg00403.txt.bz2 This is a multi-part message in MIME format. --------------020508020605010805090400 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 442 The attached patch adds a testcase to test that hardware watchpoints trigger in threads. At present, this support does not work, but it is not tested anywhere. With uncommited patches, I have the test working for x86 and ia64. The test only bothers if hardware watchpoints are supported. Ok to commit? -- Jeff J. 2004-07-27 Jeff Johnston * gdb.threads/watchthreads.exp: New test for threaded watchpoints. --------------020508020605010805090400 Content-Type: text/plain; name="watchthreads.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="watchthreads.patch" Content-length: 4295 Index: gdb.threads/watchthreads.exp =================================================================== RCS file: gdb.threads/watchthreads.exp diff -N gdb.threads/watchthreads.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb.threads/watchthreads.exp 27 Jul 2004 18:55:29 -0000 @@ -0,0 +1,125 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2004 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. + +# Check that GDB can support multiple watchpoints across threads. + +if $tracelevel { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +# This test verifies that a watchpoint is detected in the proper thread +# so the test is only meaningful on a system with hardware watchpoints. +if [target_info exists gdb,no_hardware_watchpoints] { + return 0; +} + +set testfile "schedlock" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "set can-use-hw-watchpoints 1" "" "" + +# +# Run to `main' where we begin our tests. +# + +if ![runto_main] then { + gdb_suppress_tests +} + +set args_0 0 +set args_1 0 + +# Watch values that will be modified by distinct threads. +gdb_test "watch args\[0\]" "Hardware watchpoint 2: args\\\[0\\\]" +gdb_test "watch args\[1\]" "Hardware watchpoint 3: args\\\[1\\\]" + +# Loop and continue to allow both watchpoints to be triggered. +for {set i 0} {$i < 30} {incr i} { + set test_flag 0 + gdb_test_multiple "continue" "threaded watch loop" { + -re "Hardware watchpoint 2: args\\\[0\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*schedlock.c:21.*$gdb_prompt $" + { set args_0 1; set test_flag 1 } + -re "Hardware watchpoint 3: args\\\[1\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*schedlock.c:21.*$gdb_prompt $" + { set args_1 1; set test_flag 1 } + -re "Hardware watchpoint 2: args\\\[0\\\].*Old value = $args_0.*New value = [expr $args_0+1].*in thread_function \\\(arg=0x0\\\) at .*schedlock.c:42.*$gdb_prompt $" + { set args_0 [expr $args_0+1]; set test_flag 1 } + -re "Hardware watchpoint 3: args\\\[1\\\].*Old value = $args_1.*New value = [expr $args_1+1].*in thread_function \\\(arg=0x1\\\) at .*schedlock.c:42.*$gdb_prompt $" + { set args_1 [expr $args_1+1]; set test_flag 1 } + } + # If we fail above, don't bother continuing loop + if { $test_flag == 0 } { + set i 30; + } +} + +# Print success message if loop succeeded. +if { $test_flag == 1 } { + pass "threaded watch loop" +} + +# Verify that we hit first watchpoint in main thread. +set message "first watchpoint on args\[0\] hit" +if { $args_0 > 0 } { + pass $message +} else { + fail $message +} + +# Verify that we hit second watchpoint in main thread. +set message "first watchpoint on args\[1\] hit" +if { $args_1 > 0 } { + pass $message +} else { + fail $message +} + +# Verify that we hit first watchpoint in child thread. +set message "watchpoint on args\[0\] hit in thread" +if { $args_0 > 1 } { + pass $message +} else { + fail $message +} + +# Verify that we hit second watchpoint in child thread. +set message "watchpoint on args\[1\] hit in thread" +if { $args_1 > 1 } { + pass $message +} else { + fail $message +} + +# Verify that all watchpoint hits are accounted for. +set message "combination of threaded watchpoints = 30" +if { [expr $args_0+$args_1] == 30 } { + pass $message +} else { + fail $message +} --------------020508020605010805090400--