Ticket #1436: patch
File patch, 3.0 KB (added by , 17 years ago) |
---|
-
src/bin/strace/strace.cpp
old new 8 8 #include <stdlib.h> 9 9 #include <string.h> 10 10 #include <errno.h> 11 #include <signal.h> 11 12 12 13 #include <map> 13 14 #include <string> … … 84 85 static const char *kTerminalTextRed = "\33[31m"; 85 86 static const char *kTerminalTextMagenta = "\33[35m"; 86 87 88 static const char *signalname[] = { 89 /* 0 */"SIG0", 90 /* 1 */"SIGHUP", 91 /* 2 */"SIGINT", 92 /* 3 */"SIGQUIT", 93 /* 4 */"SIGILL", 94 /* 5 */"SIGCHLD", 95 /* 6 */"SIGABRT", 96 /* 7 */"SIGPIPE", 97 /* 8 */"SIGFPE", 98 /* 9 */"SIGKILL", 99 /* 10 */"SIGSTOP", 100 /* 11 */"SIGSEGV", 101 /* 12 */"SIGCONT", 102 /* 13 */"SIGTSTP", 103 /* 14 */"SIGALRM", 104 /* 15 */"SIGTERM", 105 /* 16 */"SIGTTIN", 106 /* 17 */"SIGTTOU", 107 /* 18 */"SIGUSR1", 108 /* 19 */"SIGUSR2", 109 /* 20 */"SIGWINCH", 110 /* 21 */"SIGKILLTHR", 111 /* 22 */"SIGTRAP", 112 /* 23 */"SIGPOLL", 113 /* 24 */"SIGPROF", 114 /* 25 */"SIGSYS", 115 /* 26 */"SIGURG", 116 /* 27 */"SIGVTALRM", 117 /* 28 */"SIGXCPU", 118 /* 29 */"SIGXFSZ", 87 119 120 }; 88 121 // command line args 89 122 static int sArgc; 90 123 static const char *const *sArgv; … … 432 465 _kern_debug_output(buffer); 433 466 } 434 467 468 static 469 const char * 470 signame(int signal) 471 { 472 static char buf[32]; 473 if (signal >= 0 && signal < NSIG) 474 return signalname[signal]; 475 else { 476 sprintf(buf, "%d", signal); 477 return buf; 478 } 479 } 480 481 // print_signal 482 static 483 void 484 print_signal(FILE *outputFile, debug_signal_received &message, 485 bool colorize) 486 { 487 char buffer[4096], *string = buffer; 488 int32 length = (int32)sizeof(buffer); 489 int signalNumber = message.signal; 490 491 // print syscall name 492 if (colorize) { 493 print_to_string(&string, &length, "--- %s%s (%s) %s ---\n", 494 kTerminalTextRed, signame(signalNumber), 495 strsignal(signalNumber), kTerminalTextNormal); 496 } else { 497 print_to_string(&string, &length, "--- %s (%s) ---\n", 498 signame(signalNumber), strsignal(signalNumber)); 499 } 500 501 // output either to file or serial debug line 502 if (outputFile != NULL) 503 fwrite(buffer, sizeof(buffer) - length, 1, outputFile); 504 else 505 _kern_debug_output(buffer); 506 } 435 507 436 508 // main 437 509 int … … 597 669 598 670 // set team debugging flags 599 671 int32 teamDebugFlags = (traceTeam ? B_TEAM_DEBUG_POST_SYSCALL : 0); 672 teamDebugFlags |= B_TEAM_DEBUG_SIGNALS; 600 673 set_team_debugging_flags(nubPort, teamDebugFlags); 601 674 602 675 // set thread debugging flags … … 642 715 break; 643 716 } 644 717 718 case B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED: 719 { 720 printf("signal\n"); 721 print_signal(outputFile, message.signal_received, 722 colorize); 723 break; 724 } 645 725 case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: 646 726 case B_DEBUGGER_MESSAGE_DEBUGGER_CALL: 647 727 case B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: 648 728 case B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: 649 729 case B_DEBUGGER_MESSAGE_SINGLE_STEP: 650 730 case B_DEBUGGER_MESSAGE_PRE_SYSCALL: 651 case B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED:652 731 case B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: 653 732 case B_DEBUGGER_MESSAGE_TEAM_CREATED: 654 733 case B_DEBUGGER_MESSAGE_THREAD_CREATED: