cb83dbe71ed5d91fd226382365fa81dd65badcfb
[external/binutils.git] / gdb / testsuite / gdb.trace / mi-traceframe-changed.exp
1 # Copyright 2012-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
16 load_lib trace-support.exp
17 load_lib mi-support.exp
18 set MIFLAGS "-i=mi"
19
20 standard_testfile tfile.c
21 set executable $testfile
22
23 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
24            executable {debug nowarnings}] != "" } {
25      untested ${testfile}.exp
26      return -1
27 }
28
29 # Make sure we are starting fresh.
30 remote_file host delete tfile-basic.tf
31 remote_file target delete tfile-basic.tf
32
33 remote_exec target "$binfile"
34 # Copy tracefile from target to host.
35 remote_download host [remote_upload target tfile-basic.tf] \
36     tfile-basic.tf
37
38 proc test_tfind_tfile { } {
39     with_test_prefix "tfile" {
40         global binfile
41         global decimal
42
43         if [mi_gdb_start] {
44             return
45         }
46         mi_gdb_load ${binfile}
47
48         mi_gdb_test "-target-select tfile tfile-basic.tf" \
49             ".*=breakpoint-created,bkpt=\{number=\"${decimal}\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",.*,func=\"write_basic_trace_file\".*\\^connected" \
50             "select trace file"
51
52         mi_gdb_test "tfind 0" \
53             ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \
54             "tfind 0"
55
56         # No MI notification is sent because traceframe is not changed.
57         mi_gdb_test "tfind 0" \
58             "\\&\"tfind 0\\\\n\"\r\n\~\"Found.*\\^done" \
59             "tfind 0 again"
60
61         mi_gdb_test "tfind end" \
62             ".*=traceframe-changed,end.*\\^done" \
63             "tfind end"
64
65         # No MI notification is send because request is from MI command.
66         mi_gdb_test "-trace-find frame-number 0" \
67             "-trace-find frame-number 0\r\n\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \
68             "-trace-find frame-number 0"
69
70         mi_gdb_exit
71     }
72 }
73
74 test_tfind_tfile
75
76 # Change to a different test case in order to run it on target, and get
77 # several traceframes.
78 standard_testfile status-stop.c
79 set testfile ${testfile}-1
80 set binfile ${objdir}/${subdir}/${testfile}
81 set executable $testfile
82
83 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
84            executable {debug nowarnings}] != "" } {
85      untested ${testfile}.exp
86      return -1
87 }
88
89 # Test target supports tracepoints or not.
90
91 clean_restart $executable
92
93 if ![runto_main] {
94     fail "Can't run to main to check for trace support"
95     return -1
96 }
97
98 if ![gdb_target_supports_trace] {
99     unsupported "Current target does not support trace"
100     return -1
101 }
102
103 gdb_exit
104
105 proc test_tfind_remote { } {
106     with_test_prefix "remote" {
107         global decimal
108
109         if [mi_gdb_start] {
110             return
111         }
112         mi_run_to_main
113
114         mi_gdb_test "-break-insert end" "\\^done.*" "break end"
115         mi_gdb_test "-break-insert -a func2" "\\^done.*" "break func2"
116         mi_gdb_test "-trace-start" "=breakpoint-modified,bkpt={.*installed=\"y\".*}.*\\^done.*" \
117             "trace start"
118
119         mi_execute_to "exec-continue" "breakpoint-hit" end "" ".*" ".*" \
120             { "" "disp=\"keep\"" } \
121             "continue to end"
122         mi_gdb_test "-trace-stop" "\\^done.*" "trace stop"
123
124         mi_gdb_test "tfind 0" \
125             ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \
126             "tfind 0"
127
128         mi_gdb_test "tfind" \
129             ".*=traceframe-changed,num=\"1\",tracepoint=\"${decimal}\".*\\^done" \
130             "tfind"
131
132         mi_gdb_test "tfind end" \
133             ".*=traceframe-changed,end.*\\^done" \
134             "tfind end"
135
136         mi_gdb_exit
137     }
138 }
139
140 test_tfind_remote
141
142 return 0