This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Honor print option and value's type when printing optimized value
- From: Yao Qi <yao at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 30 Sep 2011 19:03:32 +0800
- Subject: [patch] Honor print option and value's type when printing optimized value
I am looking at the following fail in tests,
FAIL: gdb.base/frame-args.exp: frame 1 with print frame-arguments
set to scalars
test fails because the actual output is
"call_me (i=3, f=5, s=<value optimized out>, ss=0x400177a8,
u=<value optimized out>, e=green)"
but the expected output is,
"call_me (i=3, f=5, s=..., ss=0x400177a8, u=..., e=green)"
Before this test, "print frame-arguments" is set to "scalars", and
all the values of non-scalar type should be printed as `...', even
if value has been optimized out. However, GDB doesn't consider this
when value is optimized out. This patch is to address this issue.
Regression tested on x86_64-unknown-linux-gnu. OK for mainline?
--
Yao (éå)
2011-09-30 Yao Qi <yao@codesourcery.com>
gdb/
* valprint.c (value_check_printable): Add one parameter OPTIONS.
Honor OPTIONS and VAL's type.
(common_val_print, value_print): Update to pass one more parameter.
diff --git a/gdb/valprint.c b/gdb/valprint.c
index b26924a..b4ac4ec 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -399,11 +399,12 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
}
/* Check whether the value VAL is printable. Return 1 if it is;
- return 0 and print an appropriate error message to STREAM if it
- is not. */
+ return 0 and print an appropriate error message to STREAM according to
+ OPTIONS if it is not. */
static int
-value_check_printable (struct value *val, struct ui_file *stream)
+value_check_printable (struct value *val, struct ui_file *stream,
+ const struct value_print_options *options)
{
if (val == 0)
{
@@ -413,7 +414,10 @@ value_check_printable (struct value *val, struct ui_file *stream)
if (value_entirely_optimized_out (val))
{
- val_print_optimized_out (stream);
+ if (options->summary && !scalar_type_p (value_type (val)))
+ fprintf_filtered (stream, "...");
+ else
+ val_print_optimized_out (stream);
return 0;
}
@@ -441,7 +445,7 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
const struct value_print_options *options,
const struct language_defn *language)
{
- if (!value_check_printable (val, stream))
+ if (!value_check_printable (val, stream, options))
return 0;
if (language->la_language == language_ada)
@@ -467,7 +471,7 @@ int
value_print (struct value *val, struct ui_file *stream,
const struct value_print_options *options)
{
- if (!value_check_printable (val, stream))
+ if (!value_check_printable (val, stream, options))
return 0;
if (!options->raw)