Subversion Repositories HelenOS

Rev

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

Rev 3623 Rev 3684
Line 70... Line 70...
70
 
70
 
71
    ut->go_call = NULL;
71
    ut->go_call = NULL;
72
    ut->uspace_state = NULL;
72
    ut->uspace_state = NULL;
73
    ut->go = false;
73
    ut->go = false;
74
    ut->stoppable = true;
74
    ut->stoppable = true;
75
    ut->debug_active = false;
75
    ut->active = false;
76
    ut->cur_event = 0; /* none */
76
    ut->cur_event = 0; /* none */
77
}
77
}
78
 
78
 
79
/** Wait for a GO message.
79
/** Wait for a GO message.
80
 *
80
 *
Line 110... Line 110...
110
static bool udebug_thread_precheck(void)
110
static bool udebug_thread_precheck(void)
111
{
111
{
112
    bool res;
112
    bool res;
113
 
113
 
114
    mutex_lock(&THREAD->udebug.lock);
114
    mutex_lock(&THREAD->udebug.lock);
115
    res = THREAD->udebug.debug_active;
115
    res = THREAD->udebug.active;
116
    mutex_unlock(&THREAD->udebug.lock);
116
    mutex_unlock(&THREAD->udebug.lock);
117
 
117
 
118
    return res;
118
    return res;
119
}
119
}
120
 
120
 
Line 168... Line 168...
168
    } else if (TASK->udebug.dt_state == UDEBUG_TS_ACTIVE) {
168
    } else if (TASK->udebug.dt_state == UDEBUG_TS_ACTIVE) {
169
        /*
169
        /*
170
         * Active debugging session
170
         * Active debugging session
171
         */
171
         */
172
 
172
 
