Rev 4658 | Rev 4660 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4658 | Rev 4659 | ||
---|---|---|---|
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> |
47 | #include <io/console.h> |
48 | #include <io/console.h> |
48 | #include <io/keycode.h> |
49 | #include <io/keycode.h> |
49 | #include <fibril_sync.h> |
50 | #include <fibril_sync.h> |
50 | 51 | ||
Line 66... | Line 67... | ||
66 | int n_threads; |
67 | int n_threads; |
67 | 68 | ||
68 | int next_thread_id; |
69 | int next_thread_id; |
69 | 70 | ||
70 | int phoneid; |
71 | int phoneid; |
71 | int abort_trace; |
72 | bool abort_trace; |
72 | 73 | ||
73 | uintptr_t thash; |
74 | uintptr_t thash; |
74 | volatile int paused; |
75 | static bool paused; |
75 | fibril_condvar_t state_cv; |
76 | static fibril_condvar_t state_cv; |
76 | fibril_mutex_t state_lock; |
77 | static fibril_mutex_t state_lock; |
77 | 78 | ||
78 | int cev_valid; |
79 | static bool cev_valid; |
79 | console_event_t cev; |
80 | static console_event_t cev; |
80 | 81 | ||
81 | void thread_trace_start(uintptr_t thread_hash); |
82 | void thread_trace_start(uintptr_t thread_hash); |
82 | 83 | ||
83 | static proto_t *proto_console; |
84 | static proto_t *proto_console; |
84 | static task_id_t task_id; |
85 | static task_id_t task_id; |
85 | static loader_t *task_ldr; |
86 | static loader_t *task_ldr; |
86 | static int task_wait_for; |
87 | static bool task_wait_for; |
87 | 88 | ||
88 | /** Combination of events/data to print. */ |
89 | /** Combination of events/data to print. */ |
89 | display_mask_t display_mask; |
90 | display_mask_t display_mask; |
90 | 91 | ||
91 | static int program_run_fibril(void *arg); |
92 | static int program_run_fibril(void *arg); |
Line 505... | Line 506... | ||
505 | event_syscall_e(thread_id, thread_hash, val0, (int)val1); |
506 | event_syscall_e(thread_id, thread_hash, val0, (int)val1); |
506 | break; |
507 | break; |
507 | case UDEBUG_EVENT_STOP: |
508 | case UDEBUG_EVENT_STOP: |
508 | printf("Stop event\n"); |
509 | printf("Stop event\n"); |
509 | fibril_mutex_lock(&state_lock); |
510 | fibril_mutex_lock(&state_lock); |
510 | paused = 1; |
511 | paused = true; |
511 | fibril_mutex_unlock(&state_lock); |
512 | fibril_mutex_unlock(&state_lock); |
512 | break; |
513 | break; |
513 | case UDEBUG_EVENT_THREAD_B: |
514 | case UDEBUG_EVENT_THREAD_B: |
514 | event_thread_b(val0); |
515 | event_thread_b(val0); |
515 | break; |
516 | break; |
516 | case UDEBUG_EVENT_THREAD_E: |
517 | case UDEBUG_EVENT_THREAD_E: |
517 | printf("Thread 0x%lx exited.\n", val0); |
518 | printf("Thread 0x%lx exited.\n", val0); |
518 | fibril_mutex_lock(&state_lock); |
519 | fibril_mutex_lock(&state_lock); |
519 | abort_trace = 1; |
520 | abort_trace = true; |
520 | fibril_condvar_broadcast(&state_cv); |
521 | fibril_condvar_broadcast(&state_cv); |
521 | fibril_mutex_unlock(&state_lock); |
522 | fibril_mutex_unlock(&state_lock); |
522 | break; |
523 | break; |
523 | default: |
524 | default: |
524 | printf("Unknown event type %d.\n", ev_type); |
525 | printf("Unknown event type %d.\n", ev_type); |
Line 625... | Line 626... | ||
625 | 626 | ||
626 | if (!console_get_event(fphone(stdin), &cev)) |
627 | if (!console_get_event(fphone(stdin), &cev)) |
627 | return -1; |
628 | return -1; |
628 | 629 | ||
629 | fibril_mutex_lock(&state_lock); |
630 | fibril_mutex_lock(&state_lock); |
630 | cev_valid = 1; |
631 | cev_valid = true; |
631 | fibril_condvar_broadcast(&state_cv); |
632 | fibril_condvar_broadcast(&state_cv); |
632 | fibril_mutex_unlock(&state_lock); |
633 | fibril_mutex_unlock(&state_lock); |
633 | } |
634 | } |
634 | } |
635 | } |
635 | 636 | ||
Line 652... | Line 653... | ||
652 | if (rc < 0) { |
653 | if (rc < 0) { |
653 | printf("Failed to get thread list (error %d)\n", rc); |
654 | printf("Failed to get thread list (error %d)\n", rc); |
654 | return; |
655 | return; |
655 | } |
656 | } |
656 | 657 | ||
657 | abort_trace = 0; |
658 | abort_trace = false; |
658 | 659 | ||
659 | for (i = 0; i < n_threads; i++) { |
660 | for (i = 0; i < n_threads; i++) { |
660 | thread_trace_start(thread_hash_buf[i]); |
661 | thread_trace_start(thread_hash_buf[i]); |
661 | } |
662 | } |
662 | 663 | ||
Line 691... | Line 692... | ||
691 | if (rc != EOK) |
692 | if (rc != EOK) |
692 | printf("Error: stop -> %d\n", rc); |
693 | printf("Error: stop -> %d\n", rc); |
693 | break; |
694 | break; |
694 | case KC_R: |
695 | case KC_R: |
695 | fibril_mutex_lock(&state_lock); |
696 | fibril_mutex_lock(&state_lock); |
696 | paused = 0; |
697 | paused = false; |
697 | fibril_condvar_broadcast(&state_cv); |
698 | fibril_condvar_broadcast(&state_cv); |
698 | fibril_mutex_unlock(&state_lock); |
699 | fibril_mutex_unlock(&state_lock); |
699 | printf("Resume...\n"); |
700 | printf("Resume...\n"); |
700 | break; |
701 | break; |
701 | } |
702 | } |
702 | } |
703 | } |
703 | 704 | ||
704 | printf("\nTerminate debugging session...\n"); |
705 | printf("\nTerminate debugging session...\n"); |
705 | abort_trace = 1; |
706 | abort_trace = true; |
706 | udebug_end(phoneid); |
707 | udebug_end(phoneid); |
707 | ipc_hangup(phoneid); |
708 | ipc_hangup(phoneid); |
708 | 709 | ||
709 | ipcp_cleanup(); |
710 | ipcp_cleanup(); |
710 | 711 | ||
Line 732... | Line 733... | ||
732 | V_INTEGER, |
733 | V_INTEGER, |
733 | V_INTEGER |
734 | V_INTEGER |
734 | }; |
735 | }; |
735 | 736 | ||
736 | next_thread_id = 1; |
737 | next_thread_id = 1; |
737 | paused = 0; |
738 | paused = false; |
738 | cev_valid = 0; |
739 | cev_valid = false; |
739 | 740 | ||
740 | fibril_mutex_initialize(&state_lock); |
741 | fibril_mutex_initialize(&state_lock); |
741 | fibril_condvar_initialize(&state_cv); |
742 | fibril_condvar_initialize(&state_cv); |
742 | 743 | ||
743 | proto_init(); |
744 | proto_init(); |
Line 859... | Line 860... | ||
859 | if (arg[1] == 't') { |
860 | if (arg[1] == 't') { |
860 | /* Trace an already running task */ |
861 | /* Trace an already running task */ |
861 | --argc; ++argv; |
862 | --argc; ++argv; |
862 | task_id = strtol(*argv, &err_p, 10); |
863 | task_id = strtol(*argv, &err_p, 10); |
863 | task_ldr = NULL; |
864 | task_ldr = NULL; |
864 | task_wait_for = 0; |
865 | task_wait_for = false; |
865 | if (*err_p) { |
866 | if (*err_p) { |
866 | printf("Task ID syntax error\n"); |
867 | printf("Task ID syntax error\n"); |
867 | print_syntax(); |
868 | print_syntax(); |
868 | return -1; |
869 | return -1; |
869 | } |
870 | } |
Line 897... | Line 898... | ||
897 | { |
898 | { |
898 | char **cp = argv; |
899 | char **cp = argv; |
899 | while (*cp) printf("'%s'\n", *cp++); |
900 | while (*cp) printf("'%s'\n", *cp++); |
900 | } |
901 | } |
901 | task_ldr = preload_task(*argv, argv, &task_id); |
902 | task_ldr = preload_task(*argv, argv, &task_id); |
902 | task_wait_for = 1; |
903 | task_wait_for = true; |
903 | 904 | ||
904 | return 0; |
905 | return 0; |
905 | } |
906 | } |
906 | 907 | ||
907 | int main(int argc, char *argv[]) |
908 | int main(int argc, char *argv[]) |