*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / mi-trace-unavailable.exp
CommitLineData
8cb5cc78
YQ
1# Copyright 2013 Free Software Foundation, Inc.
2
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.
7#
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.
12#
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/>.
15
16load_lib trace-support.exp
17
18standard_testfile trace-unavailable.c
19
20if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug}] } {
21 return -1
22}
23
24if ![runto_main] {
25 fail "Can't run to main to check for trace support"
26 return -1
27}
28
29if ![gdb_target_supports_trace] {
30 unsupported "Current target does not support trace"
31 return -1
32}
33
34gdb_exit
35
36load_lib mi-support.exp
37set MIFLAGS "-i=mi"
38
39if [mi_gdb_start] {
40 return
41}
42mi_run_to_main
43
44mi_gdb_test "-break-insert marker" \
45 "\\^done,bkpt=\{number=\"${decimal}\",type=\"breakpoint\".*\"\}" \
46 "insert tracepoint on marker"
47mi_gdb_test "-break-insert -a bar" \
48 "\\^done,bkpt=\{number=\"${decimal}\",type=\"tracepoint\".*\"\}" \
49 "insert tracepoint on bar"
50
51# Define an action.
52mi_gdb_test "-break-commands 3 \"collect array\" \"collect j\" \"end\" " \
53 {\^done} "set action"
54
55mi_gdb_test "-trace-start" {.*\^done} "trace start"
56mi_send_resuming_command "exec-continue" "continuing to marker"
57mi_expect_stop \
58 "breakpoint-hit" "marker" ".*" ".*" ".*" {"" "disp=\"keep\""} \
59 "stop at marker"
60mi_gdb_test "-trace-stop" {.*} "trace stop"
61
62# Save trace frames to tfile.
63set tracefile [standard_output_file ${testfile}]
64mi_gdb_test "-trace-save ${tracefile}.tf" ".*\\^done" \
65 "save tfile trace file"
66# Save trace frames to ctf.
67mi_gdb_test "-trace-save -ctf ${tracefile}.ctf" ".*\\^done" \
68 "save ctf trace file"
69
70mi_gdb_test "-gdb-set print entry-values no" {\^done} \
71 "-gdb-set print entry-values no"
72
73proc test_trace_unavailable { data_source } {
74 global decimal
75
76 with_test_prefix "$data_source" {
77
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"
83
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"
88
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"
93
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"
98
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"
104 }
105}
106
107test_trace_unavailable "live"
108
109# Change target to ctf if GDB supports it.
110set msg "-target-select ctf"
111send_gdb "-target-select ctf ${tracefile}.ctf\n"
112gdb_expect {
113 -re ".*\\^connected.*${mi_gdb_prompt}$" {
114 # GDB supports ctf, do the test.
115 test_trace_unavailable "ctf"
116 }
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"
120 }
121 -re ".*$mi_gdb_prompt$" {
122 fail "$msg"
123 }
124 timeout {
125 fail "$msg (timeout)"
126 }
127}
128
129# Change target to tfile.
130mi_gdb_test "-target-select tfile ${tracefile}.tf" ".*\\^connected.*" \
131 "-target-select tfile"
132test_trace_unavailable "tfile"
133
134mi_gdb_exit
This page took 0.030866 seconds and 4 git commands to generate.