]>
Commit | Line | Data |
---|---|---|
8acc9f48 | 1 | # Copyright 2012-2013 Free Software Foundation, Inc. |
bb25a15c 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 | ||
19 | standard_testfile actions.c | |
20 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
21 | executable {debug nowarnings}] != "" } { | |
22 | untested mi-tsv-changed.exp | |
23 | return -1 | |
24 | } | |
25 | ||
26 | # Test notifications on creating and deleting TSV. | |
27 | ||
28 | proc test_create_delete_tsv { } {with_test_prefix "create delete" { | |
29 | global binfile | |
30 | global decimal | |
31 | ||
32 | if [mi_gdb_start] { | |
33 | return | |
34 | } | |
35 | mi_gdb_load ${binfile} | |
36 | ||
37 | mi_gdb_test "tvariable \$tvar1" \ | |
38 | ".*=tsv-created,name=\"tvar1\",value=\"0\"\\\\n.*\\^done" \ | |
39 | "tvariable \$tvar1" | |
40 | mi_gdb_test "tvariable \$tvar2 = 45" \ | |
41 | ".*=tsv-created,name=\"tvar2\",value=\"45\"\\\\n.*\\^done" \ | |
42 | "tvariable \$tvar2" | |
43 | ||
44 | mi_gdb_test "delete tvariable \$tvar2" \ | |
45 | ".*=tsv-deleted,name=\"tvar2\"\\\\n.*\\^done" \ | |
46 | "delete tvariable \$tvar2" | |
47 | ||
48 | mi_gdb_test "delete tvariable" \ | |
49 | ".*=tsv-deleted\\\\n.*\\^done" \ | |
50 | "delete all tvariables" | |
51 | ||
52 | }} | |
53 | ||
54 | ||
55 | # Test when GDB connects to a disconnected stub, existing TSVs in | |
56 | # remote stub can be uploaded to GDB, and GDB emits MI notification | |
57 | # for new uploaded TSVs. | |
58 | ||
59 | proc test_upload_tsv { } { with_test_prefix "upload" { | |
60 | ||
61 | global gdbserver_reconnect_p | |
62 | global gdb_prompt | |
63 | global testfile | |
64 | global decimal | |
65 | ||
66 | set gdbserver_reconnect_p 1 | |
67 | if { [info proc gdb_reconnect] == "" } { | |
68 | return 0 | |
69 | } | |
70 | ||
71 | clean_restart $testfile | |
72 | if ![runto_main] then { | |
73 | fail "Can't run to main" | |
74 | return 0 | |
75 | } | |
76 | ||
77 | gdb_test "tvariable \$tvar1" \ | |
78 | "Trace state variable \\\$tvar1 created, with initial value 0." \ | |
79 | "Create a trace state variable" | |
80 | ||
81 | gdb_test "tvariable \$tvar2 = 45" \ | |
82 | "Trace state variable \\\$tvar2 created, with initial value 45." \ | |
83 | "Create a trace state variable with initial value" | |
84 | # Define a tracepoint otherwise tracing cannot be started. | |
85 | gdb_test "trace main" "Tracepoint $decimal at .*" | |
86 | gdb_test_no_output "tstart" "start trace experiment" | |
87 | ||
88 | set test "disconnect" | |
89 | gdb_test_multiple "disconnect" $test { | |
90 | -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { | |
91 | pass $test | |
92 | ||
93 | set test "disconnected" | |
94 | gdb_test_multiple "y" $test { | |
95 | -re "$gdb_prompt $" { | |
96 | pass "$test" | |
97 | } | |
98 | } | |
99 | } | |
100 | } | |
101 | ||
102 | gdb_exit | |
103 | ||
104 | if [mi_gdb_start] { | |
105 | return | |
106 | } | |
107 | ||
108 | global srcdir | |
109 | global subdir | |
110 | global binfile | |
111 | ||
112 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
113 | mi_gdb_load ${binfile} | |
114 | ||
115 | global gdbserver_protocol | |
116 | global gdbserver_gdbport | |
117 | ||
118 | send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n" | |
119 | ||
120 | global mi_gdb_prompt | |
121 | set tsv1_created 0 | |
122 | set tsv2_created 0 | |
123 | gdb_expect { | |
124 | -re "=tsv-created,name=\"tvar1\",value=\"0\"" { | |
125 | set tsv1_created 1 | |
126 | exp_continue | |
127 | } | |
128 | -re "=tsv-created,name=\"tvar2\",value=\"45\"" { | |
129 | set tsv2_created 1 | |
130 | exp_continue | |
131 | } | |
132 | -re ".*${mi_gdb_prompt}" { | |
133 | ||
134 | } | |
135 | } | |
136 | ||
137 | if $tsv1_created { | |
138 | pass "tsv1 created" | |
139 | } else { | |
140 | fail "tsv1 created" | |
141 | } | |
142 | if $tsv2_created { | |
143 | pass "tsv2 created" | |
144 | } else { | |
145 | fail "tsv2 created" | |
146 | } | |
147 | ||
148 | set gdbserver_reconnect_p 0 | |
149 | }} | |
150 | ||
151 | test_create_delete_tsv | |
152 | ||
153 | # Test target supports tracepoints or not. | |
154 | ||
155 | clean_restart $testfile | |
156 | ||
157 | if ![runto_main] { | |
158 | fail "Can't run to main to check for trace support" | |
159 | return -1 | |
160 | } | |
161 | ||
162 | if ![gdb_target_supports_trace] { | |
163 | unsupported "Current target does not support trace" | |
164 | return -1; | |
165 | } | |
166 | ||
167 | gdb_exit | |
168 | ||
169 | test_upload_tsv | |
170 | ||
171 | return 0 |