Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33e49ea7 authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarAndi Kleen <ak@linux.intel.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 61a9f324
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ static off_t post_processing_offset;

static struct perf_session	*session;
static const char		*cpu_list;
static const char               *progname;

static void advance_output(size_t size)
{
@@ -137,18 +138,30 @@ static void mmap_read(struct perf_mmap *md)

static volatile int done = 0;
static volatile int signr = -1;
static volatile int child_finished = 0;

static void sig_handler(int sig)
{
	if (sig == SIGCHLD)
		child_finished = 1;

	done = 1;
	signr = sig;
}

static void sig_atexit(void)
{
	if (child_pid > 0)
	int status;

	if (child_pid > 0) {
		if (!child_finished)
			kill(child_pid, SIGTERM);

		wait(&status);
		if (WIFSIGNALED(status))
			psignal(WTERMSIG(status), progname);
	}

	if (signr == -1 || signr == SIGUSR1)
		return;

@@ -445,6 +458,8 @@ static int __cmd_record(int argc, const char **argv)
	char buf;
	struct machine *machine;

	progname = argv[0];

	page_size = sysconf(_SC_PAGE_SIZE);

	atexit(sig_atexit);
+2 −0
Original line number Diff line number Diff line
@@ -495,6 +495,8 @@ static int run_perf_stat(int argc __used, const char **argv)
	if (forks) {
		close(go_pipe[1]);
		wait(&status);
		if (WIFSIGNALED(status))
			psignal(WTERMSIG(status), argv[0]);
	} else {
		while(!done) sleep(1);
	}