aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2011-09-15 17:31:40 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-09-29 16:09:46 -0400
commit33e49ea70df066651a17061c62118fc3f075d21f (patch)
tree8eaa17e37ceb8398859e944385cac328ffcaa1c7 /tools
parent61a9f324292e6dd4f4b99f5366454788104a0bd9 (diff)
perf tools: Make stat/record print fatal signals of the target program
When a program crashes under perf there is no message about it, unlike when running it from bash. This can be confusing and lead to wrong actions during debugging. Print fatal signals in perf stat/record. Thanks to Furat Afram for finding the problem originally Link: http://lkml.kernel.org/r/1316122302-24306-1-git-send-email-andi@firstfloor.org Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Stephane Eranian <eranian@google.com> Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-record.c19
-rw-r--r--tools/perf/builtin-stat.c2
2 files changed, 19 insertions, 2 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 6b0519f885e4..042117f8fffa 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -73,6 +73,7 @@ static off_t post_processing_offset;
73 73
74static struct perf_session *session; 74static struct perf_session *session;
75static const char *cpu_list; 75static const char *cpu_list;
76static const char *progname;
76 77
77static void advance_output(size_t size) 78static void advance_output(size_t size)
78{ 79{
@@ -137,17 +138,29 @@ static void mmap_read(struct perf_mmap *md)
137 138
138static volatile int done = 0; 139static volatile int done = 0;
139static volatile int signr = -1; 140static volatile int signr = -1;
141static volatile int child_finished = 0;
140 142
141static void sig_handler(int sig) 143static void sig_handler(int sig)
142{ 144{
145 if (sig == SIGCHLD)
146 child_finished = 1;
147
143 done = 1; 148 done = 1;
144 signr = sig; 149 signr = sig;
145} 150}
146 151
147static void sig_atexit(void) 152static void sig_atexit(void)
148{ 153{
149 if (child_pid > 0) 154 int status;
150 kill(child_pid, SIGTERM); 155
156 if (child_pid > 0) {
157 if (!child_finished)
158 kill(child_pid, SIGTERM);
159
160 wait(&status);
161 if (WIFSIGNALED(status))
162 psignal(WTERMSIG(status), progname);
163 }
151 164
152 if (signr == -1 || signr == SIGUSR1) 165 if (signr == -1 || signr == SIGUSR1)
153 return; 166 return;
@@ -445,6 +458,8 @@ static int __cmd_record(int argc, const char **argv)
445 char buf; 458 char buf;
446 struct machine *machine; 459 struct machine *machine;
447 460
461 progname = argv[0];
462
448 page_size = sysconf(_SC_PAGE_SIZE); 463 page_size = sysconf(_SC_PAGE_SIZE);
449 464
450 atexit(sig_atexit); 465 atexit(sig_atexit);
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index b5673194870a..7ce65f52415e 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -495,6 +495,8 @@ static int run_perf_stat(int argc __used, const char **argv)
495 if (forks) { 495 if (forks) {
496 close(go_pipe[1]); 496 close(go_pipe[1]);
497 wait(&status); 497 wait(&status);
498 if (WIFSIGNALED(status))
499 psignal(WTERMSIG(status), argv[0]);
498 } else { 500 } else {
499 while(!done) sleep(1); 501 while(!done) sleep(1);
500 } 502 }