public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Help with break in printf function
@ 2024-01-26 22:37 Carl Love
  2024-01-27  9:24 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Carl Love @ 2024-01-26 22:37 UTC (permalink / raw)
  To: gdb-patches, Carl Love


GDB developers:

I have a few tests that fail on PowerPC that I could use some help to fix in gdb. The issue is you set a breakpoint in the printf function but gdb does not find/stop at the breakpoint.  I think it might have something to do with the fact that the system has support for IEEE 128-bit floating point numbers.

Initially I set a breakpoint in in printf and main for the test program
gdb/testsuite/gdb.base/annota1.c.


(gdb) break printf
Function "printf" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (printf) pending.

gdb) break main
Breakpoint 2 at 0x10000788: file /.../binutils-gdb-printf/gdb/testsuite/gdb.base/annota1.c, line 15.

Then run to main

(gdb) r
Starting program: /home/carll/GDB/build-printf/gdb/testsuite/outputs/gdb.base/annota1/annota1 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 2, main ())
    at /.../binutils-gdb-printf/gdb/testsuite/gdb.base/annota1.c:15

I then single step to the print statement in main.


gdb) s
23	  printf ("value is %d\n", value);
(gdb) s
Downloading source file /usr/src/debug/glibc-2.37-16.fc38.ppc64le/stdio-common/../sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
___ieee128_printf (format=0x100008f0 "value is %d\n")                                                    
    at ../sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c:29
29	  done = __vfprintf_internal (stdout, format, ap,
 
I can see that it stepped into an ieee128-printf.c file. But when I print out the location of the breakpoints

(gdb) maint info breakpoints
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00007ffff7a6f8b8 in __printf at printf.c:28 inf 1
1.1                         y   0x00007ffff7a6f8b8 in __printf at printf.c:28 inf 1
2       breakpoint     keep y   0x0000000010000788 in main 
                                                   at /.../gdb/testsuite/gdb.base/annota1.c:15 inf 1

I see the breakpoint is set in a different file printf.c.

So, it would seem that GDB doesn't know that the test is compiled to use the print routine in ieee128-printf.c?
I am guessing the issue has to do with gdb reading the binary to determine what files/functions the program uses.  Not sure where/how GDB parses the binary to figure out where the library functions are located.  I am guessing gdb is not getting the correct function/file information from the binary.  If anyone has any ideas on how to go about debugging/fixing the issue, the help would be greatly appreciated.  Thanks.

                                  Carl 

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

end of thread, other threads:[~2024-01-29 18:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-26 22:37 Help with break in printf function Carl Love
2024-01-27  9:24 ` Andreas Schwab
2024-01-29 16:41   ` Carl Love
2024-01-29 18:50     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).