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 1/2] Tests on displaying trace data in MI


On 06/04/2013 08:11 PM, Pedro Alves wrote:
>> +load_lib trace-support.exp
>> >+
>> >+standard_testfile trace-unavailable.c
>> >+
>> >+set executable $testfile
>> >+
>> >+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
>> >+	   executable {debug nowarnings}] != "" } {
> Why nowarnings?
> 

It is a copy-n-paste.  "nowarnings" is removed.

>> >+     untested ${testfile}.exp
> http://sourceware.org/gdb/wiki/GDBTestcaseCookbook#A.22untested.22_calls
> 
> Wouldn't prepare_for_testing work here?
> 

Yes, change to prepare_for_testing.

>> >+     return -1
>> >+}
>> >+# Test target supports tracepoints or not.
> # Test if the target supports tracepoints or not.
> 
> Or:
> 
> # Check whether the target supports tracepoints.
> 
> 

It is a copy-n-paste, again.  This line is removed in the new patch
because of using prepare_for_testing.

>> >+# Define an action.
>> >+send_gdb "actions\n"
>> >+gdb_expect {
>> >+    -re "End with" {
>> >+    }
>> >+}
>> >+send_gdb "collect array\ncollect j\nend\n"
>> >+set test "define actions"
>> >+gdb_expect {
>> >+    -re ".*${mi_gdb_prompt}$" {
>> >+	pass $test
>> >+    }
>> >+    timeout {
>> >+	fail "$test (timeout)"
>> >+    }
>> >+}
> Any reason this doesn't use MI's -break-commands to set the tracepoint's actions?
> 

Because I don't know -break-commands can set tracepoint's actions.  Use
it in the new patch.

>> >+	# Test MI command '-stack-list-locals'.
>> >+	mi_gdb_test "-stack-list-locals 2" \
> WDYT of writing '--simple-values' instead of '2' ?  I think it
> makes the test a little bit more readable, not forcing one
> to recall what does '2' mean (not just which print_values,
> but realizing it's a print_values, even).
> 

I don't have a strong opinion to it, since both '2' and
'--simple-values' are valid and documented input options.  Use
'--simple-values' in the new patch.

>> >+	    ".*\\^done,locals=\\\[\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \
>> >+	    "-stack-list-locals 2"
>> >+
>> >+	# Test MI command '-stack-list-arguments'.
>> >+	mi_gdb_test "-stack-list-arguments 2" \
>> >+	    ".*\\^done,stack-args=\\\[frame=\{level=\"0\",args=\\\[\{name=\"j\",type=\"int\",value=\"4\"\},\{name=\"s\",type=\"char \\\*\",value=\"<unavailable>\"\}\\\]\},.*\}.*" \
>> >+	    "-stack-list-arguments 2"
>> >+
>> >+	# Test MI command '-stack-list-variables'.
>> >+	mi_gdb_test "-stack-list-variables 2" \
>> >+	    ".*\\^done,variables=\\\[\{name=\"j\",arg=\"1\",type=\"int\",value=\"4\"\},\{name=\"s\",arg=\"1\",type=\"char \\\*\",value=\"<unavailable>\"\},\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \
>> >+	    "-stack-list-variables 2"
>> >+
>> >+	# Don't issue command '-trace-find none' to return from the
>> >+	# tfind mode (examining trace frames) on purpose, in order
> s/from the/from/
> 

Fixed.

>> >+	# to test GDB is able to clear its local state on tracing
>> >+	# in the following steps.
> I had a bit of trouble figuring out what this meant.  I suggest:
> 
>    to test that GDB is able to clear its tracing-related local state
>    in the next -target-select.
> 

I think "local state on tracing" equals to "tracing-related local
state", so now the comment looks like:

	# Don't issue command '-trace-find none' to return from
	# tfind mode (examining trace frames) on purpose, in order
	# to test GDB is able to clear its local state on tracing
	# in the next -target-select.

>> >+	# mi_gdb_test "-trace-find none" ".*\\^done,found=\"0\".*" "-trace-find none"
>> >+    }
>> >+}
>> >+
>> >+test_stack_list_commands "live"
>> >+
>> >+# Change target to ctf if GDB supports
> "supports it."
> 

Fixed.

