]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix gdb.base/gdb11531.exp with m32 PIE
authorTom de Vries <tdevries@suse.de>
Sat, 3 Jan 2026 15:06:29 +0000 (16:06 +0100)
committerTom de Vries <tdevries@suse.de>
Sat, 3 Jan 2026 15:06:29 +0000 (16:06 +0100)
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

gdb/testsuite/gdb.base/gdb11531.c
gdb/testsuite/gdb.base/gdb11531.exp

index 97f5928d33be083243ae1b440d6df9d8b98bfd37..2ec02373b8f48cc3e48414d0d5116e171a56d2bc 100644 (file)
@@ -31,7 +31,7 @@ static struct rec myrec;
 int
 main ()
 {
-  myrec.x = 5;
+  myrec.x = 5; /* Break here.  */
   myrec.y = 3.4;
   myrec.z = 56;
   myrec.x = 78;
index 82d399f2ef0155da6336fd5ecc0d36e26e93f823..add492c531776ec8e89b875d44b2705a15ac9371 100644 (file)
@@ -38,7 +38,8 @@ if {!$allow_hw_watchpoint_tests_p} {
    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
 }