Subversion Repositories HelenOS

Rev

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

Rev 3492 Rev 3602
Line 93... Line 93...
93
     * At the beginning the thread is stoppable, so int_lock be set, too.
93
     * At the beginning the thread is stoppable, so int_lock be set, too.
94
     */
94
     */
95
    atomic_set(&ut->int_lock, 1);
95
    atomic_set(&ut->int_lock, 1);
96
 
96
 
97
    ut->go_call = NULL;
97
    ut->go_call = NULL;
98
    ut->stop = true;
98
    ut->go = false;
99
    ut->stoppable = true;
99
    ut->stoppable = true;
100
    ut->debug_active = false;
100
    ut->debug_active = false;
101
    ut->cur_event = 0; /* none */
101
    ut->cur_event = 0; /* none */
102
}
102
}
103
 
103
 
Line 196... Line 196...
196
    } else if (TASK->udebug.dt_state == UDEBUG_TS_ACTIVE) {
196
    } else if (TASK->udebug.dt_state == UDEBUG_TS_ACTIVE) {
197
        /*
197
        /*
198
         * Active debugging session
198
         * Active debugging session
199
         */
199
         */
200
 
200
 
201
        if (THREAD->udebug.debug_active && THREAD->udebug.stop) {
201
        if (THREAD->udebug.debug_active == true &&
-
 
202
            THREAD->udebug.go == false) {
202
            /*
203
            /*
203
             * Thread was requested to stop - answer go call
204
             * Thread was requested to stop - answer go call
204
             */
205
             */
205
 
206
 
206
            /* Make sure nobody takes this call away from us */
207
            /* Make sure nobody takes this call away from us */
Line 237... Line 238...
237
restart:
238
restart:
238
    mutex_lock(&TASK->udebug.lock);
239
    mutex_lock(&TASK->udebug.lock);
239
    mutex_lock(&THREAD->udebug.lock);
240
    mutex_lock(&THREAD->udebug.lock);
240
 
241
 
241
    if (THREAD->udebug.debug_active &&
242
    if (THREAD->udebug.debug_active &&
242
        THREAD->udebug.stop == true) {
243
        THREAD->udebug.go == false) {
243
        TASK->udebug.begin_call = NULL;
244
        TASK->udebug.begin_call = NULL;
244
        mutex_unlock(&THREAD->udebug.lock);
245
        mutex_unlock(&THREAD->udebug.lock);
245
        mutex_unlock(&TASK->udebug.lock);
246
        mutex_unlock(&TASK->udebug.lock);
246
 
247
 
247
        udebug_wait_for_go(&THREAD->udebug.go_wq);
248
        udebug_wait_for_go(&THREAD->udebug.go_wq);
248
 
249
 
249
        goto restart;
250
        goto restart;
250
        /* must try again - have to lose stoppability atomically */
251
        /* Must try again - have to lose stoppability atomically. */
251
    } else {
252
    } else {
252
        ++TASK->udebug.not_stoppable_count;
253
        ++TASK->udebug.not_stoppable_count;
253
        ASSERT(THREAD->udebug.stoppable == true);
254
        ASSERT(THREAD->udebug.stoppable == true);
254
        THREAD->udebug.stoppable = false;
255
        THREAD->udebug.stoppable = false;
255
 
256
 
Line 319... Line 320...
319
    }
320
    }
320
 
321
 
321
    mutex_lock(&TASK->udebug.lock);
322
    mutex_lock(&TASK->udebug.lock);
322
    mutex_lock(&THREAD->udebug.lock);
323
    mutex_lock(&THREAD->udebug.lock);
323
 
324
 
324
    /* Must only generate events when in debugging session and have go */
325
    /* Must only generate events when in debugging session and is go. */
325
    if (THREAD->udebug.debug_active != true ||
326
    if (THREAD->udebug.debug_active != true ||
326
        THREAD->udebug.stop == true ||
327
        THREAD->udebug.go == false ||
327
        (TASK->udebug.evmask & UDEBUG_EVMASK(etype)) == 0) {
328
        (TASK->udebug.evmask & UDEBUG_EVMASK(etype)) == 0) {
328
        mutex_unlock(&THREAD->udebug.lock);
329
        mutex_unlock(&THREAD->udebug.lock);
329
        mutex_unlock(&TASK->udebug.lock);
330
        mutex_unlock(&TASK->udebug.lock);
330
        return;
331
        return;
331
    }
332
    }
Line 346... Line 347...
346
    THREAD->udebug.syscall_args[3] = a4;
347
    THREAD->udebug.syscall_args[3] = a4;
347
    THREAD->udebug.syscall_args[4] = a5;
348
    THREAD->udebug.syscall_args[4] = a5;
348
    THREAD->udebug.syscall_args[5] = a6;
349
    THREAD->udebug.syscall_args[5] = a6;
349
 
350
 
350
    /*
351
    /*
351
     * Make sure udebug.stop is true when going to sleep
352
     * Make sure udebug.go is false when going to sleep
352
     * in case we get woken up by DEBUG_END. (At which
353
     * in case we get woken up by DEBUG_END. (At which
353
     * point it must be back to the initial true value).
354
     * point it must be back to the initial true value).
354
     */
355
     */
355
    THREAD->udebug.stop = true;
356
    THREAD->udebug.go = false;
356
    THREAD->udebug.cur_event = etype;
357
    THREAD->udebug.cur_event = etype;
357
 
358
 
358
    ipc_answer(&TASK->answerbox, call);
359
    ipc_answer(&TASK->answerbox, call);
359
 
360
 
360
    mutex_unlock(&THREAD->udebug.lock);
361
    mutex_unlock(&THREAD->udebug.lock);
Line 385... Line 386...
385
    LOG("udebug_thread_b_event\n");
386
    LOG("udebug_thread_b_event\n");
386
    LOG("- check state\n");
387
    LOG("- check state\n");
387
 
388
 
388
    /* Must only generate events when in debugging session */
389
    /* Must only generate events when in debugging session */
389
    if (THREAD->udebug.debug_active != true) {
390
    if (THREAD->udebug.debug_active != true) {
390
        LOG("- debug_active: %s, udebug.stop: %s\n",
391
        LOG("- debug_active: %s, udebug.go: %s\n",
391
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
392
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
392
            THREAD->udebug.stop ? "yes(-)" : "no(+)");
393
            THREAD->udebug.go ? "yes(-)" : "no(+)");
393
        mutex_unlock(&THREAD->udebug.lock);
394
        mutex_unlock(&THREAD->udebug.lock);
394
        mutex_unlock(&TASK->udebug.lock);
395
        mutex_unlock(&TASK->udebug.lock);
395
        return;
396
        return;
396
    }
397
    }
397
 
398
 
Line 402... Line 403...
402
    IPC_SET_RETVAL(call->data, 0);
403
    IPC_SET_RETVAL(call->data, 0);
403
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B);
404
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B);
404
    IPC_SET_ARG2(call->data, (unative_t)t);
405
    IPC_SET_ARG2(call->data, (unative_t)t);
405
 
406
 
406
    /*
407
    /*
407
     * Make sure udebug.stop is true when going to sleep
408
     * Make sure udebug.go is false when going to sleep
408
     * in case we get woken up by DEBUG_END. (At which
409
     * in case we get woken up by DEBUG_END. (At which
409
     * point it must be back to the initial true value).
410
     * point it must be back to the initial true value).
410
     */
411
     */
411
    THREAD->udebug.stop = true;
412
    THREAD->udebug.go = false;
412
    THREAD->udebug.cur_event = UDEBUG_EVENT_THREAD_B;
413
    THREAD->udebug.cur_event = UDEBUG_EVENT_THREAD_B;
413
 
414
 
414
    ipc_answer(&TASK->answerbox, call);
415
    ipc_answer(&TASK->answerbox, call);
415
 
416
 
416
    mutex_unlock(&THREAD->udebug.lock);
417
    mutex_unlock(&THREAD->udebug.lock);
Line 437... Line 438...
437
    mutex_lock(&THREAD->udebug.lock);
438
    mutex_lock(&THREAD->udebug.lock);
438
 
439
 
439
    LOG("udebug_thread_e_event\n");
440
    LOG("udebug_thread_e_event\n");
440
    LOG("- check state\n");
441
    LOG("- check state\n");
441
 
442
 
442
    /* Must only generate events when in debugging session */
443
    /* Must only generate events when in debugging session. */
443
    if (THREAD->udebug.debug_active != true) {
444
    if (THREAD->udebug.debug_active != true) {
444
/*      printf("- debug_active: %s, udebug.stop: %s\n",
445
/*      printf("- debug_active: %s, udebug.go: %s\n",
445
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
446
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
446
            THREAD->udebug.stop ? "yes(-)" : "no(+)");*/
447
            THREAD->udebug.go ? "yes(-)" : "no(+)");*/
447
        mutex_unlock(&THREAD->udebug.lock);
448
        mutex_unlock(&THREAD->udebug.lock);
448
        mutex_unlock(&TASK->udebug.lock);
449
        mutex_unlock(&TASK->udebug.lock);
449
        return;
450
        return;
450
    }
451
    }
