This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Always print call-clobbered registers in outer frames.
- From: Pedro Alves <palves at redhat dot com>
- To: Andrew Burgess <aburgess at broadcom dot com>
- Cc: gdb-patches at sourceware dot org, Eli Zaretskii <eliz at gnu dot org>, Mark Kettenis <mark dot kettenis at xs4all dot nl>
- Date: Tue, 24 Sep 2013 14:43:11 +0100
- Subject: Re: [PATCH] Always print call-clobbered registers in outer frames.
- Authentication-results: sourceware.org; auth=none
- References: <5200F55E dot 2050308 at broadcom dot com> <201308061318 dot r76DIMdd016369 at glazunov dot sibelius dot xs4all dot nl> <5200FECF dot 7030304 at broadcom dot com> <201308061541 dot r76FfYQN022875 at glazunov dot sibelius dot xs4all dot nl> <520142D9 dot 4030304 at redhat dot com> <5208E3C8 dot 7060107 at broadcom dot com> <5208E938 dot 3080305 at redhat dot com> <201308122001 dot r7CK1862007934 at glazunov dot sibelius dot xs4all dot nl> <520E7255 dot 7080206 at redhat dot com> <5211F25A dot 5070907 at broadcom dot com> <5228B15F dot 7060108 at redhat dot com> <5228B2D8 dot 7060604 at broadcom dot com> <5237567C dot 8050406 at redhat dot com> <5239B2D8 dot 4030403 at broadcom dot com> <5239CCB3 dot 605 at redhat dot com> <83zjram6sw dot fsf at gnu dot org> <201309182047 dot r8IKlOGA010471 at glazunov dot sibelius dot xs4all dot nl> <83fvt1mems dot fsf at gnu dot org> <523B2D39 dot 8060303 at redhat dot com> <523B4D48 dot 3050206 at redhat dot com> <523C2B6F dot 4000007 at broadcom dot com> <5241805D dot 3020800 at redhat dot com> <52418BFA dot 6030405 at broadcom dot 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
- References:
- [PATCH] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>". (was: Re: [PATCH] Consistent display of "<optimized out>")
- Re: [PATCH] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- Re: [PATCH] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- Re: [PATCH] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- [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>".)
- Re: [PATCH] Always print call-clobbered registers in outer frames.
- Re: [PATCH] Always print call-clobbered registers in outer frames.
- Re: [PATCH] Always print call-clobbered registers in outer frames.