Subversion Repositories HelenOS

Rev

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

Rev 2834 Rev 2835
Line 130... Line 130...
130
 
130
 
131
    ipl = interrupts_disable();
131
    ipl = interrupts_disable();
132
    ta = get_lock_callee_task(phone);
132
    ta = get_lock_callee_task(phone);
133
    klog_printf("task %llu", ta->taskid);
133
    klog_printf("task %llu", ta->taskid);
134
 
134
 
135
    //TODO: UDEBUG_TS_BEGINNING
135
    if (ta->dt_state == UDEBUG_TS_BEGINNING &&
136
    if (ta->dt_state != UDEBUG_TS_ACTIVE) {
136
        ta->dt_state != UDEBUG_TS_ACTIVE) {
137
        spinlock_unlock(&ta->lock);
137
        spinlock_unlock(&ta->lock);
138
        interrupts_restore(ipl);
138
        interrupts_restore(ipl);
139
        klog_printf("udebug_rp_begin(): task not in TS_BEGINNING");
139
        klog_printf("udebug_rp_begin(): task not being debugged");
140
        return EINVAL;
140
        return EINVAL;
141
    }
141
    }
142
 
142
 
143
    /* Clear debug_active from all of the task's userspace threads */
143
    /* Finish debugging of all userspace threads */
144
 
-
 
145
    for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
144
    for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
146
        t = list_get_instance(cur, thread_t, th_link);
145
        t = list_get_instance(cur, thread_t, th_link);
147
 
146
 
148
        spinlock_lock(&t->lock);
147
        spinlock_lock(&t->lock);
149
        if ((t->flags & THREAD_FLAG_USPACE) != 0)
-
 
150
            t->debug_active = true;
-
 
151
        spinlock_unlock(&t->lock);
-
 
152
    }
-
 
153
 
148
 
154
    /* Now respond to unanswered GO calls and reset thread states */
149
        /* Only process userspace threads */
155
    for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
150
        if ((t->flags & THREAD_FLAG_USPACE) != 0) {
156
        t = list_get_instance(cur, thread_t, th_link);
151
            /* Prevent any further debug activity in thread */
157
 
-
 
158
        spinlock_lock(&t->lock);
152
            t->debug_active = false;
159
 
153
 
160
        /* Still has go? */
154
            /* Still has go? */
161
        if ((t->flags & THREAD_FLAG_USPACE) != 0 &&
-
 
162
            t->debug_stop == false) {
155
            if (t->debug_stop == false) {
163
            /*
156
                /*
164
             * Yes, so clear go. As debug_active == false,
157
                * Yes, so clear go. As debug_active == false,
165
             * this doesn't affect anything.
158
                 * this doesn't affect anything.
166
             */
159
                 */
167
            t->debug_stop = true;  
160
                t->debug_stop = true;  
168
 
161
 
169
            /* Answer GO call */
162
                /* Answer GO call */
170
            ipc_answer(&ta->answerbox, t->debug_go_call);
163
                ipc_answer(&ta->answerbox, t->debug_go_call);
171
        } else {
164
            } else {
172
            /*
165
                /*
173
             * Debug_stop is already at initial value.
166
                 * Debug_stop is already at initial value.
174
             * Yet this means the thread needs waking up.
167
                 * Yet this means the thread needs waking up.
175
             */
168
                 */
176
            waitq_wakeup(&t->go_wq, WAKEUP_FIRST);
169
                waitq_wakeup(&t->go_wq, WAKEUP_FIRST);
-
 
170
            }
177
        }
171
        }
-
 
172
 
178
        spinlock_unlock(&t->lock);
173
        spinlock_unlock(&t->lock);
179
    }
174
    }
180
 
175
 
181
    ta->dt_state = UDEBUG_TS_INACTIVE;
176
    ta->dt_state = UDEBUG_TS_INACTIVE;
182
 
177