Rev 2801 | Rev 2805 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2801 | Rev 2804 | ||
---|---|---|---|
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.h> |
13 | #include <arch.h> |
13 | #include <arch.h> |
14 | 14 | ||
15 | void udebug_stopping_point(void) |
15 | void udebug_stoppable_begin(void) |
16 | { |
16 | { |
- | 17 | int nsc; |
|
- | 18 | call_t *db_call; |
|
- | 19 | ||
- | 20 | spinlock_lock(&TASK->lock); |
|
- | 21 | ||
- | 22 | nsc = --TASK->not_stoppable_count; |
|
- | 23 | db_call = TASK->debug_begin_call; |
|
- | 24 | ||
17 | if (TASK->stop_request) { /* locking! */ |
25 | if (TASK->stop_request == true) { |
18 | klog_printf("udebug_stopping_point"); |
26 | klog_printf("udebug_stoppable_begin"); |
19 | IPC_SET_RETVAL(TASK->debug_begin_call->data, 0); |
27 | klog_printf(" - nsc := %d", nsc); |
- | 28 | } |
|
- | 29 | ||
20 | ipc_answer(&TASK->answerbox, TASK->debug_begin_call); |
30 | if (TASK->stop_request == true && nsc == 0) { |
21 | TASK->stop_request = false; |
31 | TASK->stop_request = false; |
22 | TASK->debug_begin_call = NULL; |
32 | TASK->debug_begin_call = NULL; |
- | 33 | spinlock_unlock(&TASK->lock); |
|
- | 34 | ||
- | 35 | IPC_SET_RETVAL(db_call->data, 0); |
|
- | 36 | klog_printf("udebug_stoppable_begin/ipc_answer"); |
|
- | 37 | ipc_answer(&TASK->answerbox, db_call); |
|
- | 38 | } else { |
|
- | 39 | spinlock_unlock(&TASK->lock); |
|
- | 40 | } |
|
- | 41 | } |
|
- | 42 | ||
- | 43 | void udebug_stoppable_end(void) |
|
- | 44 | { |
|
- | 45 | restart: |
|
- | 46 | spinlock_lock(&TASK->lock); |
|
- | 47 | ||
- | 48 | if (TASK->stop_request) { |
|
- | 49 | TASK->debug_begin_call = NULL; |
|
- | 50 | spinlock_unlock(&TASK->lock); |
|
- | 51 | klog_printf("udebug_stoppable_end: waitq_sleep"); |
|
23 | waitq_sleep(&THREAD->go_wq); |
52 | waitq_sleep(&THREAD->go_wq); |
- | 53 | goto restart; |
|
- | 54 | /* must try again - have to lose stoppability atomically */ |
|
- | 55 | } else { |
|
- | 56 | ++TASK->not_stoppable_count; |
|
- | 57 | spinlock_unlock(&TASK->lock); |
|
24 | } |
58 | } |
25 | } |
59 | } |
26 | 60 | ||
27 | void udebug_syscall_event(void) |
61 | void udebug_syscall_event(void) |
28 | { |
62 | { |
- | 63 | spinlock_lock(&TASK->lock); |
|
29 | /* being debugged + have go */ |
64 | /* being debugged + have go */ |
30 | if (TASK->being_debugged && !TASK->stop_request) { /* locking! */ |
65 | if (TASK->being_debugged && !TASK->stop_request) { /* locking! */ |
31 | klog_printf("udebug_syscall_event"); |
66 | klog_printf("udebug_syscall_event"); |
32 | IPC_SET_RETVAL(TASK->debug_go_call->data, 0); |
67 | IPC_SET_RETVAL(TASK->debug_go_call->data, 0); |
- | 68 | klog_printf("udebug_syscall_event/ipc_answer"); |
|
- | 69 | ||
33 | ipc_answer(&TASK->answerbox, TASK->debug_go_call); |
70 | ipc_answer(&TASK->answerbox, TASK->debug_go_call); |
- | 71 | spinlock_unlock(&TASK->lock); |
|
34 | waitq_sleep(&THREAD->go_wq); |
72 | waitq_sleep(&THREAD->go_wq); |
- | 73 | } else { |
|
- | 74 | spinlock_unlock(&TASK->lock); |
|
35 | } |
75 | } |
36 | } |
76 | } |
37 | 77 | ||
38 | /** @} |
78 | /** @} |
39 | */ |
79 | */ |
40 | 80 |