From: Pedro Alves <palves@redhat.com>
To: Andrew Burgess <aburgess@broadcom.com>
Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>,
Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: Re: [PATCH] Always print call-clobbered registers in outer frames.
Date: Tue, 24 Sep 2013 13:43:00 -0000 [thread overview]
Message-ID: <524196EF.8090107@redhat.com> (raw)
In-Reply-To: <52418BFA.6030405@broadcom.com>
On 09/24/2013 01:56 PM, Andrew Burgess wrote:
>>> My question then is, what makes you believe the inner, possibly
>>> call-clobbered value is right?
>>
>> Nothing, of course. It's just a choice -- either assume it's right,
>> and somehow warn the user it may not be right through some other means;
>> or, assume it's not right, and hide the value from the user. If
>> GDB is wrong, the user can still fetch the value, though it'll take
>> more steps (up+p $reg+down, etc.). It might still be a good idea to
>> provide an easier way to "flatten" the not-saved registers as
>> convenience for that, not sure).
>
> I guess the thing I'm struggling with is why would we /ever/ assume the
> value in an inner frame is correct?
"correct" depends on the definition. If we defined registers in
frame > 0 the way I suggested in response to Mark, then they always are.
Doing otherwise means assuming we know the ABI the outer and inner
frames agreed on. There are a number of ways to get that wrong, like
with assembly code, or even probably with gcc attributes or some JITs,
meaning GDB will hide the value from the user behind <not saved>, when
it should not. Granted, not the _usual_ scenario, but I bet it's real.
Yeah, can always be fixed in the unwind/debug itself.
> Sure, for very shallow stacks on
> machines with a non-small register set there's a reasonable chance the
> value is correct, but in any other case I seriously don't see how taking
> the value from an inner frame is any better than picking a random number.
Again, it's a matter of definition -- "taking a value from an
inner frame" just meant "if the unwind info doesn't say the register was
saved, then assume that when the inner function returned, the register
would still hold that value".
> I think that if you print it "they" (users) will use it, assuming it's
> correct. Given that I don't think it's correct I think we're likely to
> be giving users miss-information.
And here is where I'm wondering what sort of use do you think they'll
be giving them. :-) GDB will still print <optimized out> for variables
that happened to be live in such registers at the time of the call. If the
functions involved are C or even higher-level language code, nothing
changes, because indeed if the register is supposedly call-clobbered
nothing in the caller will be expecting to find the old register value
still in the register. But, when you're peeking into machine register values
in the debugger you're going deeper than that. You're probably looking into
mapping them to a disassembly of the machine code. In my mind, at this
level, it's not strictly correct for GDB to assume any particular ABI -- best
be driven by unwind info, and if the unwind info doesn't specify where the
register was saved, at least give the user some useful value, rather than
forcing her to go hunt for it in inner frames.
(Again, I think both perspectives are reasonable. But if the
always-print-registers route is harder to explain to other GDB developers,
then that does hint that users wouldn't understand it either, which does
favor the <not saved> route.)
--
Pedro Alves
next prev parent reply other threads:[~2013-09-24 13:43 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-06 13:09 [PATCH] Consistent display of "<optimized out>" Andrew Burgess
2013-08-06 13:18 ` Mark Kettenis
2013-08-06 13:49 ` Andrew Burgess
2013-08-06 15:41 ` Mark Kettenis
2013-08-06 16:02 ` Andrew Burgess
2013-08-06 18:39 ` Pedro Alves
2013-08-12 13:32 ` Andrew Burgess
2013-08-12 13:55 ` Pedro Alves
2013-08-12 14:01 ` Andrew Burgess
2013-08-12 20:01 ` Mark Kettenis
2013-08-13 8:27 ` Andrew Burgess
2013-08-16 18:41 ` Pedro Alves
2013-08-16 20:28 ` Pedro Alves
2013-08-19 10:25 ` Andrew Burgess
2013-09-05 16:29 ` [PATCH] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>". (was: Re: [PATCH] Consistent display of "<optimized out>") Pedro Alves
2013-09-05 16:35 ` [PATCH] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>" Andrew Burgess
2013-09-16 19:05 ` Pedro Alves
2013-09-18 14:04 ` Andrew Burgess
2013-09-18 15:54 ` [PATCH+DOC] " Pedro Alves
2013-09-18 16:30 ` Andreas Schwab
2013-09-18 17:36 ` Pedro Alves
2013-09-18 16:30 ` Eli Zaretskii
2013-09-18 17:35 ` Pedro Alves
2013-09-18 19:35 ` Eli Zaretskii
2013-09-18 20:47 ` Mark Kettenis
2013-09-19 7:53 ` Eli Zaretskii
2013-09-19 16:58 ` Pedro Alves
2013-09-19 19:15 ` [PATCH] Always print call-clobbered registers in outer frames. (was: Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".) Pedro Alves
2013-09-19 19:35 ` Eli Zaretskii
2013-09-19 23:13 ` Doug Evans
2013-09-19 23:22 ` Doug Evans
2013-09-20 11:04 ` [PATCH] Always print call-clobbered registers in outer frames Andrew Burgess
2013-09-24 12:07 ` Pedro Alves
2013-09-24 12:56 ` Andrew Burgess
2013-09-24 13:43 ` Pedro Alves [this message]
2013-09-24 15:18 ` Andrew Burgess
2013-09-24 19:36 ` Pedro Alves
2013-09-24 23:22 ` Andrew Burgess
2013-10-02 16:05 ` Pedro Alves
2013-10-02 19:07 ` Doug Evans
2013-09-20 12:28 ` [PATCH] Always print call-clobbered registers in outer frames. (was: Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".) Mark Kettenis
2013-09-24 12:06 ` [PATCH] Always print call-clobbered registers in outer frames Pedro Alves
2013-10-02 16:17 ` [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>" Pedro Alves
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=524196EF.8090107@redhat.com \
--to=palves@redhat.com \
--cc=aburgess@broadcom.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
/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