From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1536 invoked by alias); 9 Mar 2013 03:49:31 -0000 Received: (qmail 1436 invoked by uid 22791); 9 Mar 2013 03:49:29 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Mar 2013 03:49:18 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1UEAmZ-0003fH-9o from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 08 Mar 2013 19:49:15 -0800 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 8 Mar 2013 19:49:15 -0800 Received: from qiyao.dyndns.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Fri, 8 Mar 2013 19:49:14 -0800 From: Yao Qi To: Subject: [PATCH v3 13/15] Test on saving tracepoint defs. Date: Sat, 09 Mar 2013 03:49:00 -0000 Message-ID: <1362800844-27940-14-git-send-email-yao@codesourcery.com> In-Reply-To: <1362800844-27940-1-git-send-email-yao@codesourcery.com> References: <1362800844-27940-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-03/txt/msg00408.txt.bz2 Presently, we don't have a test on writing actions of tracepoints to trace file, and read trace file back to see if any differences on tracepoints actions. This is what this patch tries to do. This is useful to exercise the code on saving actions and restoring actions from trace file. It also paves the way for test CTF in this area. gdb/testsuite: 2013-03-08 Yao Qi * gdb.trace/actions.exp (check_tracepoint): New. (top level): Start the tracing and check the actions of tracepoints. Save trace data to tfile format. Restart GDB and read trace file in tfile target. Check the actions of tracepoints again. * gdb.trace/while-stepping.exp: Likewise. --- gdb/testsuite/gdb.trace/actions.exp | 82 ++++++++++++++++++++++++++++ gdb/testsuite/gdb.trace/while-stepping.exp | 42 ++++++++++++++ 2 files changed, 124 insertions(+), 0 deletions(-) diff --git a/gdb/testsuite/gdb.trace/actions.exp b/gdb/testsuite/gdb.trace/actions.exp index f8a5266..7bbe6b6 100644 --- a/gdb/testsuite/gdb.trace/actions.exp +++ b/gdb/testsuite/gdb.trace/actions.exp @@ -235,3 +235,85 @@ gdb_test "info tracepoints" \ \[\t \]+not installed on target." \ "5.10a: verify teval actions set for two tracepoints" +gdb_test "break main" +gdb_run_cmd +gdb_test "" "Breakpoint .*" +if ![gdb_target_supports_trace] { + unsupported "target does not support trace" + return -1; +} + +gdb_trace_setactions "set actions for first tracepoint" \ + "$trcpt1" \ + "collect \$regs" "^$" \ + "end" "" + +# Check the definition of tracepoints. These tracepoints may have +# different number in different runs. + +proc check_tracepoint { data_source } { with_test_prefix "$data_source" { + global gdb_prompt + global srcfile + + set tp_on_gdb_c_test 0 + set tp_on_gdb_asm_test 0 + set tp_on_gdb_recursion_test 0 + + # Since the three tracepoints may appear in different orders, so + # we can't do 'info tracepoints' to match the output. Instead, we + # show each tracepoint one by one and record the number of each + # tracepoint shown up the output. Check the number finally. + for {set i 1} {$i < 4} {incr i 1} { + set test "info tracepoints $i" + gdb_test_multiple "info tracepoints $i" $test { + -re "\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+\\r\\n\[\t \]+collect \\\$regs\\r\\n\[\t \]+installed on target" { + incr tp_on_gdb_c_test + exp_continue + } + -re "\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+\\r\\n\[\t \]+teval \\\$tsv \\+= 1\\r\\n\[\t \]+installed on target" { + incr tp_on_gdb_asm_test + exp_continue + } + -re "\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+\\r\\n\[\t \]+collect gdb_long_test\\r\\n\[\t \]+installed on target" { + incr tp_on_gdb_recursion_test + exp_continue + } + -re "${gdb_prompt} $" { + } + } + } + + if {$tp_on_gdb_c_test == 1} { + pass "tracepoint on gdb_c_test" + } else { + fail "tracepoint on gdb_c_test" + } + if {$tp_on_gdb_asm_test == 1} { + pass "tracepoint on gdb_asm_test" + } else { + fail "tracepoint on gdb_asm_test" + } + if {$tp_on_gdb_recursion_test == 1} { + pass "tracepoint on gdb_recursion_test" + } else { + fail "tracepoint on gdb_recursion_test $tp_on_gdb_recursion_test" + } + +}} + +# Start and stop the tracing, so that we can save tracepoints +# definitions to trace file. +gdb_test_no_output "tstart" "" +check_tracepoint "live" +gdb_test_no_output "tstop" "" +gdb_test "tsave ${testfile}.tf" \ + "Trace data saved to file '${testfile}.tf'\.\\r" + +# Restart GDB and read the trace data in tfile target. +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_file_cmd $binfile +gdb_test "target tfile ${testfile}.tf" ".*" \ + "change to tfile target" +check_tracepoint "tfile" diff --git a/gdb/testsuite/gdb.trace/while-stepping.exp b/gdb/testsuite/gdb.trace/while-stepping.exp index b80132b..0f316eb 100644 --- a/gdb/testsuite/gdb.trace/while-stepping.exp +++ b/gdb/testsuite/gdb.trace/while-stepping.exp @@ -99,3 +99,45 @@ gdb_test "info tracepoints" \ .*end.*" \ "5.16: confirm actions, step without collecting anything" +gdb_test "break main" +gdb_run_cmd +gdb_test "" "Breakpoint .*" +if ![gdb_target_supports_trace] { + unsupported "target does not support trace" + return -1; +} + +gdb_trace_setactions "set stepcount to $stepcount" \ + "" \ + "while-stepping $stepcount" "" \ + "collect \$regs " "^$" \ + "collect \$locals " "^$" \ + "end" "" + +proc check_tracepoint { data_source } { with_test_prefix "$data_source" { + global srcfile + global stepcount + + gdb_test "info tracepoints" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+. +\[\t \]+while-stepping $stepcount.* +\[\t \]+collect \\\$regs.* +\[\t \]+collect \\\$locals.* +\[\t \]+end.*" +}} + +gdb_test_no_output "tstart" +check_tracepoint "live" +gdb_test_no_output "tstop" +gdb_test "tsave ${testfile}.tf" \ + "Trace data saved to file '${testfile}.tf'\.\\r" + +# Restart GDB and read the trace data in tfile target. +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_file_cmd $binfile +gdb_test "target tfile ${testfile}.tf" ".*" \ + "change to tfile target" +check_tracepoint "tfile" -- 1.7.7.6