Subversion Repositories HelenOS

Rev

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

Rev 3108 Rev 3424
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 <console/klog.h>
51
#include <print.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 286... Line 286...
286
        mutex_unlock(&THREAD->udebug.lock);
286
        mutex_unlock(&THREAD->udebug.lock);
287
        mutex_unlock(&TASK->udebug.lock);
287
        mutex_unlock(&TASK->udebug.lock);
288
        return;
288
        return;
289
    }
289
    }
290
 
290
 
291
    //klog_printf("udebug_syscall_event");
291
    //printf("udebug_syscall_event\n");
292
    call = THREAD->udebug.go_call;
292
    call = THREAD->udebug.go_call;
293
    THREAD->udebug.go_call = NULL;
293
    THREAD->udebug.go_call = NULL;
294
 
294
 
295
    IPC_SET_RETVAL(call->data, 0);
295
    IPC_SET_RETVAL(call->data, 0);
296
    IPC_SET_ARG1(call->data, etype);
296
    IPC_SET_ARG1(call->data, etype);
297
    IPC_SET_ARG2(call->data, id);
297
    IPC_SET_ARG2(call->data, id);
298
    IPC_SET_ARG3(call->data, rc);
298
    IPC_SET_ARG3(call->data, rc);
299
    //klog_printf("udebug_syscall_event/ipc_answer");
299
    //printf("udebug_syscall_event/ipc_answer\n");
300
 
300
 
301
    THREAD->udebug.syscall_args[0] = a1;
301
    THREAD->udebug.syscall_args[0] = a1;
302
    THREAD->udebug.syscall_args[1] = a2;
302
    THREAD->udebug.syscall_args[1] = a2;
303
    THREAD->udebug.syscall_args[2] = a3;
303
    THREAD->udebug.syscall_args[2] = a3;
304
    THREAD->udebug.syscall_args[3] = a4;
304
    THREAD->udebug.syscall_args[3] = a4;
Line 330... Line 330...
330
    udebug_int_lock();
330
    udebug_int_lock();
331
 
331
 
332
    mutex_lock(&TASK->udebug.lock);
332
    mutex_lock(&TASK->udebug.lock);
333
    mutex_lock(&THREAD->udebug.lock);
333
    mutex_lock(&THREAD->udebug.lock);
334
 
334
 
335
    klog_printf("udebug_thread_b_event");
335
    printf("udebug_thread_b_event\n");
336
    klog_printf("- check state");
336
    printf("- check state\n");
337
 
337
 
338
    /* Must only generate events when in debugging session */
338
    /* Must only generate events when in debugging session */
339
    if (THREAD->udebug.debug_active != true) {
339
    if (THREAD->udebug.debug_active != true) {
340
        klog_printf("- debug_active: %s, udebug.stop: %s",
340
        printf("- debug_active: %s, udebug.stop: %s\n",
341
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
341
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
342
            THREAD->udebug.stop ? "yes(-)" : "no(+)");
342
            THREAD->udebug.stop ? "yes(-)" : "no(+)");
343
        mutex_unlock(&THREAD->udebug.lock);
343
        mutex_unlock(&THREAD->udebug.lock);
344
        mutex_unlock(&TASK->udebug.lock);
344
        mutex_unlock(&TASK->udebug.lock);
345
        return;
345
        return;
346
    }
346
    }
347
 
347
 
348
    klog_printf("- trigger event");
348
    printf("- trigger event\n");
349
 
349
 
350
    call = THREAD->udebug.go_call;
350
    call = THREAD->udebug.go_call;
351
    THREAD->udebug.go_call = NULL;
351
    THREAD->udebug.go_call = NULL;
352
    IPC_SET_RETVAL(call->data, 0);
352
    IPC_SET_RETVAL(call->data, 0);
353
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B);
353
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B);
Line 364... Line 364...
364
    ipc_answer(&TASK->answerbox, call);
364
    ipc_answer(&TASK->answerbox, call);
365
 
365
 
366
    mutex_unlock(&THREAD->udebug.lock);
366
    mutex_unlock(&THREAD->udebug.lock);
367
    mutex_unlock(&TASK->udebug.lock);
367
    mutex_unlock(&TASK->udebug.lock);
368
 
368
 
369
    klog_printf("- sleep");
369
    printf("- sleep\n");
370
    udebug_wait_for_go(&THREAD->udebug.go_wq);
370
    udebug_wait_for_go(&THREAD->udebug.go_wq);
371
 
371
 
372
    udebug_int_unlock();
372
    udebug_int_unlock();
373
}
373
}
374
 
374
 
Line 379... Line 379...
379
    udebug_int_lock();
379
    udebug_int_lock();
380
 
380
 
381
    mutex_lock(&TASK->udebug.lock);
381
    mutex_lock(&TASK->udebug.lock);
382
    mutex_lock(&THREAD->udebug.lock);
382
    mutex_lock(&THREAD->udebug.lock);
383
 
383
 
384
    klog_printf("udebug_thread_e_event");
384
    printf("udebug_thread_e_event\n");
385
    klog_printf("- check state");
385
    printf("- check state\n");
386
 
386
 
387
    /* Must only generate events when in debugging session */
387
    /* Must only generate events when in debugging session */