451
 
452
 
Line 454... Line 455...
454
    call = THREAD->udebug.go_call;
455
    call = THREAD->udebug.go_call;
455
    THREAD->udebug.go_call = NULL;
456
    THREAD->udebug.go_call = NULL;
456
    IPC_SET_RETVAL(call->data, 0);
457
    IPC_SET_RETVAL(call->data, 0);
457
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
458
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
458
 
459
 
459
    /* Prevent any further debug activity in thread */
460
    /* Prevent any further debug activity in thread. */
460
    THREAD->udebug.debug_active = false;
461
    THREAD->udebug.debug_active = false;
461
    THREAD->udebug.cur_event = 0;       /* none */
462
    THREAD->udebug.cur_event = 0;       /* none */
462
    THREAD->udebug.stop = true; /* set to initial value */
463
    THREAD->udebug.go = false;  /* set to initial value */
463
 
464
 
464
    ipc_answer(&TASK->answerbox, call);
465
    ipc_answer(&TASK->answerbox, call);
465
 
466
 
466
    mutex_unlock(&THREAD->udebug.lock);
467
    mutex_unlock(&THREAD->udebug.lock);
467
    mutex_unlock(&TASK->udebug.lock);
468
    mutex_unlock(&TASK->udebug.lock);
468
 
