Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Peter Bergner via Gdb <gdb@sourceware.org>
To: Sachin Monga <smonga@linux.ibm.com>,
	libc-help@sourceware.org,
	"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
	gdb@sourceware.org
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
	Michael Meissner <meissner@linux.ibm.com>,
	Surya Kumari Jangala <jskumari@linux.ibm.com>,
	Carl Love <cel@us.ibm.com>
Subject: Re: gdb does not stop at printf for ppc
Date: Tue, 30 Sep 2025 23:03:51 -0500	[thread overview]
Message-ID: <b795f509-4bf4-4908-9ad9-3163da998cd0@tenstorrent.com> (raw)
In-Reply-To: <f4e905f7-48cb-439a-a8e6-a50242c18e6a@linux.ibm.com>

Adding Carl, Mike, Segher and Surya to the CC for their input, so I'm
leaving Sachin's entire question for them to see.

I'm also CCing the libc-alpha and GDB lists for wider exposure, since
this is an actual BUG.  My reply is at the end of Sachin's questions.


On 9/25/25 2:47 AM, Sachin Monga wrote:
> Hi Stewards
> 
> 
> Summary:
> 
> There is a test case in GDB where printf is getting converted into 
> __printfieee128 when program is compiled with "--no-builtin" flag.
> The program is working fine on a machine with glibc 2.34, but not on 
> another machine where glibc 2.40 is installed.
> 
> 
> Test program:
> $ cat test.c
> #include <stdio.h>
> 
> int
> main ()
> {
>    printf ("Hello World!\n");
>    return 0;
> }
> 
> GDB operation:
> 1. Load the binary
> 2. Break main
> 3. Run
> 4. Once program stops at main, then Break printf
> 5. Continue
> 
> Expected ouput: GDB should stop at printf function
> 
> Actual Output on Machine1(with glibc 2.34) : GDB stop at printf symbol
> 
> Actual Output on Machine2(with glibc 2.40) : GDB does NOT stop at printf 
> symbol
> 
> 
> Analysis:
> Glibc debug package with source is required. Once it is installed.
> Then program is working fine with glibc 2.34, but not where glibc 2.40 
> is installed.
> 
> 
> 1. Install debug info package for glibc
> sudo dnf debuginfo-install glibc
> 
> Machine1: glibc packages
> $ rpm -q glibc glibc-debuginfo glibc-debugsource
> glibc-2.34-168.el9_6.23.ppc64le
> glibc-debuginfo-2.34-168.el9_6.23.ppc64le
> glibc-debugsource-2.34-168.el9_6.23.ppc64le
> 
> 
> 
> Machine2: glibc 2.40 packages
> $ rpm -q glibc glibc-debuginfo glibc-debugsource
> glibc-2.40-28.fc41.ppc64le
> glibc-debuginfo-2.40-28.fc41.ppc64le
> glibc-debugsource-2.40-28.fc41.ppc64le
> ~/GDB/latest_gdb/print$
> 
> 
> I execute additional program to check behaviour in both the machine
> 
> $] cat test_print_map.c
> #include <stdio.h>
> 
> int main(void) {
>      printf("Hello World!\n");
> 
>      // Print address of printf and its ieee128 variant
>      printf("Address of printf:        %p\n", (void*)printf);
> #ifdef __GLIBC__
>      extern int __printfieee128(const char *, ...);
>      printf("Address of __printfieee128: %p\n", (void*)__printfieee128);
> #endif
> 
>      return 0;
> }
> 
> Compilation
> gcc -O0 -g -o test_print_map test_print_map.c --no-builtin
> 
> 
> Machine 2 (with glibc 2.40)
> $ ./test_printf_map
> Hello World!
> Address of printf:        0x7fff806870c0  <---- Same address
> Address of __printfieee128: 0x7fff806870c0        <------ Same address
> Abhay@ltcd97-lp3:~/GDB/latest_gdb/print$
> 
> 
> Machine1 (with glibc 2.34)
> $ ./test_printf_map
> Hello World!
> Address of printf:        0x20002a066980  <-------- Different address
> Address of __printfieee128: 0x20002a082e80     <-------- Different address
> [abhay@kubota print]$
> 
> 
> Based on above output, my assumption are (may be it is not 100% true):
> Here, the compiler + linker decide how to bind the symbol:
> 
> In glibc 2.40 :
> printf is just a strong alias to __printfieee128, so both resolve to the 
> same address at link time.
> 
> In glibc 2.34 :
> printf lives at a different symbol table entry than __printfieee128.
> May be two different definitions or pointing to IO_printf(). I am not sure.
> 
> 
> So the query is why gdb is not able to stop at printf symbol where glibc 
> 2.40 is installed ? Is this a bug in glibc or I am missing something ?
> 
> 
> Regards:
> Sachin.


There is actually a GLIBC bugzilla about this and it's not just printf,
but all IEEE 128-bit floating point functions.  I've assigned it to you now! :-)
I don't remember if the solution in Carl's last comment was actually decided
to be the correct way to "fix" this though:

  https://sourceware.org/bugzilla/show_bug.cgi?id=29989


My guess is the difference between your two systems, is that the newer
system's gcc was built with --with-long-double-format=ieee which causes
gcc to enable -mabi=ieeelongdouble by default, meaning "long double"
is equal to IEEE128 instead of the older -mabi=ibmlongdouble usage,
where "long double" is equal to the IBM128/IBM double-double format.
With -mabi=ibmlongdouble, calls to printf() are directed at the printf
symbol in glibc.  With -mabi=ieeelongdouble, gcc remaps printf() calls
to the __printfieee128 symbol in glibc.  I don't think symbol versioning
would have helped here, since we have to handle calls to both the old
and new printf symbols.  I'll let Mike correct me if I'm wrong. :-)

Obviously, we don't want to make users have to say "break __printfieee128"
in gdb, but rather "break printf" should set breakpoints on both printf and
__printfieee128.  The best way to accomplish that though...I'm not sure
we decided that.  Ie, can we fix this in GLIBC or add a workaround in GDB?

Mike, Segher, Carl, Surya or anyone else, anything else to add?

Peter




       reply	other threads:[~2025-10-01  4:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <f4e905f7-48cb-439a-a8e6-a50242c18e6a@linux.ibm.com>
2025-10-01  4:03 ` Peter Bergner via Gdb [this message]
2025-10-01 17:20   ` Adhemerval Zanella Netto via Gdb
2025-10-02 15:57     ` [EXT] " Peter Bergner via Gdb
2025-10-02 16:19       ` Carl Love via Gdb
2025-10-02 16:58       ` Florian Weimer via Gdb
2025-10-02 18:12         ` Peter Bergner via Gdb
2025-10-02 18:49           ` Billie Alsup (balsup) via Gdb
2025-10-02 19:09             ` Peter Bergner via Gdb
2025-10-03 19:43     ` Tom Tromey
2025-10-07 17:21       ` Adhemerval Zanella Netto via Gdb
2025-10-15 14:33         ` [EXT] " Peter Bergner via Gdb
2025-10-15 17:09           ` Sachin Monga via Gdb
2025-11-05  6:00             ` Sachin Monga via Gdb
2025-11-06  4:13               ` Peter Bergner via Gdb

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=b795f509-4bf4-4908-9ad9-3163da998cd0@tenstorrent.com \
    --to=gdb@sourceware.org \
    --cc=bergner@tenstorrent.com \
    --cc=cel@us.ibm.com \
    --cc=jskumari@linux.ibm.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-help@sourceware.org \
    --cc=meissner@linux.ibm.com \
    --cc=segher@kernel.crashing.org \
    --cc=smonga@linux.ibm.com \
    /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