Rev 2805 | Rev 2823 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2805 | Rev 2813 | ||
---|---|---|---|
1 | /** @addtogroup generic |
1 | /** @addtogroup generic |
2 | * @{ |
2 | * @{ |
3 | */ |
3 | */ |
4 | 4 | ||
5 | /** |
5 | /** |
6 | * @file |
6 | * @file |
7 | * @brief Tdebug. |
7 | * @brief Tdebug. |
8 | */ |
8 | */ |
9 | 9 | ||
10 | #include <synch/waitq.h> |
10 | #include <synch/waitq.h> |
11 | #include <console/klog.h> |
11 | #include <console/klog.h> |
12 | #include <udebug.h> |
12 | #include <udebug/udebug.h> |
13 | #include <arch.h> |
13 | #include <arch.h> |
14 | 14 | ||
15 | void udebug_stoppable_begin(void) |
15 | void udebug_stoppable_begin(void) |
16 | { |
16 | { |
17 | int nsc; |
17 | int nsc; |
18 | call_t *db_call; |
18 | call_t *db_call; |
19 | 19 | ||
20 | spinlock_lock(&TASK->lock); |
20 | spinlock_lock(&TASK->lock); |
21 | 21 | ||
22 | nsc = --TASK->not_stoppable_count; |
22 | nsc = --TASK->not_stoppable_count; |
23 | db_call = TASK->debug_begin_call; |
23 | db_call = TASK->debug_begin_call; |
24 | 24 | ||
25 | if (TASK->stop_request == true) { |
25 | if (TASK->stop_request == true) { |
26 | klog_printf("udebug_stoppable_begin"); |
26 | klog_printf("udebug_stoppable_begin"); |
27 | klog_printf(" - nsc := %d", nsc); |
27 | klog_printf(" - nsc := %d", nsc); |
28 | } |
28 | } |
29 | 29 | ||
30 | if (TASK->stop_request == true && nsc == 0) { |
30 | if (TASK->stop_request == true && nsc == 0) { |
31 | TASK->stop_request = false; |
31 | TASK->stop_request = false; |
32 | TASK->debug_begin_call = NULL; |
32 | TASK->debug_begin_call = NULL; |
33 | spinlock_unlock(&TASK->lock); |
33 | spinlock_unlock(&TASK->lock); |
34 | 34 | ||
35 | IPC_SET_RETVAL(db_call->data, 0); |
35 | IPC_SET_RETVAL(db_call->data, 0); |
36 | klog_printf("udebug_stoppable_begin/ipc_answer"); |
36 | klog_printf("udebug_stoppable_begin/ipc_answer"); |
37 | ipc_answer(&TASK->answerbox, db_call); |
37 | ipc_answer(&TASK->answerbox, db_call); |
38 | } else { |
38 | } else { |
39 | spinlock_unlock(&TASK->lock); |
39 | spinlock_unlock(&TASK->lock); |
40 | } |
40 | } |
41 | } |
41 | } |
42 | 42 | ||
43 | void udebug_stoppable_end(void) |
43 | void udebug_stoppable_end(void) |
44 | { |
44 | { |
45 | restart: |
45 | restart: |
46 | spinlock_lock(&TASK->lock); |
46 | spinlock_lock(&TASK->lock); |
47 | 47 | ||
48 | if (TASK->stop_request) { |
48 | if (TASK->stop_request) { |
49 | TASK->debug_begin_call = NULL; |
49 | TASK->debug_begin_call = NULL; |
50 | spinlock_unlock(&TASK->lock); |
50 | spinlock_unlock(&TASK->lock); |
51 | klog_printf("udebug_stoppable_end: waitq_sleep"); |
51 | klog_printf("udebug_stoppable_end: waitq_sleep"); |
52 | waitq_sleep(&THREAD->go_wq); |
52 | waitq_sleep(&THREAD->go_wq); |
53 | goto restart; |
53 | goto restart; |
54 | /* must try again - have to lose stoppability atomically */ |
54 | /* must try again - have to lose stoppability atomically */ |
55 | } else { |
55 | } else { |
56 | ++TASK->not_stoppable_count; |
56 | ++TASK->not_stoppable_count; |
57 | spinlock_unlock(&TASK->lock); |
57 | spinlock_unlock(&TASK->lock); |
58 | } |
58 | } |
59 | } |
59 | } |
60 | 60 | ||
61 | void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3, |
61 | void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3, |
62 | unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc) |
62 | unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc) |
63 | { |
63 | { |
64 | call_t *call; |
64 | call_t *call; |
65 | 65 | ||
66 | spinlock_lock(&TASK->lock); |
66 | spinlock_lock(&TASK->lock); |
67 | /* being debugged + have go */ |
67 | /* being debugged + have go */ |
68 | if (TASK->being_debugged && !TASK->stop_request) { /* locking! */ |
68 | if (TASK->being_debugged && !TASK->stop_request) { /* locking! */ |
69 | klog_printf("udebug_syscall_event"); |
69 | klog_printf("udebug_syscall_event"); |
70 | call = TASK->debug_go_call; |
70 | call = TASK->debug_go_call; |
71 | IPC_SET_RETVAL(call->data, 0); |
71 | IPC_SET_RETVAL(call->data, 0); |
72 | IPC_SET_ARG1(call->data, UDEBUG_EVENT_SYSCALL); |
72 | IPC_SET_ARG1(call->data, UDEBUG_EVENT_SYSCALL); |
73 | IPC_SET_ARG2(call->data, id); |
73 | IPC_SET_ARG2(call->data, id); |
74 | IPC_SET_ARG3(call->data, rc); |
74 | IPC_SET_ARG3(call->data, rc); |
75 | klog_printf("udebug_syscall_event/ipc_answer"); |
75 | klog_printf("udebug_syscall_event/ipc_answer"); |
76 | 76 | ||
77 | THREAD->syscall_args[0] = a1; |
77 | THREAD->syscall_args[0] = a1; |
78 | THREAD->syscall_args[1] = a2; |
78 | THREAD->syscall_args[1] = a2; |
79 | THREAD->syscall_args[2] = a3; |
79 | THREAD->syscall_args[2] = a3; |
80 | THREAD->syscall_args[3] = a4; |
80 | THREAD->syscall_args[3] = a4; |
81 | THREAD->syscall_args[4] = a5; |
81 | THREAD->syscall_args[4] = a5; |
82 | THREAD->syscall_args[5] = a6; |
82 | THREAD->syscall_args[5] = a6; |
83 | 83 | ||
84 | ipc_answer(&TASK->answerbox, TASK->debug_go_call); |
84 | ipc_answer(&TASK->answerbox, TASK->debug_go_call); |
85 | spinlock_unlock(&TASK->lock); |
85 | spinlock_unlock(&TASK->lock); |
86 | waitq_sleep(&THREAD->go_wq); |
86 | waitq_sleep(&THREAD->go_wq); |
87 | } else { |
87 | } else { |
88 | spinlock_unlock(&TASK->lock); |
88 | spinlock_unlock(&TASK->lock); |
89 | } |
89 | } |
90 | } |
90 | } |
91 | 91 | ||
92 | /** @} |
92 | /** @} |
93 | */ |
93 | */ |
94 | 94 |