Subversion Repositories HelenOS

Rev

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

Rev 3108 Rev 3428
Line 66... Line 66...
66
 
66
 
67
void thread_trace_start(unsigned thread_hash);
67
void thread_trace_start(unsigned thread_hash);
68
 
68
 
69
static proto_t *proto_console;
69
static proto_t *proto_console;
70
 
70
 
71
static int task_connect(int taskid)
71
static int task_connect(task_id_t task_id)
72
{
72
{
73
    int rc;
73
    int rc;
74
 
74
 
75
    printf("ipc_connect_task(%d)... ", taskid);
75
    printf("ipc_connect_task(%lld)... ", task_id);
76
    rc = ipc_connect_kbox(taskid);
76
    rc = ipc_connect_kbox(task_id);
77
    printf("-> %d\n", rc);
77
    printf("-> %d\n", rc);
78
    phoneid = rc;
78
    phoneid = rc;
79
    if (rc < 0) return rc;
79
    if (rc < 0) return rc;
80
 
80
 
81
    printf("udebug_begin()... ");
81
    printf("udebug_begin()... ");
Line 405... Line 405...
405
        printf("Warning: Failed creating fibril\n");
405
        printf("Warning: Failed creating fibril\n");
406
    }
406
    }
407
    fibril_add_ready(fid);
407
    fibril_add_ready(fid);
408
}
408
}
409
 
409
 
410
static void trace_active_task(void)
410
static void trace_active_task(task_id_t task_id)
411
{
411
{
412
    int taskid;
-
 
413
    int i;
412
    int i;
414
    int rc;
413
    int rc;
415
    int c;
414
    int c;
416
 
415
 
417
    printf("Syscall Tracer\n");
416
    printf("Syscall Tracer\n");
418
    printf("Press 'c' to connect\n");
-
 
419
    while ((i = getchar()) != 'c')
-
 
420
        putchar(i);
-
 
421
 
417
 
422
    taskid = 13;
-
 
423
    rc = task_connect(taskid);
418
    rc = task_connect(task_id);
424
    if (rc < 0) {
419
    if (rc < 0) {
425
        printf("Failed to connect to task %d\n", taskid);
420
        printf("Failed to connect to task %lld\n", task_id);
426
        return;
421
        return;
427
    }
422
    }
428
 
423
 
429
    printf("Connected to task %d\n", taskid);
424
    printf("Connected to task %lld\n", task_id);
430
 
425
 
431
    ipcp_init();
426
    ipcp_init();
432
    ipcp_connection_set(1, 0, proto_console);
427
    ipcp_connection_set(1, 0, proto_console);
433
 
428
 
434
    rc = get_thread_list();
429
    rc = get_thread_list();
Line 504... Line 499...
504
    proto_add_oper(p, CONSOLE_GETSIZE, o);
499
    proto_add_oper(p, CONSOLE_GETSIZE, o);
505
    o = oper_new("flush");
500
    o = oper_new("flush");
506
    proto_add_oper(p, CONSOLE_FLUSH, o);
501
    proto_add_oper(p, CONSOLE_FLUSH, o);
507
    o = oper_new("set_style");
502
    o = oper_new("set_style");
508
    proto_add_oper(p, CONSOLE_SET_STYLE, o);
503
    proto_add_oper(p, CONSOLE_SET_STYLE, o);
509
    o = oper_new("flush");
-
 
510
    proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o);
-
 
511
    o = oper_new("cursor_visibility");
504
    o = oper_new("cursor_visibility");
-
 
505
    proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o);
-
 
506
    o = oper_new("flush");
512
    proto_add_oper(p, CONSOLE_FLUSH, o);
507
    proto_add_oper(p, CONSOLE_FLUSH, o);
513
 
508
 
514
    proto_console = p;
509
    proto_console = p;
515
    proto_register(SERVICE_CONSOLE, p);
510
    proto_register(SERVICE_CONSOLE, p);
516
}
511
}
517
 
512
 
518
int main(void)
513
static void print_syntax()
519
{
514
{
520
    main_init();
515
    printf("syntax: sctrace <task_id>\n");
-
 
516
}
521
 
517
 
-
 
518
int main(int argc, char *argv[])
-
 
519
{
-
 
520
    task_id_t task_id;
-
 
521
    char *err_p;
-
 
522
 
-
 
523
    if (argc != 2) {
-
 
524
        printf("Mising argument\n");
-
 
525
        print_syntax();
-
 
526
        return 1;
-
 
527
    }
-
 
528
 
-
 
529
    task_id = strtol(argv[1], &err_p, 10);
-
 
530
 
522
    while (1) {
531
    if (*err_p) {
-
 
532
        printf("Task ID syntax error\n");
523
        trace_active_task();
533
        print_syntax();
-
 
534
        return 1;
524
    }
535
    }
-
 
536
 
-
 
537
    main_init();
-
 
538
    trace_active_task(task_id);
525
}
539
}
526
 
540
 
527
/** @}
541
/** @}
528
 */
542
 */