Rev 2937 | Rev 2939 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2937 | Rev 2938 | ||
|---|---|---|---|
| Line 43... | Line 43... | ||
| 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 "include/arch.h" |
49 | #include "include/arch.h" |
| 49 | #include "fib_synch.h" |
50 | #include "fib_synch.h" |
| 50 | #include "main.h" |
51 | #include "main.h" |
| 51 | 52 | ||
| 52 | void thread_debug_start(unsigned thread_hash); |
53 | void thread_debug_start(unsigned thread_hash); |
| Line 59... | Line 60... | ||
| 59 | 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() */ |
| 60 | 61 | ||
| 61 | #define THBUF_SIZE 64 |
62 | #define THBUF_SIZE 64 |
| 62 | thash_t thread_hash_buf[THBUF_SIZE]; |
63 | thash_t thread_hash_buf[THBUF_SIZE]; |
| 63 | 64 | ||
| 64 | #define MAX_THREADS 64 |
- | |
| 65 | thash_t thread_hash[MAX_THREADS]; |
- | |
| 66 | int thread_id[MAX_THREADS]; |
- | |
| 67 | unsigned n_threads; |
- | |
| 68 | int cwt; /* index into thread_hash/thread_id */ |
- | |
| 69 | - | ||
| 70 | int next_thread_id; |
65 | int next_thread_id; |
| 71 | 66 | ||
| 72 | int app_phone; |
67 | int app_phone; |
| 73 | volatile bool abort_debug; |
68 | volatile bool abort_debug; |
| 74 | 69 | ||
| Line 78... | Line 73... | ||
| 78 | breakpoint_t brk_list[MAX_BRKPTS]; |
73 | breakpoint_t brk_list[MAX_BRKPTS]; |
| 79 | int lifted_brkpt; |
74 | int lifted_brkpt; |
| 80 | 75 | ||
| 81 | fcv_t go_cv; |
76 | fcv_t go_cv; |
| 82 | 77 | ||
| 83 | void command_split(char *cmd_str) |
78 | static void command_split(char *cmd_str) |
| 84 | { |
79 | { |
| 85 | char *p = cmd_str; |
80 | char *p = cmd_str; |
| 86 | 81 | ||
| 87 | if (*p == '\0') { |
82 | if (*p == '\0') { |
| 88 | cmd_argc = 0; |
83 | cmd_argc = 0; |
| Line 99... | Line 94... | ||
| 99 | } |
94 | } |
| 100 | ++p; |
95 | ++p; |
| 101 | } |
96 | } |
| 102 | } |
97 | } |
| 103 | 98 | ||
| 104 | void command_run(void) |
99 | static void command_run(void) |
| 105 | { |
100 | { |
| 106 | int i; |
101 | int i; |
| 107 | int cmp_len; |
102 | int cmp_len; |
| 108 | int len; |
103 | int len; |
| 109 | 104 | ||
| Line 143... | Line 138... | ||
| 143 | } |
138 | } |
| 144 | 139 | ||
| 145 | (*cmd_table[idx_found].proc)(cmd_argc, cmd_argv); |
140 | (*cmd_table[idx_found].proc)(cmd_argc, cmd_argv); |
| 146 | } |
141 | } |
| 147 | 142 | ||
| 148 | void thread_stop(void) |
143 | static void thread_stop(void) |
| 149 | { |
144 | { |
| 150 | cons_printf("[t] stopped\n"); |
145 | cons_printf("[t] stopped\n"); |
| 151 | fcv_wait(&go_cv); |
146 | fcv_wait(&go_cv); |
| 152 | cons_printf("[t] go\n"); |
147 | cons_printf("[t] go\n"); |
| 153 | } |
148 | } |
| Line 159... | Line 154... | ||
| 159 | { |
154 | { |
| 160 | cons_printf("breakpoint hit\n"); |
155 | cons_printf("breakpoint hit\n"); |
| 161 | thread_stop(); |
156 | thread_stop(); |
| 162 | } |
157 | } |
| 163 | 158 | ||
| 164 | int task_connect(int taskid) |
159 | static int task_connect(int taskid) |
| 165 | { |
160 | { |
| 166 | int rc; |
161 | int rc; |
| 167 | unsigned evmask; |
162 | unsigned evmask; |
| 168 | 163 | ||
| 169 | cons_printf("ipc_connect_kbox(%d)... ", taskid); |
164 | cons_printf("ipc_connect_kbox(%d)... ", taskid); |
| Line 184... | Line 179... | ||
| 184 | if (rc < 0) return rc; |
179 | if (rc < 0) return rc; |
| 185 | 180 | ||
| 186 | return 0; |
181 | return 0; |
| 187 | } |
182 | } |
| 188 | 183 | ||
| 189 | int get_thread_list(void) |
184 | static int get_thread_list(void) |
| 190 | { |
185 | { |
| 191 | int rc; |
186 | int rc; |
| 192 | int tb_copied; |
187 | int tb_copied; |
| 193 | int tb_needed; |
188 | int tb_needed; |
| 194 | int i; |
189 | int i; |
| Line 252... | Line 247... | ||
| 252 | cons_printf("unknown event type %d\n", ev_type); |
247 | cons_printf("unknown event type %d\n", ev_type); |
| 253 | break; |
248 | break; |
| 254 | } |
249 | } |
| 255 | } |
250 | } |
| 256 | 251 | ||
| 257 | void debug_loop(void *thread_buf_idx_arg) |
252 | void debug_loop(void *dt_arg) |
| 258 | { |
253 | { |
| 259 | int rc; |
254 | int rc; |
| 260 | udebug_event_t ev_type; |
255 | udebug_event_t ev_type; |
| 261 | unsigned thread_buf_idx; |
256 | unsigned thread_buf_idx; |
| 262 | thash_t thash; |
- | |
| 263 | int tid; |
- | |
| 264 | unsigned val0, val1; |
257 | unsigned val0, val1; |
| - | 258 | dthread_t *dt; |
|
| 265 | 259 | ||
| 266 | thread_buf_idx = (unsigned)thread_buf_idx_arg; |
- | |
| 267 | - | ||
| 268 | thash = thread_hash[thread_buf_idx]; |
- | |
| 269 | tid = thread_id[thread_buf_idx]; |
260 | dt = (dthread_t *)dt_arg; |
| 270 | 261 | ||
| 271 | cons_printf("debug_loop(%d)\n", tid); |
262 | cons_printf("debug_loop(%d)\n", dt->id); |
| 272 | 263 | ||
| 273 | while (!abort_debug) { |
264 | while (!abort_debug) { |
| 274 | 265 | ||
| 275 | /* Run thread until an event occurs */ |
266 | /* Run thread until an event occurs */ |
| 276 | rc = udebug_go(app_phone, thash, |
267 | rc = udebug_go(app_phone, dt->hash, &ev_type, &val0, &val1); |
| 277 | &ev_type, &val0, &val1); |
- | |
| 278 | 268 | ||
| 279 | if (ev_type == UDEBUG_EVENT_FINISHED) { |
269 | if (ev_type == UDEBUG_EVENT_FINISHED) { |
| 280 | cons_printf("thread %u debugging finished\n", tid); |
270 | cons_printf("thread %u debugging finished\n", dt->id); |
| 281 | break; |
271 | break; |
| 282 | } |
272 | } |
| 283 | if (rc >= 0) debug_event(thash, ev_type, val0); |
273 | if (rc >= 0) debug_event(thash, ev_type, val0); |
| 284 | } |
274 | } |
| 285 | 275 | ||
| 286 | cons_printf("debug_loop(%d) exiting\n", thread_id); |
276 | cons_printf("debug_loop(%d) exiting\n", dt->id); |
| 287 | } |
277 | } |
| 288 | 278 | ||
| 289 | void thread_debug_start(unsigned thash) |
279 | void thread_debug_start(unsigned thash) |
| 290 | { |
280 | { |
| 291 | fid_t fid; |
281 | fid_t fid; |
| - | 282 | dthread_t *dt; |
|
| 292 | 283 | ||
| 293 | thread_hash[n_threads] = thash; |
284 | dt = dthread_new(thash); |
| 294 | thread_id[n_threads] = next_thread_id++; |
- | |
| 295 | 285 | ||
| 296 | fid = fibril_create(debug_loop, (void *)n_threads++); |
286 | fid = fibril_create(debug_loop, (void *)dt); |
| 297 | if (fid == 0) { |
287 | if (fid == 0) { |
| 298 | cons_printf("Warning: Failed creating fibril\n"); |
288 | cons_printf("Warning: Failed creating fibril\n"); |
| 299 | } |
289 | } |
| 300 | fibril_add_ready(fid); |
290 | fibril_add_ready(fid); |
| 301 | } |
291 | } |
| Line 352... | Line 342... | ||
| 352 | 342 | ||
| 353 | static void main_init(void) |
343 | static void main_init(void) |
| 354 | { |
344 | { |
| 355 | next_thread_id = 1; |
345 | next_thread_id = 1; |
| 356 | paused = 0; |
346 | paused = 0; |
| - | 347 | ||
| - | 348 | list_initialize(&dthreads); |
|
| - | 349 | cwt = NULL; |
|
| 357 | 350 | ||
| 358 | fcv_init(&go_cv); |
351 | fcv_init(&go_cv); |
| 359 | } |
352 | } |
| 360 | 353 | ||
| 361 | int main(void) |
354 | int main(void) |