From: "Andrew Burgess" <aburgess@broadcom.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [PATCH] Consistent display of "<optimized out>"
Date: Tue, 06 Aug 2013 13:09:00 -0000 [thread overview]
Message-ID: <5200F55E.2050308@broadcom.com> (raw)
In some cases we report optimized out registers as "*value not available*"
rather than "<optimized out>", the patch below makes this more consistent
in the case I've spotted.
Here's an example:
(gdb) up
#1 0x0000000000400800 in first_frame () at dw2-reg-undefined.c:27
27 in dw2-reg-undefined.c
(gdb) info registers rax
rax *value not available*
(gdb) p/x $rax
$1 = <optimized out>
After the patch the behaviour is now:
(gdb) up
#1 0x0000000000400800 in first_frame () at dw2-reg-undefined.c:27
27 in dw2-reg-undefined.c
(gdb) info registers rax
rax <optimized out>
(gdb) p/x $rax
$1 = <optimized out>
The behaviour for values that are unavailable is currently unchanged,
though I have a follow up patch for this too.
OK to apply?
Thanks,
Andrew
gdb/ChangeLog
2013-08-06 Andrew Burgess <aburgess@broadcom.com>
* infcmd.c (default_print_one_register_info): Add detection of
optimized out values.
(default_print_registers_info): Switch to using
get_frame_register_value.
gdb/testsuite/ChangeLog
2013-08-06 Andrew Burgess <aburgess@broadcom.com>
* gdb.dwarf2/dw2-reg-undefined.exp: Change pattern for info
register to "<optimized out>", and also print the registers.
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 154cde2..f6a5290 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2033,6 +2033,12 @@ default_print_one_register_info (struct ui_file *file,
fprintf_filtered (file, "*value not available*\n");
return;
}
+ else if (value_optimized_out (val))
+ {
+ val_print_optimized_out (file);
+ fprintf_filtered (file, "\n");
+ return;
+ }
/* If virtual format is floating, print it that way, and in raw
hex. */
@@ -2107,9 +2113,6 @@ default_print_registers_info (struct gdbarch *gdbarch,
for (i = 0; i < numregs; i++)
{
- struct type *regtype;
- struct value *val;
-
/* Decide between printing all regs, non-float / vector regs, or
specific reg. */
if (regnum == -1)
@@ -2137,16 +2140,9 @@ default_print_registers_info (struct gdbarch *gdbarch,
|| *(gdbarch_register_name (gdbarch, i)) == '\0')
continue;
- regtype = register_type (gdbarch, i);
- val = allocate_value (regtype);
-
- /* Get the data in raw format. */
- if (! deprecated_frame_register_read (frame, i, value_contents_raw (val)))
- mark_value_bytes_unavailable (val, 0, TYPE_LENGTH (value_type (val)));
-
default_print_one_register_info (file,
gdbarch_register_name (gdbarch, i),
- val);
+ get_frame_register_value (frame, i));
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-reg-undefined.exp b/gdb/testsuite/gdb.dwarf2/dw2-reg-undefined.exp
index 7b7b4d1..4686648 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-reg-undefined.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-reg-undefined.exp
@@ -38,22 +38,34 @@ if ![runto stop_frame] {
gdb_test "bt" "#0 (0x\[0-9a-f\]+ in )?stop_frame \[^\r\n\]*\r\n#1 \[^\r\n\]*first_frame \[^\r\n\]*\r\n#2 \[^\r\n\]*main\[^\r\n\]*" \
"backtrace from stop_frame"
-set value_pattern "0x\[0-9a-f\]+\\s+\[0-9\]+"
-set opt_out_pattern "\\*value not available\\*"
-
for {set f 0} {$f < 3} {incr f} {
if {${f} == 0} {
- set pattern_rax_rbx_rcx ${value_pattern}
- set pattern_r8_r9 ${value_pattern}
+ set pattern_rax_rbx_rcx_print "$hex"
+ set pattern_rax_rbx_rcx_info "$hex\\s+$decimal"
+ set pattern_r8_r9_print "$hex"
+ set pattern_r8_r9_info "$hex\\s+$decimal"
} else {
- set pattern_rax_rbx_rcx ${opt_out_pattern}
- set pattern_r8_r9 ${value_pattern}
+ set pattern_rax_rbx_rcx_print "<optimized out>"
+ set pattern_rax_rbx_rcx_info "<optimized out>"
+ set pattern_r8_r9_print "$hex"
+ set pattern_r8_r9_info "$hex\\s+$decimal"
}
# Select frame.
gdb_test "frame ${f}" "#${f}.*" "Switch to frame ${f}"
+ gdb_test "p/x \$rax" ".*$pattern_rax_rbx_rcx_print.*" \
+ "print \$rax in frame ${f}"
+ gdb_test "p/x \$rbx" "$pattern_rax_rbx_rcx_print" \
+ "print \$rbx in frame ${f}"
+ gdb_test "p/x \$rcx" "$pattern_rax_rbx_rcx_print" \
+ "print \$rcx in frame ${f}"
+
+ gdb_test "p/x \$r8" "$pattern_r8_r9_print" "print \$r8 in frame ${f}"
+ gdb_test "p/x \$r9" "$pattern_r8_r9_print" "print \$r9 in frame ${f}"
+
+
# Display register values.
- gdb_test "info registers rax rbx rcx r8 r9" "rax\\s+${pattern_rax_rbx_rcx}\\s*\r\nrbx\\s+${pattern_rax_rbx_rcx}\\s*\r\nrcx\\s+${pattern_rax_rbx_rcx}\\s*\r\nr8\\s+${pattern_r8_r9}\\s*\r\nr9\\s+${pattern_r8_r9}\\s*" \
+ gdb_test "info registers rax rbx rcx r8 r9" "rax\\s+${pattern_rax_rbx_rcx_info}\\s*\r\nrbx\\s+${pattern_rax_rbx_rcx_info}\\s*\r\nrcx\\s+${pattern_rax_rbx_rcx_info}\\s*\r\nr8\\s+${pattern_r8_r9_info}\\s*\r\nr9\\s+${pattern_r8_r9_info}\\s*" \
"Check values of rax, rbx, rcx, r8, r9 in frame ${f}"
}
next reply other threads:[~2013-08-06 13:09 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-06 13:09 Andrew Burgess [this message]
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
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=5200F55E.2050308@broadcom.com \
--to=aburgess@broadcom.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