This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC 09/12] Display referenced values in backtraces


Hi,

I found embarassing GDB has not displayed the referenced scalar value:

this testcase:
#0  reference (refparam=@0x7fffffffdc3c) at gdb.arch/amd64-entry-value.cc:131
->
#0  reference (refparam=@0x7fffffffdc3c: 5) at gdb.arch/amd64-entry-value.cc:131

I find it much more useful in backtraces.  In fact I would even suppress the
`@0xaddr' part at all but that is outside of the scope of this patch.

Some large struct will not get displayed, GDB does not display structs by
value in the parameter list:
#0  f (c=...) at refparam.C:9
(gdb) print c
$3 = (C &) @0x7fffffffdae0: {a = 1, b = 2, c = 3}

You can see GDB already displayed even the value of references, this patch has
no effect on what `print' does.

Without this patch the effort of the [patch 10/12] would go vain, it tries
hard to recover referenced values but GDB does not try to display them at all.

Surprisingly there were no regressions in the current GDB testsuite by this
change.

You can see this patch is fully independent from the whole patchset.


Thanks,
Jan


gdb/
2011-07-18  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Display referenced values in backtraces.
	* printcmd.c (print_variable_and_value): Set OPTS.DEREF_REF to 1.
	* stack.c (print_frame_args): Likewise.

gdb/testsuite/
2011-07-18  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Display referenced values in backtraces.
	* gdb.arch/amd64-entry-value.exp (entry_reference: bt full at entry)
	(entry_reference: bt full): Update the expected output.

--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1960,6 +1960,7 @@ print_variable_and_value (const char *name, struct symbol *var,
 
       val = read_var_value (var, frame);
       get_user_print_options (&opts);
+      opts.deref_ref = 1;
 
       if (print_argument != PVAVD_IS_NOT_ARGUMENT
 	  && SYMBOL_CLASS (var) == LOC_COMPUTED
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -376,7 +376,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
                     language = current_language;
 
 		  get_raw_print_options (&opts);
-		  opts.deref_ref = 0;
+		  opts.deref_ref = 1;
 		  opts.summary = summary;
 		  common_val_print (val, stb->stream, 2, &opts, language);
 		  ui_out_field_stream (uiout, "value", stb);
--- a/gdb/testsuite/gdb.arch/amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value.exp
@@ -85,23 +85,23 @@ gdb_test "p s2" " = 4" "entry_stack: p s2"
 gdb_continue_to_breakpoint "entry_reference: reference"
 
 # (gdb) bt full
-# #0  reference (refparam=@0x7fffffffdc3c) at gdb.arch/amd64-entry-value.cc:131
+# #0  reference (refparam=@0x7fffffffdc3c: 5) at gdb.arch/amd64-entry-value.cc:131
 #         refcopy = 5
 # #1  0x0000000000400424 in main () at gdb.arch/amd64-entry-value.cc:145
 #         refvar = 5
 # Check refparam@entry is suppressed:
-gdb_test "bt full" "#0 +reference \\(refparam=@0x\[0-9a-f\]+\\) \[^\r\n\]*\r\n\[ \t\]*refcopy = 5\r\n#1 +0x\[0-9a-f\]+ in main \\(\\) \[^\r\n\]*\r\n\[ \t\]*refvar = 5" \
+gdb_test "bt full" "#0 +reference \\(refparam=@0x\[0-9a-f\]+: 5\\) \[^\r\n\]*\r\n\[ \t\]*refcopy = 5\r\n#1 +0x\[0-9a-f\]+ in main \\(\\) \[^\r\n\]*\r\n\[ \t\]*refvar = 5" \
 	 "entry_reference: bt full at entry"
 
 gdb_continue_to_breakpoint "entry_reference: breakhere_reference"
 
 # (gdb) bt full
-# #0  reference (refparam=@0x7fffffffdc3c) at gdb.arch/amd64-entry-value.cc:133
+# #0  reference (refparam=@0x7fffffffdc3c: 10) at gdb.arch/amd64-entry-value.cc:133
 #         refcopy = 5
 # #1  0x0000000000400424 in main () at gdb.arch/amd64-entry-value.cc:145
 #         refvar = 10
 # Check refparam@entry is present:
-gdb_test "bt full" "#0 +reference \\(refparam=@0x\[0-9a-f\]+\\) \[^\r\n\]*\r\n\[ \t\]*refcopy = 5\r\n#1 +0x\[0-9a-f\]+ in main \\(\\) \[^\r\n\]*\r\n\[ \t\]*refvar = 10" \
+gdb_test "bt full" "#0 +reference \\(refparam=@0x\[0-9a-f\]+: 10\\) \[^\r\n\]*\r\n\[ \t\]*refcopy = 5\r\n#1 +0x\[0-9a-f\]+ in main \\(\\) \[^\r\n\]*\r\n\[ \t\]*refvar = 10" \
 	 "entry_reference: bt full"
 gdb_test "ptype refparam" " = int &" "entry_reference: ptype refparam"
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]