Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/tui] Fix gdb.tui/list-before.exp on ppc64-linux
@ 2026-08-01 12:28 Tom de Vries
  2026-08-19 14:42 ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-08-01 12:28 UTC (permalink / raw)
  To: gdb-patches

On ppc64-linux, with test-case gdb.tui/list-before.exp I run into:
...
(gdb) tui enable^M
  ...
(gdb) Screen Dump (size 80 columns x 24 rows, cursor at column 6, row 16):
    0 +------------------------------------------------------------------------------+
    1 |                                                                              |
    2 |                                                                              |
    3 |                                                                              |
    4 |                                                                              |
    5 |                                                                              |
    6 |                                                                              |
    7 |                           [ No Source Available ]                            |
    8 |                                                                              |
    9 |                                                                              |
   10 |                                                                              |
   11 |                                                                              |
   12 |                                                                              |
   13 |                                                                              |
   14 +------------------------------------------------------------------------------+
   15 exec No process (src) In:                                          L??   PC: ??
   16 (gdb)
   17
   18
   19
   20
   21
   22
   23
FAIL: $exp: initial source listing
...

The problem is in tui_get_begin_asm_address, where we look up the minimal
symbol for main, and use its address.

With the v1 ABI, we don't get the address of main in the .text section:
...
00000000000008b4 <.main>:
 8b4:   fb e1 ff f8     std     r31,-8(r1)
 8b8:   f8 21 ff c1     stdu    r1,-64(r1)
 8bc:   7c 3f 0b 78     mr      r31,r1
...
but the address of the descriptor of main in the .opd section:
...
000000000001fee8 <main>:
   1fee8:       00 00 00 00     .long 0x0
   1feec:       00 00 08 b4     .long 0x8b4
   1fef0:       00 00 00 00     .long 0x0
   1fef4:       00 02 7f 00     .long 0x27f00
...

Fix this by using gdbarch_convert_from_func_ptr_addr, similar to how that's
used in create_internal_breakpoint.

Tested on ppc64-linux and x86_64-linux.
---
 gdb/tui/tui-disasm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 5c68312a91b..68a5c425934 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -409,7 +409,11 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
 	  bound_minimal_symbol main_symbol
 	    = lookup_minimal_symbol (current_program_space, main_name ());
 	  if (main_symbol.minsym != nullptr)
-	    addr = main_symbol.value_address ();
+	    {
+	      addr = main_symbol.value_address ();
+	      addr = gdbarch_convert_from_func_ptr_addr
+		       (gdbarch, addr, current_inferior ()->top_target ());
+	    }
 	}
     }
   else				/* The target is executing.  */

base-commit: 5b805c95e9399e35f7bc895ec5b67aabdbc6ce41
-- 
2.51.0


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

* Re: [PATCH] [gdb/tui] Fix gdb.tui/list-before.exp on ppc64-linux
  2026-08-01 12:28 [PATCH] [gdb/tui] Fix gdb.tui/list-before.exp on ppc64-linux Tom de Vries
@ 2026-08-19 14:42 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2026-08-19 14:42 UTC (permalink / raw)
  To: gdb-patches

On 8/1/26 2:28 PM, Tom de Vries wrote:
> On ppc64-linux, with test-case gdb.tui/list-before.exp I run into:
> ...
> (gdb) tui enable^M
>    ...
> (gdb) Screen Dump (size 80 columns x 24 rows, cursor at column 6, row 16):
>      0 +------------------------------------------------------------------------------+
>      1 |                                                                              |
>      2 |                                                                              |
>      3 |                                                                              |
>      4 |                                                                              |
>      5 |                                                                              |
>      6 |                                                                              |
>      7 |                           [ No Source Available ]                            |
>      8 |                                                                              |
>      9 |                                                                              |
>     10 |                                                                              |
>     11 |                                                                              |
>     12 |                                                                              |
>     13 |                                                                              |
>     14 +------------------------------------------------------------------------------+
>     15 exec No process (src) In:                                          L??   PC: ??
>     16 (gdb)
>     17
>     18
>     19
>     20
>     21
>     22
>     23
> FAIL: $exp: initial source listing
> ...
> 
> The problem is in tui_get_begin_asm_address, where we look up the minimal
> symbol for main, and use its address.
> 
> With the v1 ABI, we don't get the address of main in the .text section:
> ...
> 00000000000008b4 <.main>:
>   8b4:   fb e1 ff f8     std     r31,-8(r1)
>   8b8:   f8 21 ff c1     stdu    r1,-64(r1)
>   8bc:   7c 3f 0b 78     mr      r31,r1
> ...
> but the address of the descriptor of main in the .opd section:
> ...
> 000000000001fee8 <main>:
>     1fee8:       00 00 00 00     .long 0x0
>     1feec:       00 00 08 b4     .long 0x8b4
>     1fef0:       00 00 00 00     .long 0x0
>     1fef4:       00 02 7f 00     .long 0x27f00
> ...
> 
> Fix this by using gdbarch_convert_from_func_ptr_addr, similar to how that's
> used in create_internal_breakpoint.
> 

I'm pushing this shortly.

Thanks,
- Tom

> Tested on ppc64-linux and x86_64-linux.
> ---
>   gdb/tui/tui-disasm.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
> index 5c68312a91b..68a5c425934 100644
> --- a/gdb/tui/tui-disasm.c
> +++ b/gdb/tui/tui-disasm.c
> @@ -409,7 +409,11 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
>   	  bound_minimal_symbol main_symbol
>   	    = lookup_minimal_symbol (current_program_space, main_name ());
>   	  if (main_symbol.minsym != nullptr)
> -	    addr = main_symbol.value_address ();
> +	    {
> +	      addr = main_symbol.value_address ();
> +	      addr = gdbarch_convert_from_func_ptr_addr
> +		       (gdbarch, addr, current_inferior ()->top_target ());
> +	    }
>   	}
>       }
>     else				/* The target is executing.  */
> 
> base-commit: 5b805c95e9399e35f7bc895ec5b67aabdbc6ce41


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

end of thread, other threads:[~2026-08-19 14:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-01 12:28 [PATCH] [gdb/tui] Fix gdb.tui/list-before.exp on ppc64-linux Tom de Vries
2026-08-19 14:42 ` Tom de Vries

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