Rev 3448 | Rev 3569 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3448 | Rev 3474 | ||
---|---|---|---|
Line 40... | Line 40... | ||
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 <task.h> |
44 | #include <task.h> |
- | 45 | #include <loader/loader.h> |
|
45 | 46 | ||
46 | // Temporary: service and method names |
47 | // Temporary: service and method names |
47 | #include "proto.h" |
48 | #include "proto.h" |
48 | #include <ipc/services.h> |
49 | #include <ipc/services.h> |
49 | #include "../../srv/vfs/vfs.h" |
50 | #include "../../srv/vfs/vfs.h" |
Line 53... | Line 54... | ||
53 | #include "ipcp.h" |
54 | #include "ipcp.h" |
54 | #include "errors.h" |
55 | #include "errors.h" |
55 | #include "trace.h" |
56 | #include "trace.h" |
56 | 57 | ||
57 | #define THBUF_SIZE 64 |
58 | #define THBUF_SIZE 64 |
58 | unsigned thread_hash_buf[THBUF_SIZE]; |
59 | uintptr_t thread_hash_buf[THBUF_SIZE]; |
59 | unsigned n_threads; |
60 | int n_threads; |
60 | 61 | ||
61 | int next_thread_id; |
62 | int next_thread_id; |
62 | 63 | ||
63 | int phoneid; |
64 | int phoneid; |
64 | int abort_trace; |
65 | int abort_trace; |
65 | 66 | ||
66 | unsigned thash; |
67 | uintptr_t thash; |
67 | volatile int paused; |
68 | volatile int paused; |
68 | 69 | ||
69 | void thread_trace_start(unsigned thread_hash); |
70 | void thread_trace_start(uintptr_t thread_hash); |
70 | 71 | ||
71 | static proto_t *proto_console; |
72 | static proto_t *proto_console; |
72 | static task_id_t task_id; |
73 | static task_id_t task_id; |
- | 74 | static loader_t *task_ldr; |
|
73 | 75 | ||
74 | /** Combination of events/data to print. */ |
76 | /** Combination of events/data to print. */ |
75 | display_mask_t display_mask; |
77 | display_mask_t display_mask; |
76 | 78 | ||
- | 79 | static int program_run_fibril(void *arg); |
|
- | 80 | ||
- | 81 | static void program_run(void) |
|
- | 82 | { |
|
- | 83 | fid_t fid; |
|
- | 84 | ||
- | 85 | fid = fibril_create(program_run_fibril, NULL); |
|
- | 86 | if (fid == 0) { |
|
- | 87 | printf("Error creating fibril\n"); |
|
- | 88 | exit(1); |
|
- | 89 | } |
|
- | 90 | ||
- | 91 | fibril_add_ready(fid); |
|
- | 92 | } |
|
- | 93 | ||
- | 94 | static int program_run_fibril(void *arg) |
|
- | 95 | { |
|
- | 96 | int rc; |
|
- | 97 | ||
- | 98 | /* |
|
- | 99 | * This must be done in background as it will block until |
|
- | 100 | * we let the task reply to this call. |
|
- | 101 | */ |
|
- | 102 | rc = loader_run(task_ldr); |
|
- | 103 | if (rc != 0) { |
|
- | 104 | printf("Error running program\n"); |
|
- | 105 | exit(1); |
|
- | 106 | } |
|
- | 107 | ||
- | 108 | free(task_ldr); |
|
- | 109 | task_ldr = NULL; |
|
- | 110 | ||
- | 111 | printf("program_run_fibril exiting\n"); |
|
- | 112 | return 0; |
|
- | 113 | } |
|
- | 114 | ||
- | 115 | ||
77 | static int task_connect(task_id_t task_id) |
116 | static int connect_task(task_id_t task_id) |
78 | { |
117 | { |
79 | int rc; |
118 | int rc; |
80 | 119 | ||
81 | rc = ipc_connect_kbox(task_id); |
120 | rc = ipc_connect_kbox(task_id); |
82 | 121 | ||
Line 123... | Line 162... | ||
123 | if (rc < 0) { |
162 | if (rc < 0) { |
124 | printf("udebug_thread_read() -> %d\n", rc); |
163 | printf("udebug_thread_read() -> %d\n", rc); |
125 | return rc; |
164 | return rc; |
126 | } |
165 | } |
127 | 166 | ||
128 | n_threads = tb_copied / sizeof(unsigned); |
167 | n_threads = tb_copied / sizeof(uintptr_t); |
129 | 168 | ||
130 | printf("Threads:"); |
169 | printf("Threads:"); |
131 | for (i = 0; i < n_threads; i++) { |
170 | for (i = 0; i < n_threads; i++) { |
132 | printf(" [%d] (hash 0x%x)", 1+i, thread_hash_buf[i]); |
171 | printf(" [%d] (hash 0x%lx)", 1+i, thread_hash_buf[i]); |
133 | } |
172 | } |
134 | printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); |
173 | printf("\ntotal of %u threads\n", tb_needed / sizeof(uintptr_t)); |
135 | 174 | ||
136 | return 0; |
175 | return 0; |
137 | } |
176 | } |
138 | 177 | ||
139 | static void print_sc_retval(int retval, rv_type_t rv_type) |
178 | void val_print(sysarg_t val, val_type_t v_type) |
140 | { |
179 | { |
- | 180 | switch (v_type) { |
|
- | 181 | case V_VOID: |
|
141 | printf (" -> "); |
182 | printf("<void>"); |
- | 183 | break; |
|
- | 184 | ||
142 | if (rv_type == RV_INTEGER) { |
185 | case V_INTEGER: |
143 | printf("%d", retval); |
186 | printf("%ld", val); |
- | 187 | break; |
|
- | 188 | ||
144 | } else if (rv_type == RV_HASH) { |
189 | case V_HASH: |
- | 190 | case V_PTR: |
|
145 | printf("0x%08x", retval); |
191 | printf("0x%08lx", val); |
- | 192 | break; |
|
- | 193 | ||
- | 194 | case V_ERRNO: |
|
146 | } else if (rv_type == RV_ERRNO) { |
195 | if (val >= -15 && val <= 0) { |
- | 196 | printf("%ld %s (%s)", val, |
|
- | 197 | err_desc[-val].name, |
|
- | 198 | err_desc[-val].desc); |
|
- | 199 | } else { |
|
- | 200 | printf("%ld", val); |
|
- | 201 | } |
|
- | 202 | break; |
|
- | 203 | case V_INT_ERRNO: |
|
147 | if (retval >= -15 && retval <= 0) { |
204 | if (val >= -15 && val < 0) { |
148 | printf("%d %s (%s)", retval, |
205 | printf("%ld %s (%s)", val, |
149 | err_desc[retval].name, |
206 | err_desc[-val].name, |
150 | err_desc[retval].desc); |
207 | err_desc[-val].desc); |
151 | } else { |
208 | } else { |
152 | printf("%d", retval); |
209 | printf("%ld", val); |
153 | } |
210 | } |
- | 211 | break; |
|
- | 212 | ||
154 | } else if (rv_type == RV_INT_ERRNO) { |
213 | case V_CHAR: |
155 | if (retval >= -15 && retval < 0) { |
214 | if (val >= 0x20 && val < 0x7f) { |
156 | printf("%d %s (%s)", retval, |
215 | printf("'%c'", val); |
157 | err_desc[retval].name, |
- | |
158 | err_desc[retval].desc); |
- | |
159 | } else { |
216 | } else { |
160 | printf("%d", retval); |
217 | switch (val) { |
- | 218 | case '\a': printf("'\\a'"); break; |
|
- | 219 | case '\b': printf("'\\b'"); break; |
|
- | 220 | case '\n': printf("'\\n'"); break; |
|
- | 221 | case '\r': printf("'\\r'"); break; |
|
- | 222 | case '\t': printf("'\\t'"); break; |
|
- | 223 | case '\\': printf("'\\\\'"); break; |
|
- | 224 | default: printf("'\\x%02lX'", val); break; |
|
- | 225 | } |
|
161 | } |
226 | } |
- | 227 | break; |
|
162 | } |
228 | } |
- | 229 | } |
|
- | 230 | ||
- | 231 | ||
- | 232 | static void print_sc_retval(sysarg_t retval, val_type_t val_type) |
|
- | 233 | { |
|
- | 234 | printf(" -> "); |
|
- | 235 | val_print(retval, val_type); |
|
163 | putchar('\n'); |
236 | putchar('\n'); |
164 | } |
237 | } |
165 | 238 | ||
166 | static void print_sc_args(unsigned *sc_args, int n) |
239 | static void print_sc_args(sysarg_t *sc_args, int n) |
167 | { |
240 | { |
168 | int i; |
241 | int i; |
169 | 242 | ||
170 | putchar('('); |
243 | putchar('('); |
171 | if (n > 0) printf("%d", sc_args[0]); |
244 | if (n > 0) printf("%ld", sc_args[0]); |
172 | for (i=1; i<n; i++) { |
245 | for (i = 1; i < n; i++) { |
173 | printf(", %d", sc_args[i]); |
246 | printf(", %ld", sc_args[i]); |
174 | } |
247 | } |
175 | putchar(')'); |
248 | putchar(')'); |
176 | } |
249 | } |
177 | 250 | ||
178 | static void sc_ipc_call_async_fast(unsigned *sc_args, int sc_rc) |
251 | static void sc_ipc_call_async_fast(sysarg_t *sc_args, sysarg_t sc_rc) |
179 | { |
252 | { |
180 | ipc_call_t call; |
253 | ipc_call_t call; |
181 | int phoneid; |
254 | ipcarg_t phoneid; |
182 | 255 | ||
183 | if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY) |
256 | if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY) |
184 | return; |
257 | return; |
185 | 258 | ||
186 | phoneid = sc_args[0]; |
259 | phoneid = sc_args[0]; |
Line 193... | Line 266... | ||
193 | IPC_SET_ARG5(call, 0); |
266 | IPC_SET_ARG5(call, 0); |
194 | 267 | ||
195 | ipcp_call_out(phoneid, &call, sc_rc); |
268 | ipcp_call_out(phoneid, &call, sc_rc); |
196 | } |
269 | } |
197 | 270 | ||
198 | static void sc_ipc_call_async_slow(unsigned *sc_args, int sc_rc) |
271 | static void sc_ipc_call_async_slow(sysarg_t *sc_args, sysarg_t sc_rc) |
199 | { |
272 | { |
200 | ipc_call_t call; |
273 | ipc_call_t call; |
201 | int rc; |
274 | int rc; |
202 | 275 | ||
203 | if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY) |
276 | if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY) |
Line 209... | Line 282... | ||
209 | if (rc >= 0) { |
282 | if (rc >= 0) { |
210 | ipcp_call_out(sc_args[0], &call, sc_rc); |
283 | ipcp_call_out(sc_args[0], &call, sc_rc); |
211 | } |
284 | } |
212 | } |
285 | } |
213 | 286 | ||
214 | static void sc_ipc_call_sync_fast(unsigned *sc_args) |
287 | static void sc_ipc_call_sync_fast(sysarg_t *sc_args) |
215 | { |
288 | { |
216 | ipc_call_t question, reply; |
289 | ipc_call_t question, reply; |
217 | int rc; |
290 | int rc; |
218 | int phoneidx; |
291 | int phoneidx; |
219 | 292 | ||
Line 237... | Line 310... | ||
237 | 310 | ||
238 | // printf("call ipc_call_sync\n"); |
311 | // printf("call ipc_call_sync\n"); |
239 | ipcp_call_sync(phoneidx, &question, &reply); |
312 | ipcp_call_sync(phoneidx, &question, &reply); |
240 | } |
313 | } |
241 | 314 | ||
242 | static void sc_ipc_call_sync_slow(unsigned *sc_args) |
315 | static void sc_ipc_call_sync_slow(sysarg_t *sc_args) |
243 | { |
316 | { |
244 | ipc_call_t question, reply; |
317 | ipc_call_t question, reply; |
245 | int rc; |
318 | int rc; |
246 | 319 | ||
247 | memset(&question, 0, sizeof(question)); |
320 | memset(&question, 0, sizeof(question)); |
Line 255... | Line 328... | ||
255 | if (rc < 0) return; |
328 | if (rc < 0) return; |
256 | 329 | ||
257 | ipcp_call_sync(sc_args[0], &question, &reply); |
330 | ipcp_call_sync(sc_args[0], &question, &reply); |
258 | } |
331 | } |
259 | 332 | ||
260 | static void sc_ipc_wait(unsigned *sc_args, int sc_rc) |
333 | static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc) |
261 | { |
334 | { |
262 | ipc_call_t call; |
335 | ipc_call_t call; |
263 | int rc; |
336 | int rc; |
264 | 337 | ||
265 | if (sc_rc == 0) return; |
338 | if (sc_rc == 0) return; |
Line 272... | Line 345... | ||
272 | if (rc >= 0) { |
345 | if (rc >= 0) { |
273 | ipcp_call_in(&call, sc_rc); |
346 | ipcp_call_in(&call, sc_rc); |
274 | } |
347 | } |
275 | } |
348 | } |
276 | 349 | ||
277 | static void event_syscall_b(unsigned thread_id, unsigned thread_hash, unsigned sc_id, int sc_rc) |
350 | static void event_syscall_b(unsigned thread_id, uintptr_t thread_hash, |
- | 351 | unsigned sc_id, sysarg_t sc_rc) |
|
278 | { |
352 | { |
279 | unsigned sc_args[6]; |
353 | sysarg_t sc_args[6]; |
280 | int rc; |
354 | int rc; |
281 | 355 | ||
282 | /* Read syscall arguments */ |
356 | /* Read syscall arguments */ |
283 | rc = udebug_args_read(phoneid, thread_hash, sc_args); |
357 | rc = udebug_args_read(phoneid, thread_hash, sc_args); |
284 | 358 | ||
Line 299... | Line 373... | ||
299 | } |
373 | } |
300 | 374 | ||
301 | async_serialize_end(); |
375 | async_serialize_end(); |
302 | } |
376 | } |
303 | 377 | ||
304 | static void event_syscall_e(unsigned thread_id, unsigned thread_hash, unsigned sc_id, int sc_rc) |
378 | static void event_syscall_e(unsigned thread_id, uintptr_t thread_hash, |
- | 379 | unsigned sc_id, sysarg_t sc_rc) |
|
305 | { |
380 | { |
306 | unsigned sc_args[6]; |
381 | sysarg_t sc_args[6]; |
307 | int rv_type; |
382 | int rv_type; |
308 | int rc; |
383 | int rc; |
309 | 384 | ||
310 | /* Read syscall arguments */ |
385 | /* Read syscall arguments */ |
311 | rc = udebug_args_read(phoneid, thread_hash, sc_args); |
386 | rc = udebug_args_read(phoneid, thread_hash, sc_args); |
Line 347... | Line 422... | ||
347 | } |
422 | } |
348 | 423 | ||
349 | async_serialize_end(); |
424 | async_serialize_end(); |
350 | } |
425 | } |
351 | 426 | ||
352 | static void event_thread_b(unsigned hash) |
427 | static void event_thread_b(uintptr_t hash) |
353 | { |
428 | { |
354 | async_serialize_start(); |
429 | async_serialize_start(); |
355 | printf("New thread, hash 0x%x\n", hash); |
430 | printf("New thread, hash 0x%lx\n", hash); |
356 | async_serialize_end(); |
431 | async_serialize_end(); |
357 | 432 | ||
358 | thread_trace_start(hash); |
433 | thread_trace_start(hash); |
359 | } |
434 | } |
360 | 435 | ||
361 | static int trace_loop(void *thread_hash_arg) |
436 | static int trace_loop(void *thread_hash_arg) |
362 | { |
437 | { |
363 | int rc; |
438 | int rc; |
364 | unsigned ev_type; |
439 | unsigned ev_type; |
365 | unsigned thread_hash; |
440 | uintptr_t thread_hash; |
366 | unsigned thread_id; |
441 | unsigned thread_id; |
367 | unsigned val0, val1; |
442 | sysarg_t val0, val1; |
368 | 443 | ||
369 | thread_hash = (unsigned)thread_hash_arg; |
444 | thread_hash = (uintptr_t)thread_hash_arg; |
370 | thread_id = next_thread_id++; |
445 | thread_id = next_thread_id++; |
371 | 446 | ||
372 | printf("Start tracing thread [%d] (hash 0x%x)\n", thread_id, thread_hash); |
447 | printf("Start tracing thread [%d] (hash 0x%lx)\n", thread_id, thread_hash); |
373 | 448 | ||
374 | while (!abort_trace) { |
449 | while (!abort_trace) { |
375 | 450 | ||
376 | /* Run thread until an event occurs */ |
451 | /* Run thread until an event occurs */ |
377 | rc = udebug_go(phoneid, thread_hash, |
452 | rc = udebug_go(phoneid, thread_hash, |
Line 403... | Line 478... | ||
403 | break; |
478 | break; |
404 | case UDEBUG_EVENT_THREAD_B: |
479 | case UDEBUG_EVENT_THREAD_B: |
405 | event_thread_b(val0); |
480 | event_thread_b(val0); |
406 | break; |
481 | break; |
407 | case UDEBUG_EVENT_THREAD_E: |
482 | case UDEBUG_EVENT_THREAD_E: |
408 | printf("Thread 0x%x exited\n", val0); |
483 | printf("Thread 0x%lx exited\n", val0); |
409 | abort_trace = 1; |
484 | abort_trace = 1; |
410 | break; |
485 | break; |
411 | default: |
486 | default: |
412 | printf("Unknown event type %d\n", ev_type); |
487 | printf("Unknown event type %d\n", ev_type); |
413 | break; |
488 | break; |
Line 418... | Line 493... | ||
418 | 493 | ||
419 | printf("Finished tracing thread [%d]\n", thread_id); |
494 | printf("Finished tracing thread [%d]\n", thread_id); |
420 | return 0; |
495 | return 0; |
421 | } |
496 | } |
422 | 497 | ||
423 | void thread_trace_start(unsigned thread_hash) |
498 | void thread_trace_start(uintptr_t thread_hash) |
424 | { |
499 | { |
425 | fid_t fid; |
500 | fid_t fid; |
426 | 501 | ||
427 | thash = thread_hash; |
502 | thash = thread_hash; |
428 | 503 | ||
Line 431... | Line 506... | ||
431 | printf("Warning: Failed creating fibril\n"); |
506 | printf("Warning: Failed creating fibril\n"); |
432 | } |
507 | } |
433 | fibril_add_ready(fid); |
508 | fibril_add_ready(fid); |
434 | } |
509 | } |
435 | 510 | ||
- | 511 | static loader_t *preload_task(const char *path, char *const argv[], |
|
436 | static void trace_active_task(task_id_t task_id) |
512 | task_id_t *task_id) |
437 | { |
513 | { |
438 | int i; |
514 | loader_t *ldr; |
439 | int rc; |
515 | int rc; |
440 | int c; |
- | |
441 | 516 | ||
- | 517 | /* Spawn a program loader */ |
|
- | 518 | ldr = loader_spawn(); |
|
- | 519 | if (ldr == NULL) |
|
- | 520 | return 0; |
|
- | 521 | ||
- | 522 | /* Get task ID. */ |
|
442 | rc = task_connect(task_id); |
523 | rc = loader_get_task_id(ldr, task_id); |
443 | if (rc < 0) { |
524 | if (rc != EOK) |
- | 525 | goto error; |
|
- | 526 | ||
- | 527 | /* Send program pathname */ |
|
444 | printf("Failed to connect to task %lld\n", task_id); |
528 | rc = loader_set_pathname(ldr, path); |
- | 529 | if (rc != EOK) |
|
- | 530 | goto error; |
|
- | 531 | ||
- | 532 | /* Send arguments */ |
|
- | 533 | rc = loader_set_args(ldr, argv); |
|
- | 534 | if (rc != EOK) |
|
- | 535 | goto error; |
|
- | 536 | ||
- | 537 | /* Load the program. */ |
|
- | 538 | rc = loader_load_program(ldr); |
|
- | 539 | if (rc != EOK) |
|
- | 540 | goto error; |
|
- | 541 | ||
- | 542 | /* Success */ |
|
445 | return; |
543 | return ldr; |
- | 544 | ||
- | 545 | /* Error exit */ |
|
- | 546 | error: |
|
- | 547 | loader_abort(ldr); |
|
- | 548 | free(ldr); |
|
- | 549 | return NULL; |
|
446 | } |
550 | } |
447 | 551 | ||
448 | printf("Connected to task %lld\n", task_id); |
552 | static void trace_task(task_id_t task_id) |
- | 553 | { |
|
- | 554 | int i; |
|
- | 555 | int rc; |
|
- | 556 | int c; |
|
449 | 557 | ||
450 | ipcp_init(); |
558 | ipcp_init(); |
451 | 559 | ||
452 | /* |
560 | /* |
453 | * User apps now typically have console on phone 3. |
561 | * User apps now typically have console on phone 3. |
Line 494... | Line 602... | ||
494 | static void main_init(void) |
602 | static void main_init(void) |
495 | { |
603 | { |
496 | proto_t *p; |
604 | proto_t *p; |
497 | oper_t *o; |
605 | oper_t *o; |
498 | 606 | ||
- | 607 | val_type_t arg_def[OPER_MAX_ARGS] = { |
|
- | 608 | V_INTEGER, |
|
- | 609 | V_INTEGER, |
|
- | 610 | V_INTEGER, |
|
- | 611 | V_INTEGER, |
|
- | 612 | V_INTEGER |
|
- | 613 | }; |
|
- | 614 | ||
- | 615 | val_type_t resp_def[OPER_MAX_ARGS] = { |
|
- | 616 | V_INTEGER, |
|
- | 617 | V_INTEGER, |
|
- | 618 | V_INTEGER, |
|
- | 619 | V_INTEGER, |
|
- | 620 | V_INTEGER |
|
- | 621 | }; |
|
- | 622 | ||
499 | next_thread_id = 1; |
623 | next_thread_id = 1; |
500 | paused = 0; |
624 | paused = 0; |
501 | 625 | ||
502 | proto_init(); |
626 | proto_init(); |
503 | 627 | ||
504 | p = proto_new("vfs"); |
628 | p = proto_new("vfs"); |
505 | o = oper_new("read"); |
629 | o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def); |
506 | proto_add_oper(p, VFS_READ, o); |
630 | proto_add_oper(p, VFS_READ, o); |
507 | o = oper_new("write"); |
631 | o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def); |
508 | proto_add_oper(p, VFS_WRITE, o); |
632 | proto_add_oper(p, VFS_WRITE, o); |
509 | o = oper_new("truncate"); |
633 | o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def); |
510 | proto_add_oper(p, VFS_TRUNCATE, o); |
634 | proto_add_oper(p, VFS_TRUNCATE, o); |
511 | o = oper_new("mount"); |
635 | o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def); |
512 | proto_add_oper(p, VFS_MOUNT, o); |
636 | proto_add_oper(p, VFS_MOUNT, o); |
513 | o = oper_new("unmount"); |
637 | /* o = oper_new("unmount", 0, arg_def); |
514 | proto_add_oper(p, VFS_UNMOUNT, o); |
638 | proto_add_oper(p, VFS_UNMOUNT, o);*/ |
515 | 639 | ||
516 | proto_register(SERVICE_VFS, p); |
640 | proto_register(SERVICE_VFS, p); |
517 | 641 | ||
518 | p = proto_new("console"); |
642 | p = proto_new("console"); |
- | 643 | resp_def[0] = V_CHAR; |
|
519 | o = oper_new("getchar"); |
644 | o = oper_new("getchar", 0, arg_def, V_INTEGER, 2, resp_def); |
520 | proto_add_oper(p, CONSOLE_GETCHAR, o); |
645 | proto_add_oper(p, CONSOLE_GETCHAR, o); |
- | 646 | ||
- | 647 | arg_def[0] = V_CHAR; |
|
521 | o = oper_new("putchar"); |
648 | o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def); |
522 | proto_add_oper(p, CONSOLE_PUTCHAR, o); |
649 | proto_add_oper(p, CONSOLE_PUTCHAR, o); |
523 | o = oper_new("clear"); |
650 | o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def); |
524 | proto_add_oper(p, CONSOLE_CLEAR, o); |
651 | proto_add_oper(p, CONSOLE_CLEAR, o); |
- | 652 | ||
- | 653 | arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; |
|
525 | o = oper_new("goto"); |
654 | o = oper_new("goto", 2, arg_def, V_VOID, 0, resp_def); |
526 | proto_add_oper(p, CONSOLE_GOTO, o); |
655 | proto_add_oper(p, CONSOLE_GOTO, o); |
- | 656 | ||
- | 657 | resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER; |
|
527 | o = oper_new("getsize"); |
658 | o = oper_new("getsize", 0, arg_def, V_INTEGER, 2, resp_def); |
528 | proto_add_oper(p, CONSOLE_GETSIZE, o); |
659 | proto_add_oper(p, CONSOLE_GETSIZE, o); |
529 | o = oper_new("flush"); |
660 | o = oper_new("flush", 0, arg_def, V_VOID, 0, resp_def); |
530 | proto_add_oper(p, CONSOLE_FLUSH, o); |
661 | proto_add_oper(p, CONSOLE_FLUSH, o); |
- | 662 | ||
- | 663 | arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; |
|
531 | o = oper_new("set_style"); |
664 | o = oper_new("set_style", 2, arg_def, V_INTEGER, 0, resp_def); |
532 | proto_add_oper(p, CONSOLE_SET_STYLE, o); |
665 | proto_add_oper(p, CONSOLE_SET_STYLE, o); |
533 | o = oper_new("cursor_visibility"); |
666 | o = oper_new("cursor_visibility", 1, arg_def, V_VOID, 0, resp_def); |
534 | proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o); |
667 | proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o); |
535 | o = oper_new("flush"); |
- | |
536 | proto_add_oper(p, CONSOLE_FLUSH, o); |
- | |
537 | 668 | ||
538 | proto_console = p; |
669 | proto_console = p; |
539 | proto_register(SERVICE_CONSOLE, p); |
670 | proto_register(SERVICE_CONSOLE, p); |
540 | } |
671 | } |
541 | 672 | ||
Line 596... | Line 727... | ||
596 | } else if (arg[0] == '-') { |
727 | } else if (arg[0] == '-') { |
597 | if (arg[1] == 't') { |
728 | if (arg[1] == 't') { |
598 | /* Trace an already running task */ |
729 | /* Trace an already running task */ |
599 | --argc; ++argv; |
730 | --argc; ++argv; |
600 | task_id = strtol(*argv, &err_p, 10); |
731 | task_id = strtol(*argv, &err_p, 10); |
- | 732 | task_ldr = NULL; |
|
601 | if (*err_p) { |
733 | if (*err_p) { |
602 | printf("Task ID syntax error\n"); |
734 | printf("Task ID syntax error\n"); |
603 | print_syntax(); |
735 | print_syntax(); |
604 | return -1; |
736 | return -1; |
605 | } |
737 | } |
Line 614... | Line 746... | ||
614 | 746 | ||
615 | --argc; ++argv; |
747 | --argc; ++argv; |
616 | } |
748 | } |
617 | 749 | ||
618 | if (task_id != 0) { |
750 | if (task_id != 0) { |
619 | if (argc == 0) return; |
751 | if (argc == 0) return 0; |
620 | printf("Extra arguments\n"); |
752 | printf("Extra arguments\n"); |
621 | print_syntax(); |
753 | print_syntax(); |
622 | return -1; |
754 | return -1; |
623 | } |
755 | } |
624 | 756 | ||
Line 626... | Line 758... | ||
626 | printf("Missing argument\n"); |
758 | printf("Missing argument\n"); |
627 | print_syntax(); |
759 | print_syntax(); |
628 | return -1; |
760 | return -1; |
629 | } |
761 | } |
630 | 762 | ||
631 | /* Execute the specified command and trace the new task. */ |
763 | /* Preload the specified program file. */ |
632 | printf("Spawning '%s' with arguments:\n", *argv); |
764 | printf("Spawning '%s' with arguments:\n", *argv); |
633 | { |
765 | { |
634 | char **cp = argv; |
766 | char **cp = argv; |
635 | while (*cp) printf("'%s'\n", *cp++); |
767 | while (*cp) printf("'%s'\n", *cp++); |
636 | } |
768 | } |
637 | task_id = task_spawn(*argv, argv); |
769 | task_ldr = preload_task(*argv, argv, &task_id); |
638 | 770 | ||
639 | return 0; |
771 | return 0; |
640 | } |
772 | } |
641 | 773 | ||
642 | int main(int argc, char *argv[]) |
774 | int main(int argc, char *argv[]) |
643 | { |
775 | { |
- | 776 | int rc; |
|
- | 777 | ||
644 | printf("System Call / IPC Tracer\n"); |
778 | printf("System Call / IPC Tracer\n"); |
645 | 779 | ||
646 | display_mask = DM_THREAD | DM_SYSTEM | DM_USER; |
780 | display_mask = DM_THREAD | DM_SYSTEM | DM_USER; |
647 | 781 | ||
648 | if (parse_args(argc, argv) < 0) |
782 | if (parse_args(argc, argv) < 0) |
649 | return 1; |
783 | return 1; |
650 | 784 | ||
651 | main_init(); |
785 | main_init(); |
- | 786 | ||
- | 787 | rc = connect_task(task_id); |
|
- | 788 | if (rc < 0) { |
|
- | 789 | printf("Failed connecting to task %lld\n", task_id); |
|
- | 790 | return 1; |
|
- | 791 | } |
|
- | 792 | ||
- | 793 | printf("Connected to task %lld\n", task_id); |
|
- | 794 | ||
- | 795 | if (task_ldr != NULL) { |
|
- | 796 | program_run(); |
|
- | 797 | } |
|
- | 798 | ||
652 | trace_active_task(task_id); |
799 | trace_task(task_id); |
653 | 800 | ||
654 | return 0; |
801 | return 0; |
655 | } |
802 | } |
656 | 803 | ||
657 | /** @} |
804 | /** @} |