388
    if (THREAD->udebug.debug_active != true) {
388
    if (THREAD->udebug.debug_active != true) {
389
        klog_printf("- debug_active: %s, udebug.stop: %s",
389
        printf("- debug_active: %s, udebug.stop: %s\n",
390
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
390
            THREAD->udebug.debug_active ? "yes(+)" : "no(-)",
391
            THREAD->udebug.stop ? "yes(-)" : "no(+)");
391
            THREAD->udebug.stop ? "yes(-)" : "no(+)");
392
        mutex_unlock(&THREAD->udebug.lock);
392
        mutex_unlock(&THREAD->udebug.lock);
393
        mutex_unlock(&TASK->udebug.lock);
393
        mutex_unlock(&TASK->udebug.lock);
394
        return;
394
        return;
395
    }
395
    }
396
 
396
 
397
    klog_printf("- trigger event");
397
    printf("- trigger event\n");
398
 
398
 
399
    call = THREAD->udebug.go_call;
399
    call = THREAD->udebug.go_call;
400
    THREAD->udebug.go_call = NULL;
400
    THREAD->udebug.go_call = NULL;
401
    IPC_SET_RETVAL(call->data, 0);
401
    IPC_SET_RETVAL(call->data, 0);
402
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
402
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
Line 439... Line 439...
439
        mutex_unlock(&TASK->udebug.lock);
439
        mutex_unlock(&TASK->udebug.lock);
440
        udebug_int_unlock();
440
        udebug_int_unlock();
441
        return;
441
        return;
442
    }
442
    }
443
 
443
 
444
    klog_printf("udebug_breakpoint/trap_event");
444
    printf("udebug_breakpoint/trap_event\n");
445
    call = THREAD->udebug.go_call;
445
    call = THREAD->udebug.go_call;
446
    THREAD->udebug.go_call = NULL;
446
    THREAD->udebug.go_call = NULL;
447
 
447
 
448
    IPC_SET_RETVAL(call->data, 0);
448
    IPC_SET_RETVAL(call->data, 0);
449
    IPC_SET_ARG1(call->data, etype);
449
    IPC_SET_ARG1(call->data, etype);
Line 455... Line 455...
455
     * point it must be back to the initial true value).
455
     * point it must be back to the initial true value).
456
     */
456
     */
457
    THREAD->udebug.stop = true;
457
    THREAD->udebug.stop = true;
458
    THREAD->udebug.cur_event = etype;
458
    THREAD->udebug.cur_event = etype;
459
 
459
 
460
    klog_printf("- send answer");
460
    printf("- send answer\n");
461
    ipc_answer(&TASK->answerbox, call);
461
    ipc_answer(&TASK->answerbox, call);
462
 
462
 
463
    mutex_unlock(&THREAD->udebug.lock);
463
    mutex_unlock(&THREAD->udebug.lock);
464
    mutex_unlock(&TASK->udebug.lock);
464
    mutex_unlock(&TASK->udebug.lock);
465
 
465
 
Line 489... Line 489...
489
    thread_t *t;
489
    thread_t *t;
490
    link_t *cur;
490
    link_t *cur;
491
    int flags;
491
    int flags;
492
    ipl_t ipl;
492
    ipl_t ipl;
493
 
493
 
494
    klog_printf("udebug_task_cleanup()");
494
    printf("udebug_task_cleanup()\n");
495
    klog_printf("task %llu", ta->taskid);
495
    printf("task %llu\n", ta->taskid);
496
 
496
 
497
    udebug_int_lock();
497
    udebug_int_lock();
498
 
498
 
499
    if (ta->udebug.dt_state != UDEBUG_TS_BEGINNING &&
499
    if (ta->udebug.dt_state != UDEBUG_TS_BEGINNING &&
500
        ta->udebug.dt_state != UDEBUG_TS_ACTIVE) {
500
        ta->udebug.dt_state != UDEBUG_TS_ACTIVE) {
501
        klog_printf("udebug_task_cleanup(): task not being debugged");
501
        printf("udebug_task_cleanup(): task not being debugged\n");
502
        return EINVAL;
502
        return EINVAL;
503
    }
503
    }
504
 
504
 
505
    /* Finish debugging of all userspace threads */
505
    /* Finish debugging of all userspace threads */
506
    for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
506
    for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
Line 529... Line 529...
529
                 * this doesn't affect anything.
529
                 * this doesn't affect anything.
530
                 */
530
                 */
531
                t->udebug.stop = true; 
531
                t->udebug.stop = true; 
532
 
532
 
533
                /* Answer GO call */
533
                /* Answer GO call */
534
                klog_printf("answer GO call with EVENT_FINISHED");
534
                printf("answer GO call with EVENT_FINISHED\n");
535
                IPC_SET_RETVAL(t->udebug.go_call->data, 0);
535
                IPC_SET_RETVAL(t->udebug.go_call->data, 0);
536
                IPC_SET_ARG1(t->udebug.go_call->data, UDEBUG_EVENT_FINISHED);
536
                IPC_SET_ARG1(t->udebug.go_call->data, UDEBUG_EVENT_FINISHED);
537
 
537
 
538
                ipc_answer(&ta->answerbox, t->udebug.go_call);
538
                ipc_answer(&ta->answerbox, t->udebug.go_call);
539
                t->udebug.go_call = NULL;
539
                t->udebug.go_call = NULL;