root / gdbstub.c @ feature-archipelago
History | View | Annotate | Download (43.2 kB)
1 | b4608c04 | bellard | /*
|
---|---|---|---|
2 | b4608c04 | bellard | * gdb server stub
|
3 | 5fafdf24 | ths | *
|
4 | 3475187d | bellard | * Copyright (c) 2003-2005 Fabrice Bellard
|
5 | b4608c04 | bellard | *
|
6 | b4608c04 | bellard | * This library is free software; you can redistribute it and/or
|
7 | b4608c04 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | b4608c04 | bellard | * License as published by the Free Software Foundation; either
|
9 | b4608c04 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | b4608c04 | bellard | *
|
11 | b4608c04 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | b4608c04 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | b4608c04 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | b4608c04 | bellard | * Lesser General Public License for more details.
|
15 | b4608c04 | bellard | *
|
16 | b4608c04 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 | b4608c04 | bellard | */
|
19 | 978efd6a | pbrook | #include "config.h" |
20 | 56aebc89 | pbrook | #include "qemu-common.h" |
21 | 1fddef4b | bellard | #ifdef CONFIG_USER_ONLY
|
22 | 1fddef4b | bellard | #include <stdlib.h> |
23 | 1fddef4b | bellard | #include <stdio.h> |
24 | 1fddef4b | bellard | #include <stdarg.h> |
25 | 1fddef4b | bellard | #include <string.h> |
26 | 1fddef4b | bellard | #include <errno.h> |
27 | 1fddef4b | bellard | #include <unistd.h> |
28 | 978efd6a | pbrook | #include <fcntl.h> |
29 | 1fddef4b | bellard | |
30 | 1fddef4b | bellard | #include "qemu.h" |
31 | 1fddef4b | bellard | #else
|
32 | 83c9089e | Paolo Bonzini | #include "monitor/monitor.h" |
33 | dccfcd0e | Paolo Bonzini | #include "sysemu/char.h" |
34 | 9c17d615 | Paolo Bonzini | #include "sysemu/sysemu.h" |
35 | 022c62cb | Paolo Bonzini | #include "exec/gdbstub.h" |
36 | 1fddef4b | bellard | #endif
|
37 | 67b915a5 | bellard | |
38 | 56aebc89 | pbrook | #define MAX_PACKET_LENGTH 4096 |
39 | 56aebc89 | pbrook | |
40 | 2b41f10e | Blue Swirl | #include "cpu.h" |
41 | 1de7afc9 | Paolo Bonzini | #include "qemu/sockets.h" |
42 | 9c17d615 | Paolo Bonzini | #include "sysemu/kvm.h" |
43 | ca587a8e | aurel32 | |
44 | f3659eee | Andreas Färber | static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, |
45 | f3659eee | Andreas Färber | uint8_t *buf, int len, bool is_write) |
46 | 44520db1 | Fabien Chouteau | { |
47 | f3659eee | Andreas Färber | CPUClass *cc = CPU_GET_CLASS(cpu); |
48 | f3659eee | Andreas Färber | |
49 | f3659eee | Andreas Färber | if (cc->memory_rw_debug) {
|
50 | f3659eee | Andreas Färber | return cc->memory_rw_debug(cpu, addr, buf, len, is_write);
|
51 | f3659eee | Andreas Färber | } |
52 | f3659eee | Andreas Färber | return cpu_memory_rw_debug(cpu, addr, buf, len, is_write);
|
53 | 44520db1 | Fabien Chouteau | } |
54 | ca587a8e | aurel32 | |
55 | ca587a8e | aurel32 | enum {
|
56 | ca587a8e | aurel32 | GDB_SIGNAL_0 = 0,
|
57 | ca587a8e | aurel32 | GDB_SIGNAL_INT = 2,
|
58 | 425189a8 | Jan Kiszka | GDB_SIGNAL_QUIT = 3,
|
59 | ca587a8e | aurel32 | GDB_SIGNAL_TRAP = 5,
|
60 | 425189a8 | Jan Kiszka | GDB_SIGNAL_ABRT = 6,
|
61 | 425189a8 | Jan Kiszka | GDB_SIGNAL_ALRM = 14,
|
62 | 425189a8 | Jan Kiszka | GDB_SIGNAL_IO = 23,
|
63 | 425189a8 | Jan Kiszka | GDB_SIGNAL_XCPU = 24,
|
64 | ca587a8e | aurel32 | GDB_SIGNAL_UNKNOWN = 143
|
65 | ca587a8e | aurel32 | }; |
66 | ca587a8e | aurel32 | |
67 | ca587a8e | aurel32 | #ifdef CONFIG_USER_ONLY
|
68 | ca587a8e | aurel32 | |
69 | ca587a8e | aurel32 | /* Map target signal numbers to GDB protocol signal numbers and vice
|
70 | ca587a8e | aurel32 | * versa. For user emulation's currently supported systems, we can
|
71 | ca587a8e | aurel32 | * assume most signals are defined.
|
72 | ca587a8e | aurel32 | */
|
73 | ca587a8e | aurel32 | |
74 | ca587a8e | aurel32 | static int gdb_signal_table[] = { |
75 | ca587a8e | aurel32 | 0,
|
76 | ca587a8e | aurel32 | TARGET_SIGHUP, |
77 | ca587a8e | aurel32 | TARGET_SIGINT, |
78 | ca587a8e | aurel32 | TARGET_SIGQUIT, |
79 | ca587a8e | aurel32 | TARGET_SIGILL, |
80 | ca587a8e | aurel32 | TARGET_SIGTRAP, |
81 | ca587a8e | aurel32 | TARGET_SIGABRT, |
82 | ca587a8e | aurel32 | -1, /* SIGEMT */ |
83 | ca587a8e | aurel32 | TARGET_SIGFPE, |
84 | ca587a8e | aurel32 | TARGET_SIGKILL, |
85 | ca587a8e | aurel32 | TARGET_SIGBUS, |
86 | ca587a8e | aurel32 | TARGET_SIGSEGV, |
87 | ca587a8e | aurel32 | TARGET_SIGSYS, |
88 | ca587a8e | aurel32 | TARGET_SIGPIPE, |
89 | ca587a8e | aurel32 | TARGET_SIGALRM, |
90 | ca587a8e | aurel32 | TARGET_SIGTERM, |
91 | ca587a8e | aurel32 | TARGET_SIGURG, |
92 | ca587a8e | aurel32 | TARGET_SIGSTOP, |
93 | ca587a8e | aurel32 | TARGET_SIGTSTP, |
94 | ca587a8e | aurel32 | TARGET_SIGCONT, |
95 | ca587a8e | aurel32 | TARGET_SIGCHLD, |
96 | ca587a8e | aurel32 | TARGET_SIGTTIN, |
97 | ca587a8e | aurel32 | TARGET_SIGTTOU, |
98 | ca587a8e | aurel32 | TARGET_SIGIO, |
99 | ca587a8e | aurel32 | TARGET_SIGXCPU, |
100 | ca587a8e | aurel32 | TARGET_SIGXFSZ, |
101 | ca587a8e | aurel32 | TARGET_SIGVTALRM, |
102 | ca587a8e | aurel32 | TARGET_SIGPROF, |
103 | ca587a8e | aurel32 | TARGET_SIGWINCH, |
104 | ca587a8e | aurel32 | -1, /* SIGLOST */ |
105 | ca587a8e | aurel32 | TARGET_SIGUSR1, |
106 | ca587a8e | aurel32 | TARGET_SIGUSR2, |
107 | c72d5bf8 | blueswir1 | #ifdef TARGET_SIGPWR
|
108 | ca587a8e | aurel32 | TARGET_SIGPWR, |
109 | c72d5bf8 | blueswir1 | #else
|
110 | c72d5bf8 | blueswir1 | -1,
|
111 | c72d5bf8 | blueswir1 | #endif
|
112 | ca587a8e | aurel32 | -1, /* SIGPOLL */ |
113 | ca587a8e | aurel32 | -1,
|
114 | ca587a8e | aurel32 | -1,
|
115 | ca587a8e | aurel32 | -1,
|
116 | ca587a8e | aurel32 | -1,
|
117 | ca587a8e | aurel32 | -1,
|
118 | ca587a8e | aurel32 | -1,
|
119 | ca587a8e | aurel32 | -1,
|
120 | ca587a8e | aurel32 | -1,
|
121 | ca587a8e | aurel32 | -1,
|
122 | ca587a8e | aurel32 | -1,
|
123 | ca587a8e | aurel32 | -1,
|
124 | c72d5bf8 | blueswir1 | #ifdef __SIGRTMIN
|
125 | ca587a8e | aurel32 | __SIGRTMIN + 1,
|
126 | ca587a8e | aurel32 | __SIGRTMIN + 2,
|
127 | ca587a8e | aurel32 | __SIGRTMIN + 3,
|
128 | ca587a8e | aurel32 | __SIGRTMIN + 4,
|
129 | ca587a8e | aurel32 | __SIGRTMIN + 5,
|
130 | ca587a8e | aurel32 | __SIGRTMIN + 6,
|
131 | ca587a8e | aurel32 | __SIGRTMIN + 7,
|
132 | ca587a8e | aurel32 | __SIGRTMIN + 8,
|
133 | ca587a8e | aurel32 | __SIGRTMIN + 9,
|
134 | ca587a8e | aurel32 | __SIGRTMIN + 10,
|
135 | ca587a8e | aurel32 | __SIGRTMIN + 11,
|
136 | ca587a8e | aurel32 | __SIGRTMIN + 12,
|
137 | ca587a8e | aurel32 | __SIGRTMIN + 13,
|
138 | ca587a8e | aurel32 | __SIGRTMIN + 14,
|
139 | ca587a8e | aurel32 | __SIGRTMIN + 15,
|
140 | ca587a8e | aurel32 | __SIGRTMIN + 16,
|
141 | ca587a8e | aurel32 | __SIGRTMIN + 17,
|
142 | ca587a8e | aurel32 | __SIGRTMIN + 18,
|
143 | ca587a8e | aurel32 | __SIGRTMIN + 19,
|
144 | ca587a8e | aurel32 | __SIGRTMIN + 20,
|
145 | ca587a8e | aurel32 | __SIGRTMIN + 21,
|
146 | ca587a8e | aurel32 | __SIGRTMIN + 22,
|
147 | ca587a8e | aurel32 | __SIGRTMIN + 23,
|
148 | ca587a8e | aurel32 | __SIGRTMIN + 24,
|
149 | ca587a8e | aurel32 | __SIGRTMIN + 25,
|
150 | ca587a8e | aurel32 | __SIGRTMIN + 26,
|
151 | ca587a8e | aurel32 | __SIGRTMIN + 27,
|
152 | ca587a8e | aurel32 | __SIGRTMIN + 28,
|
153 | ca587a8e | aurel32 | __SIGRTMIN + 29,
|
154 | ca587a8e | aurel32 | __SIGRTMIN + 30,
|
155 | ca587a8e | aurel32 | __SIGRTMIN + 31,
|
156 | ca587a8e | aurel32 | -1, /* SIGCANCEL */ |
157 | ca587a8e | aurel32 | __SIGRTMIN, |
158 | ca587a8e | aurel32 | __SIGRTMIN + 32,
|
159 | ca587a8e | aurel32 | __SIGRTMIN + 33,
|
160 | ca587a8e | aurel32 | __SIGRTMIN + 34,
|
161 | ca587a8e | aurel32 | __SIGRTMIN + 35,
|
162 | ca587a8e | aurel32 | __SIGRTMIN + 36,
|
163 | ca587a8e | aurel32 | __SIGRTMIN + 37,
|
164 | ca587a8e | aurel32 | __SIGRTMIN + 38,
|
165 | ca587a8e | aurel32 | __SIGRTMIN + 39,
|
166 | ca587a8e | aurel32 | __SIGRTMIN + 40,
|
167 | ca587a8e | aurel32 | __SIGRTMIN + 41,
|
168 | ca587a8e | aurel32 | __SIGRTMIN + 42,
|
169 | ca587a8e | aurel32 | __SIGRTMIN + 43,
|
170 | ca587a8e | aurel32 | __SIGRTMIN + 44,
|
171 | ca587a8e | aurel32 | __SIGRTMIN + 45,
|
172 | ca587a8e | aurel32 | __SIGRTMIN + 46,
|
173 | ca587a8e | aurel32 | __SIGRTMIN + 47,
|
174 | ca587a8e | aurel32 | __SIGRTMIN + 48,
|
175 | ca587a8e | aurel32 | __SIGRTMIN + 49,
|
176 | ca587a8e | aurel32 | __SIGRTMIN + 50,
|
177 | ca587a8e | aurel32 | __SIGRTMIN + 51,
|
178 | ca587a8e | aurel32 | __SIGRTMIN + 52,
|
179 | ca587a8e | aurel32 | __SIGRTMIN + 53,
|
180 | ca587a8e | aurel32 | __SIGRTMIN + 54,
|
181 | ca587a8e | aurel32 | __SIGRTMIN + 55,
|
182 | ca587a8e | aurel32 | __SIGRTMIN + 56,
|
183 | ca587a8e | aurel32 | __SIGRTMIN + 57,
|
184 | ca587a8e | aurel32 | __SIGRTMIN + 58,
|
185 | ca587a8e | aurel32 | __SIGRTMIN + 59,
|
186 | ca587a8e | aurel32 | __SIGRTMIN + 60,
|
187 | ca587a8e | aurel32 | __SIGRTMIN + 61,
|
188 | ca587a8e | aurel32 | __SIGRTMIN + 62,
|
189 | ca587a8e | aurel32 | __SIGRTMIN + 63,
|
190 | ca587a8e | aurel32 | __SIGRTMIN + 64,
|
191 | ca587a8e | aurel32 | __SIGRTMIN + 65,
|
192 | ca587a8e | aurel32 | __SIGRTMIN + 66,
|
193 | ca587a8e | aurel32 | __SIGRTMIN + 67,
|
194 | ca587a8e | aurel32 | __SIGRTMIN + 68,
|
195 | ca587a8e | aurel32 | __SIGRTMIN + 69,
|
196 | ca587a8e | aurel32 | __SIGRTMIN + 70,
|
197 | ca587a8e | aurel32 | __SIGRTMIN + 71,
|
198 | ca587a8e | aurel32 | __SIGRTMIN + 72,
|
199 | ca587a8e | aurel32 | __SIGRTMIN + 73,
|
200 | ca587a8e | aurel32 | __SIGRTMIN + 74,
|
201 | ca587a8e | aurel32 | __SIGRTMIN + 75,
|
202 | ca587a8e | aurel32 | __SIGRTMIN + 76,
|
203 | ca587a8e | aurel32 | __SIGRTMIN + 77,
|
204 | ca587a8e | aurel32 | __SIGRTMIN + 78,
|
205 | ca587a8e | aurel32 | __SIGRTMIN + 79,
|
206 | ca587a8e | aurel32 | __SIGRTMIN + 80,
|
207 | ca587a8e | aurel32 | __SIGRTMIN + 81,
|
208 | ca587a8e | aurel32 | __SIGRTMIN + 82,
|
209 | ca587a8e | aurel32 | __SIGRTMIN + 83,
|
210 | ca587a8e | aurel32 | __SIGRTMIN + 84,
|
211 | ca587a8e | aurel32 | __SIGRTMIN + 85,
|
212 | ca587a8e | aurel32 | __SIGRTMIN + 86,
|
213 | ca587a8e | aurel32 | __SIGRTMIN + 87,
|
214 | ca587a8e | aurel32 | __SIGRTMIN + 88,
|
215 | ca587a8e | aurel32 | __SIGRTMIN + 89,
|
216 | ca587a8e | aurel32 | __SIGRTMIN + 90,
|
217 | ca587a8e | aurel32 | __SIGRTMIN + 91,
|
218 | ca587a8e | aurel32 | __SIGRTMIN + 92,
|
219 | ca587a8e | aurel32 | __SIGRTMIN + 93,
|
220 | ca587a8e | aurel32 | __SIGRTMIN + 94,
|
221 | ca587a8e | aurel32 | __SIGRTMIN + 95,
|
222 | ca587a8e | aurel32 | -1, /* SIGINFO */ |
223 | ca587a8e | aurel32 | -1, /* UNKNOWN */ |
224 | ca587a8e | aurel32 | -1, /* DEFAULT */ |
225 | ca587a8e | aurel32 | -1,
|
226 | ca587a8e | aurel32 | -1,
|
227 | ca587a8e | aurel32 | -1,
|
228 | ca587a8e | aurel32 | -1,
|
229 | ca587a8e | aurel32 | -1,
|
230 | ca587a8e | aurel32 | -1
|
231 | c72d5bf8 | blueswir1 | #endif
|
232 | ca587a8e | aurel32 | }; |
233 | 8f447cc7 | bellard | #else
|
234 | ca587a8e | aurel32 | /* In system mode we only need SIGINT and SIGTRAP; other signals
|
235 | ca587a8e | aurel32 | are not yet supported. */
|
236 | ca587a8e | aurel32 | |
237 | ca587a8e | aurel32 | enum {
|
238 | ca587a8e | aurel32 | TARGET_SIGINT = 2,
|
239 | ca587a8e | aurel32 | TARGET_SIGTRAP = 5
|
240 | ca587a8e | aurel32 | }; |
241 | ca587a8e | aurel32 | |
242 | ca587a8e | aurel32 | static int gdb_signal_table[] = { |
243 | ca587a8e | aurel32 | -1,
|
244 | ca587a8e | aurel32 | -1,
|
245 | ca587a8e | aurel32 | TARGET_SIGINT, |
246 | ca587a8e | aurel32 | -1,
|
247 | ca587a8e | aurel32 | -1,
|
248 | ca587a8e | aurel32 | TARGET_SIGTRAP |
249 | ca587a8e | aurel32 | }; |
250 | ca587a8e | aurel32 | #endif
|
251 | ca587a8e | aurel32 | |
252 | ca587a8e | aurel32 | #ifdef CONFIG_USER_ONLY
|
253 | ca587a8e | aurel32 | static int target_signal_to_gdb (int sig) |
254 | ca587a8e | aurel32 | { |
255 | ca587a8e | aurel32 | int i;
|
256 | ca587a8e | aurel32 | for (i = 0; i < ARRAY_SIZE (gdb_signal_table); i++) |
257 | ca587a8e | aurel32 | if (gdb_signal_table[i] == sig)
|
258 | ca587a8e | aurel32 | return i;
|
259 | ca587a8e | aurel32 | return GDB_SIGNAL_UNKNOWN;
|
260 | ca587a8e | aurel32 | } |
261 | 8f447cc7 | bellard | #endif
|
262 | b4608c04 | bellard | |
263 | ca587a8e | aurel32 | static int gdb_signal_to_target (int sig) |
264 | ca587a8e | aurel32 | { |
265 | ca587a8e | aurel32 | if (sig < ARRAY_SIZE (gdb_signal_table))
|
266 | ca587a8e | aurel32 | return gdb_signal_table[sig];
|
267 | ca587a8e | aurel32 | else
|
268 | ca587a8e | aurel32 | return -1; |
269 | ca587a8e | aurel32 | } |
270 | ca587a8e | aurel32 | |
271 | 4abe615b | bellard | //#define DEBUG_GDB
|
272 | b4608c04 | bellard | |
273 | 56aebc89 | pbrook | typedef struct GDBRegisterState { |
274 | 56aebc89 | pbrook | int base_reg;
|
275 | 56aebc89 | pbrook | int num_regs;
|
276 | 56aebc89 | pbrook | gdb_reg_cb get_reg; |
277 | 56aebc89 | pbrook | gdb_reg_cb set_reg; |
278 | 56aebc89 | pbrook | const char *xml; |
279 | 56aebc89 | pbrook | struct GDBRegisterState *next;
|
280 | 56aebc89 | pbrook | } GDBRegisterState; |
281 | 56aebc89 | pbrook | |
282 | 858693c6 | bellard | enum RSState {
|
283 | 36556b20 | aliguori | RS_INACTIVE, |
284 | 858693c6 | bellard | RS_IDLE, |
285 | 858693c6 | bellard | RS_GETLINE, |
286 | 858693c6 | bellard | RS_CHKSUM1, |
287 | 858693c6 | bellard | RS_CHKSUM2, |
288 | 858693c6 | bellard | }; |
289 | 858693c6 | bellard | typedef struct GDBState { |
290 | 2e0f2cfb | Andreas Färber | CPUState *c_cpu; /* current CPU for step/continue ops */
|
291 | 2e0f2cfb | Andreas Färber | CPUState *g_cpu; /* current CPU for other ops */
|
292 | 52f34623 | Andreas Färber | CPUState *query_cpu; /* for q{f|s}ThreadInfo */
|
293 | 41625033 | bellard | enum RSState state; /* parsing state */ |
294 | 56aebc89 | pbrook | char line_buf[MAX_PACKET_LENGTH];
|
295 | 858693c6 | bellard | int line_buf_index;
|
296 | 858693c6 | bellard | int line_csum;
|
297 | 56aebc89 | pbrook | uint8_t last_packet[MAX_PACKET_LENGTH + 4];
|
298 | 4046d913 | pbrook | int last_packet_len;
|
299 | 1f487ee9 | edgar_igl | int signal;
|
300 | 41625033 | bellard | #ifdef CONFIG_USER_ONLY
|
301 | 4046d913 | pbrook | int fd;
|
302 | 41625033 | bellard | int running_state;
|
303 | 4046d913 | pbrook | #else
|
304 | 4046d913 | pbrook | CharDriverState *chr; |
305 | 8a34a0fb | aliguori | CharDriverState *mon_chr; |
306 | 41625033 | bellard | #endif
|
307 | cdb432b2 | Meador Inge | char syscall_buf[256]; |
308 | cdb432b2 | Meador Inge | gdb_syscall_complete_cb current_syscall_cb; |
309 | 858693c6 | bellard | } GDBState; |
310 | b4608c04 | bellard | |
311 | 60897d36 | edgar_igl | /* By default use no IRQs and no timers while single stepping so as to
|
312 | 60897d36 | edgar_igl | * make single stepping like an ICE HW step.
|
313 | 60897d36 | edgar_igl | */
|
314 | 60897d36 | edgar_igl | static int sstep_flags = SSTEP_ENABLE|SSTEP_NOIRQ|SSTEP_NOTIMER; |
315 | 60897d36 | edgar_igl | |
316 | 880a7578 | aliguori | static GDBState *gdbserver_state;
|
317 | 880a7578 | aliguori | |
318 | 5b50e790 | Andreas Färber | bool gdb_has_xml;
|
319 | 56aebc89 | pbrook | |
320 | 1fddef4b | bellard | #ifdef CONFIG_USER_ONLY
|
321 | 4046d913 | pbrook | /* XXX: This is not thread safe. Do we care? */
|
322 | 4046d913 | pbrook | static int gdbserver_fd = -1; |
323 | 4046d913 | pbrook | |
324 | 858693c6 | bellard | static int get_char(GDBState *s) |
325 | b4608c04 | bellard | { |
326 | b4608c04 | bellard | uint8_t ch; |
327 | b4608c04 | bellard | int ret;
|
328 | b4608c04 | bellard | |
329 | b4608c04 | bellard | for(;;) {
|
330 | 00aa0040 | Blue Swirl | ret = qemu_recv(s->fd, &ch, 1, 0); |
331 | b4608c04 | bellard | if (ret < 0) { |
332 | 1f487ee9 | edgar_igl | if (errno == ECONNRESET)
|
333 | 1f487ee9 | edgar_igl | s->fd = -1;
|
334 | b4608c04 | bellard | if (errno != EINTR && errno != EAGAIN)
|
335 | b4608c04 | bellard | return -1; |
336 | b4608c04 | bellard | } else if (ret == 0) { |
337 | 1f487ee9 | edgar_igl | close(s->fd); |
338 | 1f487ee9 | edgar_igl | s->fd = -1;
|
339 | b4608c04 | bellard | return -1; |
340 | b4608c04 | bellard | } else {
|
341 | b4608c04 | bellard | break;
|
342 | b4608c04 | bellard | } |
343 | b4608c04 | bellard | } |
344 | b4608c04 | bellard | return ch;
|
345 | b4608c04 | bellard | } |
346 | 4046d913 | pbrook | #endif
|
347 | b4608c04 | bellard | |
348 | 654efcf3 | blueswir1 | static enum { |
349 | a2d1ebaf | pbrook | GDB_SYS_UNKNOWN, |
350 | a2d1ebaf | pbrook | GDB_SYS_ENABLED, |
351 | a2d1ebaf | pbrook | GDB_SYS_DISABLED, |
352 | a2d1ebaf | pbrook | } gdb_syscall_mode; |
353 | a2d1ebaf | pbrook | |
354 | a2d1ebaf | pbrook | /* If gdb is connected when the first semihosting syscall occurs then use
|
355 | a2d1ebaf | pbrook | remote gdb syscalls. Otherwise use native file IO. */
|
356 | a2d1ebaf | pbrook | int use_gdb_syscalls(void) |
357 | a2d1ebaf | pbrook | { |
358 | a2d1ebaf | pbrook | if (gdb_syscall_mode == GDB_SYS_UNKNOWN) {
|
359 | 880a7578 | aliguori | gdb_syscall_mode = (gdbserver_state ? GDB_SYS_ENABLED |
360 | 880a7578 | aliguori | : GDB_SYS_DISABLED); |
361 | a2d1ebaf | pbrook | } |
362 | a2d1ebaf | pbrook | return gdb_syscall_mode == GDB_SYS_ENABLED;
|
363 | a2d1ebaf | pbrook | } |
364 | a2d1ebaf | pbrook | |
365 | ba70a624 | edgar_igl | /* Resume execution. */
|
366 | ba70a624 | edgar_igl | static inline void gdb_continue(GDBState *s) |
367 | ba70a624 | edgar_igl | { |
368 | ba70a624 | edgar_igl | #ifdef CONFIG_USER_ONLY
|
369 | ba70a624 | edgar_igl | s->running_state = 1;
|
370 | ba70a624 | edgar_igl | #else
|
371 | 26ac7a31 | Paolo Bonzini | if (!runstate_needs_reset()) {
|
372 | 87f25c12 | Paolo Bonzini | vm_start(); |
373 | 87f25c12 | Paolo Bonzini | } |
374 | ba70a624 | edgar_igl | #endif
|
375 | ba70a624 | edgar_igl | } |
376 | ba70a624 | edgar_igl | |
377 | 858693c6 | bellard | static void put_buffer(GDBState *s, const uint8_t *buf, int len) |
378 | b4608c04 | bellard | { |
379 | 4046d913 | pbrook | #ifdef CONFIG_USER_ONLY
|
380 | b4608c04 | bellard | int ret;
|
381 | b4608c04 | bellard | |
382 | b4608c04 | bellard | while (len > 0) { |
383 | 8f447cc7 | bellard | ret = send(s->fd, buf, len, 0);
|
384 | b4608c04 | bellard | if (ret < 0) { |
385 | b4608c04 | bellard | if (errno != EINTR && errno != EAGAIN)
|
386 | b4608c04 | bellard | return;
|
387 | b4608c04 | bellard | } else {
|
388 | b4608c04 | bellard | buf += ret; |
389 | b4608c04 | bellard | len -= ret; |
390 | b4608c04 | bellard | } |
391 | b4608c04 | bellard | } |
392 | 4046d913 | pbrook | #else
|
393 | 2cc6e0a1 | Anthony Liguori | qemu_chr_fe_write(s->chr, buf, len); |
394 | 4046d913 | pbrook | #endif
|
395 | b4608c04 | bellard | } |
396 | b4608c04 | bellard | |
397 | b4608c04 | bellard | static inline int fromhex(int v) |
398 | b4608c04 | bellard | { |
399 | b4608c04 | bellard | if (v >= '0' && v <= '9') |
400 | b4608c04 | bellard | return v - '0'; |
401 | b4608c04 | bellard | else if (v >= 'A' && v <= 'F') |
402 | b4608c04 | bellard | return v - 'A' + 10; |
403 | b4608c04 | bellard | else if (v >= 'a' && v <= 'f') |
404 | b4608c04 | bellard | return v - 'a' + 10; |
405 | b4608c04 | bellard | else
|
406 | b4608c04 | bellard | return 0; |
407 | b4608c04 | bellard | } |
408 | b4608c04 | bellard | |
409 | b4608c04 | bellard | static inline int tohex(int v) |
410 | b4608c04 | bellard | { |
411 | b4608c04 | bellard | if (v < 10) |
412 | b4608c04 | bellard | return v + '0'; |
413 | b4608c04 | bellard | else
|
414 | b4608c04 | bellard | return v - 10 + 'a'; |
415 | b4608c04 | bellard | } |
416 | b4608c04 | bellard | |
417 | b4608c04 | bellard | static void memtohex(char *buf, const uint8_t *mem, int len) |
418 | b4608c04 | bellard | { |
419 | b4608c04 | bellard | int i, c;
|
420 | b4608c04 | bellard | char *q;
|
421 | b4608c04 | bellard | q = buf; |
422 | b4608c04 | bellard | for(i = 0; i < len; i++) { |
423 | b4608c04 | bellard | c = mem[i]; |
424 | b4608c04 | bellard | *q++ = tohex(c >> 4);
|
425 | b4608c04 | bellard | *q++ = tohex(c & 0xf);
|
426 | b4608c04 | bellard | } |
427 | b4608c04 | bellard | *q = '\0';
|
428 | b4608c04 | bellard | } |
429 | b4608c04 | bellard | |
430 | b4608c04 | bellard | static void hextomem(uint8_t *mem, const char *buf, int len) |
431 | b4608c04 | bellard | { |
432 | b4608c04 | bellard | int i;
|
433 | b4608c04 | bellard | |
434 | b4608c04 | bellard | for(i = 0; i < len; i++) { |
435 | b4608c04 | bellard | mem[i] = (fromhex(buf[0]) << 4) | fromhex(buf[1]); |
436 | b4608c04 | bellard | buf += 2;
|
437 | b4608c04 | bellard | } |
438 | b4608c04 | bellard | } |
439 | b4608c04 | bellard | |
440 | b4608c04 | bellard | /* return -1 if error, 0 if OK */
|
441 | 56aebc89 | pbrook | static int put_packet_binary(GDBState *s, const char *buf, int len) |
442 | b4608c04 | bellard | { |
443 | 56aebc89 | pbrook | int csum, i;
|
444 | 60fe76f3 | ths | uint8_t *p; |
445 | b4608c04 | bellard | |
446 | b4608c04 | bellard | for(;;) {
|
447 | 4046d913 | pbrook | p = s->last_packet; |
448 | 4046d913 | pbrook | *(p++) = '$';
|
449 | 4046d913 | pbrook | memcpy(p, buf, len); |
450 | 4046d913 | pbrook | p += len; |
451 | b4608c04 | bellard | csum = 0;
|
452 | b4608c04 | bellard | for(i = 0; i < len; i++) { |
453 | b4608c04 | bellard | csum += buf[i]; |
454 | b4608c04 | bellard | } |
455 | 4046d913 | pbrook | *(p++) = '#';
|
456 | 4046d913 | pbrook | *(p++) = tohex((csum >> 4) & 0xf); |
457 | 4046d913 | pbrook | *(p++) = tohex((csum) & 0xf);
|
458 | b4608c04 | bellard | |
459 | 4046d913 | pbrook | s->last_packet_len = p - s->last_packet; |
460 | ffe8ab83 | ths | put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); |
461 | b4608c04 | bellard | |
462 | 4046d913 | pbrook | #ifdef CONFIG_USER_ONLY
|
463 | 4046d913 | pbrook | i = get_char(s); |
464 | 4046d913 | pbrook | if (i < 0) |
465 | b4608c04 | bellard | return -1; |
466 | 4046d913 | pbrook | if (i == '+') |
467 | b4608c04 | bellard | break;
|
468 | 4046d913 | pbrook | #else
|
469 | 4046d913 | pbrook | break;
|
470 | 4046d913 | pbrook | #endif
|
471 | b4608c04 | bellard | } |
472 | b4608c04 | bellard | return 0; |
473 | b4608c04 | bellard | } |
474 | b4608c04 | bellard | |
475 | 56aebc89 | pbrook | /* return -1 if error, 0 if OK */
|
476 | 56aebc89 | pbrook | static int put_packet(GDBState *s, const char *buf) |
477 | 56aebc89 | pbrook | { |
478 | 56aebc89 | pbrook | #ifdef DEBUG_GDB
|
479 | 56aebc89 | pbrook | printf("reply='%s'\n", buf);
|
480 | 56aebc89 | pbrook | #endif
|
481 | 79808573 | bellard | |
482 | 56aebc89 | pbrook | return put_packet_binary(s, buf, strlen(buf));
|
483 | 56aebc89 | pbrook | } |
484 | 56aebc89 | pbrook | |
485 | 56aebc89 | pbrook | /* Encode data using the encoding for 'x' packets. */
|
486 | 56aebc89 | pbrook | static int memtox(char *buf, const char *mem, int len) |
487 | 56aebc89 | pbrook | { |
488 | 56aebc89 | pbrook | char *p = buf;
|
489 | 56aebc89 | pbrook | char c;
|
490 | 56aebc89 | pbrook | |
491 | 56aebc89 | pbrook | while (len--) {
|
492 | 56aebc89 | pbrook | c = *(mem++); |
493 | 56aebc89 | pbrook | switch (c) {
|
494 | 56aebc89 | pbrook | case '#': case '$': case '*': case '}': |
495 | 56aebc89 | pbrook | *(p++) = '}';
|
496 | 56aebc89 | pbrook | *(p++) = c ^ 0x20;
|
497 | 56aebc89 | pbrook | break;
|
498 | 56aebc89 | pbrook | default:
|
499 | 56aebc89 | pbrook | *(p++) = c; |
500 | 56aebc89 | pbrook | break;
|
501 | 56aebc89 | pbrook | } |
502 | 56aebc89 | pbrook | } |
503 | 56aebc89 | pbrook | return p - buf;
|
504 | 56aebc89 | pbrook | } |
505 | f1ccf904 | ths | |
506 | 5b24c641 | Andreas Färber | static const char *get_feature_xml(const char *p, const char **newp, |
507 | 5b24c641 | Andreas Färber | CPUClass *cc) |
508 | 56aebc89 | pbrook | { |
509 | 56aebc89 | pbrook | size_t len; |
510 | 56aebc89 | pbrook | int i;
|
511 | 56aebc89 | pbrook | const char *name; |
512 | 56aebc89 | pbrook | static char target_xml[1024]; |
513 | 56aebc89 | pbrook | |
514 | 56aebc89 | pbrook | len = 0;
|
515 | 56aebc89 | pbrook | while (p[len] && p[len] != ':') |
516 | 56aebc89 | pbrook | len++; |
517 | 56aebc89 | pbrook | *newp = p + len; |
518 | 56aebc89 | pbrook | |
519 | 56aebc89 | pbrook | name = NULL;
|
520 | 56aebc89 | pbrook | if (strncmp(p, "target.xml", len) == 0) { |
521 | 56aebc89 | pbrook | /* Generate the XML description for this CPU. */
|
522 | 56aebc89 | pbrook | if (!target_xml[0]) { |
523 | 56aebc89 | pbrook | GDBRegisterState *r; |
524 | eac8b355 | Andreas Färber | CPUState *cpu = first_cpu; |
525 | 56aebc89 | pbrook | |
526 | 5b3715bf | blueswir1 | snprintf(target_xml, sizeof(target_xml),
|
527 | 5b3715bf | blueswir1 | "<?xml version=\"1.0\"?>"
|
528 | 5b3715bf | blueswir1 | "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
|
529 | 5b3715bf | blueswir1 | "<target>"
|
530 | 5b3715bf | blueswir1 | "<xi:include href=\"%s\"/>",
|
531 | 5b24c641 | Andreas Färber | cc->gdb_core_xml_file); |
532 | 56aebc89 | pbrook | |
533 | eac8b355 | Andreas Färber | for (r = cpu->gdb_regs; r; r = r->next) {
|
534 | 2dc766da | blueswir1 | pstrcat(target_xml, sizeof(target_xml), "<xi:include href=\""); |
535 | 2dc766da | blueswir1 | pstrcat(target_xml, sizeof(target_xml), r->xml);
|
536 | 2dc766da | blueswir1 | pstrcat(target_xml, sizeof(target_xml), "\"/>"); |
537 | 56aebc89 | pbrook | } |
538 | 2dc766da | blueswir1 | pstrcat(target_xml, sizeof(target_xml), "</target>"); |
539 | 56aebc89 | pbrook | } |
540 | 56aebc89 | pbrook | return target_xml;
|
541 | 56aebc89 | pbrook | } |
542 | 56aebc89 | pbrook | for (i = 0; ; i++) { |
543 | 56aebc89 | pbrook | name = xml_builtin[i][0];
|
544 | 56aebc89 | pbrook | if (!name || (strncmp(name, p, len) == 0 && strlen(name) == len)) |
545 | 56aebc89 | pbrook | break;
|
546 | 56aebc89 | pbrook | } |
547 | 56aebc89 | pbrook | return name ? xml_builtin[i][1] : NULL; |
548 | 56aebc89 | pbrook | } |
549 | f1ccf904 | ths | |
550 | 385b9f0e | Andreas Färber | static int gdb_read_register(CPUState *cpu, uint8_t *mem_buf, int reg) |
551 | 56aebc89 | pbrook | { |
552 | a0e372f0 | Andreas Färber | CPUClass *cc = CPU_GET_CLASS(cpu); |
553 | 385b9f0e | Andreas Färber | CPUArchState *env = cpu->env_ptr; |
554 | 56aebc89 | pbrook | GDBRegisterState *r; |
555 | f1ccf904 | ths | |
556 | a0e372f0 | Andreas Färber | if (reg < cc->gdb_num_core_regs) {
|
557 | 5b50e790 | Andreas Färber | return cc->gdb_read_register(cpu, mem_buf, reg);
|
558 | a0e372f0 | Andreas Färber | } |
559 | f1ccf904 | ths | |
560 | eac8b355 | Andreas Färber | for (r = cpu->gdb_regs; r; r = r->next) {
|
561 | 56aebc89 | pbrook | if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {
|
562 | 56aebc89 | pbrook | return r->get_reg(env, mem_buf, reg - r->base_reg);
|
563 | 56aebc89 | pbrook | } |
564 | 56aebc89 | pbrook | } |
565 | 56aebc89 | pbrook | return 0; |
566 | f1ccf904 | ths | } |
567 | f1ccf904 | ths | |
568 | 385b9f0e | Andreas Färber | static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) |
569 | f1ccf904 | ths | { |
570 | a0e372f0 | Andreas Färber | CPUClass *cc = CPU_GET_CLASS(cpu); |
571 | 385b9f0e | Andreas Färber | CPUArchState *env = cpu->env_ptr; |
572 | 56aebc89 | pbrook | GDBRegisterState *r; |
573 | f1ccf904 | ths | |
574 | a0e372f0 | Andreas Färber | if (reg < cc->gdb_num_core_regs) {
|
575 | 5b50e790 | Andreas Färber | return cc->gdb_write_register(cpu, mem_buf, reg);
|
576 | a0e372f0 | Andreas Färber | } |
577 | 56aebc89 | pbrook | |
578 | eac8b355 | Andreas Färber | for (r = cpu->gdb_regs; r; r = r->next) {
|
579 | 56aebc89 | pbrook | if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {
|
580 | 56aebc89 | pbrook | return r->set_reg(env, mem_buf, reg - r->base_reg);
|
581 | 56aebc89 | pbrook | } |
582 | 56aebc89 | pbrook | } |
583 | 6da41eaf | bellard | return 0; |
584 | 6da41eaf | bellard | } |
585 | 6da41eaf | bellard | |
586 | 56aebc89 | pbrook | /* Register a supplemental set of CPU registers. If g_pos is nonzero it
|
587 | 56aebc89 | pbrook | specifies the first register number and these registers are included in
|
588 | 56aebc89 | pbrook | a standard "g" packet. Direction is relative to gdb, i.e. get_reg is
|
589 | 56aebc89 | pbrook | gdb reading a CPU register, and set_reg is gdb modifying a CPU register.
|
590 | 56aebc89 | pbrook | */
|
591 | 56aebc89 | pbrook | |
592 | 22169d41 | Andreas Färber | void gdb_register_coprocessor(CPUState *cpu,
|
593 | 22169d41 | Andreas Färber | gdb_reg_cb get_reg, gdb_reg_cb set_reg, |
594 | 22169d41 | Andreas Färber | int num_regs, const char *xml, int g_pos) |
595 | 6da41eaf | bellard | { |
596 | 56aebc89 | pbrook | GDBRegisterState *s; |
597 | 56aebc89 | pbrook | GDBRegisterState **p; |
598 | 56aebc89 | pbrook | |
599 | eac8b355 | Andreas Färber | p = &cpu->gdb_regs; |
600 | 56aebc89 | pbrook | while (*p) {
|
601 | 56aebc89 | pbrook | /* Check for duplicates. */
|
602 | 56aebc89 | pbrook | if (strcmp((*p)->xml, xml) == 0) |
603 | 56aebc89 | pbrook | return;
|
604 | 56aebc89 | pbrook | p = &(*p)->next; |
605 | 56aebc89 | pbrook | } |
606 | 9643c25f | Stefan Weil | |
607 | 9643c25f | Stefan Weil | s = g_new0(GDBRegisterState, 1);
|
608 | a0e372f0 | Andreas Färber | s->base_reg = cpu->gdb_num_regs; |
609 | 9643c25f | Stefan Weil | s->num_regs = num_regs; |
610 | 9643c25f | Stefan Weil | s->get_reg = get_reg; |
611 | 9643c25f | Stefan Weil | s->set_reg = set_reg; |
612 | 9643c25f | Stefan Weil | s->xml = xml; |
613 | 9643c25f | Stefan Weil | |
614 | 56aebc89 | pbrook | /* Add to end of list. */
|
615 | a0e372f0 | Andreas Färber | cpu->gdb_num_regs += num_regs; |
616 | 56aebc89 | pbrook | *p = s; |
617 | 56aebc89 | pbrook | if (g_pos) {
|
618 | 56aebc89 | pbrook | if (g_pos != s->base_reg) {
|
619 | 56aebc89 | pbrook | fprintf(stderr, "Error: Bad gdb register numbering for '%s'\n"
|
620 | 56aebc89 | pbrook | "Expected %d got %d\n", xml, g_pos, s->base_reg);
|
621 | 35143f01 | Andreas Färber | } else {
|
622 | 35143f01 | Andreas Färber | cpu->gdb_num_g_regs = cpu->gdb_num_regs; |
623 | 56aebc89 | pbrook | } |
624 | 56aebc89 | pbrook | } |
625 | 6da41eaf | bellard | } |
626 | 6da41eaf | bellard | |
627 | a1d1bb31 | aliguori | #ifndef CONFIG_USER_ONLY
|
628 | a1d1bb31 | aliguori | static const int xlat_gdb_type[] = { |
629 | a1d1bb31 | aliguori | [GDB_WATCHPOINT_WRITE] = BP_GDB | BP_MEM_WRITE, |
630 | a1d1bb31 | aliguori | [GDB_WATCHPOINT_READ] = BP_GDB | BP_MEM_READ, |
631 | a1d1bb31 | aliguori | [GDB_WATCHPOINT_ACCESS] = BP_GDB | BP_MEM_ACCESS, |
632 | a1d1bb31 | aliguori | }; |
633 | a1d1bb31 | aliguori | #endif
|
634 | a1d1bb31 | aliguori | |
635 | 880a7578 | aliguori | static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type) |
636 | a1d1bb31 | aliguori | { |
637 | 182735ef | Andreas Färber | CPUState *cpu; |
638 | 9349b4f9 | Andreas Färber | CPUArchState *env; |
639 | 880a7578 | aliguori | int err = 0; |
640 | 880a7578 | aliguori | |
641 | 62278814 | Andreas Färber | if (kvm_enabled()) {
|
642 | 2e0f2cfb | Andreas Färber | return kvm_insert_breakpoint(gdbserver_state->c_cpu, addr, len, type);
|
643 | 62278814 | Andreas Färber | } |
644 | e22a25c9 | aliguori | |
645 | a1d1bb31 | aliguori | switch (type) {
|
646 | a1d1bb31 | aliguori | case GDB_BREAKPOINT_SW:
|
647 | a1d1bb31 | aliguori | case GDB_BREAKPOINT_HW:
|
648 | bdc44640 | Andreas Färber | CPU_FOREACH(cpu) { |
649 | 182735ef | Andreas Färber | env = cpu->env_ptr; |
650 | 880a7578 | aliguori | err = cpu_breakpoint_insert(env, addr, BP_GDB, NULL);
|
651 | 880a7578 | aliguori | if (err)
|
652 | 880a7578 | aliguori | break;
|
653 | 880a7578 | aliguori | } |
654 | 880a7578 | aliguori | return err;
|
655 | a1d1bb31 | aliguori | #ifndef CONFIG_USER_ONLY
|
656 | a1d1bb31 | aliguori | case GDB_WATCHPOINT_WRITE:
|
657 | a1d1bb31 | aliguori | case GDB_WATCHPOINT_READ:
|
658 | a1d1bb31 | aliguori | case GDB_WATCHPOINT_ACCESS:
|
659 | bdc44640 | Andreas Färber | CPU_FOREACH(cpu) { |
660 | 182735ef | Andreas Färber | env = cpu->env_ptr; |
661 | 880a7578 | aliguori | err = cpu_watchpoint_insert(env, addr, len, xlat_gdb_type[type], |
662 | 880a7578 | aliguori | NULL);
|
663 | 880a7578 | aliguori | if (err)
|
664 | 880a7578 | aliguori | break;
|
665 | 880a7578 | aliguori | } |
666 | 880a7578 | aliguori | return err;
|
667 | a1d1bb31 | aliguori | #endif
|
668 | a1d1bb31 | aliguori | default:
|
669 | a1d1bb31 | aliguori | return -ENOSYS;
|
670 | a1d1bb31 | aliguori | } |
671 | a1d1bb31 | aliguori | } |
672 | a1d1bb31 | aliguori | |
673 | 880a7578 | aliguori | static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type) |
674 | a1d1bb31 | aliguori | { |
675 | 182735ef | Andreas Färber | CPUState *cpu; |
676 | 9349b4f9 | Andreas Färber | CPUArchState *env; |
677 | 880a7578 | aliguori | int err = 0; |
678 | 880a7578 | aliguori | |
679 | 62278814 | Andreas Färber | if (kvm_enabled()) {
|
680 | 2e0f2cfb | Andreas Färber | return kvm_remove_breakpoint(gdbserver_state->c_cpu, addr, len, type);
|
681 | 62278814 | Andreas Färber | } |
682 | e22a25c9 | aliguori | |
683 | a1d1bb31 | aliguori | switch (type) {
|
684 | a1d1bb31 | aliguori | case GDB_BREAKPOINT_SW:
|
685 | a1d1bb31 | aliguori | case GDB_BREAKPOINT_HW:
|
686 | bdc44640 | Andreas Färber | CPU_FOREACH(cpu) { |
687 | 182735ef | Andreas Färber | env = cpu->env_ptr; |
688 | 880a7578 | aliguori | err = cpu_breakpoint_remove(env, addr, BP_GDB); |
689 | 880a7578 | aliguori | if (err)
|
690 | 880a7578 | aliguori | break;
|
691 | 880a7578 | aliguori | } |
692 | 880a7578 | aliguori | return err;
|
693 | a1d1bb31 | aliguori | #ifndef CONFIG_USER_ONLY
|
694 | a1d1bb31 | aliguori | case GDB_WATCHPOINT_WRITE:
|
695 | a1d1bb31 | aliguori | case GDB_WATCHPOINT_READ:
|
696 | a1d1bb31 | aliguori | case GDB_WATCHPOINT_ACCESS:
|
697 | bdc44640 | Andreas Färber | CPU_FOREACH(cpu) { |
698 | 182735ef | Andreas Färber | env = cpu->env_ptr; |
699 | 880a7578 | aliguori | err = cpu_watchpoint_remove(env, addr, len, xlat_gdb_type[type]); |
700 | 880a7578 | aliguori | if (err)
|
701 | 880a7578 | aliguori | break;
|
702 | 880a7578 | aliguori | } |
703 | 880a7578 | aliguori | return err;
|
704 | a1d1bb31 | aliguori | #endif
|
705 | a1d1bb31 | aliguori | default:
|
706 | a1d1bb31 | aliguori | return -ENOSYS;
|
707 | a1d1bb31 | aliguori | } |
708 | a1d1bb31 | aliguori | } |
709 | a1d1bb31 | aliguori | |
710 | 880a7578 | aliguori | static void gdb_breakpoint_remove_all(void) |
711 | a1d1bb31 | aliguori | { |
712 | 182735ef | Andreas Färber | CPUState *cpu; |
713 | 9349b4f9 | Andreas Färber | CPUArchState *env; |
714 | 880a7578 | aliguori | |
715 | e22a25c9 | aliguori | if (kvm_enabled()) {
|
716 | 2e0f2cfb | Andreas Färber | kvm_remove_all_breakpoints(gdbserver_state->c_cpu); |
717 | e22a25c9 | aliguori | return;
|
718 | e22a25c9 | aliguori | } |
719 | e22a25c9 | aliguori | |
720 | bdc44640 | Andreas Färber | CPU_FOREACH(cpu) { |
721 | 182735ef | Andreas Färber | env = cpu->env_ptr; |
722 | 880a7578 | aliguori | cpu_breakpoint_remove_all(env, BP_GDB); |
723 | a1d1bb31 | aliguori | #ifndef CONFIG_USER_ONLY
|
724 | 880a7578 | aliguori | cpu_watchpoint_remove_all(env, BP_GDB); |
725 | a1d1bb31 | aliguori | #endif
|
726 | 880a7578 | aliguori | } |
727 | a1d1bb31 | aliguori | } |
728 | a1d1bb31 | aliguori | |
729 | fab9d284 | aurel32 | static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) |
730 | fab9d284 | aurel32 | { |
731 | 2e0f2cfb | Andreas Färber | CPUState *cpu = s->c_cpu; |
732 | f45748f1 | Andreas Färber | CPUClass *cc = CPU_GET_CLASS(cpu); |
733 | f45748f1 | Andreas Färber | |
734 | f45748f1 | Andreas Färber | cpu_synchronize_state(cpu); |
735 | f45748f1 | Andreas Färber | if (cc->set_pc) {
|
736 | f45748f1 | Andreas Färber | cc->set_pc(cpu, pc); |
737 | ff1d1977 | Nathan Froyd | } |
738 | fab9d284 | aurel32 | } |
739 | fab9d284 | aurel32 | |
740 | 2e0f2cfb | Andreas Färber | static CPUState *find_cpu(uint32_t thread_id)
|
741 | 1e9fa730 | Nathan Froyd | { |
742 | 0d34282f | Andreas Färber | CPUState *cpu; |
743 | 1e9fa730 | Nathan Froyd | |
744 | bdc44640 | Andreas Färber | CPU_FOREACH(cpu) { |
745 | aa48dd93 | Andreas Färber | if (cpu_index(cpu) == thread_id) {
|
746 | 2e0f2cfb | Andreas Färber | return cpu;
|
747 | aa48dd93 | Andreas Färber | } |
748 | 1e9fa730 | Nathan Froyd | } |
749 | aa48dd93 | Andreas Färber | |
750 | aa48dd93 | Andreas Färber | return NULL; |
751 | 1e9fa730 | Nathan Froyd | } |
752 | 1e9fa730 | Nathan Froyd | |
753 | 880a7578 | aliguori | static int gdb_handle_packet(GDBState *s, const char *line_buf) |
754 | b4608c04 | bellard | { |
755 | 2e0f2cfb | Andreas Färber | CPUState *cpu; |
756 | 5b24c641 | Andreas Färber | CPUClass *cc; |
757 | b4608c04 | bellard | const char *p; |
758 | 1e9fa730 | Nathan Froyd | uint32_t thread; |
759 | 1e9fa730 | Nathan Froyd | int ch, reg_size, type, res;
|
760 | 56aebc89 | pbrook | char buf[MAX_PACKET_LENGTH];
|
761 | 56aebc89 | pbrook | uint8_t mem_buf[MAX_PACKET_LENGTH]; |
762 | 56aebc89 | pbrook | uint8_t *registers; |
763 | 9d9754a3 | bellard | target_ulong addr, len; |
764 | 3b46e624 | ths | |
765 | 858693c6 | bellard | #ifdef DEBUG_GDB
|
766 | 858693c6 | bellard | printf("command='%s'\n", line_buf);
|
767 | 858693c6 | bellard | #endif
|
768 | 858693c6 | bellard | p = line_buf; |
769 | 858693c6 | bellard | ch = *p++; |
770 | 858693c6 | bellard | switch(ch) {
|
771 | 858693c6 | bellard | case '?': |
772 | 1fddef4b | bellard | /* TODO: Make this return the correct value for user-mode. */
|
773 | ca587a8e | aurel32 | snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP, |
774 | 2e0f2cfb | Andreas Färber | cpu_index(s->c_cpu)); |
775 | 858693c6 | bellard | put_packet(s, buf); |
776 | 7d03f82f | edgar_igl | /* Remove all the breakpoints when this query is issued,
|
777 | 7d03f82f | edgar_igl | * because gdb is doing and initial connect and the state
|
778 | 7d03f82f | edgar_igl | * should be cleaned up.
|
779 | 7d03f82f | edgar_igl | */
|
780 | 880a7578 | aliguori | gdb_breakpoint_remove_all(); |
781 | 858693c6 | bellard | break;
|
782 | 858693c6 | bellard | case 'c': |
783 | 858693c6 | bellard | if (*p != '\0') { |
784 | 9d9754a3 | bellard | addr = strtoull(p, (char **)&p, 16); |
785 | fab9d284 | aurel32 | gdb_set_cpu_pc(s, addr); |
786 | 858693c6 | bellard | } |
787 | ca587a8e | aurel32 | s->signal = 0;
|
788 | ba70a624 | edgar_igl | gdb_continue(s); |
789 | 41625033 | bellard | return RS_IDLE;
|
790 | 1f487ee9 | edgar_igl | case 'C': |
791 | ca587a8e | aurel32 | s->signal = gdb_signal_to_target (strtoul(p, (char **)&p, 16)); |
792 | ca587a8e | aurel32 | if (s->signal == -1) |
793 | ca587a8e | aurel32 | s->signal = 0;
|
794 | 1f487ee9 | edgar_igl | gdb_continue(s); |
795 | 1f487ee9 | edgar_igl | return RS_IDLE;
|
796 | dd32aa10 | Jan Kiszka | case 'v': |
797 | dd32aa10 | Jan Kiszka | if (strncmp(p, "Cont", 4) == 0) { |
798 | dd32aa10 | Jan Kiszka | int res_signal, res_thread;
|
799 | dd32aa10 | Jan Kiszka | |
800 | dd32aa10 | Jan Kiszka | p += 4;
|
801 | dd32aa10 | Jan Kiszka | if (*p == '?') { |
802 | dd32aa10 | Jan Kiszka | put_packet(s, "vCont;c;C;s;S");
|
803 | dd32aa10 | Jan Kiszka | break;
|
804 | dd32aa10 | Jan Kiszka | } |
805 | dd32aa10 | Jan Kiszka | res = 0;
|
806 | dd32aa10 | Jan Kiszka | res_signal = 0;
|
807 | dd32aa10 | Jan Kiszka | res_thread = 0;
|
808 | dd32aa10 | Jan Kiszka | while (*p) {
|
809 | dd32aa10 | Jan Kiszka | int action, signal;
|
810 | dd32aa10 | Jan Kiszka | |
811 | dd32aa10 | Jan Kiszka | if (*p++ != ';') { |
812 | dd32aa10 | Jan Kiszka | res = 0;
|
813 | dd32aa10 | Jan Kiszka | break;
|
814 | dd32aa10 | Jan Kiszka | } |
815 | dd32aa10 | Jan Kiszka | action = *p++; |
816 | dd32aa10 | Jan Kiszka | signal = 0;
|
817 | dd32aa10 | Jan Kiszka | if (action == 'C' || action == 'S') { |
818 | dd32aa10 | Jan Kiszka | signal = strtoul(p, (char **)&p, 16); |
819 | dd32aa10 | Jan Kiszka | } else if (action != 'c' && action != 's') { |
820 | dd32aa10 | Jan Kiszka | res = 0;
|
821 | dd32aa10 | Jan Kiszka | break;
|
822 | dd32aa10 | Jan Kiszka | } |
823 | dd32aa10 | Jan Kiszka | thread = 0;
|
824 | dd32aa10 | Jan Kiszka | if (*p == ':') { |
825 | dd32aa10 | Jan Kiszka | thread = strtoull(p+1, (char **)&p, 16); |
826 | dd32aa10 | Jan Kiszka | } |
827 | dd32aa10 | Jan Kiszka | action = tolower(action); |
828 | dd32aa10 | Jan Kiszka | if (res == 0 || (res == 'c' && action == 's')) { |
829 | dd32aa10 | Jan Kiszka | res = action; |
830 | dd32aa10 | Jan Kiszka | res_signal = signal; |
831 | dd32aa10 | Jan Kiszka | res_thread = thread; |
832 | dd32aa10 | Jan Kiszka | } |
833 | dd32aa10 | Jan Kiszka | } |
834 | dd32aa10 | Jan Kiszka | if (res) {
|
835 | dd32aa10 | Jan Kiszka | if (res_thread != -1 && res_thread != 0) { |
836 | 2e0f2cfb | Andreas Färber | cpu = find_cpu(res_thread); |
837 | 2e0f2cfb | Andreas Färber | if (cpu == NULL) { |
838 | dd32aa10 | Jan Kiszka | put_packet(s, "E22");
|
839 | dd32aa10 | Jan Kiszka | break;
|
840 | dd32aa10 | Jan Kiszka | } |
841 | 2e0f2cfb | Andreas Färber | s->c_cpu = cpu; |
842 | dd32aa10 | Jan Kiszka | } |
843 | dd32aa10 | Jan Kiszka | if (res == 's') { |
844 | 2e0f2cfb | Andreas Färber | cpu_single_step(s->c_cpu, sstep_flags); |
845 | dd32aa10 | Jan Kiszka | } |
846 | dd32aa10 | Jan Kiszka | s->signal = res_signal; |
847 | dd32aa10 | Jan Kiszka | gdb_continue(s); |
848 | dd32aa10 | Jan Kiszka | return RS_IDLE;
|
849 | dd32aa10 | Jan Kiszka | } |
850 | dd32aa10 | Jan Kiszka | break;
|
851 | dd32aa10 | Jan Kiszka | } else {
|
852 | dd32aa10 | Jan Kiszka | goto unknown_command;
|
853 | dd32aa10 | Jan Kiszka | } |
854 | 7d03f82f | edgar_igl | case 'k': |
855 | 00e94dbc | Jan Kiszka | #ifdef CONFIG_USER_ONLY
|
856 | 7d03f82f | edgar_igl | /* Kill the target */
|
857 | 7d03f82f | edgar_igl | fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
|
858 | 7d03f82f | edgar_igl | exit(0);
|
859 | 00e94dbc | Jan Kiszka | #endif
|
860 | 7d03f82f | edgar_igl | case 'D': |
861 | 7d03f82f | edgar_igl | /* Detach packet */
|
862 | 880a7578 | aliguori | gdb_breakpoint_remove_all(); |
863 | 7ea06da3 | Daniel Gutson | gdb_syscall_mode = GDB_SYS_DISABLED; |
864 | 7d03f82f | edgar_igl | gdb_continue(s); |
865 | 7d03f82f | edgar_igl | put_packet(s, "OK");
|
866 | 7d03f82f | edgar_igl | break;
|
867 | 858693c6 | bellard | case 's': |
868 | 858693c6 | bellard | if (*p != '\0') { |
869 | 8fac5803 | ths | addr = strtoull(p, (char **)&p, 16); |
870 | fab9d284 | aurel32 | gdb_set_cpu_pc(s, addr); |
871 | 858693c6 | bellard | } |
872 | 2e0f2cfb | Andreas Färber | cpu_single_step(s->c_cpu, sstep_flags); |
873 | ba70a624 | edgar_igl | gdb_continue(s); |
874 | 41625033 | bellard | return RS_IDLE;
|
875 | a2d1ebaf | pbrook | case 'F': |
876 | a2d1ebaf | pbrook | { |
877 | a2d1ebaf | pbrook | target_ulong ret; |
878 | a2d1ebaf | pbrook | target_ulong err; |
879 | a2d1ebaf | pbrook | |
880 | a2d1ebaf | pbrook | ret = strtoull(p, (char **)&p, 16); |
881 | a2d1ebaf | pbrook | if (*p == ',') { |
882 | a2d1ebaf | pbrook | p++; |
883 | a2d1ebaf | pbrook | err = strtoull(p, (char **)&p, 16); |
884 | a2d1ebaf | pbrook | } else {
|
885 | a2d1ebaf | pbrook | err = 0;
|
886 | a2d1ebaf | pbrook | } |
887 | a2d1ebaf | pbrook | if (*p == ',') |
888 | a2d1ebaf | pbrook | p++; |
889 | a2d1ebaf | pbrook | type = *p; |
890 | cdb432b2 | Meador Inge | if (s->current_syscall_cb) {
|
891 | 2e0f2cfb | Andreas Färber | s->current_syscall_cb(s->c_cpu, ret, err); |
892 | cdb432b2 | Meador Inge | s->current_syscall_cb = NULL;
|
893 | cdb432b2 | Meador Inge | } |
894 | a2d1ebaf | pbrook | if (type == 'C') { |
895 | a2d1ebaf | pbrook | put_packet(s, "T02");
|
896 | a2d1ebaf | pbrook | } else {
|
897 | ba70a624 | edgar_igl | gdb_continue(s); |
898 | a2d1ebaf | pbrook | } |
899 | a2d1ebaf | pbrook | } |
900 | a2d1ebaf | pbrook | break;
|
901 | 858693c6 | bellard | case 'g': |
902 | 2e0f2cfb | Andreas Färber | cpu_synchronize_state(s->g_cpu); |
903 | 56aebc89 | pbrook | len = 0;
|
904 | 35143f01 | Andreas Färber | for (addr = 0; addr < s->g_cpu->gdb_num_g_regs; addr++) { |
905 | 2e0f2cfb | Andreas Färber | reg_size = gdb_read_register(s->g_cpu, mem_buf + len, addr); |
906 | 56aebc89 | pbrook | len += reg_size; |
907 | 56aebc89 | pbrook | } |
908 | 56aebc89 | pbrook | memtohex(buf, mem_buf, len); |
909 | 858693c6 | bellard | put_packet(s, buf); |
910 | 858693c6 | bellard | break;
|
911 | 858693c6 | bellard | case 'G': |
912 | 2e0f2cfb | Andreas Färber | cpu_synchronize_state(s->g_cpu); |
913 | 56aebc89 | pbrook | registers = mem_buf; |
914 | 858693c6 | bellard | len = strlen(p) / 2;
|
915 | 858693c6 | bellard | hextomem((uint8_t *)registers, p, len); |
916 | 35143f01 | Andreas Färber | for (addr = 0; addr < s->g_cpu->gdb_num_g_regs && len > 0; addr++) { |
917 | 2e0f2cfb | Andreas Färber | reg_size = gdb_write_register(s->g_cpu, registers, addr); |
918 | 56aebc89 | pbrook | len -= reg_size; |
919 | 56aebc89 | pbrook | registers += reg_size; |
920 | 56aebc89 | pbrook | } |
921 | 858693c6 | bellard | put_packet(s, "OK");
|
922 | 858693c6 | bellard | break;
|
923 | 858693c6 | bellard | case 'm': |
924 | 9d9754a3 | bellard | addr = strtoull(p, (char **)&p, 16); |
925 | 858693c6 | bellard | if (*p == ',') |
926 | 858693c6 | bellard | p++; |
927 | 9d9754a3 | bellard | len = strtoull(p, NULL, 16); |
928 | 2e0f2cfb | Andreas Färber | if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len, false) != 0) { |
929 | 6f970bd9 | bellard | put_packet (s, "E14");
|
930 | 6f970bd9 | bellard | } else {
|
931 | 6f970bd9 | bellard | memtohex(buf, mem_buf, len); |
932 | 6f970bd9 | bellard | put_packet(s, buf); |
933 | 6f970bd9 | bellard | } |
934 | 858693c6 | bellard | break;
|
935 | 858693c6 | bellard | case 'M': |
936 | 9d9754a3 | bellard | addr = strtoull(p, (char **)&p, 16); |
937 | 858693c6 | bellard | if (*p == ',') |
938 | 858693c6 | bellard | p++; |
939 | 9d9754a3 | bellard | len = strtoull(p, (char **)&p, 16); |
940 | b328f873 | bellard | if (*p == ':') |
941 | 858693c6 | bellard | p++; |
942 | 858693c6 | bellard | hextomem(mem_buf, p, len); |
943 | 2e0f2cfb | Andreas Färber | if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len,
|
944 | f3659eee | Andreas Färber | true) != 0) { |
945 | 905f20b1 | bellard | put_packet(s, "E14");
|
946 | 44520db1 | Fabien Chouteau | } else {
|
947 | 858693c6 | bellard | put_packet(s, "OK");
|
948 | 44520db1 | Fabien Chouteau | } |
949 | 858693c6 | bellard | break;
|
950 | 56aebc89 | pbrook | case 'p': |
951 | 56aebc89 | pbrook | /* Older gdb are really dumb, and don't use 'g' if 'p' is avaialable.
|
952 | 56aebc89 | pbrook | This works, but can be very slow. Anything new enough to
|
953 | 56aebc89 | pbrook | understand XML also knows how to use this properly. */
|
954 | 56aebc89 | pbrook | if (!gdb_has_xml)
|
955 | 56aebc89 | pbrook | goto unknown_command;
|
956 | 56aebc89 | pbrook | addr = strtoull(p, (char **)&p, 16); |
957 | 2e0f2cfb | Andreas Färber | reg_size = gdb_read_register(s->g_cpu, mem_buf, addr); |
958 | 56aebc89 | pbrook | if (reg_size) {
|
959 | 56aebc89 | pbrook | memtohex(buf, mem_buf, reg_size); |
960 | 56aebc89 | pbrook | put_packet(s, buf); |
961 | 56aebc89 | pbrook | } else {
|
962 | 56aebc89 | pbrook | put_packet(s, "E14");
|
963 | 56aebc89 | pbrook | } |
964 | 56aebc89 | pbrook | break;
|
965 | 56aebc89 | pbrook | case 'P': |
966 | 56aebc89 | pbrook | if (!gdb_has_xml)
|
967 | 56aebc89 | pbrook | goto unknown_command;
|
968 | 56aebc89 | pbrook | addr = strtoull(p, (char **)&p, 16); |
969 | 56aebc89 | pbrook | if (*p == '=') |
970 | 56aebc89 | pbrook | p++; |
971 | 56aebc89 | pbrook | reg_size = strlen(p) / 2;
|
972 | 56aebc89 | pbrook | hextomem(mem_buf, p, reg_size); |
973 | 2e0f2cfb | Andreas Färber | gdb_write_register(s->g_cpu, mem_buf, addr); |
974 | 56aebc89 | pbrook | put_packet(s, "OK");
|
975 | 56aebc89 | pbrook | break;
|
976 | 858693c6 | bellard | case 'Z': |
977 | 858693c6 | bellard | case 'z': |
978 | 858693c6 | bellard | type = strtoul(p, (char **)&p, 16); |
979 | 858693c6 | bellard | if (*p == ',') |
980 | 858693c6 | bellard | p++; |
981 | 9d9754a3 | bellard | addr = strtoull(p, (char **)&p, 16); |
982 | 858693c6 | bellard | if (*p == ',') |
983 | 858693c6 | bellard | p++; |
984 | 9d9754a3 | bellard | len = strtoull(p, (char **)&p, 16); |
985 | a1d1bb31 | aliguori | if (ch == 'Z') |
986 | 880a7578 | aliguori | res = gdb_breakpoint_insert(addr, len, type); |
987 | a1d1bb31 | aliguori | else
|
988 | 880a7578 | aliguori | res = gdb_breakpoint_remove(addr, len, type); |
989 | a1d1bb31 | aliguori | if (res >= 0) |
990 | a1d1bb31 | aliguori | put_packet(s, "OK");
|
991 | a1d1bb31 | aliguori | else if (res == -ENOSYS) |
992 | 0f459d16 | pbrook | put_packet(s, "");
|
993 | a1d1bb31 | aliguori | else
|
994 | a1d1bb31 | aliguori | put_packet(s, "E22");
|
995 | 858693c6 | bellard | break;
|
996 | 880a7578 | aliguori | case 'H': |
997 | 880a7578 | aliguori | type = *p++; |
998 | 880a7578 | aliguori | thread = strtoull(p, (char **)&p, 16); |
999 | 880a7578 | aliguori | if (thread == -1 || thread == 0) { |
1000 | 880a7578 | aliguori | put_packet(s, "OK");
|
1001 | 880a7578 | aliguori | break;
|
1002 | 880a7578 | aliguori | } |
1003 | 2e0f2cfb | Andreas Färber | cpu = find_cpu(thread); |
1004 | 2e0f2cfb | Andreas Färber | if (cpu == NULL) { |
1005 | 880a7578 | aliguori | put_packet(s, "E22");
|
1006 | 880a7578 | aliguori | break;
|
1007 | 880a7578 | aliguori | } |
1008 | 880a7578 | aliguori | switch (type) {
|
1009 | 880a7578 | aliguori | case 'c': |
1010 | 2e0f2cfb | Andreas Färber | s->c_cpu = cpu; |
1011 | 880a7578 | aliguori | put_packet(s, "OK");
|
1012 | 880a7578 | aliguori | break;
|
1013 | 880a7578 | aliguori | case 'g': |
1014 | 2e0f2cfb | Andreas Färber | s->g_cpu = cpu; |
1015 | 880a7578 | aliguori | put_packet(s, "OK");
|
1016 | 880a7578 | aliguori | break;
|
1017 | 880a7578 | aliguori | default:
|
1018 | 880a7578 | aliguori | put_packet(s, "E22");
|
1019 | 880a7578 | aliguori | break;
|
1020 | 880a7578 | aliguori | } |
1021 | 880a7578 | aliguori | break;
|
1022 | 880a7578 | aliguori | case 'T': |
1023 | 880a7578 | aliguori | thread = strtoull(p, (char **)&p, 16); |
1024 | 2e0f2cfb | Andreas Färber | cpu = find_cpu(thread); |
1025 | 1e9fa730 | Nathan Froyd | |
1026 | 2e0f2cfb | Andreas Färber | if (cpu != NULL) { |
1027 | 1e9fa730 | Nathan Froyd | put_packet(s, "OK");
|
1028 | 1e9fa730 | Nathan Froyd | } else {
|
1029 | 880a7578 | aliguori | put_packet(s, "E22");
|
1030 | 1e9fa730 | Nathan Froyd | } |
1031 | 880a7578 | aliguori | break;
|
1032 | 978efd6a | pbrook | case 'q': |
1033 | 60897d36 | edgar_igl | case 'Q': |
1034 | 60897d36 | edgar_igl | /* parse any 'q' packets here */
|
1035 | 60897d36 | edgar_igl | if (!strcmp(p,"qemu.sstepbits")) { |
1036 | 60897d36 | edgar_igl | /* Query Breakpoint bit definitions */
|
1037 | 363a37d5 | blueswir1 | snprintf(buf, sizeof(buf), "ENABLE=%x,NOIRQ=%x,NOTIMER=%x", |
1038 | 363a37d5 | blueswir1 | SSTEP_ENABLE, |
1039 | 363a37d5 | blueswir1 | SSTEP_NOIRQ, |
1040 | 363a37d5 | blueswir1 | SSTEP_NOTIMER); |
1041 | 60897d36 | edgar_igl | put_packet(s, buf); |
1042 | 60897d36 | edgar_igl | break;
|
1043 | 60897d36 | edgar_igl | } else if (strncmp(p,"qemu.sstep",10) == 0) { |
1044 | 60897d36 | edgar_igl | /* Display or change the sstep_flags */
|
1045 | 60897d36 | edgar_igl | p += 10;
|
1046 | 60897d36 | edgar_igl | if (*p != '=') { |
1047 | 60897d36 | edgar_igl | /* Display current setting */
|
1048 | 363a37d5 | blueswir1 | snprintf(buf, sizeof(buf), "0x%x", sstep_flags); |
1049 | 60897d36 | edgar_igl | put_packet(s, buf); |
1050 | 60897d36 | edgar_igl | break;
|
1051 | 60897d36 | edgar_igl | } |
1052 | 60897d36 | edgar_igl | p++; |
1053 | 60897d36 | edgar_igl | type = strtoul(p, (char **)&p, 16); |
1054 | 60897d36 | edgar_igl | sstep_flags = type; |
1055 | 60897d36 | edgar_igl | put_packet(s, "OK");
|
1056 | 60897d36 | edgar_igl | break;
|
1057 | 880a7578 | aliguori | } else if (strcmp(p,"C") == 0) { |
1058 | 880a7578 | aliguori | /* "Current thread" remains vague in the spec, so always return
|
1059 | 880a7578 | aliguori | * the first CPU (gdb returns the first thread). */
|
1060 | 880a7578 | aliguori | put_packet(s, "QC1");
|
1061 | 880a7578 | aliguori | break;
|
1062 | 880a7578 | aliguori | } else if (strcmp(p,"fThreadInfo") == 0) { |
1063 | 52f34623 | Andreas Färber | s->query_cpu = first_cpu; |
1064 | 880a7578 | aliguori | goto report_cpuinfo;
|
1065 | 880a7578 | aliguori | } else if (strcmp(p,"sThreadInfo") == 0) { |
1066 | 880a7578 | aliguori | report_cpuinfo:
|
1067 | 880a7578 | aliguori | if (s->query_cpu) {
|
1068 | 52f34623 | Andreas Färber | snprintf(buf, sizeof(buf), "m%x", cpu_index(s->query_cpu)); |
1069 | 880a7578 | aliguori | put_packet(s, buf); |
1070 | bdc44640 | Andreas Färber | s->query_cpu = CPU_NEXT(s->query_cpu); |
1071 | 880a7578 | aliguori | } else
|
1072 | 880a7578 | aliguori | put_packet(s, "l");
|
1073 | 880a7578 | aliguori | break;
|
1074 | 880a7578 | aliguori | } else if (strncmp(p,"ThreadExtraInfo,", 16) == 0) { |
1075 | 880a7578 | aliguori | thread = strtoull(p+16, (char **)&p, 16); |
1076 | 2e0f2cfb | Andreas Färber | cpu = find_cpu(thread); |
1077 | 2e0f2cfb | Andreas Färber | if (cpu != NULL) { |
1078 | cb446eca | Andreas Färber | cpu_synchronize_state(cpu); |
1079 | 1e9fa730 | Nathan Froyd | len = snprintf((char *)mem_buf, sizeof(mem_buf), |
1080 | 55e5c285 | Andreas Färber | "CPU#%d [%s]", cpu->cpu_index,
|
1081 | 259186a7 | Andreas Färber | cpu->halted ? "halted " : "running"); |
1082 | 1e9fa730 | Nathan Froyd | memtohex(buf, mem_buf, len); |
1083 | 1e9fa730 | Nathan Froyd | put_packet(s, buf); |
1084 | 1e9fa730 | Nathan Froyd | } |
1085 | 880a7578 | aliguori | break;
|
1086 | 60897d36 | edgar_igl | } |
1087 | 0b8a988c | blueswir1 | #ifdef CONFIG_USER_ONLY
|
1088 | 60897d36 | edgar_igl | else if (strncmp(p, "Offsets", 7) == 0) { |
1089 | 2e0f2cfb | Andreas Färber | CPUArchState *env = s->c_cpu->env_ptr; |
1090 | 2e0f2cfb | Andreas Färber | TaskState *ts = env->opaque; |
1091 | 978efd6a | pbrook | |
1092 | 363a37d5 | blueswir1 | snprintf(buf, sizeof(buf),
|
1093 | 363a37d5 | blueswir1 | "Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx |
1094 | 363a37d5 | blueswir1 | ";Bss=" TARGET_ABI_FMT_lx,
|
1095 | 363a37d5 | blueswir1 | ts->info->code_offset, |
1096 | 363a37d5 | blueswir1 | ts->info->data_offset, |
1097 | 363a37d5 | blueswir1 | ts->info->data_offset); |
1098 | 978efd6a | pbrook | put_packet(s, buf); |
1099 | 978efd6a | pbrook | break;
|
1100 | 978efd6a | pbrook | } |
1101 | 0b8a988c | blueswir1 | #else /* !CONFIG_USER_ONLY */ |
1102 | 8a34a0fb | aliguori | else if (strncmp(p, "Rcmd,", 5) == 0) { |
1103 | 8a34a0fb | aliguori | int len = strlen(p + 5); |
1104 | 8a34a0fb | aliguori | |
1105 | 8a34a0fb | aliguori | if ((len % 2) != 0) { |
1106 | 8a34a0fb | aliguori | put_packet(s, "E01");
|
1107 | 8a34a0fb | aliguori | break;
|
1108 | 8a34a0fb | aliguori | } |
1109 | 8a34a0fb | aliguori | hextomem(mem_buf, p + 5, len);
|
1110 | 8a34a0fb | aliguori | len = len / 2;
|
1111 | 8a34a0fb | aliguori | mem_buf[len++] = 0;
|
1112 | fa5efccb | Anthony Liguori | qemu_chr_be_write(s->mon_chr, mem_buf, len); |
1113 | 8a34a0fb | aliguori | put_packet(s, "OK");
|
1114 | 8a34a0fb | aliguori | break;
|
1115 | 8a34a0fb | aliguori | } |
1116 | 0b8a988c | blueswir1 | #endif /* !CONFIG_USER_ONLY */ |
1117 | 56aebc89 | pbrook | if (strncmp(p, "Supported", 9) == 0) { |
1118 | 5b3715bf | blueswir1 | snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH); |
1119 | 5b24c641 | Andreas Färber | cc = CPU_GET_CLASS(first_cpu); |
1120 | 5b24c641 | Andreas Färber | if (cc->gdb_core_xml_file != NULL) { |
1121 | 5b24c641 | Andreas Färber | pstrcat(buf, sizeof(buf), ";qXfer:features:read+"); |
1122 | 5b24c641 | Andreas Färber | } |
1123 | 56aebc89 | pbrook | put_packet(s, buf); |
1124 | 56aebc89 | pbrook | break;
|
1125 | 56aebc89 | pbrook | } |
1126 | 56aebc89 | pbrook | if (strncmp(p, "Xfer:features:read:", 19) == 0) { |
1127 | 56aebc89 | pbrook | const char *xml; |
1128 | 56aebc89 | pbrook | target_ulong total_len; |
1129 | 56aebc89 | pbrook | |
1130 | 5b24c641 | Andreas Färber | cc = CPU_GET_CLASS(first_cpu); |
1131 | 5b24c641 | Andreas Färber | if (cc->gdb_core_xml_file == NULL) { |
1132 | 5b24c641 | Andreas Färber | goto unknown_command;
|
1133 | 5b24c641 | Andreas Färber | } |
1134 | 5b24c641 | Andreas Färber | |
1135 | 5b50e790 | Andreas Färber | gdb_has_xml = true;
|
1136 | 56aebc89 | pbrook | p += 19;
|
1137 | 5b24c641 | Andreas Färber | xml = get_feature_xml(p, &p, cc); |
1138 | 56aebc89 | pbrook | if (!xml) {
|
1139 | 5b3715bf | blueswir1 | snprintf(buf, sizeof(buf), "E00"); |
1140 | 56aebc89 | pbrook | put_packet(s, buf); |
1141 | 56aebc89 | pbrook | break;
|
1142 | 56aebc89 | pbrook | } |
1143 | 56aebc89 | pbrook | |
1144 | 56aebc89 | pbrook | if (*p == ':') |
1145 | 56aebc89 | pbrook | p++; |
1146 | 56aebc89 | pbrook | addr = strtoul(p, (char **)&p, 16); |
1147 | 56aebc89 | pbrook | if (*p == ',') |
1148 | 56aebc89 | pbrook | p++; |
1149 | 56aebc89 | pbrook | len = strtoul(p, (char **)&p, 16); |
1150 | 56aebc89 | pbrook | |
1151 | 56aebc89 | pbrook | total_len = strlen(xml); |
1152 | 56aebc89 | pbrook | if (addr > total_len) {
|
1153 | 5b3715bf | blueswir1 | snprintf(buf, sizeof(buf), "E00"); |
1154 | 56aebc89 | pbrook | put_packet(s, buf); |
1155 | 56aebc89 | pbrook | break;
|
1156 | 56aebc89 | pbrook | } |
1157 | 56aebc89 | pbrook | if (len > (MAX_PACKET_LENGTH - 5) / 2) |
1158 | 56aebc89 | pbrook | len = (MAX_PACKET_LENGTH - 5) / 2; |
1159 | 56aebc89 | pbrook | if (len < total_len - addr) {
|
1160 | 56aebc89 | pbrook | buf[0] = 'm'; |
1161 | 56aebc89 | pbrook | len = memtox(buf + 1, xml + addr, len);
|
1162 | 56aebc89 | pbrook | } else {
|
1163 | 56aebc89 | pbrook | buf[0] = 'l'; |
1164 | 56aebc89 | pbrook | len = memtox(buf + 1, xml + addr, total_len - addr);
|
1165 | 56aebc89 | pbrook | } |
1166 | 56aebc89 | pbrook | put_packet_binary(s, buf, len + 1);
|
1167 | 56aebc89 | pbrook | break;
|
1168 | 56aebc89 | pbrook | } |
1169 | 56aebc89 | pbrook | /* Unrecognised 'q' command. */
|
1170 | 56aebc89 | pbrook | goto unknown_command;
|
1171 | 56aebc89 | pbrook | |
1172 | 858693c6 | bellard | default:
|
1173 | 56aebc89 | pbrook | unknown_command:
|
1174 | 858693c6 | bellard | /* put empty packet */
|
1175 | 858693c6 | bellard | buf[0] = '\0'; |
1176 | 858693c6 | bellard | put_packet(s, buf); |
1177 | 858693c6 | bellard | break;
|
1178 | 858693c6 | bellard | } |
1179 | 858693c6 | bellard | return RS_IDLE;
|
1180 | 858693c6 | bellard | } |
1181 | 858693c6 | bellard | |
1182 | 64f6b346 | Andreas Färber | void gdb_set_stop_cpu(CPUState *cpu)
|
1183 | 880a7578 | aliguori | { |
1184 | 2e0f2cfb | Andreas Färber | gdbserver_state->c_cpu = cpu; |
1185 | 2e0f2cfb | Andreas Färber | gdbserver_state->g_cpu = cpu; |
1186 | 880a7578 | aliguori | } |
1187 | 880a7578 | aliguori | |
1188 | 1fddef4b | bellard | #ifndef CONFIG_USER_ONLY
|
1189 | 1dfb4dd9 | Luiz Capitulino | static void gdb_vm_state_change(void *opaque, int running, RunState state) |
1190 | 858693c6 | bellard | { |
1191 | 880a7578 | aliguori | GDBState *s = gdbserver_state; |
1192 | 2e0f2cfb | Andreas Färber | CPUArchState *env = s->c_cpu->env_ptr; |
1193 | 2e0f2cfb | Andreas Färber | CPUState *cpu = s->c_cpu; |
1194 | 858693c6 | bellard | char buf[256]; |
1195 | d6fc1b39 | aliguori | const char *type; |
1196 | 858693c6 | bellard | int ret;
|
1197 | 858693c6 | bellard | |
1198 | cdb432b2 | Meador Inge | if (running || s->state == RS_INACTIVE) {
|
1199 | cdb432b2 | Meador Inge | return;
|
1200 | cdb432b2 | Meador Inge | } |
1201 | cdb432b2 | Meador Inge | /* Is there a GDB syscall waiting to be sent? */
|
1202 | cdb432b2 | Meador Inge | if (s->current_syscall_cb) {
|
1203 | cdb432b2 | Meador Inge | put_packet(s, s->syscall_buf); |
1204 | a2d1ebaf | pbrook | return;
|
1205 | e07bbac5 | Jan Kiszka | } |
1206 | 1dfb4dd9 | Luiz Capitulino | switch (state) {
|
1207 | 0461d5a6 | Luiz Capitulino | case RUN_STATE_DEBUG:
|
1208 | 880a7578 | aliguori | if (env->watchpoint_hit) {
|
1209 | 880a7578 | aliguori | switch (env->watchpoint_hit->flags & BP_MEM_ACCESS) {
|
1210 | a1d1bb31 | aliguori | case BP_MEM_READ:
|
1211 | d6fc1b39 | aliguori | type = "r";
|
1212 | d6fc1b39 | aliguori | break;
|
1213 | a1d1bb31 | aliguori | case BP_MEM_ACCESS:
|
1214 | d6fc1b39 | aliguori | type = "a";
|
1215 | d6fc1b39 | aliguori | break;
|
1216 | d6fc1b39 | aliguori | default:
|
1217 | d6fc1b39 | aliguori | type = "";
|
1218 | d6fc1b39 | aliguori | break;
|
1219 | d6fc1b39 | aliguori | } |
1220 | 880a7578 | aliguori | snprintf(buf, sizeof(buf),
|
1221 | 880a7578 | aliguori | "T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";", |
1222 | 0d34282f | Andreas Färber | GDB_SIGNAL_TRAP, cpu_index(cpu), type, |
1223 | 880a7578 | aliguori | env->watchpoint_hit->vaddr); |
1224 | 880a7578 | aliguori | env->watchpoint_hit = NULL;
|
1225 | 425189a8 | Jan Kiszka | goto send_packet;
|
1226 | 6658ffb8 | pbrook | } |
1227 | 425189a8 | Jan Kiszka | tb_flush(env); |
1228 | ca587a8e | aurel32 | ret = GDB_SIGNAL_TRAP; |
1229 | 425189a8 | Jan Kiszka | break;
|
1230 | 0461d5a6 | Luiz Capitulino | case RUN_STATE_PAUSED:
|
1231 | 9781e040 | aliguori | ret = GDB_SIGNAL_INT; |
1232 | 425189a8 | Jan Kiszka | break;
|
1233 | 0461d5a6 | Luiz Capitulino | case RUN_STATE_SHUTDOWN:
|
1234 | 425189a8 | Jan Kiszka | ret = GDB_SIGNAL_QUIT; |
1235 | 425189a8 | Jan Kiszka | break;
|
1236 | 0461d5a6 | Luiz Capitulino | case RUN_STATE_IO_ERROR:
|
1237 | 425189a8 | Jan Kiszka | ret = GDB_SIGNAL_IO; |
1238 | 425189a8 | Jan Kiszka | break;
|
1239 | 0461d5a6 | Luiz Capitulino | case RUN_STATE_WATCHDOG:
|
1240 | 425189a8 | Jan Kiszka | ret = GDB_SIGNAL_ALRM; |
1241 | 425189a8 | Jan Kiszka | break;
|
1242 | 0461d5a6 | Luiz Capitulino | case RUN_STATE_INTERNAL_ERROR:
|
1243 | 425189a8 | Jan Kiszka | ret = GDB_SIGNAL_ABRT; |
1244 | 425189a8 | Jan Kiszka | break;
|
1245 | 0461d5a6 | Luiz Capitulino | case RUN_STATE_SAVE_VM:
|
1246 | 0461d5a6 | Luiz Capitulino | case RUN_STATE_RESTORE_VM:
|
1247 | 425189a8 | Jan Kiszka | return;
|
1248 | 0461d5a6 | Luiz Capitulino | case RUN_STATE_FINISH_MIGRATE:
|
1249 | 425189a8 | Jan Kiszka | ret = GDB_SIGNAL_XCPU; |
1250 | 425189a8 | Jan Kiszka | break;
|
1251 | 425189a8 | Jan Kiszka | default:
|
1252 | 425189a8 | Jan Kiszka | ret = GDB_SIGNAL_UNKNOWN; |
1253 | 425189a8 | Jan Kiszka | break;
|
1254 | bbeb7b5c | bellard | } |
1255 | 0d34282f | Andreas Färber | snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_index(cpu)); |
1256 | 425189a8 | Jan Kiszka | |
1257 | 425189a8 | Jan Kiszka | send_packet:
|
1258 | 858693c6 | bellard | put_packet(s, buf); |
1259 | 425189a8 | Jan Kiszka | |
1260 | 425189a8 | Jan Kiszka | /* disable single step if it was enabled */
|
1261 | 3825b28f | Andreas Färber | cpu_single_step(cpu, 0);
|
1262 | 858693c6 | bellard | } |
1263 | 1fddef4b | bellard | #endif
|
1264 | 858693c6 | bellard | |
1265 | a2d1ebaf | pbrook | /* Send a gdb syscall request.
|
1266 | a2d1ebaf | pbrook | This accepts limited printf-style format specifiers, specifically:
|
1267 | a87295e8 | pbrook | %x - target_ulong argument printed in hex.
|
1268 | a87295e8 | pbrook | %lx - 64-bit argument printed in hex.
|
1269 | a87295e8 | pbrook | %s - string pointer (target_ulong) and length (int) pair. */
|
1270 | 7ccfb2eb | blueswir1 | void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) |
1271 | a2d1ebaf | pbrook | { |
1272 | a2d1ebaf | pbrook | va_list va; |
1273 | a2d1ebaf | pbrook | char *p;
|
1274 | cdb432b2 | Meador Inge | char *p_end;
|
1275 | a2d1ebaf | pbrook | target_ulong addr; |
1276 | a87295e8 | pbrook | uint64_t i64; |
1277 | a2d1ebaf | pbrook | GDBState *s; |
1278 | a2d1ebaf | pbrook | |
1279 | 880a7578 | aliguori | s = gdbserver_state; |
1280 | a2d1ebaf | pbrook | if (!s)
|
1281 | a2d1ebaf | pbrook | return;
|
1282 | cdb432b2 | Meador Inge | s->current_syscall_cb = cb; |
1283 | a2d1ebaf | pbrook | #ifndef CONFIG_USER_ONLY
|
1284 | 0461d5a6 | Luiz Capitulino | vm_stop(RUN_STATE_DEBUG); |
1285 | a2d1ebaf | pbrook | #endif
|
1286 | a2d1ebaf | pbrook | va_start(va, fmt); |
1287 | cdb432b2 | Meador Inge | p = s->syscall_buf; |
1288 | cdb432b2 | Meador Inge | p_end = &s->syscall_buf[sizeof(s->syscall_buf)];
|
1289 | a2d1ebaf | pbrook | *(p++) = 'F';
|
1290 | a2d1ebaf | pbrook | while (*fmt) {
|
1291 | a2d1ebaf | pbrook | if (*fmt == '%') { |
1292 | a2d1ebaf | pbrook | fmt++; |
1293 | a2d1ebaf | pbrook | switch (*fmt++) {
|
1294 | a2d1ebaf | pbrook | case 'x': |
1295 | a2d1ebaf | pbrook | addr = va_arg(va, target_ulong); |
1296 | cdb432b2 | Meador Inge | p += snprintf(p, p_end - p, TARGET_FMT_lx, addr); |
1297 | a2d1ebaf | pbrook | break;
|
1298 | a87295e8 | pbrook | case 'l': |
1299 | a87295e8 | pbrook | if (*(fmt++) != 'x') |
1300 | a87295e8 | pbrook | goto bad_format;
|
1301 | a87295e8 | pbrook | i64 = va_arg(va, uint64_t); |
1302 | cdb432b2 | Meador Inge | p += snprintf(p, p_end - p, "%" PRIx64, i64);
|
1303 | a87295e8 | pbrook | break;
|
1304 | a2d1ebaf | pbrook | case 's': |
1305 | a2d1ebaf | pbrook | addr = va_arg(va, target_ulong); |
1306 | cdb432b2 | Meador Inge | p += snprintf(p, p_end - p, TARGET_FMT_lx "/%x",
|
1307 | 363a37d5 | blueswir1 | addr, va_arg(va, int));
|
1308 | a2d1ebaf | pbrook | break;
|
1309 | a2d1ebaf | pbrook | default:
|
1310 | a87295e8 | pbrook | bad_format:
|
1311 | a2d1ebaf | pbrook | fprintf(stderr, "gdbstub: Bad syscall format string '%s'\n",
|
1312 | a2d1ebaf | pbrook | fmt - 1);
|
1313 | a2d1ebaf | pbrook | break;
|
1314 | a2d1ebaf | pbrook | } |
1315 | a2d1ebaf | pbrook | } else {
|
1316 | a2d1ebaf | pbrook | *(p++) = *(fmt++); |
1317 | a2d1ebaf | pbrook | } |
1318 | a2d1ebaf | pbrook | } |
1319 | 8a93e02a | pbrook | *p = 0;
|
1320 | a2d1ebaf | pbrook | va_end(va); |
1321 | a2d1ebaf | pbrook | #ifdef CONFIG_USER_ONLY
|
1322 | cdb432b2 | Meador Inge | put_packet(s, s->syscall_buf); |
1323 | 2e0f2cfb | Andreas Färber | gdb_handlesig(s->c_cpu, 0);
|
1324 | a2d1ebaf | pbrook | #else
|
1325 | cdb432b2 | Meador Inge | /* In this case wait to send the syscall packet until notification that
|
1326 | cdb432b2 | Meador Inge | the CPU has stopped. This must be done because if the packet is sent
|
1327 | cdb432b2 | Meador Inge | now the reply from the syscall request could be received while the CPU
|
1328 | cdb432b2 | Meador Inge | is still in the running state, which can cause packets to be dropped
|
1329 | cdb432b2 | Meador Inge | and state transition 'T' packets to be sent while the syscall is still
|
1330 | cdb432b2 | Meador Inge | being processed. */
|
1331 | 2e0f2cfb | Andreas Färber | cpu_exit(s->c_cpu); |
1332 | a2d1ebaf | pbrook | #endif
|
1333 | a2d1ebaf | pbrook | } |
1334 | a2d1ebaf | pbrook | |
1335 | 6a00d601 | bellard | static void gdb_read_byte(GDBState *s, int ch) |
1336 | 858693c6 | bellard | { |
1337 | 858693c6 | bellard | int i, csum;
|
1338 | 60fe76f3 | ths | uint8_t reply; |
1339 | 858693c6 | bellard | |
1340 | 1fddef4b | bellard | #ifndef CONFIG_USER_ONLY
|
1341 | 4046d913 | pbrook | if (s->last_packet_len) {
|
1342 | 4046d913 | pbrook | /* Waiting for a response to the last packet. If we see the start
|
1343 | 4046d913 | pbrook | of a new command then abandon the previous response. */
|
1344 | 4046d913 | pbrook | if (ch == '-') { |
1345 | 4046d913 | pbrook | #ifdef DEBUG_GDB
|
1346 | 4046d913 | pbrook | printf("Got NACK, retransmitting\n");
|
1347 | 4046d913 | pbrook | #endif
|
1348 | ffe8ab83 | ths | put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); |
1349 | 4046d913 | pbrook | } |
1350 | 4046d913 | pbrook | #ifdef DEBUG_GDB
|
1351 | 4046d913 | pbrook | else if (ch == '+') |
1352 | 4046d913 | pbrook | printf("Got ACK\n");
|
1353 | 4046d913 | pbrook | else
|
1354 | 4046d913 | pbrook | printf("Got '%c' when expecting ACK/NACK\n", ch);
|
1355 | 4046d913 | pbrook | #endif
|
1356 | 4046d913 | pbrook | if (ch == '+' || ch == '$') |
1357 | 4046d913 | pbrook | s->last_packet_len = 0;
|
1358 | 4046d913 | pbrook | if (ch != '$') |
1359 | 4046d913 | pbrook | return;
|
1360 | 4046d913 | pbrook | } |
1361 | 1354869c | Luiz Capitulino | if (runstate_is_running()) {
|
1362 | 858693c6 | bellard | /* when the CPU is running, we cannot do anything except stop
|
1363 | 858693c6 | bellard | it when receiving a char */
|
1364 | 0461d5a6 | Luiz Capitulino | vm_stop(RUN_STATE_PAUSED); |
1365 | 5fafdf24 | ths | } else
|
1366 | 1fddef4b | bellard | #endif
|
1367 | 41625033 | bellard | { |
1368 | 858693c6 | bellard | switch(s->state) {
|
1369 | 858693c6 | bellard | case RS_IDLE:
|
1370 | 858693c6 | bellard | if (ch == '$') { |
1371 | 858693c6 | bellard | s->line_buf_index = 0;
|
1372 | 858693c6 | bellard | s->state = RS_GETLINE; |
1373 | c33a346e | bellard | } |
1374 | b4608c04 | bellard | break;
|
1375 | 858693c6 | bellard | case RS_GETLINE:
|
1376 | 858693c6 | bellard | if (ch == '#') { |
1377 | 858693c6 | bellard | s->state = RS_CHKSUM1; |
1378 | 858693c6 | bellard | } else if (s->line_buf_index >= sizeof(s->line_buf) - 1) { |
1379 | 858693c6 | bellard | s->state = RS_IDLE; |
1380 | 4c3a88a2 | bellard | } else {
|
1381 | 858693c6 | bellard | s->line_buf[s->line_buf_index++] = ch; |
1382 | 4c3a88a2 | bellard | } |
1383 | 4c3a88a2 | bellard | break;
|
1384 | 858693c6 | bellard | case RS_CHKSUM1:
|
1385 | 858693c6 | bellard | s->line_buf[s->line_buf_index] = '\0';
|
1386 | 858693c6 | bellard | s->line_csum = fromhex(ch) << 4;
|
1387 | 858693c6 | bellard | s->state = RS_CHKSUM2; |
1388 | 858693c6 | bellard | break;
|
1389 | 858693c6 | bellard | case RS_CHKSUM2:
|
1390 | 858693c6 | bellard | s->line_csum |= fromhex(ch); |
1391 | 858693c6 | bellard | csum = 0;
|
1392 | 858693c6 | bellard | for(i = 0; i < s->line_buf_index; i++) { |
1393 | 858693c6 | bellard | csum += s->line_buf[i]; |
1394 | 858693c6 | bellard | } |
1395 | 858693c6 | bellard | if (s->line_csum != (csum & 0xff)) { |
1396 | 60fe76f3 | ths | reply = '-';
|
1397 | 60fe76f3 | ths | put_buffer(s, &reply, 1);
|
1398 | 858693c6 | bellard | s->state = RS_IDLE; |
1399 | 4c3a88a2 | bellard | } else {
|
1400 | 60fe76f3 | ths | reply = '+';
|
1401 | 60fe76f3 | ths | put_buffer(s, &reply, 1);
|
1402 | 880a7578 | aliguori | s->state = gdb_handle_packet(s, s->line_buf); |
1403 | 4c3a88a2 | bellard | } |
1404 | 4c3a88a2 | bellard | break;
|
1405 | a2d1ebaf | pbrook | default:
|
1406 | a2d1ebaf | pbrook | abort(); |
1407 | 858693c6 | bellard | } |
1408 | 858693c6 | bellard | } |
1409 | 858693c6 | bellard | } |
1410 | 858693c6 | bellard | |
1411 | 0e1c9c54 | Paul Brook | /* Tell the remote gdb that the process has exited. */
|
1412 | 9349b4f9 | Andreas Färber | void gdb_exit(CPUArchState *env, int code) |
1413 | 0e1c9c54 | Paul Brook | { |
1414 | 0e1c9c54 | Paul Brook | GDBState *s; |
1415 | 0e1c9c54 | Paul Brook | char buf[4]; |
1416 | 0e1c9c54 | Paul Brook | |
1417 | 0e1c9c54 | Paul Brook | s = gdbserver_state; |
1418 | 0e1c9c54 | Paul Brook | if (!s) {
|
1419 | 0e1c9c54 | Paul Brook | return;
|
1420 | 0e1c9c54 | Paul Brook | } |
1421 | 0e1c9c54 | Paul Brook | #ifdef CONFIG_USER_ONLY
|
1422 | 0e1c9c54 | Paul Brook | if (gdbserver_fd < 0 || s->fd < 0) { |
1423 | 0e1c9c54 | Paul Brook | return;
|
1424 | 0e1c9c54 | Paul Brook | } |
1425 | 0e1c9c54 | Paul Brook | #endif
|
1426 | 0e1c9c54 | Paul Brook | |
1427 | 0e1c9c54 | Paul Brook | snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); |
1428 | 0e1c9c54 | Paul Brook | put_packet(s, buf); |
1429 | e2af15b2 | Fabien Chouteau | |
1430 | e2af15b2 | Fabien Chouteau | #ifndef CONFIG_USER_ONLY
|
1431 | e2af15b2 | Fabien Chouteau | if (s->chr) {
|
1432 | 70f24fb6 | Anthony Liguori | qemu_chr_delete(s->chr); |
1433 | e2af15b2 | Fabien Chouteau | } |
1434 | e2af15b2 | Fabien Chouteau | #endif
|
1435 | 0e1c9c54 | Paul Brook | } |
1436 | 0e1c9c54 | Paul Brook | |
1437 | 1fddef4b | bellard | #ifdef CONFIG_USER_ONLY
|
1438 | 1fddef4b | bellard | int
|
1439 | ca587a8e | aurel32 | gdb_queuesig (void)
|
1440 | ca587a8e | aurel32 | { |
1441 | ca587a8e | aurel32 | GDBState *s; |
1442 | ca587a8e | aurel32 | |
1443 | ca587a8e | aurel32 | s = gdbserver_state; |
1444 | ca587a8e | aurel32 | |
1445 | ca587a8e | aurel32 | if (gdbserver_fd < 0 || s->fd < 0) |
1446 | ca587a8e | aurel32 | return 0; |
1447 | ca587a8e | aurel32 | else
|
1448 | ca587a8e | aurel32 | return 1; |
1449 | ca587a8e | aurel32 | } |
1450 | ca587a8e | aurel32 | |
1451 | ca587a8e | aurel32 | int
|
1452 | db6b81d4 | Andreas Färber | gdb_handlesig(CPUState *cpu, int sig)
|
1453 | 1fddef4b | bellard | { |
1454 | db6b81d4 | Andreas Färber | CPUArchState *env = cpu->env_ptr; |
1455 | 5ca666c7 | Andreas Färber | GDBState *s; |
1456 | 5ca666c7 | Andreas Färber | char buf[256]; |
1457 | 5ca666c7 | Andreas Färber | int n;
|
1458 | 1fddef4b | bellard | |
1459 | 5ca666c7 | Andreas Färber | s = gdbserver_state; |
1460 | 5ca666c7 | Andreas Färber | if (gdbserver_fd < 0 || s->fd < 0) { |
1461 | 5ca666c7 | Andreas Färber | return sig;
|
1462 | 5ca666c7 | Andreas Färber | } |
1463 | 1fddef4b | bellard | |
1464 | 5ca666c7 | Andreas Färber | /* disable single step if it was enabled */
|
1465 | 3825b28f | Andreas Färber | cpu_single_step(cpu, 0);
|
1466 | 5ca666c7 | Andreas Färber | tb_flush(env); |
1467 | 1fddef4b | bellard | |
1468 | 5ca666c7 | Andreas Färber | if (sig != 0) { |
1469 | 5ca666c7 | Andreas Färber | snprintf(buf, sizeof(buf), "S%02x", target_signal_to_gdb(sig)); |
1470 | 5ca666c7 | Andreas Färber | put_packet(s, buf); |
1471 | 5ca666c7 | Andreas Färber | } |
1472 | 5ca666c7 | Andreas Färber | /* put_packet() might have detected that the peer terminated the
|
1473 | 5ca666c7 | Andreas Färber | connection. */
|
1474 | 5ca666c7 | Andreas Färber | if (s->fd < 0) { |
1475 | 5ca666c7 | Andreas Färber | return sig;
|
1476 | 5ca666c7 | Andreas Färber | } |
1477 | 1fddef4b | bellard | |
1478 | 5ca666c7 | Andreas Färber | sig = 0;
|
1479 | 5ca666c7 | Andreas Färber | s->state = RS_IDLE; |
1480 | 5ca666c7 | Andreas Färber | s->running_state = 0;
|
1481 | 5ca666c7 | Andreas Färber | while (s->running_state == 0) { |
1482 | 5ca666c7 | Andreas Färber | n = read(s->fd, buf, 256);
|
1483 | 5ca666c7 | Andreas Färber | if (n > 0) { |
1484 | 5ca666c7 | Andreas Färber | int i;
|
1485 | 5ca666c7 | Andreas Färber | |
1486 | 5ca666c7 | Andreas Färber | for (i = 0; i < n; i++) { |
1487 | 5ca666c7 | Andreas Färber | gdb_read_byte(s, buf[i]); |
1488 | 5ca666c7 | Andreas Färber | } |
1489 | 5ca666c7 | Andreas Färber | } else if (n == 0 || errno != EAGAIN) { |
1490 | 5ca666c7 | Andreas Färber | /* XXX: Connection closed. Should probably wait for another
|
1491 | 5ca666c7 | Andreas Färber | connection before continuing. */
|
1492 | 5ca666c7 | Andreas Färber | return sig;
|
1493 | 1fddef4b | bellard | } |
1494 | 5ca666c7 | Andreas Färber | } |
1495 | 5ca666c7 | Andreas Färber | sig = s->signal; |
1496 | 5ca666c7 | Andreas Färber | s->signal = 0;
|
1497 | 5ca666c7 | Andreas Färber | return sig;
|
1498 | 1fddef4b | bellard | } |
1499 | e9009676 | bellard | |
1500 | ca587a8e | aurel32 | /* Tell the remote gdb that the process has exited due to SIG. */
|
1501 | 9349b4f9 | Andreas Färber | void gdb_signalled(CPUArchState *env, int sig) |
1502 | ca587a8e | aurel32 | { |
1503 | 5ca666c7 | Andreas Färber | GDBState *s; |
1504 | 5ca666c7 | Andreas Färber | char buf[4]; |
1505 | ca587a8e | aurel32 | |
1506 | 5ca666c7 | Andreas Färber | s = gdbserver_state; |
1507 | 5ca666c7 | Andreas Färber | if (gdbserver_fd < 0 || s->fd < 0) { |
1508 | 5ca666c7 | Andreas Färber | return;
|
1509 | 5ca666c7 | Andreas Färber | } |
1510 | ca587a8e | aurel32 | |
1511 | 5ca666c7 | Andreas Färber | snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); |
1512 | 5ca666c7 | Andreas Färber | put_packet(s, buf); |
1513 | ca587a8e | aurel32 | } |
1514 | 1fddef4b | bellard | |
1515 | 880a7578 | aliguori | static void gdb_accept(void) |
1516 | 858693c6 | bellard | { |
1517 | 858693c6 | bellard | GDBState *s; |
1518 | 858693c6 | bellard | struct sockaddr_in sockaddr;
|
1519 | 858693c6 | bellard | socklen_t len; |
1520 | bf1c852a | MORITA Kazutaka | int fd;
|
1521 | 858693c6 | bellard | |
1522 | 858693c6 | bellard | for(;;) {
|
1523 | 858693c6 | bellard | len = sizeof(sockaddr);
|
1524 | 858693c6 | bellard | fd = accept(gdbserver_fd, (struct sockaddr *)&sockaddr, &len);
|
1525 | 858693c6 | bellard | if (fd < 0 && errno != EINTR) { |
1526 | 858693c6 | bellard | perror("accept");
|
1527 | 858693c6 | bellard | return;
|
1528 | 858693c6 | bellard | } else if (fd >= 0) { |
1529 | 40ff6d7e | Kevin Wolf | #ifndef _WIN32
|
1530 | 40ff6d7e | Kevin Wolf | fcntl(fd, F_SETFD, FD_CLOEXEC); |
1531 | 40ff6d7e | Kevin Wolf | #endif
|
1532 | b4608c04 | bellard | break;
|
1533 | b4608c04 | bellard | } |
1534 | b4608c04 | bellard | } |
1535 | 858693c6 | bellard | |
1536 | 858693c6 | bellard | /* set short latency */
|
1537 | bf1c852a | MORITA Kazutaka | socket_set_nodelay(fd); |
1538 | 3b46e624 | ths | |
1539 | 7267c094 | Anthony Liguori | s = g_malloc0(sizeof(GDBState));
|
1540 | 2e0f2cfb | Andreas Färber | s->c_cpu = first_cpu; |
1541 | 2e0f2cfb | Andreas Färber | s->g_cpu = first_cpu; |
1542 | 858693c6 | bellard | s->fd = fd; |
1543 | 5b50e790 | Andreas Färber | gdb_has_xml = false;
|
1544 | 858693c6 | bellard | |
1545 | 880a7578 | aliguori | gdbserver_state = s; |
1546 | a2d1ebaf | pbrook | |
1547 | 858693c6 | bellard | fcntl(fd, F_SETFL, O_NONBLOCK); |
1548 | 858693c6 | bellard | } |
1549 | 858693c6 | bellard | |
1550 | 858693c6 | bellard | static int gdbserver_open(int port) |
1551 | 858693c6 | bellard | { |
1552 | 858693c6 | bellard | struct sockaddr_in sockaddr;
|
1553 | 6669ca13 | Sebastian Ottlik | int fd, ret;
|
1554 | 858693c6 | bellard | |
1555 | 858693c6 | bellard | fd = socket(PF_INET, SOCK_STREAM, 0);
|
1556 | 858693c6 | bellard | if (fd < 0) { |
1557 | 858693c6 | bellard | perror("socket");
|
1558 | 858693c6 | bellard | return -1; |
1559 | 858693c6 | bellard | } |
1560 | 40ff6d7e | Kevin Wolf | #ifndef _WIN32
|
1561 | 40ff6d7e | Kevin Wolf | fcntl(fd, F_SETFD, FD_CLOEXEC); |
1562 | 40ff6d7e | Kevin Wolf | #endif
|
1563 | 858693c6 | bellard | |
1564 | 6669ca13 | Sebastian Ottlik | socket_set_fast_reuse(fd); |
1565 | 858693c6 | bellard | |
1566 | 858693c6 | bellard | sockaddr.sin_family = AF_INET; |
1567 | 858693c6 | bellard | sockaddr.sin_port = htons(port); |
1568 | 858693c6 | bellard | sockaddr.sin_addr.s_addr = 0;
|
1569 | 858693c6 | bellard | ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); |
1570 | 858693c6 | bellard | if (ret < 0) { |
1571 | 858693c6 | bellard | perror("bind");
|
1572 | bb16172c | Peter Maydell | close(fd); |
1573 | 858693c6 | bellard | return -1; |
1574 | 858693c6 | bellard | } |
1575 | 858693c6 | bellard | ret = listen(fd, 0);
|
1576 | 858693c6 | bellard | if (ret < 0) { |
1577 | 858693c6 | bellard | perror("listen");
|
1578 | bb16172c | Peter Maydell | close(fd); |
1579 | 858693c6 | bellard | return -1; |
1580 | 858693c6 | bellard | } |
1581 | 858693c6 | bellard | return fd;
|
1582 | 858693c6 | bellard | } |
1583 | 858693c6 | bellard | |
1584 | 858693c6 | bellard | int gdbserver_start(int port) |
1585 | 858693c6 | bellard | { |
1586 | 858693c6 | bellard | gdbserver_fd = gdbserver_open(port); |
1587 | 858693c6 | bellard | if (gdbserver_fd < 0) |
1588 | 858693c6 | bellard | return -1; |
1589 | 858693c6 | bellard | /* accept connections */
|
1590 | 880a7578 | aliguori | gdb_accept(); |
1591 | 4046d913 | pbrook | return 0; |
1592 | 4046d913 | pbrook | } |
1593 | 2b1319c8 | aurel32 | |
1594 | 2b1319c8 | aurel32 | /* Disable gdb stub for child processes. */
|
1595 | 9349b4f9 | Andreas Färber | void gdbserver_fork(CPUArchState *env)
|
1596 | 2b1319c8 | aurel32 | { |
1597 | 2b1319c8 | aurel32 | GDBState *s = gdbserver_state; |
1598 | 9f6164d6 | edgar_igl | if (gdbserver_fd < 0 || s->fd < 0) |
1599 | 2b1319c8 | aurel32 | return;
|
1600 | 2b1319c8 | aurel32 | close(s->fd); |
1601 | 2b1319c8 | aurel32 | s->fd = -1;
|
1602 | 2b1319c8 | aurel32 | cpu_breakpoint_remove_all(env, BP_GDB); |
1603 | 2b1319c8 | aurel32 | cpu_watchpoint_remove_all(env, BP_GDB); |
1604 | 2b1319c8 | aurel32 | } |
1605 | 1fddef4b | bellard | #else
|
1606 | aa1f17c1 | ths | static int gdb_chr_can_receive(void *opaque) |
1607 | 4046d913 | pbrook | { |
1608 | 56aebc89 | pbrook | /* We can handle an arbitrarily large amount of data.
|
1609 | 56aebc89 | pbrook | Pick the maximum packet size, which is as good as anything. */
|
1610 | 56aebc89 | pbrook | return MAX_PACKET_LENGTH;
|
1611 | 4046d913 | pbrook | } |
1612 | 4046d913 | pbrook | |
1613 | aa1f17c1 | ths | static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) |
1614 | 4046d913 | pbrook | { |
1615 | 4046d913 | pbrook | int i;
|
1616 | 4046d913 | pbrook | |
1617 | 4046d913 | pbrook | for (i = 0; i < size; i++) { |
1618 | 880a7578 | aliguori | gdb_read_byte(gdbserver_state, buf[i]); |
1619 | 4046d913 | pbrook | } |
1620 | 4046d913 | pbrook | } |
1621 | 4046d913 | pbrook | |
1622 | 4046d913 | pbrook | static void gdb_chr_event(void *opaque, int event) |
1623 | 4046d913 | pbrook | { |
1624 | 4046d913 | pbrook | switch (event) {
|
1625 | b6b8df56 | Amit Shah | case CHR_EVENT_OPENED:
|
1626 | 0461d5a6 | Luiz Capitulino | vm_stop(RUN_STATE_PAUSED); |
1627 | 5b50e790 | Andreas Färber | gdb_has_xml = false;
|
1628 | 4046d913 | pbrook | break;
|
1629 | 4046d913 | pbrook | default:
|
1630 | 4046d913 | pbrook | break;
|
1631 | 4046d913 | pbrook | } |
1632 | 4046d913 | pbrook | } |
1633 | 4046d913 | pbrook | |
1634 | 8a34a0fb | aliguori | static void gdb_monitor_output(GDBState *s, const char *msg, int len) |
1635 | 8a34a0fb | aliguori | { |
1636 | 8a34a0fb | aliguori | char buf[MAX_PACKET_LENGTH];
|
1637 | 8a34a0fb | aliguori | |
1638 | 8a34a0fb | aliguori | buf[0] = 'O'; |
1639 | 8a34a0fb | aliguori | if (len > (MAX_PACKET_LENGTH/2) - 1) |
1640 | 8a34a0fb | aliguori | len = (MAX_PACKET_LENGTH/2) - 1; |
1641 | 8a34a0fb | aliguori | memtohex(buf + 1, (uint8_t *)msg, len);
|
1642 | 8a34a0fb | aliguori | put_packet(s, buf); |
1643 | 8a34a0fb | aliguori | } |
1644 | 8a34a0fb | aliguori | |
1645 | 8a34a0fb | aliguori | static int gdb_monitor_write(CharDriverState *chr, const uint8_t *buf, int len) |
1646 | 8a34a0fb | aliguori | { |
1647 | 8a34a0fb | aliguori | const char *p = (const char *)buf; |
1648 | 8a34a0fb | aliguori | int max_sz;
|
1649 | 8a34a0fb | aliguori | |
1650 | 8a34a0fb | aliguori | max_sz = (sizeof(gdbserver_state->last_packet) - 2) / 2; |
1651 | 8a34a0fb | aliguori | for (;;) {
|
1652 | 8a34a0fb | aliguori | if (len <= max_sz) {
|
1653 | 8a34a0fb | aliguori | gdb_monitor_output(gdbserver_state, p, len); |
1654 | 8a34a0fb | aliguori | break;
|
1655 | 8a34a0fb | aliguori | } |
1656 | 8a34a0fb | aliguori | gdb_monitor_output(gdbserver_state, p, max_sz); |
1657 | 8a34a0fb | aliguori | p += max_sz; |
1658 | 8a34a0fb | aliguori | len -= max_sz; |
1659 | 8a34a0fb | aliguori | } |
1660 | 8a34a0fb | aliguori | return len;
|
1661 | 8a34a0fb | aliguori | } |
1662 | 8a34a0fb | aliguori | |
1663 | 59030a8c | aliguori | #ifndef _WIN32
|
1664 | 59030a8c | aliguori | static void gdb_sigterm_handler(int signal) |
1665 | 59030a8c | aliguori | { |
1666 | 1354869c | Luiz Capitulino | if (runstate_is_running()) {
|
1667 | 0461d5a6 | Luiz Capitulino | vm_stop(RUN_STATE_PAUSED); |
1668 | e07bbac5 | Jan Kiszka | } |
1669 | 59030a8c | aliguori | } |
1670 | 59030a8c | aliguori | #endif
|
1671 | 59030a8c | aliguori | |
1672 | 59030a8c | aliguori | int gdbserver_start(const char *device) |
1673 | 4046d913 | pbrook | { |
1674 | 4046d913 | pbrook | GDBState *s; |
1675 | 59030a8c | aliguori | char gdbstub_device_name[128]; |
1676 | 36556b20 | aliguori | CharDriverState *chr = NULL;
|
1677 | 36556b20 | aliguori | CharDriverState *mon_chr; |
1678 | cfc3475a | pbrook | |
1679 | 59030a8c | aliguori | if (!device)
|
1680 | 59030a8c | aliguori | return -1; |
1681 | 59030a8c | aliguori | if (strcmp(device, "none") != 0) { |
1682 | 59030a8c | aliguori | if (strstart(device, "tcp:", NULL)) { |
1683 | 59030a8c | aliguori | /* enforce required TCP attributes */
|
1684 | 59030a8c | aliguori | snprintf(gdbstub_device_name, sizeof(gdbstub_device_name),
|
1685 | 59030a8c | aliguori | "%s,nowait,nodelay,server", device);
|
1686 | 59030a8c | aliguori | device = gdbstub_device_name; |
1687 | 36556b20 | aliguori | } |
1688 | 59030a8c | aliguori | #ifndef _WIN32
|
1689 | 59030a8c | aliguori | else if (strcmp(device, "stdio") == 0) { |
1690 | 59030a8c | aliguori | struct sigaction act;
|
1691 | 4046d913 | pbrook | |
1692 | 59030a8c | aliguori | memset(&act, 0, sizeof(act)); |
1693 | 59030a8c | aliguori | act.sa_handler = gdb_sigterm_handler; |
1694 | 59030a8c | aliguori | sigaction(SIGINT, &act, NULL);
|
1695 | 59030a8c | aliguori | } |
1696 | 59030a8c | aliguori | #endif
|
1697 | 27143a44 | Anthony Liguori | chr = qemu_chr_new("gdb", device, NULL); |
1698 | 36556b20 | aliguori | if (!chr)
|
1699 | 36556b20 | aliguori | return -1; |
1700 | 36556b20 | aliguori | |
1701 | 456d6069 | Hans de Goede | qemu_chr_fe_claim_no_fail(chr); |
1702 | 36556b20 | aliguori | qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive, |
1703 | 36556b20 | aliguori | gdb_chr_event, NULL);
|
1704 | cfc3475a | pbrook | } |
1705 | cfc3475a | pbrook | |
1706 | 36556b20 | aliguori | s = gdbserver_state; |
1707 | 36556b20 | aliguori | if (!s) {
|
1708 | 7267c094 | Anthony Liguori | s = g_malloc0(sizeof(GDBState));
|
1709 | 36556b20 | aliguori | gdbserver_state = s; |
1710 | 4046d913 | pbrook | |
1711 | 36556b20 | aliguori | qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
|
1712 | 36556b20 | aliguori | |
1713 | 36556b20 | aliguori | /* Initialize a monitor terminal for gdb */
|
1714 | 7267c094 | Anthony Liguori | mon_chr = g_malloc0(sizeof(*mon_chr));
|
1715 | 36556b20 | aliguori | mon_chr->chr_write = gdb_monitor_write; |
1716 | 36556b20 | aliguori | monitor_init(mon_chr, 0);
|
1717 | 36556b20 | aliguori | } else {
|
1718 | 36556b20 | aliguori | if (s->chr)
|
1719 | 70f24fb6 | Anthony Liguori | qemu_chr_delete(s->chr); |
1720 | 36556b20 | aliguori | mon_chr = s->mon_chr; |
1721 | 36556b20 | aliguori | memset(s, 0, sizeof(GDBState)); |
1722 | 36556b20 | aliguori | } |
1723 | 2e0f2cfb | Andreas Färber | s->c_cpu = first_cpu; |
1724 | 2e0f2cfb | Andreas Färber | s->g_cpu = first_cpu; |
1725 | 4046d913 | pbrook | s->chr = chr; |
1726 | 36556b20 | aliguori | s->state = chr ? RS_IDLE : RS_INACTIVE; |
1727 | 36556b20 | aliguori | s->mon_chr = mon_chr; |
1728 | cdb432b2 | Meador Inge | s->current_syscall_cb = NULL;
|
1729 | 8a34a0fb | aliguori | |
1730 | b4608c04 | bellard | return 0; |
1731 | b4608c04 | bellard | } |
1732 | 4046d913 | pbrook | #endif |