With test-case gdb.base/gdb11531.exp and target board unix/-m32/-fPIE/-pie I get:
...
(gdb) next^M
34 myrec.x = 5;^M
(gdb) FAIL: gdb.base/gdb11531.exp: watchpoint variable triggers at next
...
For contrast, with target board unix/-m32 I get instead:
...
(gdb) next^M
^M
Hardware watchpoint 2: myrec.x^M
^M
Old value = 0^M
New value = 5^M
main () at /data/vries/gdb/src/gdb/testsuite/gdb.base/gdb11531.c:35^M
35 myrec.y = 3.4;^M
(gdb) PASS: gdb.base/gdb11531.exp: watchpoint variable triggers at next
...
The problem is that the runto_main doesn't set a breakpoint on the same line
in both cases.
Fix this by using runto "$srcfile:34".
[ The underlying problem here is the failure of prologue analysis to deal with
get_pc_thunk. But since there's a PR [1] open about this, and the problem is
unrelated to the test-case, we work around it. ]
Tested on x86_64-linux.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=29043
int
main ()
{
- myrec.x = 5;
+ myrec.x = 5; /* Break here. */
myrec.y = 3.4;
myrec.z = 56;
myrec.x = 78;
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
-if {![runto_main]} {
+set line [gdb_get_line_number "Break here"]
+if {![runto "$srcfile:$line"]} {
return
}