1 # Copyright 2013 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 load_lib trace-support.exp
18 standard_testfile trace-unavailable.c
20 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug}] } {
25 fail "Can't run to main to check for trace support"
29 if ![gdb_target_supports_trace] {
30 unsupported "Current target does not support trace"
36 load_lib mi-support.exp
44 mi_gdb_test "-break-insert marker" \
45 "\\^done,bkpt=\{number=\"${decimal}\",type=\"breakpoint\".*\"\}" \
46 "insert tracepoint on marker"
47 mi_gdb_test "-break-insert -a bar" \
48 "\\^done,bkpt=\{number=\"${decimal}\",type=\"tracepoint\".*\"\}" \
49 "insert tracepoint on bar"
52 mi_gdb_test "-break-commands 3 \"collect array\" \"collect j\" \"end\" " \
55 mi_gdb_test "-trace-start" {.*\^done} "trace start"
56 mi_send_resuming_command "exec-continue" "continuing to marker"
58 "breakpoint-hit" "marker" ".*" ".*" ".*" {"" "disp=\"keep\""} \
60 mi_gdb_test "-trace-stop" {.*} "trace stop"
62 # Save trace frames to tfile.
63 set tracefile [standard_output_file ${testfile}]
64 mi_gdb_test "-trace-save ${tracefile}.tf" ".*\\^done" \
65 "save tfile trace file"
66 # Save trace frames to ctf.
67 mi_gdb_test "-trace-save -ctf ${tracefile}.ctf" ".*\\^done" \
70 mi_gdb_test "-gdb-set print entry-values no" {\^done} \
71 "-gdb-set print entry-values no"
73 proc test_trace_unavailable { data_source } {
76 with_test_prefix "$data_source" {
78 # Test MI commands '-stack-list-locals', '-stack-list-arguments',
79 # and '-stack-list-variables'.
80 mi_gdb_test "-trace-find frame-number 0" \
81 ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \
82 "-trace-find frame-number 0"
84 # Test MI command '-stack-list-locals'.
85 mi_gdb_test "-stack-list-locals --simple-values" \
86 ".*\\^done,locals=\\\[\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \
87 "-stack-list-locals --simple-values"
89 # Test MI command '-stack-list-arguments'.
90 mi_gdb_test "-stack-list-arguments --simple-values" \
91 ".*\\^done,stack-args=\\\[frame=\{level=\"0\",args=\\\[\{name=\"j\",type=\"int\",value=\"4\"\},\{name=\"s\",type=\"char \\\*\",value=\"<unavailable>\"\}\\\]\},.*\}.*" \
92 "-stack-list-arguments --simple-values"
94 # Test MI command '-stack-list-variables'.
95 mi_gdb_test "-stack-list-variables --simple-values" \
96 ".*\\^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>\"\}\\\]" \
97 "-stack-list-variables --simple-values"
99 # Don't issue command '-trace-find none' to return from
100 # tfind mode (examining trace frames) on purpose, in order
101 # to test that GDB is able to clear its tracing-related local state
102 # in the next -target-select.
103 # mi_gdb_test "-trace-find none" ".*\\^done,found=\"0\".*" "-trace-find none"
107 test_trace_unavailable "live"
109 # Change target to ctf if GDB supports it.
110 set msg "-target-select ctf"
111 send_gdb "-target-select ctf ${tracefile}.ctf\n"
113 -re ".*\\^connected.*${mi_gdb_prompt}$" {
114 # GDB supports ctf, do the test.
115 test_trace_unavailable "ctf"
117 -re ".*\\^error,msg=\"Undefined target command.*${mi_gdb_prompt}$" {
118 # GDB doesn't support ctf, skip the test.
119 unsupported "gdb does not support ctf target"
121 -re ".*$mi_gdb_prompt$" {
125 fail "$msg (timeout)"
129 # Change target to tfile.
130 mi_gdb_test "-target-select tfile ${tracefile}.tf" ".*\\^connected.*" \
131 "-target-select tfile"
132 test_trace_unavailable "tfile"