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