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]

Re: [PATCH 3/3] Select the current frame in command tdump.


On 07/29/2013 11:44 PM, Pedro Alves wrote:
> IMO, this testing method isn't as robust or easy to understand/debug as it
> could be.  IMO, the best would be to store the output of tdump while looking
> at frame #0, and then compare that to the output of tdump while looking
> at frame #1.  It should come out the same.  See gdb.base/gcore.exp,
> capture_command_output, etc..  WDYT?

That makes sense to me.  The output on frame 0 and on frame 1
should be identical.  We can compare them.  How do you think the
patch below?

-- 
Yao (éå)


gdb:

2013-07-30  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* tracepoint.c (trace_dump_command): Select the current frame.

gdb/testsuite:

2013-07-30  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/backtrace.exp (gdb_backtrace_tdp_4): Test command
	'tdump' on stack frame 0 and 1 respectively.
---
 gdb/testsuite/gdb.trace/backtrace.exp |   31 +++++++++++++++++++++++++++++++
 gdb/tracepoint.c                      |    6 ++++++
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp
index e40428f..f35c22a 100644
--- a/gdb/testsuite/gdb.trace/backtrace.exp
+++ b/gdb/testsuite/gdb.trace/backtrace.exp
@@ -230,6 +230,37 @@ proc gdb_backtrace_tdp_4 { msg depth traceframe } {
 		fail "$msg (fewer than $depth stack frames found)"
 	    }
 	}
+
+	set output_string0 ""
+	# Match the output of command 'tdump' and save it in
+	# $output_string0.
+	set test "tdump on frame 0"
+	gdb_test_multiple "tdump" $test {
+	    -re "tdump\[\r\n\]+(.*)\[\r\n\]+$gdb_prompt $" {
+		set output_string0 $expect_out(1,string)
+	    }
+	}
+
+	gdb_test "up" ".*" ""
+
+	# Test command 'tdump' still work properly when the selected
+	# frame is not the current frame, and save the output in
+	# $output_string1.
+	set test "tdump on frame 1"
+	set output_string1 ""
+	gdb_test_multiple "tdump" $test {
+	    -re "tdump\[\r\n\]+(.*)\[\r\n\]+$gdb_prompt $" {
+		set output_string1 $expect_out(1,string)
+	    }
+	}
+
+	# Output of 'tdump' on frame 0 and frame 1 should be
+	# identical.
+	if ![string compare $output_string0 $output_string1]  {
+	    pass "tdump output"
+	} else {
+	    fail "tdump output"
+	}
     }
 }
 
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 8b70bd3..ce61fb7 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -3065,6 +3065,12 @@ trace_dump_command (char *args, int from_tty)
 		   tracepoint_number, traceframe_number);
 
   old_chain = make_cleanup (null_cleanup, NULL);
+
+  /* This command only makes sense for the current frame, not the
+     selected frame.  */
+  make_cleanup_restore_current_thread ();
+  select_frame (get_current_frame ());
+
   actions = all_tracepoint_actions_and_cleanup (loc->owner);
 
   trace_dump_actions (actions, 0, stepping_frame, from_tty);
-- 
1.7.7.6


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