[PATCH v3 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp

Thiago Jung Bauermann thiago.bauermann@linaro.org
Wed Apr 24 17:05:31 GMT 2024


Kevin Buettner <kevinb@redhat.com> writes:

> On Mon, 22 Apr 2024 20:07:00 -0300
> Thiago Jung Bauermann <thiago.bauermann@linaro.org> wrote:
>
>> +set saw_watch_trigger 0
>> +set saw_function 0
>> +set is_supported 1
>> +set message "continue until memcpy watchpoint hits"
>> +set watch_trigger \
>> +	[multi_line \
>> +	     "Continuing\\." \
>> +	     "" \
>> +	     "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
>> +	     "" \
>> +	     "Old value = 101 'e'" \
>> +	     "New value = 114 'r'"]
>> +gdb_test_multiple "continue" $message {
>> +    -re $watch_trigger {
>> +	set saw_watch_trigger 1
>> +	exp_continue
>> +    }
>> +    -re ".*memcpy.* \\(\\) at .*:$decimal\r\n" {
>> +	set saw_function 1
>> +	exp_continue
>> +    }
>> +    -re ".*memcpy.* \\(\\) from .*libc\[^\r\n\]+\r\n" {
>> +	set saw_function 1
>> +	exp_continue
>> +    }
>> +    -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
>> +	set is_supported 0
>> +	unsupported "symbol for memcpy not found"
>> +	exp_continue
>> +    }
>> +    -re "$gdb_prompt $" {
>> +	if { $is_supported } {
>> +	    setup_kfail breakpoints/31665 arm*-*-linux*
>> +	    gdb_assert { $saw_watch_trigger && $saw_function } $message
>> +	}
>> +    }
>> +}
>
> For this test, on Fedora 39 x86_64 without glibc debuginfo, I see:
>
>     continue
>     Continuing.
>
>     Hardware watchpoint 3: -location b[28]
>
>     Old value = 101 'e'
>     New value = 114 'r'
>     0x00007ffff7e34b19 in __memmove_avx_unaligned () from /lib64/libc.so.6
>     (gdb) FAIL: gdb.base/memops-watchpoint.exp: continue until memcpy watchpoint hits
>
>
> When I run it on Fedora 39 x86_64 w/ glibc debuginfo, I see the expected PASS:
>
>     continue
>     Continuing.
>
>     Hardware watchpoint 3: -location b[28]
>
>     Old value = 101 'e'
>     New value = 114 'r'
>     __memcpy_avx_unaligned () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:226
>     226		VMOVU	%VMM(1), -VEC_SIZE(%rdi,%rdx)
>     (gdb) PASS: gdb.base/memops-watchpoint.exp: continue until memcpy watchpoint hits
>
> I think you can fix the FAIL for the no-glibc-debuginfo case by
> tweaking the RE in the same way that you did for the memmove test.

That's true. Thanks! I'll make the change for v4.

> I also have Fedora 39 (Asahi Remix) running on an M1 macbook.  When
> I try this test on that machine, I see some timeouts...
>
>     (gdb) watch -location a[28]
>     Hardware watchpoint 2: -location a[28]
>     (gdb) PASS: gdb.base/memops-watchpoint.exp: set watch on a
>     watch -location b[28]
>     Hardware watchpoint 3: -location b[28]
>     (gdb) PASS: gdb.base/memops-watchpoint.exp: set watchpoint on b
>     watch -location c[28]
>     Hardware watchpoint 4: -location c[28]
>     (gdb) PASS: gdb.base/memops-watchpoint.exp: set watchpoint on c
>     continue
>     Continuing.
>
>     Hardware watchpoint 2: -location a[28]
>
>     Old value = 104 'h'
>     New value = 0 '\000'
>     __GI___memset_generic () at ../sysdeps/aarch64/memset.S:67
>     67		tbz	count, 5, 1f
>     (gdb) PASS: gdb.base/memops-watchpoint.exp: continue until memset watchpoint hits
>     continue
>     Continuing.
>     FAIL: gdb.base/memops-watchpoint.exp: continue until memcpy watchpoint hits (timeout)
>     continue
>     FAIL: gdb.base/memops-watchpoint.exp: continue until memmove watchpoint hits (timeout)
>     testcase /ironwood1/sourceware-git/macbook-review/bld/../../worktree-review/gdb/testsuite/gdb.base/memops-watchpoint.exp completed in 20 seconds
>
> 		    === gdb Summary ===
>
>     # of expected passes		4
>     # of unexpected failures	2
>
> Is this demonstrating the bug (31484) ?

Hm. Probably. I haven't seen this behaviour in my tests. It's hard to
say why GDB hung. Can you try to "set debug infrun on" at that point?

diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.exp b/gdb/testsuite/gdb.base/memops-watchpoint.exp
index 4005b1eecf85..5920608453a4 100644
--- a/gdb/testsuite/gdb.base/memops-watchpoint.exp
+++ b/gdb/testsuite/gdb.base/memops-watchpoint.exp
@@ -82,6 +82,8 @@ gdb_test_multiple "continue" $message {
     }
 }
 
+gdb_test_no_output "set debug infrun on"
+
 set saw_watch_trigger 0
 set saw_function 0
 set is_supported 1

-- 
Thiago


More information about the Gdb-patches mailing list