This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/2] Tests on displaying trace data in MI
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 04 Jun 2013 13:11:20 +0100
- Subject: Re: [PATCH 1/2] Tests on displaying trace data in MI
- References: <1369714812-3307-1-git-send-email-yao at codesourcery dot com>
On 05/28/2013 05:20 AM, Yao Qi wrote:
> GDB has some MI commands (such as -stack-list-locals) to examine the
> local variables and arguments on a certain frame. These commands also
> work when examining trace frames. However, we don't have a test case
> to these commands on the case that reading from trace frames. This
> patch adds a test case, and it is a preparatory patch for my
> following patches.
Thanks.
> --- /dev/null
> +++ b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
> +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?
> + untested ${testfile}.exp
http://sourceware.org/gdb/wiki/GDBTestcaseCookbook#A.22untested.22_calls
Wouldn't prepare_for_testing work here?
> + return -1
> +}
> +# Test target supports tracepoints or not.
# Test if the target supports tracepoints or not.
Or:
# Check whether the target supports tracepoints.
> +# 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?
> + # 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).
> + ".*\\^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/
> + # 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.
> + # 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."
> +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?
--
Pedro Alves