Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb/testsuite] Fix gdb.tui/tailcall-msym.exp on ppc64-linux
Date: Sat,  1 Aug 2026 12:15:42 +0200	[thread overview]
Message-ID: <20260801101542.3131974-1-tdevries@suse.de> (raw)

On ppc64-linux, with test-case gdb.tui/tailcall-msym.exp I ran into:
...
FAIL: $exp: status bar says main
...

The test-case:
- compiles the source to executable tailcall-msym
- gets some information about addresses
- recompiles the source to assembly
- adds some extra text to the assembly
- compiles the updated assembly into tailcall-msym-updated

The test-case source contains three functions: main, caller and callee.

The idea is that the updated executable has the same instructions, but an
additional function dumy_func at the location of the instructions of caller
after the call to callee.

On x86_64-linux, that looks like this:
...
000000000040111d <caller>:
  40111d:	55                   	push   %rbp
  40111e:	48 89 e5             	mov    %rsp,%rbp
  401121:	e8 f0 ff ff ff       	call   401116 <callee>

0000000000401126 <dummy_func>:
  401126:	8b 05 e8 2e 00 00    	mov    0x2ee8(%rip),%eax
  40112c:	83 c0 01             	add    $0x1,%eax
  40112f:	89 05 df 2e 00 00    	mov    %eax,0x2edf(%rip)
  401135:	8b 05 d9 2e 00 00    	mov    0x2ed9(%rip),%eax
  40113b:	83 c0 01             	add    $0x1,%eax
  40113e:	89 05 d0 2e 00 00    	mov    %eax,0x2ed0(%rip)
  401144:	90                   	nop
  401145:	5d                   	pop    %rbp
  401146:	c3                   	ret
...

On ppc64-linux using the v1 ABI that doesn't work out (because of the complex
way functions are laid out in assembly), and instead caller stays the same,
but main is renamed to dummy_func:
...
(gdb) p dummy_func
$3 = {<text variable, no debug info>} 0x9b0 <dummy_func>
(gdb) p main
$4 = {<text variable, no debug info>} 0x9b0 <dummy_func>
(gdb)
...

There's a note in the test-case:
...
 # Emit a new size for function 'caller', the assembler seems happy
 # enough to just use this new length instead of the original length
 # the compiler emitted.
 #
 # If this is ever a problem then we'll need to parse through the
 # assembler file and remove the original .size directive.
...
and I tried that out manually, but it didn't help either.

Fix this by bailing out if not all four functions exist:
...
UNSUPPORTED: $exp: couldn't find function main
...

Likewise in gdb.base/tailcall-msym.exp.

Tested on ppc64-linux and x86_64-linux.
---
 gdb/testsuite/gdb.base/tailcall-msym.exp | 19 +++++++++++++++++
 gdb/testsuite/gdb.tui/tailcall-msym.exp  | 27 +++++++++++++++++++++---
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.base/tailcall-msym.exp b/gdb/testsuite/gdb.base/tailcall-msym.exp
index d6cd06f88cd..9ffaa7f17c1 100644
--- a/gdb/testsuite/gdb.base/tailcall-msym.exp
+++ b/gdb/testsuite/gdb.base/tailcall-msym.exp
@@ -132,6 +132,25 @@ if { [prepare_for_testing "prepare" ${testfile}-updated $asm_file {nodebug}] } {
     return
 }
 
+foreach func {caller callee main dummy_func} {
+    set re_found \
+	"^$valnum_re = {<text variable, no debug info>} $hex <$func>"
+
+    set found 0
+    gdb_test_multiple "p $func" "" {
+       -re -wrap $re_found {
+	   set found 1
+       }
+       -re -wrap "" {
+       }
+    }
+
+    if {!$found} {
+       unsupported "couldn't find function $func"
+       return
+    }
+}
+
 if {![runto callee]} {
     return
 }
diff --git a/gdb/testsuite/gdb.tui/tailcall-msym.exp b/gdb/testsuite/gdb.tui/tailcall-msym.exp
index 81b52355c01..1e13414f760 100644
--- a/gdb/testsuite/gdb.tui/tailcall-msym.exp
+++ b/gdb/testsuite/gdb.tui/tailcall-msym.exp
@@ -136,15 +136,36 @@ if { [build_executable "build" $real_testfile $asm_file {nodebug}] } {
 
 Term::clean_restart 24 80 $real_testfile
 
-if {![runto callee]} {
+if {![Term::prepare_for_tui]} {
+    unsupported "TUI not supported"
     return
 }
 
-if {![Term::enter_tui]} {
-    unsupported "TUI not supported"
+foreach func {caller callee main dummy_func} {
+    set re_found \
+	"^$valnum_re = {<text variable, no debug info>} $hex <$func>"
+
+    set found 0
+    gdb_test_multiple "p $func" "" {
+       -re -wrap $re_found {
+	   set found 1
+       }
+       -re -wrap "" {
+       }
+    }
+
+    if {!$found} {
+       unsupported "couldn't find function $func"
+       return
+    }
+}
+
+if {![runto callee]} {
     return
 }
 
+Term::command_no_prompt_prefix "tui enable"
+
 # Check the function name on display in the status bar.  The interesting
 # case here is 'caller', which is a tailcall function in an objfile with
 # no debug information.

base-commit: 5b805c95e9399e35f7bc895ec5b67aabdbc6ce41
-- 
2.51.0


             reply	other threads:[~2026-08-01 10:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01 10:15 Tom de Vries [this message]
2026-08-19  9:21 ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260801101542.3131974-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox