public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Paul Smith <psmith@gnu.org>
To: gdb@sourceware.org
Subject: Re: GDB 13.2: breakpoint at wrong line after unrelated change
Date: Mon, 11 Mar 2024 16:17:24 -0400	[thread overview]
Message-ID: <5bda356936aebae24db2bfc2d091d61224de5890.camel@gnu.org> (raw)
In-Reply-To: <06c7a0d1-6ba7-440a-a21a-616ed05cb5b0@simark.ca>

On Mon, 2024-03-11 at 15:50 -0400, Simon Marchi wrote:
> > FYI I'm switching to the fmt library (if you're familiar with that)
> 
> Yes, I love it, we should use it in GDB :).

It's very nice for portable programming, but I really hope that GCC
will add __attribute__ support for it like they have for printf()
formatting.  The errors generated are incomprehensible (basically you
get pages of error messages and the only useful thing is you get a
filename and linenumber to look at) and it has one significant failing:
it will throw a compile error if you have _too few_ arguments for the
formatting string, or the argument can't be formatted, but it is
completely silent if you have _too many_ arguments for the formatting
string.  In the abstract this makes sense since unlike with varargs
it's quite possible to have extra arguments that are not formatted...
but in real life I expect that capability is virtually never used, and
the lack of this warning makes porting very tricky (if you forget to
switch a "%s" to a "{}", the compiler will not warn you).

> If you never call it, if never generates code, so it kinda make sense
> that it doesn't change anything.

Yes agreed.

> > If I have some invocation of criticalError() somewhere in the
> > translation unit, I get this problem.  I haven't checked moving it
> > around to see if it needs to be invoked before/after the "problem"
> > method in the TU to get this behavior.

Just to try it I put only one invocation near the start of the TU, then
only one invocation near the end of the TU.  I got the problem in both
cases, so that's kind of odd.  Maybe.

> Ok, so clearly GDB failed to analyze the prologue.  Which is weird
> because the two functions are identical (modulo the addresses).

Yes!  Very weird.

> To get to the bottom of this, you (or someone else) would need to
> debug GDB itself.

OK.  I will look into this but it may take a few days.  The first thing
I'll do is build the latest release of GDB and see if it makes a
difference.  I'm hopeful that the problem is in GDB not GCC or binutils
since those are harder to change, but we'll see.

Thanks for the conversation Simon I'll let you know where I get, with
the goal of filing a bug if I can repro with the latest code and can
get some idea of what's going on.

  reply	other threads:[~2024-03-11 20:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 18:28 Paul Smith
2024-03-11 19:14 ` Simon Marchi
2024-03-11 19:38   ` Paul Smith
2024-03-11 19:50     ` Simon Marchi
2024-03-11 20:17       ` Paul Smith [this message]
2024-03-15 21:11       ` Paul Smith
2024-03-15 22:19         ` Paul Smith
2024-03-16 16:33           ` Simon Marchi
2024-03-16 19:57             ` Paul Smith

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=5bda356936aebae24db2bfc2d091d61224de5890.camel@gnu.org \
    --to=psmith@gnu.org \
    --cc=gdb@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).