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