[patch 3/4] Fix hw watchpoints: remove dead code

Jan Kratochvil
2009-08-17T19:46:37Z

Hi,

simple dead code removal. Code would become invalid with the changes anyway.

The testcase is in fact unrelated, just I was surprised "hbreak" functionality
is currently not regression tested anywhere.

Thanks,
Jan

gdb/
2009-08-17 Jan Kratochvil <jan.kratochvil@redhat.com>

* i386-nat.c (i386_stopped_by_hwbp): Remove.

gdb/testsuite/
2009-08-17 Jan Kratochvil <jan.kratochvil@redhat.com>

* gdb.base/watchpoint-hw.exp: Use prepare_for_testing. Fix test name
for "untested". New variable breakline.
(hbreak, continue to break-at-exit after hbreak): New tests.

--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -590,27 +590,6 @@ i386_stopped_by_watchpoint (void)
return target_stopped_data_address (&current_target, &addr);
}

-/* Return non-zero if the inferior has some break/watchpoint that
- triggered. */
-
-static int
-i386_stopped_by_hwbp (void)
-{
- int i;
-
- dr_status_mirror = i386_dr_low.get_status ();
- if (maint_show_dr)
- i386_show_dr ("stopped_by_hwbp", 0, 0, hw_execute);
-
- ALL_DEBUG_REGISTERS(i)
- {
- if (I386_DR_WATCH_HIT (i))
- return 1;
- }
-
- return 0;
-}
-
/* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
Return 0 on success, EBUSY on failure. */
static int
--- a/gdb/testsuite/gdb.base/watchpoint-hw.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-hw.exp
@@ -21,19 +21,12 @@ if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"]
return
}

-set testfile watchpoint-hw
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "Couldn't compile test program"
+set test watchpoint-hw
+set srcfile ${test}.c
+if { [prepare_for_testing ${test}.exp ${test} ${srcfile}] } {
return -1
}

-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
# Create the watchpoint before the inferior gets started. Now the native CPU
# target is still not active and its `to_can_use_hw_breakpoint' is not
# installed, therefore only a software watchpoint gets created.
@@ -43,7 +36,7 @@ gdb_test "watch watchee" "atchpoint 1: watchee"
# `runto_main' or `runto main' would delete the watchpoint created above.

if { [gdb_start_cmd] < 0 } {
- untested start
+ untested ${test}.exp
return -1
}
gdb_test "" "main .* at .*" "start"
@@ -56,11 +49,27 @@ gdb_test "info watchpoints" "1 *hw watchpoint .* watchee"
gdb_test "delete 1"
gdb_test "rwatch watchee"

-gdb_breakpoint [gdb_get_line_number "break-at-exit"]
+set breakline [gdb_get_line_number "break-at-exit"]
+gdb_breakpoint $breakline

gdb_test "continue" "Continuing.\r\nHardware read watchpoint 3: watchee\r\n\r\nValue = 0\r\n.*"

# Here should be no repeated notification of the read watchpoint.
gdb_test "continue" \
"Continuing\\.\[ \r\n\]+Breakpoint \[0-9\]+, .*break-at-exit.*" \
- "continue to break-at-exit"
+ "continue to break-at-exit after rwatch"
+
+clean_restart ${test}
+
+if ![runto_main] {
+ untested ${test}.exp
+ return -1
+}
+
+gdb_test "hbreak ${srcfile}:${breakline}" \
+ "Hardware assisted breakpoint 2 at 0x\[0-9a-f\]+: file .*${srcfile}, line ${breakline}\\." \
+ "hbreak"
+
+gdb_test "continue" \
+ "Continuing\\.\[ \r\n\]+Breakpoint \[0-9\]+, .*break-at-exit.*" \
+ "continue to break-at-exit after hbreak"