This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 6/6] New test: gdb.trace/mi-trace-frame-collected.exp
- From: Yao Qi <yao at codesourcery dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Wed, 26 Jun 2013 16:29:03 +0800
- Subject: Re: [PATCH 6/6] New test: gdb.trace/mi-trace-frame-collected.exp
- References: <1370610493-26468-1-git-send-email-yao at codesourcery dot com> <1371086914-8398-1-git-send-email-yao at codesourcery dot com> <1371086914-8398-7-git-send-email-yao at codesourcery dot com> <51C9D3F6 dot 8090202 at redhat dot com>
On 06/26/2013 01:31 AM, Pedro Alves wrote:
>> +# Define an action.
>> >+set pcreg ""
> Suggest giving it an empty line after the comment, as the set
> is not yet defining the action.
>
Right. I move this line of comment to the place really defines an
action.
>> >+if [is_amd64_regs_target] {
>> >+ set pcreg "rip"
>> >+} elseif [is_x86_like_target] {
>> >+ set pcreg "eip"
>> >+} else {
>> >+ # Other ports support tracepoing should set the name of pc
>> >+ # register.
> # Other ports that support tracepoints should set the name
> # of the pc register here.
>
Fixed.
>> >+ fail "set the number and the name of pc register"
>> >+ return -1
>> >+}
>> >+
>> >+mi_gdb_test "-break-commands 3 \"collect gdb_char_test\" \"collect gdb_union1_test\" \"collect gdb_struct1_test.l\" \"collect gdb_arr_test\[0\]\" \"collect $${pcreg}\" \"teval \$tsv += 1\" \"collect \$tsv\" \"end\" " \
>> >+ {\^done} "set action"
>> >+
>> >+mi_gdb_test "-break-insert -a gdb_c_test" \
>> >+ "\\^done,bkpt=\{number=\"${decimal}\",type=\"tracepoint\".*\"\}" \
>> >+ "insert tracepoint on gdb_c_test"
>> >+# Collect a global variable to make sure no registers are collected
>> >+# expect PC.
> Typo: except. I do that one often too.:-)
>
Fixed.
> Suggest s/make sure/be sure/.
>
>> >+# Test MI command '-trace-frame-collected' from different data source.
> "from different" threw me off a second (different compared to what?).
>
> Suggest:
>
> # Test the MI command '-trace-frame-collected' with DATA_SOURCE as
> # trace data source.
>
OK, your suggestion is good. Patch is updated to address your
comments and committed.
--
Yao (éå)
gdb/testsuite
2013-06-26 Yao Qi <yao@codesourcery.com>
* gdb.trace/mi-trace-frame-collected.exp: New.
---
.../gdb.trace/mi-trace-frame-collected.exp | 156 ++++++++++++++++++++
1 files changed, 156 insertions(+), 0 deletions(-)
create mode 100644 gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
diff --git a/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp b/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
new file mode 100644
index 0000000..ecfa098
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
@@ -0,0 +1,156 @@
+# Copyright 2013 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib trace-support.exp
+
+standard_testfile actions.c
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug}] } {
+ return -1
+}
+
+if ![runto_main] {
+ fail "Can't run to main to check for trace support"
+ return -1
+}
+
+if ![gdb_target_supports_trace] {
+ unsupported "Current target does not support trace"
+ return -1
+}
+
+gdb_exit
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+if [mi_gdb_start] {
+ return
+}
+mi_run_to_main
+
+mi_gdb_test "-break-insert end" \
+ "\\^done,bkpt=\{number=\"${decimal}\",type=\"breakpoint\".*\"\}" \
+ "insert tracepoint on end"
+mi_gdb_test "-break-insert -a gdb_recursion_test" \
+ "\\^done,bkpt=\{number=\"${decimal}\",type=\"tracepoint\".*\"\}" \
+ "insert tracepoint on gdb_recursion_test"
+
+mi_gdb_test "-trace-define-variable \$tsv 1" {.*\^done} \
+ "-trace-define-variable"
+
+set pcreg ""
+if [is_amd64_regs_target] {
+ set pcreg "rip"
+} elseif [is_x86_like_target] {
+ set pcreg "eip"
+} else {
+ # Other ports that support tracepoints should set the name of pc
+ # register here.
+ fail "set the name of pc register"
+ return -1
+}
+
+mi_gdb_test "-break-commands 3 \"collect gdb_char_test\" \"collect gdb_union1_test\" \"collect gdb_struct1_test.l\" \"collect gdb_arr_test\[0\]\" \"collect $${pcreg}\" \"teval \$tsv += 1\" \"collect \$tsv\" \"end\" " \
+ {\^done} "set action"
+
+mi_gdb_test "-break-insert -a gdb_c_test" \
+ "\\^done,bkpt=\{number=\"${decimal}\",type=\"tracepoint\".*\"\}" \
+ "insert tracepoint on gdb_c_test"
+
+# Define an action.
+# Collect a global variable to be sure no registers are collected
+# except PC.
+mi_gdb_test "-break-commands 4 \"collect gdb_char_test\" \"end\" " \
+ {\^done} "set action on tracepoint 4"
+
+mi_gdb_test "-trace-start" {.*\^done} "trace start"
+mi_send_resuming_command "exec-continue" "continuing to end"
+mi_expect_stop \
+ "breakpoint-hit" "end" ".*" ".*" ".*" {"" "disp=\"keep\""} \
+ "stop at end"
+mi_gdb_test "-trace-stop" {.*\^done,stop-reason=.*} "trace stop"
+
+# Save trace frames to tfile.
+set tracefile [standard_output_file ${testfile}]
+mi_gdb_test "-trace-save ${tracefile}.tf" ".*\\^done" \
+ "save tfile trace file"
+# Save trace frames to ctf.
+mi_gdb_test "-trace-save -ctf ${tracefile}.ctf" ".*\\^done" \
+ "save ctf trace file"
+
+# Test the MI command '-trace-frame-collected' with DATA_SOURCE as
+# trace data source.
+
+proc test_trace_frame_collected { data_source } {
+ global decimal hex
+ global mi_gdb_prompt
+
+ with_test_prefix "$data_source" {
+ mi_gdb_test "-trace-find frame-number 0" \
+ ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \
+ "-trace-find frame-number 0"
+
+ # Test MI command '-trace-frame-collected' dumps only
+ # collected registers.
+ mi_gdb_test "-trace-frame-collected" \
+ "\\^done,explicit-variables=\\\[\{name=\"gdb_char_test\",value=\".*\"\}\\\],computed-expressions=\\\[\\\],registers=\\\[\{number=\"$decimal\",value=\"$hex\"\}\\\],tvars=\\\[\\\],memory=\\\[\{address=\"$hex\",length=\"1\"\}\\\]"\
+ "-trace-frame-collected (register)"
+
+ mi_gdb_test "-trace-find frame-number 1" \
+ ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"1\",frame=\{.*" \
+ "-trace-find frame-number 1"
+
+ # Test MI command '-trace-frame-collected'
+ mi_gdb_test "-trace-frame-collected" \
+ "\\^done,explicit-variables=\\\[\{name=\"gdb_char_test\",value=\".*\"\},\{name=\"gdb_union1_test\",value=\".*\"\}\\\],computed-expressions=\\\[\{name=\"gdb_struct1_test\.l\",.*\},\{name=\"gdb_arr_test\\\[0\\\]\",.*\}\\\],registers=\\\[.*\\\],tvars=\\\[\{name=\"\\\$tsv\",current=\"2\"\}\\\],memory=\\\[\{address=\"$hex\",length=\"1\"\},.*\\\]"\
+ "-trace-frame-collected"
+ mi_gdb_test "-trace-frame-collected --var-print-values 2 --comp-print-values --simple-values --registers-format x --memory-contents" \
+ "\\^done,explicit-variables=\\\[\{name=\"gdb_char_test\",type=\"char\",value=\".*\"\},\{name=\"gdb_union1_test\",type=\"union GDB_UNION_TEST\"\}\\\],computed-expressions=\\\[.*\\\],registers=\\\[.*\\\],tvars=\\\[\{name=\"\\\$tsv\",current=\"2\"\}\\\],memory=\\\[\{address=\"$hex\",length=\"1\",contents=\".*\"\},.*\\\]" \
+ "-trace-frame-collected --var-print-values 2 --comp-print-values --simple-values --registers-format x --memory-contents"
+
+ mi_gdb_test "-trace-find none" ".*\\^done,found=\"0\".*" \
+ "-trace-find none"
+ }
+}
+
+test_trace_frame_collected "live"
+
+# Change target to ctf if GDB supports it.
+set msg "-target-select ctf"
+send_gdb "-target-select ctf ${tracefile}.ctf\n"
+gdb_expect {
+ -re ".*\\^connected.*${mi_gdb_prompt}$" {
+ # GDB supports ctf, do the test.
+ test_trace_frame_collected "ctf"
+ }
+ -re ".*\\^error,msg=\"Undefined target command.*${mi_gdb_prompt}$" {
+ # GDB doesn't support ctf, skip the test.
+ unsupported "gdb does not support ctf target"
+ }
+ -re ".*$mi_gdb_prompt$" {
+ fail "$msg"
+ }
+ timeout {
+ fail "$msg (timeout)"
+ }
+}
+
+# Change target to tfile.
+mi_gdb_test "-target-select tfile ${tracefile}.tf" ".*\\^connected.*" \
+ "-target-select tfile"
+test_trace_frame_collected "tfile"
+
+mi_gdb_exit
--
1.7.7.6