Subversion Repositories HelenOS

Rev

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

Rev 2841 Rev 2842
Line 63... Line 63...
63
    interrupts_restore(ipl);
63
    interrupts_restore(ipl);
64
 
64
 
65
    return ta;
65
    return ta;
66
}
66
}
67
 
67
 
-
 
68
/**
-
 
69
 * Verify that thread t is valid for debugging ops.
-
 
70
 *
-
 
71
 * Verifies that t belongs to task ta and that debugging operations
-
 
72
 * may be used on it.
-
 
73
 *
-
 
74
 * Thread t's lock must already be held and interrupts must be disabled.
-
 
75
 */
68
static int verify_thread(thread_t *t)
76
static int verify_thread(thread_t *t, task_t *ta)
69
{
77
{
70
    /* Verify that 't' exists and belongs to task 'ta' */
78
    /* Verify that 't' exists and belongs to task 'ta' */
71
    if (!thread_exists(t) || (t->task != ta)) {
79
    if (!thread_exists(t) || (t->task != ta)) {
72
        spinlock_unlock(&threads_lock);
-
 
73
        interrupts_restore(ipl);
-
 
74
        return ENOENT;
80
        return ENOENT;
75
    }
81
    }
76
 
82
 
77
    /* Verify that 't' is a userspace thread */
83
    /* Verify that 't' is a userspace thread */
78
    if ((t->flags & THREAD_FLAG_USPACE) == 0) {
84
    if ((t->flags & THREAD_FLAG_USPACE) == 0) {
79
        /* It's not, deny its existence */
85
        /* It's not, deny its existence */
80
        return ENOENT;
86
        return ENOENT;
81
    }
87
    }
82
 
88
 
83
    if ((t->debug_active != true) || (t->debug_stop != true)) {
89
    if ((t->debug_active != true) || (t->debug_stop != true)) {
84
        /* Not in debugging session or already has GO */
90
        /* Not in debugging session or already has GO */
85
        spinlock_unlock(&threads_lock);
-
 
86
        interrupts_restore(ipl);       
-
 
87
        return EBUSY;
91
        return EBUSY;
88
    }
92
    }
89
 
93
 
90
    return EOK;
94
    return EOK;
91
}
95
}
Line 260... Line 264...
260
 
264
 
261
    ipl = interrupts_disable();
265
    ipl = interrupts_disable();
262
    spinlock_lock(&threads_lock);
266
    spinlock_lock(&threads_lock);
263
 
267
 
264
    /* Verify that thread t exists and may be operated on */
268
    /* Verify that thread t exists and may be operated on */
265
    rc = verify_thread(t);
269
    rc = verify_thread(t, ta);
266
    if (rc != EOK) {
270
    if (rc != EOK) {
267
        spinlock_unlock(&threads_lock);
271
        spinlock_unlock(&threads_lock);
268
        interrupts_restore(ipl);
272
        interrupts_restore(ipl);
269
        return rc;
273
        return rc;
270
    }
274
    }
Line 313... Line 317...
313
    spinlock_lock(&threads_lock);
317
    spinlock_lock(&threads_lock);
314
 
318
 
315
    t = (thread_t *) IPC_GET_ARG2(call->data);
319
    t = (thread_t *) IPC_GET_ARG2(call->data);
316
 
320
 
317
    /* Verify that thread t exists and may be operated on */
321
    /* Verify that thread t exists and may be operated on */
318
    rc = verify_thread(t);
322
    rc = verify_thread(t, ta);
319
    if (rc != EOK) {
323
    if (rc != EOK) {
320
        spinlock_unlock(&threads_lock);
324
        spinlock_unlock(&threads_lock);
321
        interrupts_restore(ipl);
325
        interrupts_restore(ipl);
322
        return rc;
326
        return rc;
323
    }
327
    }
Line 388... Line 392...
388
    spinlock_lock(&threads_lock);
392
    spinlock_lock(&threads_lock);
389
 
393
 
390
    t = (thread_t *) IPC_GET_ARG2(call->data);
394
    t = (thread_t *) IPC_GET_ARG2(call->data);
391
 
395
 
392
    /* Verify that thread t exists and may be operated on */
396
    /* Verify that thread t exists and may be operated on */
393
    rc = verify_thread(t);
397
    rc = verify_thread(t, ta);
394
    if (rc != EOK) {
398
    if (rc != EOK) {
395
        spinlock_unlock(&threads_lock);
399
        spinlock_unlock(&threads_lock);
396
        interrupts_restore(ipl);
400
        interrupts_restore(ipl);
397
        return rc;
401
        return rc;
398
    }
402
    }