[PATCH 16/19] perf ftrace: Add a signal handler for SIGSEGV
From: Namhyung Kim
Date: Wed Jun 26 2013 - 03:15:09 EST
From: Namhyung Kim <namhyung.kim@xxxxxxx>
It's for debugging purpose.
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/builtin-ftrace.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 698dd0b5cecf..3b6bcc29715b 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -41,6 +41,13 @@ struct perf_ftrace {
static bool done;
+static void sig_exit(int sig)
+{
+ psignal(sig, "perf");
+ signal(sig, SIG_DFL);
+ raise(sig);
+}
+
static void sig_handler(int sig __maybe_unused)
{
done = true;
@@ -228,6 +235,7 @@ static int do_ftrace_live(struct perf_ftrace *ftrace)
signal(SIGUSR1, sig_handler);
signal(SIGCHLD, sig_handler);
signal(SIGPIPE, sig_handler);
+ signal(SIGSEGV, sig_exit);
if (setup_tracing_files(ftrace) < 0)
goto out_reset;
@@ -599,6 +607,7 @@ static int do_ftrace_record(struct perf_ftrace *ftrace)
signal(SIGINT, sig_handler);
signal(SIGUSR1, sig_handler);
signal(SIGCHLD, sig_handler);
+ signal(SIGSEGV, sig_exit);
if (setup_tracing_files(ftrace) < 0)
goto out_reset;
@@ -1100,6 +1109,8 @@ static int do_ftrace_show(struct perf_ftrace *ftrace)
},
};
+ signal(SIGSEGV, sig_exit);
+
scnprintf(buf, sizeof(buf), "%s.dir/perf.header", ftrace->dirname);
session = perf_session__new(buf, O_RDONLY, false, false, &show.tool);
@@ -1189,6 +1200,8 @@ static int do_ftrace_report(struct perf_ftrace *ftrace)
struct machine *machine;
struct dso *dso;
+ signal(SIGSEGV, sig_exit);
+
scnprintf(buf, sizeof(buf), "%s.dir/perf.header", ftrace->dirname);
session = perf_session__new(buf, O_RDONLY, false, false, &report.tool);
--
1.7.11.7
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/