Subversion Repositories HelenOS

Rev

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

Rev 3665 Rev 3742
Line 56... Line 56...
56
 * but only if it verifies all conditions.
56
 * but only if it verifies all conditions.
57
 *
57
 *
58
 * Specifically, verifies that thread t exists, is a userspace thread,
58
 * Specifically, verifies that thread t exists, is a userspace thread,
59
 * and belongs to the current task (TASK). Verifies, that the thread
59
 * and belongs to the current task (TASK). Verifies, that the thread
60
 * is (or is not) go according to being_go (typically false).
60
 * is (or is not) go according to being_go (typically false).
61
 * It also locks t->udebug.lock, making sure that t->udebug.debug_active
61
 * It also locks t->udebug.lock, making sure that t->udebug.active
62
 * is true - that the thread is in a valid debugging session.
62
 * is true - that the thread is in a valid debugging session.
63
 *
63
 *
64
 * With this verified and the t->udebug.lock mutex held, it is ensured
64
 * With this verified and the t->udebug.lock mutex held, it is ensured
65
 * that the thread cannot leave the debugging session, let alone cease
65
 * that the thread cannot leave the debugging session, let alone cease
66
 * to exist.
66
 * to exist.
Line 106... Line 106...
106
        mutex_unlock(&TASK->udebug.lock);
106
        mutex_unlock(&TASK->udebug.lock);
107
        return ENOENT;
107
        return ENOENT;
108
    }
108
    }
109
 
109
 
110
    /* Verify debugging state. */
110
    /* Verify debugging state. */
111
    if (t->udebug.debug_active != true) {
111
    if (t->udebug.active != true) {
112
        /* Not in debugging session or undesired GO state */
112
        /* Not in debugging session or undesired GO state */
113
        spinlock_unlock(&t->lock);
113
        spinlock_unlock(&t->lock);
114
        interrupts_restore(ipl);
114
        interrupts_restore(ipl);
115
        mutex_unlock(&TASK->udebug.lock);
115
        mutex_unlock(&TASK->udebug.lock);
116
        return ENOENT;
116
        return ENOENT;
117
    }
117
    }
118
 
118
 
119
    /*
119
    /*
120
     * Since the thread has debug_active == true, TASK->udebug.lock
120
     * Since the thread has active == true, TASK->udebug.lock
121
     * is enough to ensure its existence and that debug_active remains
121
     * is enough to ensure its existence and that active remains
122
     * true.
122
     * true.
123
     */
123
     */
124
    spinlock_unlock(&t->lock);
124
    spinlock_unlock(&t->lock);
125
    interrupts_restore(ipl);
125
    interrupts_restore(ipl);
126
 
126
 
Line 202... Line 202...
202
        reply = 1; /* immediate reply */
202
        reply = 1; /* immediate reply */
203
    } else {
203
    } else {
204
        reply = 0; /* no reply */
204
        reply = 0; /* no reply */
205
    }
205
    }
206
   
206
   
207
    /* Set udebug.debug_active on all of the task's userspace threads. */
207
    /* Set udebug.active on all of the task's userspace threads. */
208
 
208
 
209
    for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
209
    for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
210
        t = list_get_instance(cur, thread_t, th_link);
210
        t = list_get_instance(cur, thread_t, th_link);
211
 
211
 
212
        mutex_lock(&t->udebug.lock);
212
        mutex_lock(&t->udebug.lock);
213
        if ((t->flags & THREAD_FLAG_USPACE) != 0)
213
        if ((t->flags & THREAD_FLAG_USPACE) != 0)
214
            t->udebug.debug_active = true;
214
            t->udebug.active = true;
215
        mutex_unlock(&t->udebug.lock);
215
        mutex_unlock(&t->udebug.lock);
216
    }
216
    }
217
 
217
 
218
    mutex_unlock(&TASK->udebug.lock);
218
    mutex_unlock(&TASK->udebug.lock);
219
 
219