Re: [PATCH] [gdb/testsuite] Add xfail for failure to break on ppc printf
Tom de Vries <[email protected]>
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
On 7/29/26 4:46 PM, Tom de Vries wrote:
> With test-case gdb.server/sysroot.exp, we run into:
> ...
> (gdb) break printf^M
> Breakpoint 2 at 0x7ffff7c2045c^M
> (gdb) continue^M
> Continuing.^M
> [Inferior 1 (process 469972) exited normally]^M
> (gdb) FAIL: $exp: sysroot=local: continue to printf (the program exited)
> ...
>
> The problem is that while breakpoint is indeed set on printf:
> ...
> (gdb) b printf
> Breakpoint 2 at 0x7ffff7c2045c
> (gdb) disassemble 0x7ffff7c2045c
> Dump of assembler code for function printf@@GLIBC_2.17:
> ...
> the function that is called instead is __printfieee128.
>
> Glibc commit f05ab7c4a9 ("ldbl-128ibm-compat: Add local aliases for printf
> family symbols") should fix this, but that's available starting version 2.43.
>
> Add an xfail for older glibc (without backport of that patch).
>
I had claude code review this. It pointed that that the unsupported
message "inferior exited" was somewhat vague, so I changed that into
"printf breakpoint didn't trigger".
I also noticed that in gdb.server/sysroot.exp the changes were done in a
loop, so I should also add an if unsupported clause there.
Pushed with those changes.
Thanks,
- Tom
> Tested on ppc64le-linux and x86_64-linux.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29989
> ---
> gdb/testsuite/gdb.base/annota1.exp | 20 +++++++++++++
> gdb/testsuite/gdb.base/annota3.exp | 44 +++++++++++++++++++++-------
> gdb/testsuite/gdb.server/sysroot.exp | 20 +++++++++++--
> 3 files changed, 72 insertions(+), 12 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp
> index 35eaf26103e..ca3365500c0 100644
> --- a/gdb/testsuite/gdb.base/annota1.exp
> +++ b/gdb/testsuite/gdb.base/annota1.exp
> @@ -262,13 +262,33 @@ set pat_begin "\r\n\032\032post-prompt\r\nContinuing.\r\n\r\n\032\032starting\r\
> set pat_adjust "warning: Breakpoint 3 address previously adjusted from $hex to $hex.\r\n"
> set pat_end "\r\n\032\032breakpoint 3\r\n\r\nBreakpoint 3(\\.$decimal)?, \r\n\032\032frame-begin 0 $hex\r\n\r\n(\032\032frame-address\r\n$hex\r\n\032\032frame-address-end\r\n in \r\n)*.*\032\032frame-function-name\r\n.*printf(@.*)?\r\n\032\032frame-args\r\n.*\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$"
>
> +set unsupported 0
> gdb_test_multiple "continue" "continue to printf" {
> -re "${pat_begin}($pat_adjust)?$pat_end" {
> pass $gdb_test_name
> }
> + -re $inferior_exited_re.*\r\n$gdb_prompt$ {
> + if {[istarget "powerpc64*-linux*"]} {
> + # On ppc64, glibc without commit f05ab7c4a9
> + # ("ldbl-128ibm-compat: Add local aliases for printf
> + # family symbols") may have two printf breakpoint
> + # locations, but export only one of them. Consequently,
> + # gdb sets a breakpoint on only one location, and there's
> + # no guarantee that the breakpoint will trigger.
> + xfail "$gdb_test_name (the program exited)"
> + } else {
> + fail "$gdb_test_name (the program exited)"
> + }
> + set unsupported 1
> + }
> -re ".*$gdb_prompt$" { fail $gdb_test_name }
> }
>
> +if {$unsupported} {
> + unsupported "inferior exited"
> + return
> +}
> +
> set pac [string_to_regexp {[PAC]}]
>
> #
> diff --git a/gdb/testsuite/gdb.base/annota3.exp b/gdb/testsuite/gdb.base/annota3.exp
> index 8a69350f1d5..f8b65d776f6 100644
> --- a/gdb/testsuite/gdb.base/annota3.exp
> +++ b/gdb/testsuite/gdb.base/annota3.exp
> @@ -163,16 +163,40 @@ gdb_test -prompt "$gdb_prompt$" "break printf" \
> #
> # get to printf
> #
> -send_gdb "continue\n"
> -gdb_expect_list "continue to printf" "$gdb_prompt$" [subst_vars {
> - "\r\n\032\032post-prompt\r\n"
> - "Continuing.\r\n"
> - "\r\n\032\032starting\r\n"
> - "\r\n\032\032breakpoint 3\r\n"
> - "\r\n"
> - "Breakpoint 3(\\.$decimal)?, \[^\r\n\]*\r\n"
> - "\r\n\032\032stopped\r\n"
> -}]
> +set re_pass \
> + [string cat \
> + "\r\n\032\032post-prompt\r\n" \
> + "Continuing.\r\n" \
> + "\r\n\032\032starting\r\n" \
> + "\r\n\032\032breakpoint 3\r\n" \
> + "\r\n" \
> + [subst_vars {Breakpoint 3(\.$decimal)?, [^\r\n]*\r\n}] \
> + ".*" \
> + "\r\n\032\032stopped"]
> +set unsupported 0
> +gdb_test_multiple "continue" "continue to printf" -prompt "$gdb_prompt$" {
> + -re -wrap $re_pass {
> + pass $gdb_test_name
> + }
> + -re -wrap $inferior_exited_re.* {
> + if {[istarget "powerpc64*-linux*"]} {
> + # On ppc64, glibc without commit f05ab7c4a9
> + # ("ldbl-128ibm-compat: Add local aliases for printf
> + # family symbols") may have two printf breakpoint
> + # locations, but export only one of them. Consequently,
> + # gdb sets a breakpoint on only one location, and there's
> + # no guarantee that the breakpoint will trigger.
> + xfail "$gdb_test_name (the program exited)"
> + } else {
> + fail "$gdb_test_name (the program exited)"
> + }
> + set unsupported 1
> + }
> +}
> +if {$unsupported} {
> + unsupported "inferior exited"
> + return
> +}
>
> send_gdb "backtrace\n"
> gdb_expect_list "backtrace from shlibrary" "$gdb_prompt$" {
> diff --git a/gdb/testsuite/gdb.server/sysroot.exp b/gdb/testsuite/gdb.server/sysroot.exp
> index 7e4a796e879..6a5d0b7c418 100644
> --- a/gdb/testsuite/gdb.server/sysroot.exp
> +++ b/gdb/testsuite/gdb.server/sysroot.exp
> @@ -88,7 +88,23 @@ foreach_with_prefix sysroot $modes {
>
> # Test that we can stop inside a library.
> gdb_breakpoint printf
> - gdb_test "continue" "Breakpoint $decimal.* (__|___ieee128_)?printf.*" \
> - "continue to printf"
> + gdb_test_multiple "continue" "continue to printf" {
> + -re -wrap "Breakpoint $decimal.* (__|___ieee128_)?printf.*" {
> + pass $gdb_test_name
> + }
> + -re -wrap $inferior_exited_re\[^\r\n\]+ {
> + if {[istarget "powerpc64*-linux*"]} {
> + # On ppc64, glibc without commit f05ab7c4a9
> + # ("ldbl-128ibm-compat: Add local aliases for printf
> + # family symbols") may have two printf breakpoint
> + # locations, but export only one of them. Consequently,
> + # gdb sets a breakpoint on only one location, and there's
> + # no guarantee that the breakpoint will trigger.
> + xfail "$gdb_test_name (the program exited)"
> + } else {
> + fail "$gdb_test_name (the program exited)"
> + }
> + }
> + }
> }
> }
>
> base-commit: 36af47b3a8348b9ff9c717100c44049c6f3d6315