This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- From: Pedro Alves <palves at redhat dot com>
- To: Eli Zaretskii <eliz at gnu dot org>
- Cc: aburgess at broadcom dot com, gdb-patches at sourceware dot org, mark dot kettenis at xs4all dot nl
- Date: Wed, 18 Sep 2013 18:35:07 +0100
- Subject: Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
- 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>
On 09/18/2013 05:30 PM, Eli Zaretskii wrote:
>> Date: Wed, 18 Sep 2013 16:54:27 +0100
>> From: Pedro Alves <palves@redhat.com>
>> CC: gdb-patches@sourceware.org, Mark Kettenis <mark.kettenis@xs4all.nl>
>>
>> Eli, I've added NEWS and documentation changes to this patch.
>> Are those OK?
>
> Almost.
>
>> +* GDB now shows "<not saved>" when printing values of registers that
>> + have not been saved in the frame:
>> +
>> + (gdb) p $rax $1 = <not saved>
>> + (gdb) info registers rax rax <not saved>
>
> Wrong formatting of what GDB prints.
Blah. Bad copy/paste. Thanks.
>
>> +In some ABIs, some registers may not be preserved, or saved, across
>> +function calls. It may therefore not be possible for @value{GDBN} to
>> +know the value a register had before the call (in other words, in a
> ^
> "the"
Fixed.
>
>> +outer frame). Values of registers that @value{GDBN} can tell were not
>> +saved in their stack frames are shown as @w{@samp{<not saved>}}.
>> +
>> +However, if debug or unwind information is missing, @value{GDBN} must
>> +deduce where registers are saved, from the machine code generated by
>> +your compiler. If some registers are not saved, or if @value{GDBN} is
>> +unable to locate the saved registers, the selected stack frame makes
>> +no difference.
>
> I don't understand the significance of the last paragraph.
It's preexisting actually. I just added the "debug or unwind info" bit.
But yeah, it's confusing. I _think_ I know what it's talking about.
I think "makes no difference" refers to GDB assuming $reg in an outer
frame is found at the same location as in the inner frame (that is,
assuming the call clobbered register hasn't been clobbered yet).
I've rewritten all this text now. What do you think?
> Also, shouldn't we mention optimizations as (the main) reason for
> registers being unavailable?
I'm not actually sure how to say that. Not sure you actually
always need optimization to see this in the debugger. But maybe
we don't need to in this new version. :-)
diff --git c/gdb/NEWS w/gdb/NEWS
index af06a21..7c10cbb 100644
--- c/gdb/NEWS
+++ w/gdb/NEWS
@@ -15,6 +15,19 @@
* The "catch syscall" command now works on arm*-linux* targets.
+* GDB now shows "<not saved>" when printing values of registers the
+ debug info indicates have not been saved in the frame and there's
+ nowhere to retrieve them from:
+
+ (gdb) p $rax
+ $1 = <not saved>
+
+ (gdb) info registers rax
+ rax <not saved>
+
+ Before, the former would print "<optimized out>", and the latter
+ "*value not available*".
+
* Python scripting
** Frame filters and frame decorators have been added.
diff --git c/gdb/doc/gdb.texinfo w/gdb/doc/gdb.texinfo
index 60d2877..d122874 100644
--- c/gdb/doc/gdb.texinfo
+++ w/gdb/doc/gdb.texinfo
@@ -10031,10 +10031,21 @@ were exited and their saved registers restored. In order to see the
true contents of hardware registers, you must select the innermost
frame (with @samp{frame 0}).
-However, @value{GDBN} must deduce where registers are saved, from the machine
-code generated by your compiler. If some registers are not saved, or if
-@value{GDBN} is unable to locate the saved registers, the selected stack
-frame makes no difference.
+In some ABIs, some registers may not be preserved, or saved, across
+function calls. It may therefore not be possible for @value{GDBN} to
+know the value a register had before the call (in other words, in the
+outer frame), if the register has since been clobbered by the callee.
+@value{GDBN} tries to deduce where registers are saved, from the debug
+info, unwind info, or the machine code generated by your compiler. If
+some register is not saved, or if @value{GDBN} is unable to locate the
+saved register, @value{GDBN} will assume the register in the outer
+frame had the same location and value it has in the inner frame. This
+is usually harmless, but note however that if you change a register in
+the outer frame, you may also be affecting the inner frame. Values of
+registers that @value{GDBN} can definitely tell from the debug/unwind
+info were not saved in their stack frames and there's nowhere to
+retrieve the original value from anymore are shown as
+@w{@samp{<not saved>}}.
@node Floating Point Hardware
@section Floating Point Hardware