Changeset 1643855 in mainline for uspace/app/trace/trace.c
- Timestamp:
- 2008-09-17T18:04:01Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e028660
- Parents:
- 8c125ad
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/trace.c
r8c125ad r1643855 52 52 #include "ipcp.h" 53 53 #include "errors.h" 54 #include "trace.h" 54 55 55 56 #define THBUF_SIZE 64 … … 68 69 69 70 static proto_t *proto_console; 71 static task_id_t task_id; 72 73 /** Combination of events/data to print. */ 74 display_mask_t display_mask; 70 75 71 76 static int task_connect(task_id_t task_id) … … 287 292 } 288 293 289 /* Print syscall name, id and arguments */ 290 printf("%s", syscall_desc[sc_id].name); 291 print_sc_args(sc_args, syscall_desc[sc_id].n_args); 294 if ((display_mask & DM_SYSCALL) != 0) { 295 /* Print syscall name and arguments */ 296 printf("%s", syscall_desc[sc_id].name); 297 print_sc_args(sc_args, syscall_desc[sc_id].n_args); 298 } 292 299 293 300 async_serialize_end(); … … 313 320 } 314 321 315 rv_type = syscall_desc[sc_id].rv_type; 316 print_sc_retval(sc_rc, rv_type); 322 if ((display_mask & DM_SYSCALL) != 0) { 323 /* Print syscall return value */ 324 rv_type = syscall_desc[sc_id].rv_type; 325 print_sc_retval(sc_rc, rv_type); 326 } 317 327 318 328 switch (sc_id) { … … 429 439 int c; 430 440 431 printf("Syscall Tracer\n");432 433 441 rc = task_connect(task_id); 434 442 if (rc < 0) { … … 533 541 static void print_syntax() 534 542 { 535 printf("Syntax: trace <task_id>\n"); 536 } 537 538 int main(int argc, char *argv[]) 539 { 540 task_id_t task_id; 543 printf("Syntax: trace [+<events>] <task_id>\n"); 544 printf("Events: (default is +tp)\n"); 545 printf("\n"); 546 printf("\tt ... Thread creation and termination\n"); 547 printf("\ts ... System calls\n"); 548 printf("\ti ... Low-level IPC\n"); 549 printf("\tp ... Protocol level\n"); 550 printf("\n"); 551 printf("Example: trace +tsip 12\n"); 552 } 553 554 static display_mask_t parse_display_mask(char *text) 555 { 556 display_mask_t dm; 557 char *c; 558 559 c = text; 560 561 while (*c) { 562 switch (*c) { 563 case 't': dm = dm | DM_THREAD; break; 564 case 's': dm = dm | DM_SYSCALL; break; 565 case 'i': dm = dm | DM_IPC; break; 566 case 'p': dm = dm | DM_SYSTEM | DM_USER; break; 567 default: 568 printf("Unexpected event type '%c'\n", *c); 569 exit(1); 570 } 571 572 ++c; 573 } 574 575 return dm; 576 } 577 578 static int parse_args(int argc, char *argv[]) 579 { 580 char *arg; 541 581 char *err_p; 542 582 543 if (argc != 2) { 544 printf("Mising argument\n"); 583 --argc; ++argv; 584 585 while (argc > 1) { 586 arg = *argv; 587 if (arg[0] == '+') { 588 display_mask = parse_display_mask(&arg[1]); 589 } else { 590 printf("Unexpected argument '%s'\n", arg); 591 print_syntax(); 592 return -1; 593 } 594 595 --argc; ++argv; 596 } 597 598 if (argc != 1) { 599 printf("Missing argument\n"); 545 600 print_syntax(); 546 601 return 1; 547 602 } 548 603 549 task_id = strtol( argv[1], &err_p, 10);604 task_id = strtol(*argv, &err_p, 10); 550 605 551 606 if (*err_p) { 552 607 printf("Task ID syntax error\n"); 553 608 print_syntax(); 609 return -1; 610 } 611 612 return 0; 613 } 614 615 int main(int argc, char *argv[]) 616 { 617 printf("System Call / IPC Tracer\n"); 618 619 display_mask = DM_THREAD | DM_SYSTEM | DM_USER; 620 621 if (parse_args(argc, argv) < 0) 554 622 return 1; 555 }556 623 557 624 main_init(); 558 625 trace_active_task(task_id); 626 627 return 0; 559 628 } 560 629
Note:
See TracChangeset
for help on using the changeset viewer.