public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Carl Love <cel@linux.ibm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: Help with break in printf function
Date: Sat, 27 Jan 2024 10:24:47 +0100	[thread overview]
Message-ID: <87cytn2ko0.fsf@linux-m68k.org> (raw)
In-Reply-To: <4c92aa19-ca28-44e4-97c6-3b0b4d9da512@linux.ibm.com> (Carl Love's message of "Fri, 26 Jan 2024 14:37:05 -0800")

On Jan 26 2024, Carl Love wrote:

> 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.

That's because nothing in the program actually calls the printf
function, it calls ___ieee128_printf instead.  The function in printf.c
implements the pre-ieee128 printf function, and due to compiler magic
the printf call in the source is rewritten to __ieee128_printf.

> So, it would seem that GDB doesn't know that the test is compiled to use the print routine in ieee128-printf.c?

Probably GDB needs to implement some magic to know that printf and
__ieee128_printf are somewhat related.  Similar issues exist with
__isoc99_ and __isoc23_ prefixed symbols for all architectures.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

  reply	other threads:[~2024-01-27  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26 22:37 Carl Love
2024-01-27  9:24 ` Andreas Schwab [this message]
2024-01-29 16:41   ` Carl Love
2024-01-29 18:50     ` Tom Tromey

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=87cytn2ko0.fsf@linux-m68k.org \
    --to=schwab@linux-m68k.org \
    --cc=cel@linux.ibm.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).