Subversion Repositories HelenOS

Rev

Rev 2813 | Rev 2825 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2813 Rev 2823
Line 14... Line 14...
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
    ipl_t ipl;
19
 
20
 
-
 
21
    ipl = interrupts_disable();
20
    spinlock_lock(&TASK->lock);
22
    spinlock_lock(&TASK->lock);
21
 
23
 
22
    nsc = --TASK->not_stoppable_count;
24
    nsc = --TASK->not_stoppable_count;
23
    db_call = TASK->debug_begin_call;
25
    db_call = TASK->debug_begin_call;
24
 
26
 
Line 29... Line 31...
29
 
31
 
30
    if (TASK->stop_request == true && nsc == 0) {
32
    if (TASK->stop_request == true && nsc == 0) {
31
        TASK->stop_request = false;
33
        TASK->stop_request = false;
32
        TASK->debug_begin_call = NULL;
34
        TASK->debug_begin_call = NULL;
33
        spinlock_unlock(&TASK->lock);
35
        spinlock_unlock(&TASK->lock);
-
 
36
        interrupts_restore(ipl);
34
 
37
 
35
        IPC_SET_RETVAL(db_call->data, 0);
38
        IPC_SET_RETVAL(db_call->data, 0);
36
        klog_printf("udebug_stoppable_begin/ipc_answer");
39
        klog_printf("udebug_stoppable_begin/ipc_answer");
37
        ipc_answer(&TASK->answerbox, db_call);     
40
        ipc_answer(&TASK->answerbox, db_call);     
38
    } else {
41
    } else {
39
            spinlock_unlock(&TASK->lock);
42
            spinlock_unlock(&TASK->lock);
-
 
43
        interrupts_restore(ipl);
40
    }
44
    }
41
}
45
}
42
 
46
 
43
void udebug_stoppable_end(void)
47
void udebug_stoppable_end(void)
44
{
48
{
-
 
49
    ipl_t ipl;
-
 
50
 
45
restart:
51
restart:
-
 
52
    ipl = interrupts_disable();
46
    spinlock_lock(&TASK->lock);
53
    spinlock_lock(&TASK->lock);
47
 
54
 
48
    if (TASK->stop_request) {
55
    if (TASK->stop_request) {
49
        TASK->debug_begin_call = NULL;
56
        TASK->debug_begin_call = NULL;
50
        spinlock_unlock(&TASK->lock);
57
        spinlock_unlock(&TASK->lock);
-
 
58
        interrupts_restore(ipl);
-
 
59
 
51
        klog_printf("udebug_stoppable_end: waitq_sleep");
60
        klog_printf("udebug_stoppable_end: waitq_sleep");
52
        waitq_sleep(&THREAD->go_wq);
61
        waitq_sleep(&THREAD->go_wq);
53
        goto restart;
62
        goto restart;
54
        /* must try again - have to lose stoppability atomically */
63
        /* must try again - have to lose stoppability atomically */
55
    } else {
64
    } else {
56
        ++TASK->not_stoppable_count;
65
        ++TASK->not_stoppable_count;
57
        spinlock_unlock(&TASK->lock);
66
        spinlock_unlock(&TASK->lock);
-
 
67
        interrupts_restore(ipl);
58
    }
68
    }
59
}
69
}
60
 
70
 
61
void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3,
71
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)
72
    unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc)
63
{
73
{
64
    call_t *call;
74
    call_t *call;
-
 
75
    ipl_t ipl;
65
 
76
 
-
 
77
    ipl = interrupts_disable();
66
    spinlock_lock(&TASK->lock);
78
    spinlock_lock(&TASK->lock);
-
 
79
 
67
    /* being debugged + have go */
80
    /* being debugged + have go */
68
    if (TASK->being_debugged && !TASK->stop_request) { /* locking! */
81
    if (TASK->being_debugged && !TASK->stop_request) {
69
        klog_printf("udebug_syscall_event");
82
        klog_printf("udebug_syscall_event");
70
        call = TASK->debug_go_call;
83
        call = TASK->debug_go_call;
71
        IPC_SET_RETVAL(call->data, 0);
84
        IPC_SET_RETVAL(call->data, 0);
72
        IPC_SET_ARG1(call->data, UDEBUG_EVENT_SYSCALL);
85
        IPC_SET_ARG1(call->data, UDEBUG_EVENT_SYSCALL);
73
        IPC_SET_ARG2(call->data, id);
86
        IPC_SET_ARG2(call->data, id);
Line 81... Line 94...
81
        THREAD->syscall_args[4] = a5;
94
        THREAD->syscall_args[4] = a5;
82
        THREAD->syscall_args[5] = a6;
95
        THREAD->syscall_args[5] = a6;
83
 
96
 
84
        ipc_answer(&TASK->answerbox, TASK->debug_go_call);
97
        ipc_answer(&TASK->answerbox, TASK->debug_go_call);
85
        spinlock_unlock(&TASK->lock);
98
        spinlock_unlock(&TASK->lock);
-
 
99
        interrupts_restore(ipl);
-
 
100
 
86
        waitq_sleep(&THREAD->go_wq);
101
        waitq_sleep(&THREAD->go_wq);
87
    } else {
102
    } else {
88
        spinlock_unlock(&TASK->lock);
103
        spinlock_unlock(&TASK->lock);
-
 
104
        interrupts_restore(ipl);
89
    }
105
    }
90
}
106
}
91
 
107
 
92
/** @}
108
/** @}
93
 */
109
 */