This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[10/10] watchpoint.exp: Run tests twice: once with hw watchpoints enabled; another time with hw watchpoints disabled.


Finally, this makes tests that can run with or without hw watchpoints run twice,
on targets that can do hw watchpoints.

2012-01-26  Pedro Alves  <palves@redhat.com>

	* gdb.base/watchpoint.exp (no_hw): New global.
	(maybe_clean_restart, maybe_reinitialize): If no_hw is set,
	disable hw watchpoints.
	(test_wide_location_1, test_wide_location_2): If no_hw is set,
	don't expect hw watchpoints.
	(no_hw_watchpoints): Always clean restart.
	(do_tests): New procedure, factored out from the top level.
	(top level): Run tests twice.  Once with hw watchpoints enabled,
	another time with hw watchpoints disabled.
---

 gdb/testsuite/gdb.base/watchpoint.exp |   68 ++++++++++++++++++++++++++++-----
 1 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index b1c6c94..c6f74e3 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -29,6 +29,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }

+# True if we're forcing no hardware watchpoints.
+set no_hw 0
+
 # Prepare for watchpoint tests by setting up two breakpoints and one
 # watchpoint.
 #
@@ -97,6 +100,10 @@ proc maybe_clean_restart { } {
 	global testfile

 	clean_restart $testfile
+
+	if {$no_hw} {
+	    gdb_test_no_output "set can-use-hw-watchpoints 0" ""
+	}
     }
 }

@@ -108,6 +115,11 @@ proc maybe_reinitialize { } {
 	global testfile

 	clean_restart $testfile
+
+	if {$no_hw} {
+	    gdb_test_no_output "set can-use-hw-watchpoints 0" ""
+	}
+
 	initialize
     }
 }
@@ -629,12 +641,14 @@ proc test_watch_location {} {
 # Tests watching areas larger than a word.

 proc test_wide_location_1 {} {
+    global no_hw
+
     # This test watches two words on most 32-bit ABIs, and one word on
     # most 64-bit ABIs.

     # Platforms where the target can't watch such a large region
     # should clear hw_expected below.
-    if [target_info exists gdb,no_hardware_watchpoints] {
+    if { $no_hw || [target_info exists gdb,no_hardware_watchpoints] } {
 	set hw_expected 0
     } else {
 	set hw_expected 1
@@ -659,12 +673,14 @@ proc test_wide_location_1 {} {
 }

 proc test_wide_location_2 {} {
+    global no_hw
+
     # This test watches four words on most 32-bit ABIs, and two words
     # on 64-bit ABIs.

     # Platforms where the target can't watch such a large region
     # should clear hw_expected below.
-    if [target_info exists gdb,no_hardware_watchpoints] {
+    if { $no_hw || [target_info exists gdb,no_hardware_watchpoints] } {
 	set hw_expected 0
     } else {
 	set hw_expected 1
@@ -768,7 +784,9 @@ proc test_inaccessible_watchpoint {} {
 }

 proc test_no_hw_watchpoints {} {
-    maybe_clean_restart
+    global testfile
+
+    clean_restart $testfile

     # Verify that a user can force GDB to use "slow" watchpoints.
     # (This proves rather little on kernels that don't support
@@ -852,25 +870,41 @@ proc test_watchpoint_in_big_blob {} {

 # Start with a fresh gdb.

-clean_restart $testfile
 set prev_timeout $timeout
 set timeout 600	
 verbose "Timeout now 600 sec.\n"

-if [initialize] then {
+test_no_hw_watchpoints

-    test_simple_watchpoint
+proc do_tests {} {
+    global testfile
+    global no_hw

-    test_disabling_watchpoints
+    clean_restart $testfile

-    if ![target_info exists gdb,cannot_call_functions] {
-	test_stepping
+    if {$no_hw} {
+	gdb_test_no_output "set can-use-hw-watchpoints 0" ""
+    }
+
+    if [initialize] then {
+
+	test_simple_watchpoint
+
+	test_disabling_watchpoints
+
+	if ![target_info exists gdb,cannot_call_functions] {
+	    test_stepping
+	}
     }

     # Tests below don't rely on the markers and watchpoint set by
     # `initialize' anymore.
     clean_restart $testfile

+    if {$no_hw} {
+	gdb_test_no_output "set can-use-hw-watchpoints 0" ""
+    }
+
     # Only enabled for some targets merely because it has not been tested
     # elsewhere.
     # On sparc-sun-sunos4.1.3, GDB was running all the way to the marker4
@@ -883,8 +917,6 @@ if [initialize] then {

     test_inaccessible_watchpoint

-    test_no_hw_watchpoints
-
     test_watchpoint_and_breakpoint

     test_watchpoint_in_big_blob
@@ -899,6 +931,20 @@ if [initialize] then {
     test_wide_location_2
 }

+# On targets that can do hardware watchpoints, run the tests twice:
+# once with hardware watchpoints enabled; another with hardware
+# watchpoints force-disabled.
+
+do_tests
+if ![target_info exists gdb,no_hardware_watchpoints] {
+    set save_pf_prefix $pf_prefix
+    lappend pf_prefix "no-hw:"
+
+    set no_hw 1
+    do_tests
+    set pf_prefix $save_pf_prefix
+}
+
 # Restore old timeout
 set timeout $prev_timeout
 verbose "Timeout now $timeout sec.\n"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]