173
        if (THREAD->udebug.debug_active == true &&
173
        if (THREAD->udebug.active == true &&
174
            THREAD->udebug.go == false) {
174
            THREAD->udebug.go == false) {
175
            /*
175
            /*
176
             * Thread was requested to stop - answer go call
176
             * Thread was requested to stop - answer go call
177
             */
177
             */
178
 
178
 
Line 208... Line 208...
208
 
208
 
209
restart:
209
restart:
210
    mutex_lock(&TASK->udebug.lock);
210
    mutex_lock(&TASK->udebug.lock);
211
    mutex_lock(&THREAD->udebug.lock);
211
    mutex_lock(&THREAD->udebug.lock);
212
 
212
 
213
    if (THREAD->udebug.debug_active &&
-
 
214
        THREAD->udebug.go == false) {
213
    if (THREAD->udebug.active && THREAD->udebug.go == false) {
215
        TASK->udebug.begin_call = NULL;
214
        TASK->udebug.begin_call = NULL;
216
        mutex_unlock(&THREAD->udebug.lock);
215
        mutex_unlock(&THREAD->udebug.lock);
217
        mutex_unlock(&TASK->udebug.lock);
216
        mutex_unlock(&TASK->udebug.lock);
218
 
217
 
219
        udebug_wait_for_go(&THREAD->udebug.go_wq);
218
        udebug_wait_for_go(&THREAD->udebug.go_wq);
Line 262... Line 261...
262
 
261
 
263
    mutex_lock(&TASK->udebug.lock);
262
    mutex_lock(&TASK->udebug.lock);
264
    mutex_lock(&THREAD->udebug.lock);
263
    mutex_lock(&THREAD->udebug.lock);
265
 
264
 
266
    /* Must only generate events when in debugging session and is go. */
265
    /* Must only generate events when in debugging session and is go. */
267
    if (THREAD->udebug.debug_active != true ||
-
 
268
        THREAD->udebug.go == false ||
266
    if (THREAD->udebug.active != true || THREAD->udebug.go == false ||
269
        (TASK->udebug.evmask & UDEBUG_EVMASK(etype)) == 0) {
267
        (TASK->udebug.evmask & UDEBUG_EVMASK(etype)) == 0) {
270
        mutex_unlock(&THREAD->udebug.lock);
268
        mutex_unlock(&THREAD->udebug.lock);
271
        mutex_unlock(&TASK->udebug.lock);
269
        mutex_unlock(&TASK->udebug.lock);
272
        return;
270
        return;
273
    }
271
    }
Line 332... Line 330...
332
 
330
 
333
    LOG("udebug_thread_b_event\n");
331
    LOG("udebug_thread_b_event\n");
334
    LOG("- check state\n");
332
    LOG("- check state\n");
335
 
333
 
336
    /* Must only generate events when in debugging session */
334
    /* Must only generate events when in debugging session */
337
    if (THREAD->udebug.debug_active != true) {
335
    if (THREAD->udebug.active != true) {
338
        LOG("- debug_active: %s, udebug.go: %s\n",
336
        LOG("- udebug.active: %s, udebug.go: %s\n",
339
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
337
            THREAD->udebug.active ? "yes(+)" : "no(-)",
340
            THREAD->udebug.go ? "yes(-)" : "no(+)");
338
            THREAD->udebug.go ? "yes(-)" : "no(+)");
341
        mutex_unlock(&THREAD->udebug.lock);
339
        mutex_unlock(&THREAD->udebug.lock);
342
        mutex_unlock(&TASK->udebug.lock);
340
        mutex_unlock(&TASK->udebug.lock);
343
        return;
341
        return;
344
    }
342
    }
Line 382... Line 380...
382
 
380
 
383
    LOG("udebug_thread_e_event\n");
381
    LOG("udebug_thread_e_event\n");
384
    LOG("- check state\n");
382
    LOG("- check state\n");
385
 
383
 
386
    /* Must only generate events when in debugging session. */
384
    /* Must only generate events when in debugging session. */
387
    if (THREAD->udebug.debug_active != true) {
385
    if (THREAD->udebug.active != true) {
388
/*      printf("- debug_active: %s, udebug.go: %s\n",
386
/*      printf("- udebug.active: %s, udebug.go: %s\n",
389
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
387
            THREAD->udebug.active ? "yes(+)" : "no(-)",
390
            THREAD->udebug.go ? "yes(-)" : "no(+)");*/
388
            THREAD->udebug.go ? "yes(-)" : "no(+)");*/
391
        mutex_unlock(&THREAD->udebug.lock);
389
        mutex_unlock(&THREAD->udebug.lock);
392
        mutex_unlock(&TASK->udebug.lock);
390
        mutex_unlock(&TASK->udebug.lock);
393
        return;
391
        return;
394
    }
392
    }
Line 399... Line 397...
399
    THREAD->udebug.go_call = NULL;
397
    THREAD->udebug.go_call = NULL;
400
    IPC_SET_RETVAL(call->data, 0);
398
    IPC_SET_RETVAL(call->data, 0);
401
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
399
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
402
 
400
 
403
    /* Prevent any further debug activity in thread. */
401
    /* Prevent any further debug activity in thread. */
404
    THREAD->udebug.debug_active = false;
402
    THREAD->udebug.active = false;
405
    THREAD->udebug.cur_event = 0;       /* none */
403
    THREAD->udebug.cur_event = 0;       /* none */
406
    THREAD->udebug.go = false;  /* set to initial value */
404
    THREAD->udebug.go = false;  /* set to initial value */
407
 
405
 
408
    ipc_answer(&TASK->answerbox, call);
406
    ipc_answer(&TASK->answerbox, call);
409
 
407
 
Line 422... Line 420...
422
 
420
 
423
    mutex_lock(&TASK->udebug.lock);
421
    mutex_lock(&TASK->udebug.lock);
424
    mutex_lock(&THREAD->udebug.lock);
422
    mutex_lock(&THREAD->udebug.lock);
425
 
423
 
426
    /* Must only generate events when in debugging session and have go. */
424
    /* Must only generate events when in debugging session and have go. */
427
    if (THREAD->udebug.debug_active != true ||
-
 
428
        THREAD->udebug.go == false) {
425
    if (THREAD->udebug.active != true || THREAD->udebug.go == false) {
429
        mutex_unlock(&THREAD->udebug.lock);
426
        mutex_unlock(&THREAD->udebug.lock);
430
        mutex_unlock(&TASK->udebug.lock);
427
        mutex_unlock(&TASK->udebug.lock);
431
        return;
428
        return;
432
    }
429
    }
433
 
430
 
Line 514... Line 511...
514
        interrupts_restore(ipl);
511
        interrupts_restore(ipl);
515
 
512
 
516
        /* Only process userspace threads. */
513
        /* Only process userspace threads. */
517
        if ((flags & THREAD_FLAG_USPACE) != 0) {
514
        if ((flags & THREAD_FLAG_USPACE) != 0) {
518
            /* Prevent any further debug activity in thread. */
515
            /* Prevent any further debug activity in thread. */
519
            t->udebug.debug_active = false;
516
            t->udebug.active = false;
520
            t->udebug.cur_event = 0;    /* none */
517
            t->udebug.cur_event = 0;    /* none */
521
 
518
 
522
            /* Is the thread still go? */
519
            /* Is the thread still go? */
523
            if (t->udebug.go == true) {
520
            if (t->udebug.go == true) {
524
                /*
521
                /*
525
                * Yes, so clear go. As debug_active == false,
522
                * Yes, so clear go. As active == false,
526
                 * this doesn't affect anything.
523
                 * this doesn't affect anything.
527
                 */
524
                 */
528
                t->udebug.go = false;  
525
                t->udebug.go = false;  
529
 
526
 
530
                /* Answer GO call */
527
                /* Answer GO call */