From 51c9e134b78401e6fbcbb4ff0cb40e11b5ae12f7 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sun, 26 May 2024 00:48:16 +1200 Subject: [PATCH] Make watchpoint_unaligned test work under gdb and lldb --- src/test/util.py | 11 +++++++++-- src/test/watchpoint_unaligned.py | 10 +++++----- src/test/watchpoint_unaligned.run | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/test/util.py b/src/test/util.py index c03ac5527ff..460f30b05d6 100644 --- a/src/test/util.py +++ b/src/test/util.py @@ -4,8 +4,9 @@ 'restart_replay', 'interrupt_gdb', 'expect_gdb', 'send_gdb', 'ok', 'failed', 'iterlines_both', 'last_match', 'get_exe_arch', 'get_gdb_version', 'breakpoint_at_function', - 'watchpoint_at_address', 'cont', 'backtrace', - 'expect_breakpoint_stop', 'expect_watchpoint_stop' ] + 'watchpoint_at_address', 'cont', 'backtrace', 'up', + 'expect_breakpoint_stop', 'expect_watchpoint_stop', + 'delete_watchpoint' ] # Don't use python timeout. Use test-monitor timeout instead. TIMEOUT_SEC = 10000 @@ -88,9 +89,15 @@ def watchpoint_at_address(address, size): expect_debugger(r'atchpoint (\d+)') return int(last_match().group(1)) +def delete_watchpoint(watchpoint): + send_debugger(f'delete {watchpoint}', f'watchpoint delete {watchpoint}') + def cont(): send_debugger('continue', 'continue') +def up(): + send_debugger('up', 'up') + def backtrace(): send_debugger('bt', 'thread backtrace') diff --git a/src/test/watchpoint_unaligned.py b/src/test/watchpoint_unaligned.py index 7a7b8995a82..f27a69135cd 100644 --- a/src/test/watchpoint_unaligned.py +++ b/src/test/watchpoint_unaligned.py @@ -4,17 +4,17 @@ def test(): for size in [2, 4, 8]: - send_gdb('c') + cont() expect_breakpoint_stop(breakpoint) # Get the value of `wp_addr` from the parent frame. # On Ubuntu 20 LTS, gdb stops before the `breakpoint` prelude so # gets the wrong value of `wp_addr`. - send_gdb('up') - expect_gdb('test') + up() + expect_debugger('test') wp = watchpoint_at_address('wp_addr', size) - send_gdb('c') + cont() expect_watchpoint_stop(wp) - send_gdb(f'delete {wp}') + delete_watchpoint(wp) test() test() diff --git a/src/test/watchpoint_unaligned.run b/src/test/watchpoint_unaligned.run index 0e9b81df833..3eadb5a637f 100644 --- a/src/test/watchpoint_unaligned.run +++ b/src/test/watchpoint_unaligned.run @@ -1,2 +1,2 @@ source `dirname $0`/util.sh -debug_test_gdb_only +debug_test