>> >+send_gdb "-target-select ctf ${tracefile}.ctf\n"
>> >+gdb_expect {
>> >+    -re ".*\\^connected.*${mi_gdb_prompt}$" {
>> >+	# GDB supports ctf, do the test.
>> >+	test_stack_list_commands "ctf"
>> >+    }
>> >+    -re ".*\\^error,msg=\"Undefined target command.*${mi_gdb_prompt}$" {
>> >+	# GDB doesn't support ctf, skip the test.
> Call unsupported?

OK, call unsupported,

  unsupported "gdb does not support ctf target"

-- 
Yao (éå)

gdb/testsuite/

2013-06-05  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/mi-trace-unavailable.exp: New.
	* gdb.trace/trace-unavailable.c: New.
---
 gdb/testsuite/gdb.trace/mi-trace-unavailable.exp |  127 ++++++++++++++++++++++
 gdb/testsuite/gdb.trace/trace-unavailable.c      |   40 +++++++
 2 files changed, 167 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
 create mode 100644 gdb/testsuite/gdb.trace/trace-unavailable.c

diff --git a/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
new file mode 100644
index 0000000..ee12c93
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
@@ -0,0 +1,127 @@
+# 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 trace-unavailable.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 marker" \
+    "\\^done,bkpt=\{number=\"${decimal}\",type=\"breakpoint\".*\"\}" \
+    "insert tracepoint on marker"
+mi_gdb_test "-break-insert -a bar" \
+    "\\^done,bkpt=\{number=\"${decimal}\",type=\"tracepoint\".*\"\}" \
+    "insert tracepoint on bar"
+
+# Define an action.
+mi_gdb_test "-break-commands 3 \"collect array\" \"collect j\" \"end\" " \
+    {\^done} "set action"
+
+mi_gdb_test "-trace-start" {.*\^done} "trace start"
+mi_send_resuming_command "exec-continue" "continuing to marker"
+mi_expect_stop \
+    "breakpoint-hit" "marker" ".*" ".*" ".*" {"" "disp=\"keep\""} \
+    "stop at marker"
+mi_gdb_test "-trace-stop" {.*} "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"
+
+mi_gdb_test "-gdb-set print entry-values no" {\^done} \
+    "-gdb-set print entry-values no"
+
+proc test_trace_unavailable { data_source } {
+    global decimal
+
+    with_test_prefix "$data_source" {
+
+	# Test MI commands '-stack-list-locals', '-stack-list-arguments',
+	#  and '-stack-list-variables'.
+	mi_gdb_test "-trace-find frame-number 0" \
+	    ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \
+	    "-trace-find frame-number 0"
+
+	# Test MI command '-stack-list-locals'.
+	mi_gdb_test "-stack-list-locals --simple-values" \
+	    ".*\\^done,locals=\\\[\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \
+	    "-stack-list-locals --simple-values"
+
+	# Test MI command '-stack-list-arguments'.
+	mi_gdb_test "-stack-list-arguments --simple-values" \
+	    ".*\\^done,stack-args=\\\[frame=\{level=\"0\",args=\\\[\{name=\"j\",type=\"int\",value=\"4\"\},\{name=\"s\",type=\"char \\\*\",value=\"<unavailable>\"\}\\\]\},.*\}.*" \
+	    "-stack-list-arguments --simple-values"
+
+	# Test MI command '-stack-list-variables'.
+	mi_gdb_test "-stack-list-variables --simple-values" \
+	    ".*\\^done,variables=\\\[\{name=\"j\",arg=\"1\",type=\"int\",value=\"4\"\},\{name=\"s\",arg=\"1\",type=\"char \\\*\",value=\"<unavailable>\"\},\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \
+	    "-stack-list-variables --simple-values"
+
+	# Don't issue command '-trace-find none' to return from
+	# tfind mode (examining trace frames) on purpose, in order
+	# to test GDB is able to clear its local state on tracing
+	# in the next -target-select.
+	# mi_gdb_test "-trace-find none" ".*\\^done,found=\"0\".*" "-trace-find none"
+    }
+}
+
+test_trace_unavailable "live"
+
+# Change target to ctf if GDB supports it.
+send_gdb "-target-select ctf ${tracefile}.ctf\n"
+gdb_expect {
+    -re ".*\\^connected.*${mi_gdb_prompt}$" {
+	# GDB supports ctf, do the test.
+	test_trace_unavailable "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"
+    }
+}
+
+# Change target to tfile.
+mi_gdb_test "-target-select tfile ${tracefile}.tf" ".*\\^connected.*" \
+    "-target-select tfile"
+test_trace_unavailable "tfile"
+
+mi_gdb_exit
diff --git a/gdb/testsuite/gdb.trace/trace-unavailable.c b/gdb/testsuite/gdb.trace/trace-unavailable.c
new file mode 100644
index 0000000..9b3e230
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/trace-unavailable.c
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   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/>.  */
+
+static void
+bar (int j, char *s)
+{
+  unsigned char array[2];
+  int i = 0;
+
+  array[0] = 'c';
+  array[1] = 'd';
+}
+
+static void
+marker (void)
+{}
+
+int
+main (void)
+{
+  char s[4];
+
+  bar (4, s);
+  marker ();
+  return 0;
+}
-- 
1.7.7.6


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