469
 
469
    /* Leave int_lock enabled */
470
    /* Leave int_lock enabled. */
470
    /* This event does not sleep - debugging has finished in this thread */
471
    /* This event does not sleep - debugging has finished in this thread. */
471
}
472
}
472
 
473
 
473
/**
474
/**
474
 * Terminate task debugging session.
475
 * Terminate task debugging session.
475
 *
476
 *
Line 510... Line 511...
510
        flags = t->flags;
511
        flags = t->flags;
511
 
512
 
512
        spinlock_unlock(&t->lock);
513
        spinlock_unlock(&t->lock);
513
        interrupts_restore(ipl);
514
        interrupts_restore(ipl);
514
 
515
 
515
        /* Only process userspace threads */
516
        /* Only process userspace threads. */
516
        if ((flags & THREAD_FLAG_USPACE) != 0) {
517
        if ((flags & THREAD_FLAG_USPACE) != 0) {
517
            /* Prevent any further debug activity in thread */
518
            /* Prevent any further debug activity in thread. */
518
            t->udebug.debug_active = false;
519
            t->udebug.debug_active = false;
519
            t->udebug.cur_event = 0;    /* none */
520
            t->udebug.cur_event = 0;    /* none */
520
 
521
 
521
            /* Still has go? */
522
            /* Is the thread still go? */
522
            if (t->udebug.stop == false) {
523
            if (t->udebug.go == true) {
523
                /*
524
                /*
524
                * Yes, so clear go. As debug_active == false,
525
                * Yes, so clear go. As debug_active == false,
525
                 * this doesn't affect anything.
526
                 * this doesn't affect anything.
526
                 */
527
                 */
527
                t->udebug.stop = true; 
528
                t->udebug.go = false;  
528
 
529
 
529
                /* Answer GO call */
530
                /* Answer GO call */
530
                LOG("answer GO call with EVENT_FINISHED\n");
531
                LOG("answer GO call with EVENT_FINISHED\n");
531
                IPC_SET_RETVAL(t->udebug.go_call->data, 0);
532
                IPC_SET_RETVAL(t->udebug.go_call->data, 0);
532
                IPC_SET_ARG1(t->udebug.go_call->data,
533
                IPC_SET_ARG1(t->udebug.go_call->data,