Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Fix gdb.python/py-finish-breakpoint-tailcall.exp with gcc 16
@ 2026-07-31  9:35 Tom de Vries
  2026-07-31 13:49 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-07-31  9:35 UTC (permalink / raw)
  To: gdb-patches

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=true: create finish breakpoint
...

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=true: create finish breakpoint
...

The only difference is in the line numbers, 43 and 44, both in main:
...
    39	int
    40	main (void)
    41	{
    42	  int result = tailcall_function (42);
    43	  result -= global_var;  /* Temporary breakpoint here.  */
    44	  return result;
    45	}
...

The executable is compiled with O2, and the code for main is different.

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_function>
  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 after the
call is 43:
...
File name                        Line number  Starting address    View    Stmt
py-finish-breakpoint-tailcall.c           43          0x40102a               x
...

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_function>
  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.

Fix this by merging lines 43 and 44 in the test-case:
...
-  result -= global_var;  /* Temporary breakpoint here.  */
-  return result;
+  return result - global_var;  /* Temporary breakpoint here.  */
...

Tested on x86_64-linux.

I've also verified that reverting the fix in commit e6bdfed6f5d ("gdb: fix
frame_unwind_caller_WHAT functions for inline and tail calls"), the commit
that introduced the test-case still makes the test-case fail.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33989
---
 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 = tailcall_function (42);
-  result -= global_var;			/* Temporary breakpoint here.  */
-  return result;
+  return result - global_var;			/* Temporary breakpoint here.  */
 }

base-commit: 6d1be0b90e837e4c82eaaf6f9e8c7da7227902e1
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [gdb/testsuite] Fix gdb.python/py-finish-breakpoint-tailcall.exp with gcc 16
  2026-07-31  9:35 [PATCH] [gdb/testsuite] Fix gdb.python/py-finish-breakpoint-tailcall.exp with gcc 16 Tom de Vries
@ 2026-07-31 13:49 ` Andrew Burgess
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2026-07-31 13:49 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

Tom de Vries <tdevries@suse.de> writes:

> 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=true: create finish breakpoint
> ...
>
> 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=true: create finish breakpoint
> ...
>
> The only difference is in the line numbers, 43 and 44, both in main:
> ...
>     39	int
>     40	main (void)
>     41	{
>     42	  int result = tailcall_function (42);
>     43	  result -= global_var;  /* Temporary breakpoint here.  */
>     44	  return result;
>     45	}
> ...
>
> The executable is compiled with O2, and the code for main is different.
>
> 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_function>
>   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 after the
> call is 43:
> ...
> File name                        Line number  Starting address    View    Stmt
> py-finish-breakpoint-tailcall.c           43          0x40102a               x
> ...
>
> 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_function>
>   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.
>
> Fix this by merging lines 43 and 44 in the test-case:
> ...
> -  result -= global_var;  /* Temporary breakpoint here.  */
> -  return result;
> +  return result - global_var;  /* Temporary breakpoint here.  */
> ...
>
> Tested on x86_64-linux.
>
> I've also verified that reverting the fix in commit e6bdfed6f5d ("gdb: fix
> frame_unwind_caller_WHAT functions for inline and tail calls"), the commit
> that introduced the test-case still makes the test-case fail.

Thanks for taking the time to do this.  This fix LGTM.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33989
> ---
>  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 = tailcall_function (42);
> -  result -= global_var;			/* Temporary breakpoint here.  */
> -  return result;
> +  return result - global_var;			/* Temporary breakpoint here.  */
>  }
>
> base-commit: 6d1be0b90e837e4c82eaaf6f9e8c7da7227902e1
> -- 
> 2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-31 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-31  9:35 [PATCH] [gdb/testsuite] Fix gdb.python/py-finish-breakpoint-tailcall.exp with gcc 16 Tom de Vries
2026-07-31 13:49 ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox