Rev 2939 | Rev 2942 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2939 | Rev 2940 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2008 Jiri Svoboda |
2 | * Copyright (c) 2008 Jiri Svoboda |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup debug |
29 | /** @addtogroup debug |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #include <stdio.h> |
35 | #include <stdio.h> |
36 | #include <stdlib.h> |
36 | #include <stdlib.h> |
37 | #include <unistd.h> |
37 | #include <unistd.h> |
38 | #include <syscall.h> |
38 | #include <syscall.h> |
39 | #include <ipc/ipc.h> |
39 | #include <ipc/ipc.h> |
40 | #include <fibril.h> |
40 | #include <fibril.h> |
41 | #include <errno.h> |
41 | #include <errno.h> |
42 | #include <udebug.h> |
42 | #include <udebug.h> |
43 | #include <async.h> |
43 | #include <async.h> |
44 | #include <string.h> |
44 | #include <string.h> |
45 | 45 | ||
46 | #include "cmd.h" |
46 | #include "cmd.h" |
47 | #include "cons.h" |
47 | #include "cons.h" |
48 | #include "dthread.h" |
48 | #include "dthread.h" |
49 | #include "include/arch.h" |
49 | #include "include/arch.h" |
50 | #include "fib_synch.h" |
50 | #include "fib_synch.h" |
51 | #include "main.h" |
51 | #include "main.h" |
52 | 52 | ||
53 | void thread_debug_start(unsigned thread_hash); |
53 | void thread_debug_start(unsigned thread_hash); |
54 | 54 | ||
55 | #define IN_BUF_SIZE 64 |
55 | #define IN_BUF_SIZE 64 |
56 | static char in_buf[IN_BUF_SIZE]; |
56 | static char in_buf[IN_BUF_SIZE]; |
57 | 57 | ||
58 | #define MAX_ARGC 10 |
58 | #define MAX_ARGC 10 |
59 | int cmd_argc; |
59 | int cmd_argc; |
60 | char *cmd_argv[MAX_ARGC + 1]; /* need one spare field for cmd_split() */ |
60 | char *cmd_argv[MAX_ARGC + 1]; /* need one spare field for cmd_split() */ |
61 | 61 | ||
62 | #define THBUF_SIZE 64 |
- | |
63 | thash_t thread_hash_buf[THBUF_SIZE]; |
- | |
64 | 62 | ||
65 | int next_thread_id; |
63 | int next_thread_id; |
66 | 64 | ||
67 | int app_phone; |
65 | int app_phone; |
68 | volatile bool abort_debug; |
66 | volatile bool abort_debug; |
69 | 67 | ||
70 | volatile int paused; |
68 | volatile int paused; |
71 | 69 | ||
72 | breakpoint_t brk_list[MAX_BRKPTS]; |
70 | breakpoint_t brk_list[MAX_BRKPTS]; |
73 | int lifted_brkpt; |
71 | int lifted_brkpt; |
74 | 72 | ||
75 | fcv_t go_cv; |
73 | fcv_t go_cv; |
76 | 74 | ||
77 | static void command_split(char *cmd_str) |
75 | static void command_split(char *cmd_str) |
78 | { |
76 | { |
79 | char *p = cmd_str; |
77 | char *p = cmd_str; |
80 | 78 | ||
81 | if (*p == '\0') { |
79 | if (*p == '\0') { |
82 | cmd_argc = 0; |
80 | cmd_argc = 0; |
83 | return; |
81 | return; |
84 | } |
82 | } |
85 | 83 | ||
86 | cmd_argc = 1; |
84 | cmd_argc = 1; |
87 | cmd_argv[0] = p; |
85 | cmd_argv[0] = p; |
88 | 86 | ||
89 | while (*p != '\0') { |
87 | while (*p != '\0') { |
90 | if (*p == ' ') { |
88 | if (*p == ' ') { |
91 | cmd_argv[cmd_argc++] = p + 1; |
89 | cmd_argv[cmd_argc++] = p + 1; |
92 | *p = '\0'; |
90 | *p = '\0'; |
93 | } |
91 | } |
94 | ++p; |
92 | ++p; |
95 | } |
93 | } |
96 | } |
94 | } |
97 | 95 | ||
98 | static void command_run(void) |
96 | static void command_run(void) |
99 | { |
97 | { |
100 | int i; |
98 | int i; |
101 | int cmp_len; |
99 | int cmp_len; |
102 | int len; |
100 | int len; |
103 | 101 | ||
104 | int idx_found; |
102 | int idx_found; |
105 | int num_found; |
103 | int num_found; |
106 | 104 | ||
107 | len = strlen(cmd_argv[0]); |
105 | len = strlen(cmd_argv[0]); |
108 | cmp_len = 1; |
106 | cmp_len = 1; |
109 | 107 | ||
110 | while (cmp_len <= len + 1) { |
108 | while (cmp_len <= len + 1) { |
111 | 109 | ||
112 | num_found = 0; |
110 | num_found = 0; |
113 | i = 0; |
111 | i = 0; |
114 | while (cmd_table[i].name != NULL) { |
112 | while (cmd_table[i].name != NULL) { |
115 | if (strncmp(cmd_table[i].name, cmd_argv[0], cmp_len) == 0) { |
113 | if (strncmp(cmd_table[i].name, cmd_argv[0], cmp_len) == 0) { |
116 | idx_found = i; |
114 | idx_found = i; |
117 | ++num_found; |
115 | ++num_found; |
118 | } |
116 | } |
119 | ++i; |
117 | ++i; |
120 | } |
118 | } |
121 | 119 | ||
122 | if (num_found < 2) break; |
120 | if (num_found < 2) break; |
123 | 121 | ||
124 | --cmp_len; |
122 | --cmp_len; |
125 | } |
123 | } |
126 | 124 | ||
127 | if (num_found == 0) { |
125 | if (num_found == 0) { |
128 | cons_printf("Unknown command. Try one of:\n"); |
126 | cons_printf("Unknown command. Try one of:\n"); |
129 | cmd_help(0, NULL); |
127 | cmd_help(0, NULL); |
130 | return; |
128 | return; |
131 | } |
129 | } |
132 | 130 | ||
133 | if (cmd_argc - 1 != cmd_table[idx_found].argc) { |
131 | if (cmd_argc - 1 != cmd_table[idx_found].argc) { |
134 | cons_printf("Command '%s' expects %d arguments\n", |
132 | cons_printf("Command '%s' expects %d arguments\n", |
135 | cmd_table[idx_found].name, cmd_table[idx_found].argc); |
133 | cmd_table[idx_found].name, cmd_table[idx_found].argc); |
136 | return; |
134 | return; |
137 | } |
135 | } |
138 | 136 | ||
139 | (*cmd_table[idx_found].proc)(cmd_argc, cmd_argv); |
137 | (*cmd_table[idx_found].proc)(cmd_argc, cmd_argv); |
140 | } |
138 | } |
141 | 139 | ||
142 | static void thread_stop(void) |
140 | static void thread_stop(void) |
143 | { |
141 | { |
144 | dthread_t *dt; |
142 | dthread_t *dt; |
- | 143 | uintptr_t pc; |
|
145 | 144 | ||
146 | dt = dthread_get(); |
145 | dt = dthread_get(); |
- | 146 | pc = dthread_get_pc(dt); |
|
147 | cons_printf("[thread %d] stopped\n", dt->id); |
147 | cons_printf("[thread %d] stopped at 0x%lx\n", dt->id, pc); |
148 | dthread_stop_me(); |
148 | dthread_stop_me(); |
149 | cons_printf("[thread %d] go\n", dt->id); |
149 | cons_printf("[thread %d] go\n", dt->id); |
150 | } |
150 | } |
151 | 151 | ||
152 | /* |
152 | /* |
153 | * Called by a fibril (from arch code) when a breakpoint is hit. |
153 | * Called by a fibril (from arch code) when a breakpoint is hit. |
154 | */ |
154 | */ |
155 | void breakpoint_hit(void) |
155 | void breakpoint_hit(void) |
156 | { |
156 | { |
157 | cons_printf("breakpoint hit\n"); |
157 | cons_printf("breakpoint hit\n"); |
158 | thread_stop(); |
158 | thread_stop(); |
159 | } |
159 | } |
160 | 160 | ||
161 | static int task_connect(int taskid) |
161 | static int task_connect(int taskid) |
162 | { |
162 | { |
163 | int rc; |
163 | int rc; |
164 | unsigned evmask; |
164 | unsigned evmask; |
165 | 165 | ||
166 | cons_printf("ipc_connect_kbox(%d)... ", taskid); |
166 | cons_printf("ipc_connect_kbox(%d)... ", taskid); |
167 | rc = ipc_connect_kbox(taskid); |
167 | rc = ipc_connect_kbox(taskid); |
168 | cons_printf("-> %d\n", rc); |
168 | cons_printf("-> %d\n", rc); |
169 | app_phone = rc; |
169 | app_phone = rc; |
170 | if (rc < 0) return rc; |
170 | if (rc < 0) return rc; |
171 | 171 | ||
172 | cons_printf("udebug_begin()... "); |
172 | cons_printf("udebug_begin()... "); |
173 | rc = udebug_begin(app_phone); |
173 | rc = udebug_begin(app_phone); |
174 | cons_printf("-> %d\n", rc); |
174 | cons_printf("-> %d\n", rc); |
175 | if (rc < 0) return rc; |
175 | if (rc < 0) return rc; |
176 | 176 | ||
177 | evmask = UDEBUG_EM_ALL & ~(UDEBUG_EM_SYSCALL_B | UDEBUG_EM_SYSCALL_E); |
177 | evmask = UDEBUG_EM_ALL & ~(UDEBUG_EM_SYSCALL_B | UDEBUG_EM_SYSCALL_E); |
178 | cons_printf("udebug_set_evmask(0x%x)... ", evmask); |
178 | cons_printf("udebug_set_evmask(0x%x)... ", evmask); |
179 | rc = udebug_set_evmask(app_phone, evmask); |
179 | rc = udebug_set_evmask(app_phone, evmask); |
180 | cons_printf("-> %d\n", rc); |
180 | cons_printf("-> %d\n", rc); |
181 | if (rc < 0) return rc; |
181 | if (rc < 0) return rc; |
182 | 182 | ||
183 | return 0; |
183 | return 0; |
184 | } |
184 | } |
185 | 185 | ||
- | 186 | #define THASH_BUF_INIT_LENGTH 32 |
|
- | 187 | ||
186 | static int get_thread_list(void) |
188 | static int get_thread_list(thash_t **thash_buf_ptr, int *n) |
187 | { |
189 | { |
188 | int rc; |
190 | int rc; |
189 | int tb_copied; |
191 | int tb_copied; |
190 | int tb_needed; |
192 | int tb_needed; |
191 | int i; |
193 | int i; |
192 | int n; |
194 | size_t tb_size; |
- | 195 | thash_t *thash_buf; |
|
193 | 196 | ||
194 | cons_printf("send IPC_M_DEBUG_THREAD_READ message\n"); |
197 | tb_size = THASH_BUF_INIT_LENGTH * sizeof(thash_t); |
- | 198 | thash_buf = malloc(tb_size); |
|
- | 199 | ||
195 | rc = udebug_thread_read(app_phone, (unsigned)thread_hash_buf, |
200 | rc = udebug_thread_read(app_phone, (sysarg_t)thash_buf, |
196 | THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed); |
201 | tb_size, &tb_copied, &tb_needed); |
197 | cons_printf("-> %d\n", rc); |
- | |
198 | if (rc < 0) return rc; |
202 | if (rc < 0) return rc; |
199 | 203 | ||
- | 204 | if (tb_needed > tb_size) { |
|
- | 205 | /* Larger buffer needed */ |
|
- | 206 | ||
- | 207 | free(thash_buf); |
|
- | 208 | ||
- | 209 | tb_size = tb_needed; |
|
- | 210 | thash_buf = malloc(tb_size); |
|
- | 211 | ||
- | 212 | if (!thash_buf) { |
|
- | 213 | printf("malloc failed\n"); |
|
- | 214 | exit(1); |
|
- | 215 | } |
|
- | 216 | ||
- | 217 | /* Try again */ |
|
- | 218 | ||
- | 219 | rc = udebug_thread_read(app_phone, (sysarg_t)thash_buf, |
|
200 | n = tb_copied / sizeof(unsigned); |
220 | tb_size, &tb_copied, &tb_needed); |
201 | 221 | ||
202 | cons_printf("thread IDs:"); |
- | |
203 | for (i=0; i<n; i++) { |
222 | if (rc < 0) return rc; |
204 | cons_printf(" %u", thread_hash_buf[i]); |
- | |
205 | } |
223 | } |
206 | cons_printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); |
- | |
207 | 224 | ||
- | 225 | *n = tb_copied / sizeof(thash_t); |
|
- | 226 | ||
- | 227 | cons_printf("thread hashes:"); |
|
- | 228 | ||
- | 229 | for (i = 0; i < *n; ++i) { |
|
- | 230 | cons_printf("0x%x\n", thash_buf[i]); |
|
- | 231 | } |
|
- | 232 | ||
- | 233 | cons_printf("Total of %u threads\n", *n); |
|
- | 234 | ||
- | 235 | *thash_buf_ptr = thash_buf; |
|
- | 236 | ||
208 | return n; |
237 | return 0; |
209 | } |
238 | } |
210 | 239 | ||
211 | void event_thread_b(unsigned hash) |
240 | void event_thread_b(unsigned hash) |
212 | { |
241 | { |
213 | async_serialize_start(); |
242 | async_serialize_start(); |
214 | cons_printf("new thread, hash 0x%x\n", hash); |
243 | cons_printf("new thread, hash 0x%x\n", hash); |
215 | async_serialize_end(); |
244 | async_serialize_end(); |
216 | 245 | ||
217 | thread_debug_start(hash); |
246 | thread_debug_start(hash); |
218 | } |
247 | } |
219 | 248 | ||
220 | static unsigned buffer[1024]; |
249 | static unsigned buffer[1024]; |
221 | 250 | ||
222 | static void debug_event(thash_t thash, udebug_event_t ev_type, sysarg_t val0) |
251 | static void debug_event(thash_t thash, udebug_event_t ev_type, sysarg_t val0) |
223 | { |
252 | { |
224 | switch (ev_type) { |
253 | switch (ev_type) { |
225 | case UDEBUG_EVENT_STOP: |
254 | case UDEBUG_EVENT_STOP: |
226 | cons_printf("stop event\n"); |
255 | cons_printf("stop event\n"); |
227 | thread_stop(); |
256 | thread_stop(); |
228 | break; |
257 | break; |
229 | case UDEBUG_EVENT_THREAD_B: |
258 | case UDEBUG_EVENT_THREAD_B: |
230 | event_thread_b(val0); |
259 | event_thread_b(val0); |
231 | break; |
260 | break; |
232 | case UDEBUG_EVENT_THREAD_E: |
261 | case UDEBUG_EVENT_THREAD_E: |
233 | cons_printf("thread 0x%x exited\n", val0); |
262 | cons_printf("thread 0x%x exited\n", val0); |
234 | abort_debug = true; |
263 | abort_debug = true; |
235 | break; |
264 | break; |
236 | case UDEBUG_EVENT_BREAKPOINT: |
265 | case UDEBUG_EVENT_BREAKPOINT: |
237 | arch_event_breakpoint(thash); |
266 | arch_event_breakpoint(thash); |
238 | break; |
267 | break; |
239 | case UDEBUG_EVENT_TRAP: |
268 | case UDEBUG_EVENT_TRAP: |
240 | arch_event_trap(thash); |
269 | arch_event_trap(thash); |
241 | break; |
270 | break; |
242 | default: |
271 | default: |
243 | cons_printf("unknown event type %d\n", ev_type); |
272 | cons_printf("unknown event type %d\n", ev_type); |
244 | break; |
273 | break; |
245 | } |
274 | } |
246 | } |
275 | } |
247 | 276 | ||
248 | void debug_loop(void *dt_arg) |
277 | void debug_loop(void *dt_arg) |
249 | { |
278 | { |
250 | int rc; |
279 | int rc; |
251 | udebug_event_t ev_type; |
280 | udebug_event_t ev_type; |
252 | unsigned thread_buf_idx; |
281 | unsigned thread_buf_idx; |
253 | unsigned val0, val1; |
282 | unsigned val0, val1; |
254 | dthread_t *dt; |
283 | dthread_t *dt; |
255 | 284 | ||
256 | dt = (dthread_t *)dt_arg; |
285 | dt = (dthread_t *)dt_arg; |
257 | 286 | ||
258 | cons_printf("debug_loop(%d)\n", dt->id); |
287 | cons_printf("debug_loop(%d)\n", dt->id); |
259 | 288 | ||
260 | while (!abort_debug) { |
289 | while (!abort_debug) { |
261 | 290 | ||
262 | /* Run thread until an event occurs */ |
291 | /* Run thread until an event occurs */ |
263 | rc = udebug_go(app_phone, dt->hash, &ev_type, &val0, &val1); |
292 | rc = udebug_go(app_phone, dt->hash, &ev_type, &val0, &val1); |
264 | 293 | ||
265 | if (ev_type == UDEBUG_EVENT_FINISHED) { |
294 | if (ev_type == UDEBUG_EVENT_FINISHED) { |
266 | cons_printf("thread %u debugging finished\n", dt->id); |
295 | cons_printf("thread %u debugging finished\n", dt->id); |
267 | break; |
296 | break; |
268 | } |
297 | } |
269 | if (rc >= 0) debug_event(dt->hash, ev_type, val0); |
298 | if (rc >= 0) debug_event(dt->hash, ev_type, val0); |
270 | } |
299 | } |
271 | 300 | ||
272 | cons_printf("debug_loop(%d) exiting\n", dt->id); |
301 | cons_printf("debug_loop(%d) exiting\n", dt->id); |
273 | } |
302 | } |
274 | 303 | ||
275 | void thread_debug_start(unsigned thash) |
304 | void thread_debug_start(unsigned thash) |
276 | { |
305 | { |
277 | fid_t fid; |
306 | fid_t fid; |
278 | dthread_t *dt; |
307 | dthread_t *dt; |
279 | 308 | ||
280 | dt = dthread_new(thash); |
309 | dt = dthread_new(thash); |
281 | 310 | ||
282 | fid = fibril_create(debug_loop, (void *)dt); |
311 | fid = fibril_create(debug_loop, (void *)dt); |
283 | if (fid == 0) { |
312 | if (fid == 0) { |
284 | cons_printf("Warning: Failed creating fibril\n"); |
313 | cons_printf("Warning: Failed creating fibril\n"); |
285 | } |
314 | } |
286 | dt->fid = fid; |
315 | dt->fid = fid; |
287 | 316 | ||
288 | fibril_add_ready(fid); |
317 | fibril_add_ready(fid); |
289 | } |
318 | } |
290 | 319 | ||
291 | void debug_active_task(void) |
320 | void debug_active_task(void) |
292 | { |
321 | { |
293 | int taskid; |
322 | int taskid; |
294 | int i; |
323 | int i; |
295 | int rc; |
324 | int rc; |
296 | int c; |
325 | int c; |
297 | 326 | ||
- | 327 | thash_t *thash_buffer; |
|
- | 328 | int n_threads; |
|
- | 329 | ||
298 | cons_printf("Breakpoint Debugger\n"); |
330 | cons_printf("Breakpoint Debugger\n"); |
299 | cons_printf("Press 'c' to connect\n"); |
331 | cons_printf("Press 'c' to connect\n"); |
300 | while ((i = getchar()) != 'c') |
332 | while ((i = getchar()) != 'c') |
301 | putchar(i); |
333 | putchar(i); |
302 | 334 | ||
303 | taskid = 14; |
335 | taskid = 14; |
304 | rc = task_connect(taskid); |
336 | rc = task_connect(taskid); |
305 | if (rc < 0) { |
337 | if (rc < 0) { |
306 | cons_printf("Failed to connect to task %d\n", taskid); |
338 | cons_printf("Failed to connect to task %d\n", taskid); |
307 | return; |
339 | return; |
308 | } |
340 | } |
309 | 341 | ||
310 | cons_printf("Connected to task %d\n", taskid); |
342 | cons_printf("Connected to task %d\n", taskid); |
311 | 343 | ||
312 | rc = get_thread_list(); |
344 | rc = get_thread_list(&thash_buffer, &n_threads); |
313 | if (rc < 0) { |
345 | if (rc < 0) { |
314 | cons_printf("Failed to get thread list (error %d)\n", rc); |
346 | cons_printf("Failed to get thread list\n", rc); |
315 | return; |
347 | return; |
316 | } |
348 | } |
317 | 349 | ||
318 | abort_debug = false; |
350 | abort_debug = false; |
319 | 351 | ||
320 | for (i = 0; i < rc; i++) { |
352 | for (i = 0; i < n_threads; i++) { |
321 | thread_debug_start(thread_hash_buf[i]); |
353 | thread_debug_start(thash_buffer[i]); |
322 | } |
354 | } |
323 | 355 | ||
324 | while (!quit) { |
356 | while (!quit) { |
325 | cons_read_line(in_buf, IN_BUF_SIZE); |
357 | cons_read_line(in_buf, IN_BUF_SIZE); |
326 | command_split(in_buf); |
358 | command_split(in_buf); |
327 | if (cmd_argc == 0) continue; |
359 | if (cmd_argc == 0) continue; |
328 | 360 | ||
329 | command_run(); |
361 | command_run(); |
330 | } |
362 | } |
331 | 363 | ||
332 | cons_printf("terminate debugging session...\n"); |
364 | cons_printf("terminate debugging session...\n"); |
333 | abort_debug = true; |
365 | abort_debug = true; |
334 | udebug_end(app_phone); |
366 | udebug_end(app_phone); |
335 | ipc_hangup(app_phone); |
367 | ipc_hangup(app_phone); |
336 | 368 | ||
337 | cons_printf("done\n"); |
369 | cons_printf("done\n"); |
338 | return; |
370 | return; |
339 | } |
371 | } |
340 | 372 | ||
341 | static void main_init(void) |
373 | static void main_init(void) |
342 | { |
374 | { |
343 | next_thread_id = 1; |
375 | next_thread_id = 1; |
344 | paused = 0; |
376 | paused = 0; |
345 | 377 | ||
346 | list_initialize(&dthreads); |
378 | list_initialize(&dthreads); |
347 | cwt = NULL; |
379 | cwt = NULL; |
348 | 380 | ||
349 | fcv_init(&go_cv); |
381 | fcv_init(&go_cv); |
350 | } |
382 | } |
351 | 383 | ||
352 | int main(void) |
384 | int main(void) |
353 | { |
385 | { |
354 | main_init(); |
386 | main_init(); |
355 | 387 | ||
356 | while (1) { |
388 | while (1) { |
357 | debug_active_task(); |
389 | debug_active_task(); |
358 | } |
390 | } |
359 | } |
391 | } |
360 | 392 | ||
361 | /** @} |
393 | /** @} |
362 | */ |
394 | */ |
363 | 395 |