Subversion Repositories HelenOS

Rev

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

Rev 3438 Rev 3441
Line 46... Line 46...
46
 * so they needn't be protected from the (preemptible) interrupt-initiated
46
 * so they needn't be protected from the (preemptible) interrupt-initiated
47
 * code.
47
 * code.
48
 */
48
 */
49
 
49
 
50
#include <synch/waitq.h>
50
#include <synch/waitq.h>
51
#include <print.h>
51
#include <debug.h>
52
#include <udebug/udebug.h>
52
#include <udebug/udebug.h>
53
#include <errno.h>
53
#include <errno.h>
54
#include <arch.h>
54
#include <arch.h>
55
 
55
 
56
static inline void udebug_int_lock(void)
56
static inline void udebug_int_lock(void)
Line 329... Line 329...
329
    udebug_int_lock();
329
    udebug_int_lock();
330
 
330
 
331
    mutex_lock(&TASK->udebug.lock);
331
    mutex_lock(&TASK->udebug.lock);
332
    mutex_lock(&THREAD->udebug.lock);
332
    mutex_lock(&THREAD->udebug.lock);
333
 
333
 
334
    printf("udebug_thread_b_event\n");
334
    LOG("udebug_thread_b_event\n");
335
    printf("- check state\n");
335
    LOG("- check state\n");
336
 
336
 
337
    /* Must only generate events when in debugging session */
337
    /* Must only generate events when in debugging session */
338
    if (THREAD->udebug.debug_active != true) {
338
    if (THREAD->udebug.debug_active != true) {
339
        printf("- debug_active: %s, udebug.stop: %s\n",
339
        LOG("- debug_active: %s, udebug.stop: %s\n",
340
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
340
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
341
            THREAD->udebug.stop ? "yes(-)" : "no(+)");
341
            THREAD->udebug.stop ? "yes(-)" : "no(+)");
342
        mutex_unlock(&THREAD->udebug.lock);
342
        mutex_unlock(&THREAD->udebug.lock);
343
        mutex_unlock(&TASK->udebug.lock);
343
        mutex_unlock(&TASK->udebug.lock);
344
        return;
344
        return;
345
    }
345
    }
346
 
346
 
347
    printf("- trigger event\n");
347
    LOG("- trigger event\n");
348
 
348
 
349
    call = THREAD->udebug.go_call;
349
    call = THREAD->udebug.go_call;
350
    THREAD->udebug.go_call = NULL;
350
    THREAD->udebug.go_call = NULL;
351
    IPC_SET_RETVAL(call->data, 0);
351
    IPC_SET_RETVAL(call->data, 0);
352
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B);
352
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B);
Line 363... Line 363...
363
    ipc_answer(&TASK->answerbox, call);
363
    ipc_answer(&TASK->answerbox, call);
364
 
364
 
365
    mutex_unlock(&THREAD->udebug.lock);
365
    mutex_unlock(&THREAD->udebug.lock);
366
    mutex_unlock(&TASK->udebug.lock);
366
    mutex_unlock(&TASK->udebug.lock);
367
 
367
 
368
    printf("- sleep\n");
368
    LOG("- sleep\n");
369
    udebug_wait_for_go(&THREAD->udebug.go_wq);
369
    udebug_wait_for_go(&THREAD->udebug.go_wq);
370
 
370
 
371
    udebug_int_unlock();
371
    udebug_int_unlock();
372
}
372
}
373
 
373
 
Line 378... Line 378...
378
    udebug_int_lock();
378
    udebug_int_lock();
379
 
379
 
380
    mutex_lock(&TASK->udebug.lock);
380
    mutex_lock(&TASK->udebug.lock);
381
    mutex_lock(&THREAD->udebug.lock);
381
    mutex_lock(&THREAD->udebug.lock);
382
 
382
 
383
//  printf("udebug_thread_e_event\n");
383
    LOG("udebug_thread_e_event\n");
384
//  printf("- check state\n");
384
    LOG("- check state\n");
385
 
385
 
386
    /* Must only generate events when in debugging session */
386
    /* Must only generate events when in debugging session */
387
    if (THREAD->udebug.debug_active != true) {
387
    if (THREAD->udebug.debug_active != true) {
388
/*      printf("- debug_active: %s, udebug.stop: %s\n",
388
/*      printf("- debug_active: %s, udebug.stop: %s\n",
389
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
389
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
Line 391... Line 391...
391
        mutex_unlock(&THREAD->udebug.lock);
391
        mutex_unlock(&THREAD->udebug.lock);
392
        mutex_unlock(&TASK->udebug.lock);
392
        mutex_unlock(&TASK->udebug.lock);
393
        return;
393
        return;
394
    }
394
    }
395
 
395
 
396
//  printf("- trigger event\n");
396
    LOG("- trigger event\n");
397
 
397
 
398
    call = THREAD->udebug.go_call;
398
    call = THREAD->udebug.go_call;
399
    THREAD->udebug.go_call = NULL;
399
    THREAD->udebug.go_call = NULL;
400
    IPC_SET_RETVAL(call->data, 0);
400
    IPC_SET_RETVAL(call->data, 0);
401
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
401
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
Line 425... Line 425...
425
    thread_t *t;
425
    thread_t *t;
426
    link_t *cur;
426
    link_t *cur;
427
    int flags;
427
    int flags;
428
    ipl_t ipl;
428
    ipl_t ipl;
429
 
429
 
430
    printf("udebug_task_cleanup()\n");
430
    LOG("udebug_task_cleanup()\n");
431
    printf("task %llu\n", ta->taskid);
431
    LOG("task %" PRIu64 "\n", ta->taskid);
432
 
432
 
433
    udebug_int_lock();
433
    udebug_int_lock();
434
 
434
 
435
    if (ta->udebug.dt_state != UDEBUG_TS_BEGINNING &&
435
    if (ta->udebug.dt_state != UDEBUG_TS_BEGINNING &&
436
        ta->udebug.dt_state != UDEBUG_TS_ACTIVE) {
436
        ta->udebug.dt_state != UDEBUG_TS_ACTIVE) {
437
        printf("udebug_task_cleanup(): task not being debugged\n");
437
        LOG("udebug_task_cleanup(): task not being debugged\n");
438
        return EINVAL;
438
        return EINVAL;
439
    }
439
    }
440
 
440
 
441
    /* Finish debugging of all userspace threads */
441
    /* Finish debugging of all userspace threads */
442
    for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
442
    for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
Line 465... Line 465...
465
                 * this doesn't affect anything.
465
                 * this doesn't affect anything.
466
                 */
466
                 */
467
                t->udebug.stop = true; 
467
                t->udebug.stop = true; 
468
 
468
 
469
                /* Answer GO call */
469
                /* Answer GO call */
470
                printf("answer GO call with EVENT_FINISHED\n");
470
                LOG("answer GO call with EVENT_FINISHED\n");
471
                IPC_SET_RETVAL(t->udebug.go_call->data, 0);
471
                IPC_SET_RETVAL(t->udebug.go_call->data, 0);
472
                IPC_SET_ARG1(t->udebug.go_call->data, UDEBUG_EVENT_FINISHED);
472
                IPC_SET_ARG1(t->udebug.go_call->data, UDEBUG_EVENT_FINISHED);
473
 
473
 
474
                ipc_answer(&ta->answerbox, t->udebug.go_call);
474
                ipc_answer(&ta->answerbox, t->udebug.go_call);
475
                t->udebug.go_call = NULL;
475
                t->udebug.go_call = NULL;