[binutils-gdb] [gdb/testsuite] Fix gdb.python/py-finish-breakpoint-tailcall.exp with gcc 16
Tom de Vries via Gdb-cvs <[email protected]> Fri, 31 Jul 2026 14:50:19 +0000 (GMT)
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Df100243d1f10= 2567e639d9e0c2c3da3185835b54 commit f100243d1f102567e639d9e0c2c3da3185835b54 Author: Tom de Vries <[email protected]> Date: Fri Jul 31 16:50:15 2026 +0200 [gdb/testsuite] Fix gdb.python/py-finish-breakpoint-tailcall.exp with g= cc 16 =20 On openSUSE Leap 16.0, with gcc 15.3.0, for test-case gdb.python/py-finish-breakpoint-tailcall.exp I get: ... (gdb) python MyFinishBreakpoint(frame) Temporary breakpoint 2 at 0x40102a: file py-finish-breakpoint-tailcall.= c, \ line 43. (gdb) PASS: $exp: parent_frame=3Dtrue: create finish breakpoint ... =20 And on openSUSE Tumbleweed, with gcc 16.1.1 I get instead: ... (gdb) python MyFinishBreakpoint(frame) Temporary breakpoint 2 at 0x40102a: file py-finish-breakpoint-tailcall.= c, \ line 44. (gdb) FAIL: $exp: parent_frame=3Dtrue: create finish breakpoint ... =20 The only difference is in the line numbers, 43 and 44, both in main: ... 39 int 40 main (void) 41 { 42 int result =3D tailcall_function (42); 43 result -=3D global_var; /* Temporary breakpoint here. */ 44 return result; 45 } ... =20 The executable is compiled with O2, and the code for main is different. =20 With gcc 15, we have: ... 0000000000401020 <main>: 401020: bf 2a 00 00 00 mov $0x2a,%edi 401025: e8 26 01 00 00 call 401150 <tailcall_functio= n> 40102a: 8b 15 e0 2f 00 00 mov 0x2fe0(%rip),%edx 401030: 29 d0 sub %edx,%eax 401032: c3 ret ... and the line number associated with 0x40102a, the first instruction aft= er the call is 43: ... File name Line number Starting address View = Stmt py-finish-breakpoint-tailcall.c 43 0x40102a = x ... =20 With gcc 16, the mov and sub have been merged: ... 0000000000401020 <main>: 401020: bf 2a 00 00 00 mov $0x2a,%edi 401025: e8 26 01 00 00 call 401150 <tailcall_functio= n> 40102a: 2b 05 e0 2f 00 00 sub 0x2fe0(%rip),%eax 401030: c3 ret ... and the line number info is different: ... File name Line number Starting address View = Stmt py-finish-breakpoint-tailcall.c 43 0x40102a = x py-finish-breakpoint-tailcall.c 44 0x40102a 1 = x py-finish-breakpoint-tailcall.c 43 0x40102a 2 ... and gdb picks 44 in this case. =20 Fix this by merging lines 43 and 44 in the test-case: ... - result -=3D global_var; /* Temporary breakpoint here. */ - return result; + return result - global_var; /* Temporary breakpoint here. */ ... =20 Tested on x86_64-linux. =20 I've also verified that reverting the fix in commit e6bdfed6f5d ("gdb: = fix frame_unwind_caller_WHAT functions for inline and tail calls"), the com= mit that introduced the test-case still makes the test-case fail. =20 Approved-By: Andrew Burgess <[email protected]> =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D33989 Diff: --- gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.c b/gdb= /testsuite/gdb.python/py-finish-breakpoint-tailcall.c index d129d7e41b4..844ac1d2ea6 100644 --- a/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.c +++ b/gdb/testsuite/gdb.python/py-finish-breakpoint-tailcall.c @@ -40,6 +40,5 @@ int main (void) { int result =3D tailcall_function (42); - result -=3D global_var; /* Temporary breakpoint here. */ - return result; + return result - global_var; /* Temporary breakpoint here. */ }