* [PATCH 0/3] Select the current frame in command tdump.
@ 2013-06-27 14:02 Yao Qi
2013-06-27 14:02 ` [PATCH 1/3] Tweak gdb.trace/backtrace.exp Yao Qi
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Yao Qi @ 2013-06-27 14:02 UTC (permalink / raw)
To: gdb-patches
Hi,
Command 'tdump' should be run on the current stack frame instead of
the selected stack frame. The patch 3/3 is to change to the current
stack trace when executing command 'tdump'. When writing test case
for this change, I did some cleanups in gdb.trace/backtrace.exp (in
patch 1/3) and get the test result unique (patch 2/3).
Regression tested on x86_64-linux.
*** BLURB HERE ***
Yao Qi (3):
Tweak gdb.trace/backtrace.exp
Make test result of gdb.trace/backtrace.exp unique
Select the current frame in command tdump.
gdb/testsuite/gdb.trace/backtrace.exp | 86 ++++++++++++++++++++-------------
gdb/tracepoint.c | 6 ++
2 files changed, 59 insertions(+), 33 deletions(-)
--
1.7.7.6
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH 1/3] Tweak gdb.trace/backtrace.exp 2013-06-27 14:02 [PATCH 0/3] Select the current frame in command tdump Yao Qi @ 2013-06-27 14:02 ` Yao Qi 2013-07-29 15:44 ` Pedro Alves 2013-06-27 14:02 ` [PATCH 2/3] Make test result of gdb.trace/backtrace.exp unique Yao Qi ` (2 subsequent siblings) 3 siblings, 1 reply; 12+ messages in thread From: Yao Qi @ 2013-06-27 14:02 UTC (permalink / raw) To: gdb-patches Hi, When I write test for command 'tdump' on selected frame, I find backtrace.exp is a good place. However, backtrace.exp needs some cleanups here and there. This is what this patch does. gdb/testsuite: 2013-06-27 Yao Qi <yao@codesourcery.com> * gdb.trace/backtrace.exp: Don't invoke 'get_exit' and 'gdb_start'. Invoke 'prepare_for_testing' instead of 'gdb_compile'. Use gdb_test_no_output to issue commands 'tstart' and 'tstop'. --- gdb/testsuite/gdb.trace/backtrace.exp | 25 ++++++++++++------------- 1 files changed, 12 insertions(+), 13 deletions(-) diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp index e6447ac..5349f02 100644 --- a/gdb/testsuite/gdb.trace/backtrace.exp +++ b/gdb/testsuite/gdb.trace/backtrace.exp @@ -17,21 +17,20 @@ load_lib "trace-support.exp" +standard_testfile actions.c +set executable $testfile +set expfile $testfile.exp -gdb_exit -gdb_start +if [prepare_for_testing $expfile $executable $srcfile \ + [list debug nowarnings]] { + untested "failed to prepare for trace tests" + return -1 +} -standard_testfile actions.c -if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug nowarnings}] != "" } { - untested backtrace.exp +if ![runto_main] { + fail "Can't run to main to check for trace support" return -1 } -gdb_load $binfile -gdb_test "tstop" ".*" "" -gdb_test "tfind none" ".*" "" -runto_main -gdb_reinitialize_dir $srcdir/$subdir if { ![gdb_target_supports_trace] } then { unsupported "Current target does not support trace" @@ -156,14 +155,14 @@ gdb_trace_setactions "8.6: setup TP to collect stack mem cast expr" \ "$tdp6" \ "collect $fpreg, \(\*\(void \*\*\) \($spreg\)\) @ 64" "^$" -gdb_test "tstart" ".*" "" +gdb_test_no_output "tstart" "" gdb_test "break end" ".*" "" gdb_test "continue" \ "Continuing.*Breakpoint $decimal, end.*" \ "run trace experiment" -gdb_test "tstop" ".*" "" +gdb_test_no_output "tstop" "" proc gdb_backtrace_tdp_1 { msg } { global gdb_prompt -- 1.7.7.6 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] Tweak gdb.trace/backtrace.exp 2013-06-27 14:02 ` [PATCH 1/3] Tweak gdb.trace/backtrace.exp Yao Qi @ 2013-07-29 15:44 ` Pedro Alves 0 siblings, 0 replies; 12+ messages in thread From: Pedro Alves @ 2013-07-29 15:44 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches On 06/27/2013 03:02 PM, Yao Qi wrote: > 2013-06-27 Yao Qi <yao@codesourcery.com> > > * gdb.trace/backtrace.exp: Don't invoke 'get_exit' and 'gdb_start'. > Invoke 'prepare_for_testing' instead of 'gdb_compile'. > Use gdb_test_no_output to issue commands 'tstart' and 'tstop'. OK. -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] Make test result of gdb.trace/backtrace.exp unique 2013-06-27 14:02 [PATCH 0/3] Select the current frame in command tdump Yao Qi 2013-06-27 14:02 ` [PATCH 1/3] Tweak gdb.trace/backtrace.exp Yao Qi @ 2013-06-27 14:02 ` Yao Qi 2013-07-29 15:44 ` Pedro Alves 2013-06-27 14:22 ` [PATCH 3/3] Select the current frame in command tdump Yao Qi 2013-07-22 1:13 ` [PATCH 0/3] " Yao Qi 3 siblings, 1 reply; 12+ messages in thread From: Yao Qi @ 2013-06-27 14:02 UTC (permalink / raw) To: gdb-patches The test result of gdb.trace/backtrace.exp is not unique. $ cat testsuite/gdb.sum | grep "gdb..*:" | sed 's/[A-Z]\+: //g' | sort | uniq -c | sort -n 4 gdb.trace/backtrace.exp: 8.6: Backtrace, depth == 1, collect stack mem expr This patch is fix it. With this patch applied, the result becomes: 1 gdb.trace/backtrace.exp: traceframe 14: 8.6: Backtrace, depth == 1, collect stack mem expr 1 gdb.trace/backtrace.exp: traceframe 19: 8.6: Backtrace, depth == 1, collect stack mem expr 1 gdb.trace/backtrace.exp: traceframe 4: 8.6: Backtrace, depth == 1, collect stack mem expr 1 gdb.trace/backtrace.exp: traceframe 9: 8.6: Backtrace, depth == 1, collect stack mem expr gdb/testsuite: 2013-06-27 Yao Qi <yao@codesourcery.com> PR gdb/13443 * gdb.trace/backtrace.exp (gdb_backtrace_tdp_3): Add parameter 'traceframe'. Wrap test with with_test_prefix. (top level): Update. --- gdb/testsuite/gdb.trace/backtrace.exp | 42 +++++++++++++++++--------------- 1 files changed, 22 insertions(+), 20 deletions(-) diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp index 5349f02..e40428f 100644 --- a/gdb/testsuite/gdb.trace/backtrace.exp +++ b/gdb/testsuite/gdb.trace/backtrace.exp @@ -209,24 +209,26 @@ proc gdb_backtrace_tdp_3 { msg } { } } -proc gdb_backtrace_tdp_4 { msg depth } { +proc gdb_backtrace_tdp_4 { msg depth traceframe } { global gdb_prompt - # We are in a trace frame at which we collected all registers, - # plus a sizeable hunk of stack memory. This should enable us to - # display at least several stack frames worth of backtrace. We'll - # assume that if we can't display at least "depth" levels (with - # args), it counts as an error. - - gdb_test_multiple "backtrace" "$msg" { - -re "#$depth\[\t \].*gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" { - pass "$msg" - } - -re "#$depth\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" { - fail "$msg (args missing from #$depth stack frame)" - } - -re "#\[0-9\]+\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" { - fail "$msg (fewer than $depth stack frames found)" + with_test_prefix "traceframe $traceframe" { + # We are in a trace frame at which we collected all registers, + # plus a sizeable hunk of stack memory. This should enable us to + # display at least several stack frames worth of backtrace. We'll + # assume that if we can't display at least "depth" levels (with + # args), it counts as an error. + + gdb_test_multiple "backtrace" "$msg" { + -re "#$depth\[\t \].*gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" { + pass "$msg" + } + -re "#$depth\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" { + fail "$msg (args missing from #$depth stack frame)" + } + -re "#\[0-9\]+\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" { + fail "$msg (fewer than $depth stack frames found)" + } } } } @@ -258,7 +260,7 @@ gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 1, collect args and locals" gdb_tfind_test "8.6: find frame 4" "4" "4" gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \ "TDP $tdp6:" "" -gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0" +gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0" 4 gdb_tfind_test "8.6: find frame 5" "5" "5" gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \ @@ -279,7 +281,7 @@ gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 2, collect args and locals" gdb_tfind_test "8.6: find frame 9" "9" "9" gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \ "TDP $tdp6:" "" -gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0" +gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0" 9 gdb_tfind_test "8.6: find frame 10" "10" "10" gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \ @@ -300,7 +302,7 @@ gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 3, collect args and locals" gdb_tfind_test "8.6: find frame 14" "14" "14" gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \ "TDP $tdp6:" "" -gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0" +gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0" 14 gdb_tfind_test "8.6: find frame 15" "15" "15" gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \ @@ -321,7 +323,7 @@ gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 4, collect args and locals" gdb_tfind_test "8.6: find frame 19" "19" "19" gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \ "TDP $tdp6:" "" -gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0" +gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0" 19 gdb_test "printf \"x \%d x\\n\", depth == 3" \ "x 0 x" \ -- 1.7.7.6 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] Make test result of gdb.trace/backtrace.exp unique 2013-06-27 14:02 ` [PATCH 2/3] Make test result of gdb.trace/backtrace.exp unique Yao Qi @ 2013-07-29 15:44 ` Pedro Alves 0 siblings, 0 replies; 12+ messages in thread From: Pedro Alves @ 2013-07-29 15:44 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches On 06/27/2013 03:02 PM, Yao Qi wrote: > 2013-06-27 Yao Qi <yao@codesourcery.com> > > PR gdb/13443 > * gdb.trace/backtrace.exp (gdb_backtrace_tdp_3): Add parameter > 'traceframe'. Wrap test with with_test_prefix. > (top level): Update. OK. -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] Select the current frame in command tdump. 2013-06-27 14:02 [PATCH 0/3] Select the current frame in command tdump Yao Qi 2013-06-27 14:02 ` [PATCH 1/3] Tweak gdb.trace/backtrace.exp Yao Qi 2013-06-27 14:02 ` [PATCH 2/3] Make test result of gdb.trace/backtrace.exp unique Yao Qi @ 2013-06-27 14:22 ` Yao Qi 2013-07-29 15:44 ` Pedro Alves 2013-07-22 1:13 ` [PATCH 0/3] " Yao Qi 3 siblings, 1 reply; 12+ messages in thread From: Yao Qi @ 2013-06-27 14:22 UTC (permalink / raw) To: gdb-patches Command 'tdump' should be run on the current stack frame instead of the selected stack frame. This patch is to change to the current stack trace when executing command 'tdump'. This patch also adds a test in gdb.trace/backtrace.exp, to test 'tdump' on frame 0 and frame 1 respectively. If only test part of patch is applied, we'll get a fail: Data collected at tracepoint 6, trace frame 4:^M $ebp = (void *) 0xbfffe7c8^M (*(void **) ($esp)) @ 64 = {0x3, 0x2, 0x3, 0x4, 0x5, 0x5, 0x6, 0x4cf0d152 <handle_intel+146>, 0xbfffe7cf, 0x0, 0x8a18d300, 0xbfffe7a0, 0x8, 0xbfffe7a3, 0x80487c0, 0x80487b4, 0xf0b2ff, 0x8048243, 0xca0000, 0x4d01cff4, 0x0, 0x0, 0xbfffe818, 0x80486c7 <main+62>, 0xbfffe7e4, 0x8049abc, 0x1, 0x80482cd <_init+41>, 0x4d01b1b4, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x80486e0 <__libc_csu_init>, 0x0, 0x0, 0x4ce896b3 <__libc_start_main+243>, 0x1, 0xbfffe8b4, 0xbfffe8bc, 0x4ce6cfc4, <unavailable> <unavailable>, <unavailable>, <unavailable>, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>} ^^^^^^^^^^^^^^ (gdb) FAIL: gdb.trace/backtrace.exp: traceframe 4: tdump on frame 1 as we can see, "<unavailable>" is unexpected. With all the patch applied, the fail is fixed, and we'll see that no "<unavailable>" appeared in the output. Data collected at tracepoint 6, trace frame 4:^M $ebp = (void *) 0xbfffe768^M (*(void **) ($esp)) @ 64 = {0xbfffe810, 0x4ce55a39 <_dl_lookup_symbol_x+265>, 0xbfffe7f0, 0x80481cc, 0xbfffe7d8, 0x4ce6da54, 0x0, 0xb7ffeca8, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0xbfffe7c8, 0x80485fc <gdb_c_test+450>, 0x3, 0x2, 0x3, 0x4, 0x5, 0x5, 0x6, 0x4cf0d152 <handle_intel+146>, 0xbfffe7cf, 0x0, 0x96dfd800, 0xbfffe7a0, 0x8, 0xbfffe7a3, 0x80487c0, 0x80487b4, 0xf0b2ff, 0x8048243, 0xca0000, 0x4d01cff4, 0x0, 0x0, 0xbfffe818, 0x80486c7 <main+62>, 0xbfffe7e4, 0x8049abc, 0x1, 0x80482cd <_init+41>, 0x4d01b1b4, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x80486e0 <__libc_csu_init>, 0x0, 0x0, 0x4ce896b3 <__libc_start_main+243>, 0x1, 0xbfffe8b4, 0xbfffe8bc, 0x4ce6cfc4}^M (gdb) PASS: gdb.trace/backtrace.exp: traceframe 4: tdump on frame 1 gdb: 2013-06-27 Pedro Alves <pedro@codesourcery.com> Yao Qi <yao@codesourcery.com> * tracepoint.c (trace_dump_command): Select the current frame. gdb/testsuite: 2013-06-27 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 | 19 +++++++++++++++++++ gdb/tracepoint.c | 6 ++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp index e40428f..6f32f2a 100644 --- a/gdb/testsuite/gdb.trace/backtrace.exp +++ b/gdb/testsuite/gdb.trace/backtrace.exp @@ -211,6 +211,7 @@ proc gdb_backtrace_tdp_3 { msg } { proc gdb_backtrace_tdp_4 { msg depth traceframe } { global gdb_prompt + global decimal hex with_test_prefix "traceframe $traceframe" { # We are in a trace frame at which we collected all registers, @@ -230,6 +231,24 @@ proc gdb_backtrace_tdp_4 { msg depth traceframe } { fail "$msg (fewer than $depth stack frames found)" } } + + # Make sure no output like "0x0 <repeats 2 times>" confuses + # the matching below. + gdb_test_no_output "set print repeats 64" "" + + # Match the output of command 'tdump' like '0xbfffe810' or + # '0x4ce55a39 <_dl_lookup_symbol_x+265>'. + gdb_test "tdump" \ + "Data collected at tracepoint $decimal, trace frame $decimal:.* = \\{($hex, |$hex <.*>, ){63}($hex|$hex <.*>)\\}" \ + "tdump on frame 0" + + gdb_test "up" ".*" "" + + # Test command 'tdump' still work properly when the selected + # frame is not the current frame. + gdb_test "tdump" \ + "Data collected at tracepoint $decimal, trace frame $decimal:.* = \\{($hex, |$hex <.*>, ){63}($hex|$hex <.*>)\\}" \ + "tdump on frame 1" } } diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 4277843..eb276e9 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3071,6 +3071,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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Select the current frame in command tdump. 2013-06-27 14:22 ` [PATCH 3/3] Select the current frame in command tdump Yao Qi @ 2013-07-29 15:44 ` Pedro Alves 2013-07-30 13:23 ` Yao Qi 0 siblings, 1 reply; 12+ messages in thread From: Pedro Alves @ 2013-07-29 15:44 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches On 06/27/2013 03:02 PM, Yao Qi wrote: > Command 'tdump' should be run on the current stack frame instead of > the selected stack frame. Thanks. > This patch is to change to the current > stack trace when executing command 'tdump'. > > This patch also adds a test in gdb.trace/backtrace.exp, to test > 'tdump' on frame 0 and frame 1 respectively. If only test > part of patch is applied, we'll get a fail: > > Data collected at tracepoint 6, trace frame 4:^M > $ebp = (void *) 0xbfffe7c8^M > (*(void **) ($esp)) @ 64 = {0x3, 0x2, 0x3, 0x4, 0x5, 0x5, 0x6, > 0x4cf0d152 <handle_intel+146>, 0xbfffe7cf, 0x0, 0x8a18d300, > 0xbfffe7a0, 0x8, 0xbfffe7a3, 0x80487c0, 0x80487b4, 0xf0b2ff, > 0x8048243, 0xca0000, 0x4d01cff4, 0x0, 0x0, 0xbfffe818, 0x80486c7 > <main+62>, 0xbfffe7e4, 0x8049abc, 0x1, 0x80482cd <_init+41>, > 0x4d01b1b4, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, > 0x80486e0 <__libc_csu_init>, 0x0, 0x0, 0x4ce896b3 > <__libc_start_main+243>, 0x1, 0xbfffe8b4, 0xbfffe8bc, 0x4ce6cfc4, > <unavailable> <unavailable>, <unavailable>, <unavailable>, > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > <unavailable>, <unavailable>, <unavailable>, <unavailable>, > <unavailable>, <unavailable>, <unavailable>, <unavailable>, > <unavailable>, <unavailable>, <unavailable>, <unavailable>, > <unavailable>} > ^^^^^^^^^^^^^^ > (gdb) FAIL: gdb.trace/backtrace.exp: traceframe 4: tdump on frame 1 > > as we can see, "<unavailable>" is unexpected. With all the patch > applied, the fail is fixed, and we'll see that no "<unavailable>" > appeared in the output. > > Data collected at tracepoint 6, trace frame 4:^M > $ebp = (void *) 0xbfffe768^M > (*(void **) ($esp)) @ 64 = {0xbfffe810, 0x4ce55a39 > <_dl_lookup_symbol_x+265>, 0xbfffe7f0, 0x80481cc, 0xbfffe7d8, > 0x4ce6da54, 0x0, 0xb7ffeca8, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0xbfffe7c8, > 0x80485fc <gdb_c_test+450>, 0x3, 0x2, 0x3, 0x4, 0x5, 0x5, 0x6, > 0x4cf0d152 <handle_intel+146>, 0xbfffe7cf, 0x0, 0x96dfd800, > 0xbfffe7a0, 0x8, 0xbfffe7a3, 0x80487c0, 0x80487b4, 0xf0b2ff, > 0x8048243, 0xca0000, 0x4d01cff4, 0x0, 0x0, 0xbfffe818, 0x80486c7 > <main+62>, 0xbfffe7e4, 0x8049abc, 0x1, 0x80482cd <_init+41>, > 0x4d01b1b4, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, > 0x80486e0 <__libc_csu_init>, 0x0, 0x0, 0x4ce896b3 > <__libc_start_main+243>, 0x1, 0xbfffe8b4, 0xbfffe8bc, 0x4ce6cfc4}^M > (gdb) PASS: gdb.trace/backtrace.exp: traceframe 4: tdump on frame 1 > > gdb: > > 2013-06-27 Pedro Alves <pedro@codesourcery.com> > Yao Qi <yao@codesourcery.com> > > * tracepoint.c (trace_dump_command): Select the current frame. > > gdb/testsuite: > > 2013-06-27 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 | 19 +++++++++++++++++++ > gdb/tracepoint.c | 6 ++++++ > 2 files changed, 25 insertions(+), 0 deletions(-) > > diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp > index e40428f..6f32f2a 100644 > --- a/gdb/testsuite/gdb.trace/backtrace.exp > +++ b/gdb/testsuite/gdb.trace/backtrace.exp > @@ -211,6 +211,7 @@ proc gdb_backtrace_tdp_3 { msg } { > > proc gdb_backtrace_tdp_4 { msg depth traceframe } { > global gdb_prompt > + global decimal hex > > with_test_prefix "traceframe $traceframe" { > # We are in a trace frame at which we collected all registers, > @@ -230,6 +231,24 @@ proc gdb_backtrace_tdp_4 { msg depth traceframe } { > fail "$msg (fewer than $depth stack frames found)" > } > } > + > + # Make sure no output like "0x0 <repeats 2 times>" confuses > + # the matching below. > + gdb_test_no_output "set print repeats 64" "" > + > + # Match the output of command 'tdump' like '0xbfffe810' or > + # '0x4ce55a39 <_dl_lookup_symbol_x+265>'. > + gdb_test "tdump" \ > + "Data collected at tracepoint $decimal, trace frame $decimal:.* = \\{($hex, |$hex <.*>, ){63}($hex|$hex <.*>)\\}" \ > + "tdump on frame 0" > + > + gdb_test "up" ".*" "" > + > + # Test command 'tdump' still work properly when the selected > + # frame is not the current frame. > + gdb_test "tdump" \ > + "Data collected at tracepoint $decimal, trace frame $decimal:.* = \\{($hex, |$hex <.*>, ){63}($hex|$hex <.*>)\\}" \ > + "tdump on frame 1" 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? -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Select the current frame in command tdump. 2013-07-29 15:44 ` Pedro Alves @ 2013-07-30 13:23 ` Yao Qi 2013-07-30 13:31 ` Pedro Alves 0 siblings, 1 reply; 12+ messages in thread From: Yao Qi @ 2013-07-30 13:23 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Select the current frame in command tdump. 2013-07-30 13:23 ` Yao Qi @ 2013-07-30 13:31 ` Pedro Alves 2013-07-31 0:47 ` Yao Qi 0 siblings, 1 reply; 12+ messages in thread From: Pedro Alves @ 2013-07-30 13:31 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches On 07/30/2013 02:22 PM, Yao Qi wrote: > 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. OK, thanks. > + # Test command 'tdump' still work properly when the selected > + # frame is not the current frame, and save the output in > + # $output_string1. "still works". Suggest: Test that the 'tdump' command still works -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] Select the current frame in command tdump. 2013-07-30 13:31 ` Pedro Alves @ 2013-07-31 0:47 ` Yao Qi 0 siblings, 0 replies; 12+ messages in thread From: Yao Qi @ 2013-07-31 0:47 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches On 07/30/2013 09:30 PM, Pedro Alves wrote: > "still works". > > Suggest: > > Test that the 'tdump' command still works Fixed. Patch 1/3 and 2/3 are committed. Patch 3/3 is committed too with the typo fix in comment. -- Yao (é½å°§) gdb: 2013-07-31 Pedro Alves <pedro@codesourcery.com> Yao Qi <yao@codesourcery.com> * tracepoint.c (trace_dump_command): Select the current frame. gdb/testsuite: 2013-07-31 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..c3a7ec3 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 that command 'tdump' still works 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/3] Select the current frame in command tdump. 2013-06-27 14:02 [PATCH 0/3] Select the current frame in command tdump Yao Qi ` (2 preceding siblings ...) 2013-06-27 14:22 ` [PATCH 3/3] Select the current frame in command tdump Yao Qi @ 2013-07-22 1:13 ` Yao Qi 2013-07-29 9:31 ` [ping 2]: " Yao Qi 3 siblings, 1 reply; 12+ messages in thread From: Yao Qi @ 2013-07-22 1:13 UTC (permalink / raw) To: gdb-patches On 06/27/2013 10:02 PM, Yao Qi wrote: > Command 'tdump' should be run on the current stack frame instead of > the selected stack frame. The patch 3/3 is to change to the current > stack trace when executing command 'tdump'. When writing test case > for this change, I did some cleanups in gdb.trace/backtrace.exp (in > patch 1/3) and get the test result unique (patch 2/3). > > Regression tested on x86_64-linux. Ping. http://sourceware.org/ml/gdb-patches/2013-06/msg00817.html -- Yao (é½å°§) ^ permalink raw reply [flat|nested] 12+ messages in thread
* [ping 2]: [PATCH 0/3] Select the current frame in command tdump. 2013-07-22 1:13 ` [PATCH 0/3] " Yao Qi @ 2013-07-29 9:31 ` Yao Qi 0 siblings, 0 replies; 12+ messages in thread From: Yao Qi @ 2013-07-29 9:31 UTC (permalink / raw) To: gdb-patches On 07/22/2013 09:13 AM, Yao Qi wrote: >> Command 'tdump' should be run on the current stack frame instead of >> >the selected stack frame. The patch 3/3 is to change to the current >> >stack trace when executing command 'tdump'. When writing test case >> >for this change, I did some cleanups in gdb.trace/backtrace.exp (in >> >patch 1/3) and get the test result unique (patch 2/3). >> > >> >Regression tested on x86_64-linux. > Ping.http://sourceware.org/ml/gdb-patches/2013-06/msg00817.html Ping 2. http://sourceware.org/ml/gdb-patches/2013-06/msg00817.html -- Yao (é½å°§) ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-07-31 0:47 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-06-27 14:02 [PATCH 0/3] Select the current frame in command tdump Yao Qi 2013-06-27 14:02 ` [PATCH 1/3] Tweak gdb.trace/backtrace.exp Yao Qi 2013-07-29 15:44 ` Pedro Alves 2013-06-27 14:02 ` [PATCH 2/3] Make test result of gdb.trace/backtrace.exp unique Yao Qi 2013-07-29 15:44 ` Pedro Alves 2013-06-27 14:22 ` [PATCH 3/3] Select the current frame in command tdump Yao Qi 2013-07-29 15:44 ` Pedro Alves 2013-07-30 13:23 ` Yao Qi 2013-07-30 13:31 ` Pedro Alves 2013-07-31 0:47 ` Yao Qi 2013-07-22 1:13 ` [PATCH 0/3] " Yao Qi 2013-07-29 9:31 ` [ping 2]: " Yao Qi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox