Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jeff Johnston <jjohnstn@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA]: threaded watchpoint test
Date: Tue, 27 Jul 2004 18:56:00 -0000	[thread overview]
Message-ID: <4106A553.7010202@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

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  <jjohnstn@redhat.com>

	* gdb.threads/watchthreads.exp: New test for threaded watchpoints.



[-- Attachment #2: watchthreads.patch --]
[-- Type: text/plain, Size: 4295 bytes --]

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

             reply	other threads:[~2004-07-27 18:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-27 18:56 Jeff Johnston [this message]
2004-07-27 22:56 ` Michael Chastain
2004-07-27 23:02 ` Daniel Jacobowitz
2004-07-27 23:24   ` Jeff Johnston
2004-07-27 23:27     ` Daniel Jacobowitz
2004-07-27 23:41       ` Jeff Johnston
2004-07-28  0:13       ` Michael Chastain
2004-07-29 15:26         ` Daniel Jacobowitz
2004-07-29 23:39           ` Mark Kettenis
2004-07-30  0:55             ` Michael Chastain
2004-07-30 22:33               ` Andrew Cagney

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=4106A553.7010202@redhat.com \
    --to=jjohnstn@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /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