Rev 3444 | Rev 3452 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3444 | Rev 3447 | ||
|---|---|---|---|
| Line 39... | Line 39... | ||
| 39 | #include <ipc/ipc.h> |
39 | #include <ipc/ipc.h> |
| 40 | #include <fibril.h> |
40 | #include <fibril.h> |
| 41 | #include <errno.h> |
41 | #include <errno.h> |
| 42 | #include <udebug.h> |
42 | #include <udebug.h> |
| 43 | #include <async.h> |
43 | #include <async.h> |
| - | 44 | #include <task.h> |
|
| 44 | 45 | ||
| 45 | // Temporary: service and method names |
46 | // Temporary: service and method names |
| 46 | #include "proto.h" |
47 | #include "proto.h" |
| 47 | #include <ipc/services.h> |
48 | #include <ipc/services.h> |
| 48 | #include "../../srv/vfs/vfs.h" |
49 | #include "../../srv/vfs/vfs.h" |
| Line 126... | Line 127... | ||
| 126 | 127 | ||
| 127 | n_threads = tb_copied / sizeof(unsigned); |
128 | n_threads = tb_copied / sizeof(unsigned); |
| 128 | 129 | ||
| 129 | printf("Threads:"); |
130 | printf("Threads:"); |
| 130 | for (i = 0; i < n_threads; i++) { |
131 | for (i = 0; i < n_threads; i++) { |
| 131 | printf(" [%d] (hash 0x%u)", 1+i, thread_hash_buf[i]); |
132 | printf(" [%d] (hash 0x%x)", 1+i, thread_hash_buf[i]); |
| 132 | } |
133 | } |
| 133 | printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); |
134 | printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); |
| 134 | 135 | ||
| 135 | return 0; |
136 | return 0; |
| 136 | } |
137 | } |
| Line 538... | Line 539... | ||
| 538 | proto_register(SERVICE_CONSOLE, p); |
539 | proto_register(SERVICE_CONSOLE, p); |
| 539 | } |
540 | } |
| 540 | 541 | ||
| 541 | static void print_syntax() |
542 | static void print_syntax() |
| 542 | { |
543 | { |
| - | 544 | printf("Syntax:\n"); |
|
| - | 545 | printf("\ttrace [+<events>] <executable> [<arg1> [...]]\n"); |
|
| 543 | printf("Syntax: trace [+<events>] <task_id>\n"); |
546 | printf("or\ttrace [+<events>] -t <task_id>\n"); |
| 544 | printf("Events: (default is +tp)\n"); |
547 | printf("Events: (default is +tp)\n"); |
| 545 | printf("\n"); |
548 | printf("\n"); |
| 546 | printf("\tt ... Thread creation and termination\n"); |
549 | printf("\tt ... Thread creation and termination\n"); |
| 547 | printf("\ts ... System calls\n"); |
550 | printf("\ts ... System calls\n"); |
| 548 | printf("\ti ... Low-level IPC\n"); |
551 | printf("\ti ... Low-level IPC\n"); |
| 549 | printf("\tp ... Protocol level\n"); |
552 | printf("\tp ... Protocol level\n"); |
| 550 | printf("\n"); |
553 | printf("\n"); |
| - | 554 | printf("Examples:\n"); |
|
| - | 555 | printf("\ttrace +s /app/tetris\n"); |
|
| 551 | printf("Example: trace +tsip 12\n"); |
556 | printf("\ttrace +tsip -t 12\n"); |
| 552 | } |
557 | } |
| 553 | 558 | ||
| 554 | static display_mask_t parse_display_mask(char *text) |
559 | static display_mask_t parse_display_mask(char *text) |
| 555 | { |
560 | { |
| 556 | display_mask_t dm; |
561 | display_mask_t dm; |
| Line 578... | Line 583... | ||
| 578 | static int parse_args(int argc, char *argv[]) |
583 | static int parse_args(int argc, char *argv[]) |
| 579 | { |
584 | { |
| 580 | char *arg; |
585 | char *arg; |
| 581 | char *err_p; |
586 | char *err_p; |
| 582 | 587 | ||
| - | 588 | task_id = 0; |
|
| - | 589 | ||
| 583 | --argc; ++argv; |
590 | --argc; ++argv; |
| 584 | 591 | ||
| 585 | while (argc > 1) { |
592 | while (argc > 0) { |
| 586 | arg = *argv; |
593 | arg = *argv; |
| 587 | if (arg[0] == '+') { |
594 | if (arg[0] == '+') { |
| 588 | display_mask = parse_display_mask(&arg[1]); |
595 | display_mask = parse_display_mask(&arg[1]); |
| - | 596 | } else if (arg[0] == '-') { |
|
| - | 597 | if (arg[1] == 't') { |
|
| - | 598 | /* Trace an already running task */ |
|
| - | 599 | --argc; ++argv; |
|
| - | 600 | task_id = strtol(*argv, &err_p, 10); |
|
| - | 601 | if (*err_p) { |
|
| - | 602 | printf("Task ID syntax error\n"); |
|
| - | 603 | print_syntax(); |
|
| - | 604 | return -1; |
|
| - | 605 | } |
|
| - | 606 | } else { |
|
| - | 607 | printf("Uknown option '%s'\n", arg[0]); |
|
| - | 608 | print_syntax(); |
|
| - | 609 | return -1; |
|
| - | 610 | } |
|
| 589 | } else { |
611 | } else { |
| 590 | printf("Unexpected argument '%s'\n", arg); |
- | |
| 591 | print_syntax(); |
- | |
| 592 | return -1; |
612 | break; |
| 593 | } |
613 | } |
| 594 | 614 | ||
| 595 | --argc; ++argv; |
615 | --argc; ++argv; |
| 596 | } |
616 | } |
| 597 | 617 | ||
| 598 | if (argc != 1) { |
618 | if (task_id != 0) { |
| - | 619 | if (argc == 0) return; |
|
| 599 | printf("Missing argument\n"); |
620 | printf("Extra arguments\n"); |
| 600 | print_syntax(); |
621 | print_syntax(); |
| 601 | return 1; |
622 | return -1; |
| 602 | } |
623 | } |
| 603 | 624 | ||
| 604 | task_id = strtol(*argv, &err_p, 10); |
- | |
| 605 | - | ||
| 606 | if (*err_p) { |
625 | if (argc < 1) { |
| 607 | printf("Task ID syntax error\n"); |
626 | printf("Missing argument\n"); |
| 608 | print_syntax(); |
627 | print_syntax(); |
| 609 | return -1; |
628 | return -1; |
| 610 | } |
629 | } |
| 611 | 630 | ||
| - | 631 | /* Execute the specified command and trace the new task. */ |
|
| - | 632 | printf("Spawning '%s' with arguments:\n", *argv); |
|
| - | 633 | { |
|
| - | 634 | char **cp = argv; |
|
| - | 635 | while (*cp) printf("'%s'\n", *cp++); |
|
| - | 636 | } |
|
| - | 637 | task_id = task_spawn(*argv, argv); |
|
| - | 638 | ||
| 612 | return 0; |
639 | return 0; |
| 613 | } |
640 | } |
| 614 | 641 | ||
| 615 | int main(int argc, char *argv[]) |
642 | int main(int argc, char *argv[]) |
| 616 | { |
643 | { |