Rev 3593 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3593 | Rev 3665 | ||
---|---|---|---|
Line 443... | Line 443... | ||
443 | sysarg_t val0, val1; |
443 | sysarg_t val0, val1; |
444 | 444 | ||
445 | thread_hash = (uintptr_t)thread_hash_arg; |
445 | thread_hash = (uintptr_t)thread_hash_arg; |
446 | thread_id = next_thread_id++; |
446 | thread_id = next_thread_id++; |
447 | 447 | ||
448 | printf("Start tracing thread [%d] (hash 0x%lx)\n", thread_id, thread_hash); |
448 | printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash); |
449 | 449 | ||
450 | while (!abort_trace) { |
450 | while (!abort_trace) { |
451 | 451 | ||
- | 452 | if (paused) { |
|
- | 453 | printf("Press R to resume (and be patient).\n"); |
|
- | 454 | while (paused) { |
|
- | 455 | usleep(1000000); |
|
- | 456 | fibril_yield(); |
|
- | 457 | printf("."); |
|
- | 458 | } |
|
- | 459 | printf("Resumed\n"); |
|
- | 460 | } |
|
- | 461 | ||
452 | /* Run thread until an event occurs */ |
462 | /* Run thread until an event occurs */ |
453 | rc = udebug_go(phoneid, thread_hash, |
463 | rc = udebug_go(phoneid, thread_hash, |
454 | &ev_type, &val0, &val1); |
464 | &ev_type, &val0, &val1); |
455 | 465 | ||
456 | // printf("rc = %d, ev_type=%d\n", rc, ev_type); |
466 | // printf("rc = %d, ev_type=%d\n", rc, ev_type); |
Line 467... | Line 477... | ||
467 | case UDEBUG_EVENT_SYSCALL_E: |
477 | case UDEBUG_EVENT_SYSCALL_E: |
468 | event_syscall_e(thread_id, thread_hash, val0, (int)val1); |
478 | event_syscall_e(thread_id, thread_hash, val0, (int)val1); |
469 | break; |
479 | break; |
470 | case UDEBUG_EVENT_STOP: |
480 | case UDEBUG_EVENT_STOP: |
471 | printf("Stop event\n"); |
481 | printf("Stop event\n"); |
472 | printf("Waiting for resume\n"); |
- | |
473 | while (paused) { |
- | |
474 | usleep(1000000); |
- | |
475 | fibril_yield(); |
- | |
476 | printf("."); |
- | |
477 | } |
- | |
478 | printf("Resumed\n"); |
- | |
479 | break; |
482 | break; |
480 | case UDEBUG_EVENT_THREAD_B: |
483 | case UDEBUG_EVENT_THREAD_B: |
481 | event_thread_b(val0); |
484 | event_thread_b(val0); |
482 | break; |
485 | break; |
483 | case UDEBUG_EVENT_THREAD_E: |
486 | case UDEBUG_EVENT_THREAD_E: |
484 | printf("Thread 0x%lx exited\n", val0); |
487 | printf("Thread 0x%lx exited.\n", val0); |
485 | abort_trace = 1; |
488 | abort_trace = 1; |
486 | break; |
489 | break; |
487 | default: |
490 | default: |
488 | printf("Unknown event type %d\n", ev_type); |
491 | printf("Unknown event type %d.\n", ev_type); |
489 | break; |
492 | break; |
490 | } |
493 | } |
491 | } |
494 | } |
492 | 495 | ||
493 | } |
496 | } |
494 | 497 | ||
495 | printf("Finished tracing thread [%d]\n", thread_id); |
498 | printf("Finished tracing thread [%d].\n", thread_id); |
496 | return 0; |
499 | return 0; |
497 | } |
500 | } |
498 | 501 | ||
499 | void thread_trace_start(uintptr_t thread_hash) |
502 | void thread_trace_start(uintptr_t thread_hash) |
500 | { |
503 | { |
Line 578... | Line 581... | ||
578 | 581 | ||
579 | while(1) { |
582 | while(1) { |
580 | c = getchar(); |
583 | c = getchar(); |
581 | if (c == 'q') break; |
584 | if (c == 'q') break; |
582 | if (c == 'p') { |
585 | if (c == 'p') { |
- | 586 | printf("Pause...\n"); |
|
583 | paused = 1; |
587 | paused = 1; |
584 | rc = udebug_stop(phoneid, thash); |
588 | rc = udebug_stop(phoneid, thash); |
585 | printf("stop -> %d\n", rc); |
589 | printf("stop -> %d\n", rc); |
586 | } |
590 | } |
587 | if (c == 'r') { |
591 | if (c == 'r') { |
588 | paused = 0; |
592 | paused = 0; |
- | 593 | printf("Resume...\n"); |
|
589 | } |
594 | } |
590 | } |
595 | } |
591 | 596 | ||
592 | printf("\nTerminate debugging session...\n"); |
597 | printf("\nTerminate debugging session...\n"); |
593 | abort_trace = 1; |
598 | abort_trace = 1; |
Line 700... | Line 705... | ||
700 | case 't': dm = dm | DM_THREAD; break; |
705 | case 't': dm = dm | DM_THREAD; break; |
701 | case 's': dm = dm | DM_SYSCALL; break; |
706 | case 's': dm = dm | DM_SYSCALL; break; |
702 | case 'i': dm = dm | DM_IPC; break; |
707 | case 'i': dm = dm | DM_IPC; break; |
703 | case 'p': dm = dm | DM_SYSTEM | DM_USER; break; |
708 | case 'p': dm = dm | DM_SYSTEM | DM_USER; break; |
704 | default: |
709 | default: |
705 | printf("Unexpected event type '%c'\n", *c); |
710 | printf("Unexpected event type '%c'.\n", *c); |
706 | exit(1); |
711 | exit(1); |
707 | } |
712 | } |
708 | 713 | ||
709 | ++c; |
714 | ++c; |
710 | } |
715 | } |
Line 775... | Line 780... | ||
775 | int main(int argc, char *argv[]) |
780 | int main(int argc, char *argv[]) |
776 | { |
781 | { |
777 | int rc; |
782 | int rc; |
778 | 783 | ||
779 | printf("System Call / IPC Tracer\n"); |
784 | printf("System Call / IPC Tracer\n"); |
- | 785 | printf("Controls: Q - Quit, P - Pause, R - Resume\n"); |
|
780 | 786 | ||
781 | display_mask = DM_THREAD | DM_SYSTEM | DM_USER; |
787 | display_mask = DM_THREAD | DM_SYSTEM | DM_USER; |
782 | 788 | ||
783 | if (parse_args(argc, argv) < 0) |
789 | if (parse_args(argc, argv) < 0) |
784 | return 1; |
790 | return 1; |
785 | 791 | ||
786 | main_init(); |
792 | main_init(); |
787 | 793 | ||
788 | rc = connect_task(task_id); |
794 | rc = connect_task(task_id); |
789 | if (rc < 0) { |
795 | if (rc < 0) { |
790 | printf("Failed connecting to task %lld\n", task_id); |
796 | printf("Failed connecting to task %lld.\n", task_id); |
791 | return 1; |
797 | return 1; |
792 | } |
798 | } |
793 | 799 | ||
794 | printf("Connected to task %lld\n", task_id); |
800 | printf("Connected to task %lld.\n", task_id); |
795 | 801 | ||
796 | if (task_ldr != NULL) { |
802 | if (task_ldr != NULL) { |
797 | program_run(); |
803 | program_run(); |
798 | } |
804 | } |
799 | 805 |