Rev 4537 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4537 | Rev 4668 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | #include <udebug.h> |
41 | #include <udebug.h> |
42 | #include <async.h> |
42 | #include <async.h> |
43 | #include <task.h> |
43 | #include <task.h> |
44 | #include <mem.h> |
44 | #include <mem.h> |
45 | #include <string.h> |
45 | #include <string.h> |
- | 46 | #include <bool.h> |
|
46 | #include <loader/loader.h> |
47 | #include <loader/loader.h> |
- | 48 | #include <io/console.h> |
|
- | 49 | #include <io/keycode.h> |
|
- | 50 | #include <fibril_sync.h> |
|
47 | 51 | ||
48 | #include <libc.h> |
52 | #include <libc.h> |
49 | 53 | ||
50 | // Temporary: service and method names |
54 | // Temporary: service and method names |
51 | #include "proto.h" |
55 | #include "proto.h" |
Line 62... | Line 66... | ||
62 | uintptr_t thread_hash_buf[THBUF_SIZE]; |
66 | uintptr_t thread_hash_buf[THBUF_SIZE]; |
63 | int n_threads; |
67 | int n_threads; |
64 | 68 | ||
65 | int next_thread_id; |
69 | int next_thread_id; |
66 | 70 | ||
- | 71 | ipc_call_t thread_ipc_req[THBUF_SIZE]; |
|
- | 72 | ||
67 | int phoneid; |
73 | int phoneid; |
68 | int abort_trace; |
74 | bool abort_trace; |
69 | 75 | ||
70 | uintptr_t thash; |
76 | uintptr_t thash; |
71 | volatile int paused; |
77 | static bool paused; |
- | 78 | static fibril_condvar_t state_cv; |
|
- | 79 | static fibril_mutex_t state_lock; |
|
- | 80 | ||
- | 81 | static bool cev_valid; |
|
- | 82 | static console_event_t cev; |
|
72 | 83 | ||
73 | void thread_trace_start(uintptr_t thread_hash); |
84 | void thread_trace_start(uintptr_t thread_hash); |
74 | 85 | ||
75 | static proto_t *proto_console; |
86 | static proto_t *proto_console; |
76 | static task_id_t task_id; |
87 | static task_id_t task_id; |
77 | static loader_t *task_ldr; |
88 | static loader_t *task_ldr; |
- | 89 | static bool task_wait_for; |
|
78 | 90 | ||
79 | /** Combination of events/data to print. */ |
91 | /** Combination of events/data to print. */ |
80 | display_mask_t display_mask; |
92 | display_mask_t display_mask; |
81 | 93 | ||
82 | static int program_run_fibril(void *arg); |
94 | static int program_run_fibril(void *arg); |
- | 95 | static int cev_fibril(void *arg); |
|
83 | 96 | ||
84 | static void program_run(void) |
97 | static void program_run(void) |
85 | { |
98 | { |
86 | fid_t fid; |
99 | fid_t fid; |
87 | 100 | ||
Line 92... | Line 105... | ||
92 | } |
105 | } |
93 | 106 | ||
94 | fibril_add_ready(fid); |
107 | fibril_add_ready(fid); |
95 | } |
108 | } |
96 | 109 | ||
- | 110 | static void cev_fibril_start(void) |
|
- | 111 | { |
|
- | 112 | fid_t fid; |
|
- | 113 | ||
- | 114 | fid = fibril_create(cev_fibril, NULL); |
|
- | 115 | if (fid == 0) { |
|
- | 116 | printf("Error creating fibril\n"); |
|
- | 117 | exit(1); |
|
- | 118 | } |
|
- | 119 | ||
- | 120 | fibril_add_ready(fid); |
|
- | 121 | } |
|
- | 122 | ||
97 | static int program_run_fibril(void *arg) |
123 | static int program_run_fibril(void *arg) |
98 | { |
124 | { |
99 | int rc; |
125 | int rc; |
100 | 126 | ||
101 | /* |
127 | /* |
Line 313... | Line 339... | ||
313 | 339 | ||
314 | // printf("call ipc_call_sync\n"); |
340 | // printf("call ipc_call_sync\n"); |
315 | ipcp_call_sync(phoneidx, &question, &reply); |
341 | ipcp_call_sync(phoneidx, &question, &reply); |
316 | } |
342 | } |
317 | 343 | ||
318 | static void sc_ipc_call_sync_slow(sysarg_t *sc_args) |
344 | static void sc_ipc_call_sync_slow_b(unsigned thread_id, sysarg_t *sc_args) |
319 | { |
345 | { |
320 | ipc_call_t question, reply; |
346 | ipc_call_t question, reply; |
321 | int rc; |
347 | int rc; |
322 | 348 | ||
323 | memset(&question, 0, sizeof(question)); |
349 | memset(&question, 0, sizeof(question)); |
324 | rc = udebug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args)); |
350 | rc = udebug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args)); |
- | 351 | if (rc < 0) { |
|
325 | printf("dmr->%d\n", rc); |
352 | printf("Error: mem_read->%d\n", rc); |
326 | if (rc < 0) return; |
353 | return; |
- | 354 | } |
|
- | 355 | ||
- | 356 | thread_ipc_req[thread_id] = question; |
|
- | 357 | } |
|
- | 358 | ||
- | 359 | static void sc_ipc_call_sync_slow_e(unsigned thread_id, sysarg_t *sc_args) |
|
- | 360 | { |
|
- | 361 | ipc_call_t question, reply; |
|
- | 362 | int rc; |
|
327 | 363 | ||
328 | memset(&reply, 0, sizeof(reply)); |
364 | memset(&reply, 0, sizeof(reply)); |
329 | rc = udebug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args)); |
365 | rc = udebug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args)); |
- | 366 | if (rc < 0) { |
|
330 | printf("dmr->%d\n", rc); |
367 | printf("Error: mem_read->%d\n", rc); |
331 | if (rc < 0) return; |
368 | return; |
- | 369 | } |
|
332 | 370 | ||
333 | ipcp_call_sync(sc_args[0], &question, &reply); |
371 | ipcp_call_sync(sc_args[0], &thread_ipc_req[thread_id], &reply); |
334 | } |
372 | } |
335 | 373 | ||
336 | static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc) |
374 | static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc) |
337 | { |
375 | { |
338 | ipc_call_t call; |
376 | ipc_call_t call; |
Line 373... | Line 411... | ||
373 | /* Print syscall name and arguments */ |
411 | /* Print syscall name and arguments */ |
374 | printf("%s", syscall_desc[sc_id].name); |
412 | printf("%s", syscall_desc[sc_id].name); |
375 | print_sc_args(sc_args, syscall_desc[sc_id].n_args); |
413 | print_sc_args(sc_args, syscall_desc[sc_id].n_args); |
376 | } |
414 | } |
377 | 415 | ||
- | 416 | switch (sc_id) { |
|
- | 417 | case SYS_IPC_CALL_SYNC_SLOW: |
|
- | 418 | sc_ipc_call_sync_slow_b(thread_id, sc_args); |
|
- | 419 | break; |
|
- | 420 | default: |
|
- | 421 | break; |
|
- | 422 | } |
|
- | 423 | ||
378 | async_serialize_end(); |
424 | async_serialize_end(); |
379 | } |
425 | } |
380 | 426 | ||
381 | static void event_syscall_e(unsigned thread_id, uintptr_t thread_hash, |
427 | static void event_syscall_e(unsigned thread_id, uintptr_t thread_hash, |
382 | unsigned sc_id, sysarg_t sc_rc) |
428 | unsigned sc_id, sysarg_t sc_rc) |
Line 413... | Line 459... | ||
413 | break; |
459 | break; |
414 | case SYS_IPC_CALL_SYNC_FAST: |
460 | case SYS_IPC_CALL_SYNC_FAST: |
415 | sc_ipc_call_sync_fast(sc_args); |
461 | sc_ipc_call_sync_fast(sc_args); |
416 | break; |
462 | break; |
417 | case SYS_IPC_CALL_SYNC_SLOW: |
463 | case SYS_IPC_CALL_SYNC_SLOW: |
418 | sc_ipc_call_sync_slow(sc_args); |
464 | sc_ipc_call_sync_slow_e(thread_id, sc_args); |
419 | break; |
465 | break; |
420 | case SYS_IPC_WAIT: |
466 | case SYS_IPC_WAIT: |
421 | sc_ipc_wait(sc_args, sc_rc); |
467 | sc_ipc_wait(sc_args, sc_rc); |
422 | break; |
468 | break; |
423 | default: |
469 | default: |
Line 444... | Line 490... | ||
444 | unsigned thread_id; |
490 | unsigned thread_id; |
445 | sysarg_t val0, val1; |
491 | sysarg_t val0, val1; |
446 | 492 | ||
447 | thread_hash = (uintptr_t)thread_hash_arg; |
493 | thread_hash = (uintptr_t)thread_hash_arg; |
448 | thread_id = next_thread_id++; |
494 | thread_id = next_thread_id++; |
- | 495 | if (thread_id >= THBUF_SIZE) { |
|
- | 496 | printf("Too many threads.\n"); |
|
- | 497 | return ELIMIT; |
|
- | 498 | } |
|
449 | 499 | ||
450 | printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash); |
500 | printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash); |
451 | 501 | ||
452 | while (!abort_trace) { |
502 | while (!abort_trace) { |
453 | 503 | ||
- | 504 | fibril_mutex_lock(&state_lock); |
|
454 | if (paused) { |
505 | if (paused) { |
455 | printf("Press R to resume (and be patient).\n"); |
506 | printf("Thread [%d] paused. Press R to resume.\n", |
456 | while (paused) { |
507 | thread_id); |
- | 508 | ||
457 | usleep(1000000); |
509 | while (paused) |
458 | fibril_yield(); |
510 | fibril_condvar_wait(&state_cv, &state_lock); |
459 | printf("."); |
- | |
460 | } |
511 | |
461 | printf("Resumed\n"); |
512 | printf("Thread [%d] resumed.\n", thread_id); |
462 | } |
513 | } |
- | 514 | fibril_mutex_unlock(&state_lock); |
|
463 | 515 | ||
464 | /* Run thread until an event occurs */ |
516 | /* Run thread until an event occurs */ |
465 | rc = udebug_go(phoneid, thread_hash, |
517 | rc = udebug_go(phoneid, thread_hash, |
466 | &ev_type, &val0, &val1); |
518 | &ev_type, &val0, &val1); |
467 | 519 | ||
Line 479... | Line 531... | ||
479 | case UDEBUG_EVENT_SYSCALL_E: |
531 | case UDEBUG_EVENT_SYSCALL_E: |
480 | event_syscall_e(thread_id, thread_hash, val0, (int)val1); |
532 | event_syscall_e(thread_id, thread_hash, val0, (int)val1); |
481 | break; |
533 | break; |
482 | case UDEBUG_EVENT_STOP: |
534 | case UDEBUG_EVENT_STOP: |
483 | printf("Stop event\n"); |
535 | printf("Stop event\n"); |
- | 536 | fibril_mutex_lock(&state_lock); |
|
- | 537 | paused = true; |
|
- | 538 | fibril_mutex_unlock(&state_lock); |
|
484 | break; |
539 | break; |
485 | case UDEBUG_EVENT_THREAD_B: |
540 | case UDEBUG_EVENT_THREAD_B: |
486 | event_thread_b(val0); |
541 | event_thread_b(val0); |
487 | break; |
542 | break; |
488 | case UDEBUG_EVENT_THREAD_E: |
543 | case UDEBUG_EVENT_THREAD_E: |
489 | printf("Thread 0x%lx exited.\n", val0); |
544 | printf("Thread 0x%lx exited.\n", val0); |
- | 545 | fibril_mutex_lock(&state_lock); |
|
490 | abort_trace = 1; |
546 | abort_trace = true; |
- | 547 | fibril_condvar_broadcast(&state_cv); |
|
- | 548 | fibril_mutex_unlock(&state_lock); |
|
491 | break; |
549 | break; |
492 | default: |
550 | default: |
493 | printf("Unknown event type %d.\n", ev_type); |
551 | printf("Unknown event type %d.\n", ev_type); |
494 | break; |
552 | break; |
495 | } |
553 | } |
Line 538... | Line 596... | ||
538 | /* Send arguments */ |
596 | /* Send arguments */ |
539 | rc = loader_set_args(ldr, argv); |
597 | rc = loader_set_args(ldr, argv); |
540 | if (rc != EOK) |
598 | if (rc != EOK) |
541 | goto error; |
599 | goto error; |
542 | 600 | ||
- | 601 | /* Send default files */ |
|
- | 602 | fdi_node_t *files[4]; |
|
- | 603 | fdi_node_t stdin_node; |
|
- | 604 | fdi_node_t stdout_node; |
|
- | 605 | fdi_node_t stderr_node; |
|
- | 606 | ||
- | 607 | if ((stdin != NULL) && (fnode(stdin, &stdin_node) == EOK)) |
|
- | 608 | files[0] = &stdin_node; |
|
- | 609 | else |
|
- | 610 | files[0] = NULL; |
|
- | 611 | ||
- | 612 | if ((stdout != NULL) && (fnode(stdout, &stdout_node) == EOK)) |
|
- | 613 | files[1] = &stdout_node; |
|
- | 614 | else |
|
- | 615 | files[1] = NULL; |
|
- | 616 | ||
- | 617 | if ((stderr != NULL) && (fnode(stderr, &stderr_node) == EOK)) |
|
- | 618 | files[2] = &stderr_node; |
|
- | 619 | else |
|
- | 620 | files[2] = NULL; |
|
- | 621 | ||
- | 622 | files[3] = NULL; |
|
- | 623 | ||
- | 624 | rc = loader_set_files(ldr, files); |
|
- | 625 | if (rc != EOK) |
|
- | 626 | goto error; |
|
- | 627 | ||
543 | /* Load the program. */ |
628 | /* Load the program. */ |
544 | rc = loader_load_program(ldr); |
629 | rc = loader_load_program(ldr); |
545 | if (rc != EOK) |
630 | if (rc != EOK) |
546 | goto error; |
631 | goto error; |
547 | 632 | ||
Line 553... | Line 638... | ||
553 | loader_abort(ldr); |
638 | loader_abort(ldr); |
554 | free(ldr); |
639 | free(ldr); |
555 | return NULL; |
640 | return NULL; |
556 | } |
641 | } |
557 | 642 | ||
- | 643 | static int cev_fibril(void *arg) |
|
- | 644 | { |
|
- | 645 | (void) arg; |
|
- | 646 | ||
- | 647 | while (true) { |
|
- | 648 | fibril_mutex_lock(&state_lock); |
|
- | 649 | while (cev_valid) |
|
- | 650 | fibril_condvar_wait(&state_cv, &state_lock); |
|
- | 651 | fibril_mutex_unlock(&state_lock); |
|
- | 652 | ||
- | 653 | if (!console_get_event(fphone(stdin), &cev)) |
|
- | 654 | return -1; |
|
- | 655 | ||
- | 656 | fibril_mutex_lock(&state_lock); |
|
- | 657 | cev_valid = true; |
|
- | 658 | fibril_condvar_broadcast(&state_cv); |
|
- | 659 | fibril_mutex_unlock(&state_lock); |
|
- | 660 | } |
|
- | 661 | } |
|
- | 662 | ||
558 | static void trace_task(task_id_t task_id) |
663 | static void trace_task(task_id_t task_id) |
559 | { |
664 | { |
- | 665 | console_event_t ev; |
|
- | 666 | bool done; |
|
560 | int i; |
667 | int i; |
561 | int rc; |
668 | int rc; |
562 | int c; |
- | |
563 | 669 | ||
564 | ipcp_init(); |
670 | ipcp_init(); |
565 | 671 | ||
566 | /* |
672 | /* |
567 | * User apps now typically have console on phone 3. |
673 | * User apps now typically have console on phone 3. |
Line 573... | Line 679... | ||
573 | if (rc < 0) { |
679 | if (rc < 0) { |
574 | printf("Failed to get thread list (error %d)\n", rc); |
680 | printf("Failed to get thread list (error %d)\n", rc); |
575 | return; |
681 | return; |
576 | } |
682 | } |
577 | 683 | ||
578 | abort_trace = 0; |
684 | abort_trace = false; |
579 | 685 | ||
580 | for (i = 0; i < n_threads; i++) { |
686 | for (i = 0; i < n_threads; i++) { |
581 | thread_trace_start(thread_hash_buf[i]); |
687 | thread_trace_start(thread_hash_buf[i]); |
582 | } |
688 | } |
583 | 689 | ||
- | 690 | done = false; |
|
- | 691 | ||
584 | while(1) { |
692 | while (!done) { |
- | 693 | fibril_mutex_lock(&state_lock); |
|
- | 694 | while (!cev_valid && !abort_trace) |
|
- | 695 | fibril_condvar_wait(&state_cv, &state_lock); |
|
- | 696 | fibril_mutex_unlock(&state_lock); |
|
- | 697 | ||
585 | c = getchar(); |
698 | ev = cev; |
- | 699 | ||
- | 700 | fibril_mutex_lock(&state_lock); |
|
- | 701 | cev_valid = false; |
|
- | 702 | fibril_condvar_broadcast(&state_cv); |
|
- | 703 | fibril_mutex_unlock(&state_lock); |
|
- | 704 | ||
586 | if (c == 'q') break; |
705 | if (abort_trace) |
- | 706 | break; |
|
- | 707 | ||
- | 708 | if (ev.type != KEY_PRESS) |
|
- | 709 | continue; |
|
- | 710 | ||
587 | if (c == 'p') { |
711 | switch (ev.key) { |
- | 712 | case KC_Q: |
|
- | 713 | done = true; |
|
- | 714 | break; |
|
- | 715 | case KC_P: |
|
588 | printf("Pause...\n"); |
716 | printf("Pause...\n"); |
589 | paused = 1; |
- | |
590 | rc = udebug_stop(phoneid, thash); |
717 | rc = udebug_stop(phoneid, thash); |
- | 718 | if (rc != EOK) |
|
591 | printf("stop -> %d\n", rc); |
719 | printf("Error: stop -> %d\n", rc); |
592 | } |
720 | break; |
593 | if (c == 'r') { |
721 | case KC_R: |
- | 722 | fibril_mutex_lock(&state_lock); |
|
594 | paused = 0; |
723 | paused = false; |
- | 724 | fibril_condvar_broadcast(&state_cv); |
|
- | 725 | fibril_mutex_unlock(&state_lock); |
|
595 | printf("Resume...\n"); |
726 | printf("Resume...\n"); |
- | 727 | break; |
|
596 | } |
728 | } |
597 | } |
729 | } |
598 | 730 | ||
599 | printf("\nTerminate debugging session...\n"); |
731 | printf("\nTerminate debugging session...\n"); |
600 | abort_trace = 1; |
732 | abort_trace = true; |
601 | udebug_end(phoneid); |
733 | udebug_end(phoneid); |
602 | ipc_hangup(phoneid); |
734 | ipc_hangup(phoneid); |
603 | 735 | ||
604 | ipcp_cleanup(); |
736 | ipcp_cleanup(); |
605 | 737 | ||
Line 627... | Line 759... | ||
627 | V_INTEGER, |
759 | V_INTEGER, |
628 | V_INTEGER |
760 | V_INTEGER |
629 | }; |
761 | }; |
630 | 762 | ||
631 | next_thread_id = 1; |
763 | next_thread_id = 1; |
632 | paused = 0; |
764 | paused = false; |
- | 765 | cev_valid = false; |
|
- | 766 | ||
- | 767 | fibril_mutex_initialize(&state_lock); |
|
- | 768 | fibril_condvar_initialize(&state_cv); |
|
633 | 769 | ||
634 | proto_init(); |
770 | proto_init(); |
635 | 771 | ||
636 | p = proto_new("vfs"); |
772 | p = proto_new("vfs"); |
- | 773 | o = oper_new("open", 2, arg_def, V_INT_ERRNO, 0, resp_def); |
|
- | 774 | proto_add_oper(p, VFS_IN_OPEN, o); |
|
- | 775 | o = oper_new("open_node", 4, arg_def, V_INT_ERRNO, 0, resp_def); |
|
- | 776 | proto_add_oper(p, VFS_IN_OPEN_NODE, o); |
|
637 | o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def); |
777 | o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def); |
638 | proto_add_oper(p, VFS_READ, o); |
778 | proto_add_oper(p, VFS_IN_READ, o); |
639 | o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def); |
779 | o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def); |
640 | proto_add_oper(p, VFS_WRITE, o); |
780 | proto_add_oper(p, VFS_IN_WRITE, o); |
- | 781 | o = oper_new("seek", 3, arg_def, V_ERRNO, 0, resp_def); |
|
- | 782 | proto_add_oper(p, VFS_IN_SEEK, o); |
|
641 | o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def); |
783 | o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def); |
642 | proto_add_oper(p, VFS_TRUNCATE, o); |
784 | proto_add_oper(p, VFS_IN_TRUNCATE, o); |
- | 785 | o = oper_new("fstat", 1, arg_def, V_ERRNO, 0, resp_def); |
|
- | 786 | proto_add_oper(p, VFS_IN_FSTAT, o); |
|
- | 787 | o = oper_new("close", 1, arg_def, V_ERRNO, 0, resp_def); |
|
- | 788 | proto_add_oper(p, VFS_IN_CLOSE, o); |
|
643 | o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def); |
789 | o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def); |
644 | proto_add_oper(p, VFS_MOUNT, o); |
790 | proto_add_oper(p, VFS_IN_MOUNT, o); |
645 | /* o = oper_new("unmount", 0, arg_def); |
791 | /* o = oper_new("unmount", 0, arg_def); |
646 | proto_add_oper(p, VFS_UNMOUNT, o);*/ |
792 | proto_add_oper(p, VFS_IN_UNMOUNT, o);*/ |
647 | o = oper_new("open", 2, arg_def, V_INT_ERRNO, 0, resp_def); |
- | |
648 | proto_add_oper(p, VFS_OPEN, o); |
- | |
649 | o = oper_new("close", 1, arg_def, V_ERRNO, 0, resp_def); |
- | |
650 | proto_add_oper(p, VFS_CLOSE, o); |
- | |
651 | o = oper_new("seek", 3, arg_def, V_ERRNO, 0, resp_def); |
793 | o = oper_new("sync", 1, arg_def, V_ERRNO, 0, resp_def); |
652 | proto_add_oper(p, VFS_SEEK, o); |
794 | proto_add_oper(p, VFS_IN_SYNC, o); |
653 | o = oper_new("mkdir", 1, arg_def, V_ERRNO, 0, resp_def); |
795 | o = oper_new("mkdir", 1, arg_def, V_ERRNO, 0, resp_def); |
654 | proto_add_oper(p, VFS_MKDIR, o); |
796 | proto_add_oper(p, VFS_IN_MKDIR, o); |
655 | o = oper_new("unlink", 0, arg_def, V_ERRNO, 0, resp_def); |
797 | o = oper_new("unlink", 0, arg_def, V_ERRNO, 0, resp_def); |
656 | proto_add_oper(p, VFS_UNLINK, o); |
798 | proto_add_oper(p, VFS_IN_UNLINK, o); |
657 | o = oper_new("rename", 0, arg_def, V_ERRNO, 0, resp_def); |
799 | o = oper_new("rename", 0, arg_def, V_ERRNO, 0, resp_def); |
658 | proto_add_oper(p, VFS_RENAME, o); |
800 | proto_add_oper(p, VFS_IN_RENAME, o); |
- | 801 | o = oper_new("stat", 0, arg_def, V_ERRNO, 0, resp_def); |
|
- | 802 | proto_add_oper(p, VFS_IN_STAT, o); |
|
659 | 803 | ||
660 | proto_register(SERVICE_VFS, p); |
804 | proto_register(SERVICE_VFS, p); |
661 | 805 | ||
662 | p = proto_new("console"); |
806 | p = proto_new("console"); |
- | 807 | ||
- | 808 | o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def); |
|
- | 809 | proto_add_oper(p, VFS_IN_WRITE, o); |
|
- | 810 | ||
663 | resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER; |
811 | resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER; |
664 | resp_def[2] = V_INTEGER; resp_def[3] = V_CHAR; |
812 | resp_def[2] = V_INTEGER; resp_def[3] = V_CHAR; |
665 | o = oper_new("getkey", 0, arg_def, V_ERRNO, 4, resp_def); |
813 | o = oper_new("getkey", 0, arg_def, V_ERRNO, 4, resp_def); |
666 | 814 | ||
667 | arg_def[0] = V_CHAR; |
815 | arg_def[0] = V_CHAR; |
Line 750... | Line 898... | ||
750 | if (arg[1] == 't') { |
898 | if (arg[1] == 't') { |
751 | /* Trace an already running task */ |
899 | /* Trace an already running task */ |
752 | --argc; ++argv; |
900 | --argc; ++argv; |
753 | task_id = strtol(*argv, &err_p, 10); |
901 | task_id = strtol(*argv, &err_p, 10); |
754 | task_ldr = NULL; |
902 | task_ldr = NULL; |
- | 903 | task_wait_for = false; |
|
755 | if (*err_p) { |
904 | if (*err_p) { |
756 | printf("Task ID syntax error\n"); |
905 | printf("Task ID syntax error\n"); |
757 | print_syntax(); |
906 | print_syntax(); |
758 | return -1; |
907 | return -1; |
759 | } |
908 | } |
Line 787... | Line 936... | ||
787 | { |
936 | { |
788 | char **cp = argv; |
937 | char **cp = argv; |
789 | while (*cp) printf("'%s'\n", *cp++); |
938 | while (*cp) printf("'%s'\n", *cp++); |
790 | } |
939 | } |
791 | task_ldr = preload_task(*argv, argv, &task_id); |
940 | task_ldr = preload_task(*argv, argv, &task_id); |
- | 941 | task_wait_for = true; |
|
792 | 942 | ||
793 | return 0; |
943 | return 0; |
794 | } |
944 | } |
795 | 945 | ||
796 | int main(int argc, char *argv[]) |
946 | int main(int argc, char *argv[]) |
797 | { |
947 | { |
798 | int rc; |
948 | int rc; |
- | 949 | task_exit_t texit; |
|
- | 950 | int retval; |
|
799 | 951 | ||
800 | printf("System Call / IPC Tracer\n"); |
952 | printf("System Call / IPC Tracer\n"); |
801 | printf("Controls: Q - Quit, P - Pause, R - Resume\n"); |
953 | printf("Controls: Q - Quit, P - Pause, R - Resume\n"); |
802 | 954 | ||
803 | display_mask = DM_THREAD | DM_SYSTEM | DM_USER; |
955 | display_mask = DM_THREAD | DM_SYSTEM | DM_USER; |
Line 813... | Line 965... | ||
813 | return 1; |
965 | return 1; |
814 | } |
966 | } |
815 | 967 | ||
816 | printf("Connected to task %lld.\n", task_id); |
968 | printf("Connected to task %lld.\n", task_id); |
817 | 969 | ||
818 | if (task_ldr != NULL) { |
970 | if (task_ldr != NULL) |
819 | program_run(); |
971 | program_run(); |
820 | } |
- | |
821 | 972 | ||
- | 973 | cev_fibril_start(); |
|
822 | trace_task(task_id); |
974 | trace_task(task_id); |
823 | 975 | ||
- | 976 | if (task_wait_for) { |
|
- | 977 | printf("Waiting for task to exit.\n"); |
|
- | 978 | ||
- | 979 | rc = task_wait(task_id, &texit, &retval); |
|
- | 980 | if (rc != EOK) { |
|
- | 981 | printf("Failed waiting for task.\n"); |
|
- | 982 | return -1; |
|
- | 983 | } |
|
- | 984 | ||
- | 985 | if (texit == TASK_EXIT_NORMAL) { |
|
- | 986 | printf("Task exited normally, return value %d.\n", |
|
- | 987 | retval); |
|
- | 988 | } else { |
|
- | 989 | printf("Task exited unexpectedly.\n"); |
|
- | 990 | } |
|
- | 991 | } |
|
- | 992 | ||
824 | return 0; |
993 | return 0; |
825 | } |
994 | } |
826 | 995 | ||
827 | /** @} |
996 | /** @} |
828 | */ |
997 | */ |