From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
David Ahern <dsahern@gmail.com>,
Stephane Eranian <eranian@google.com>,
Adrian Hunter <adrian.hunter@intel.com>
Subject: [PATCH 3/7] perf ui/tui: Print backtrace symbols when segfault occurred
Date: Mon, 22 Dec 2014 13:44:11 +0900 [thread overview]
Message-ID: <1419223455-4362-4-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1419223455-4362-1-git-send-email-namhyung@kernel.org>
The output will look like below. (I added an error into ui__init()
for the test).
$ perf report
perf: Segmentation fault
-------- backtrace --------
perf[0x503781]
/usr/lib/libc.so.6(+0x33b20)[0x7f1a14f04b20]
perf(ui__init+0xd5)[0x503645]
perf(setup_browser+0x97)[0x4ce4e7]
perf(cmd_report+0xcea)[0x4392ba]
perf[0x428493]
perf(main+0x60a)[0x427c0a]
/usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f1a14ef1040]
perf[0x427d29]
[0x0]
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/ui/tui/setup.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
index 2f612562978c..3c38f25b1695 100644
--- a/tools/perf/ui/tui/setup.c
+++ b/tools/perf/ui/tui/setup.c
@@ -1,5 +1,8 @@
#include <signal.h>
#include <stdbool.h>
+#ifdef HAVE_BACKTRACE_SUPPORT
+#include <execinfo.h>
+#endif
#include "../../util/cache.h"
#include "../../util/debug.h"
@@ -88,6 +91,25 @@ int ui__getch(int delay_secs)
return SLkp_getkey();
}
+#ifdef HAVE_BACKTRACE_SUPPORT
+static void ui__signal_backtrace(int sig)
+{
+ void *stackdump[32];
+ size_t size;
+
+ ui__exit(false);
+ psignal(sig, "perf");
+
+ printf("-------- backtrace --------\n");
+ size = backtrace(stackdump, ARRAY_SIZE(stackdump));
+ backtrace_symbols_fd(stackdump, size, STDOUT_FILENO);
+
+ exit(0);
+}
+#else
+# define ui__signal_backtrace ui__signal
+#endif
+
static void ui__signal(int sig)
{
ui__exit(false);
@@ -122,8 +144,8 @@ int ui__init(void)
ui_browser__init();
tui_progress__init();
- signal(SIGSEGV, ui__signal);
- signal(SIGFPE, ui__signal);
+ signal(SIGSEGV, ui__signal_backtrace);
+ signal(SIGFPE, ui__signal_backtrace);
signal(SIGINT, ui__signal);
signal(SIGQUIT, ui__signal);
signal(SIGTERM, ui__signal);
--
2.1.3
next prev parent reply other threads:[~2014-12-22 4:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-22 4:44 [PATCHSET 0/7] perf tools: A small random cleanup and fixups Namhyung Kim
2014-12-22 4:44 ` [PATCH 1/7] perf report: Get rid of report__inc_stat() Namhyung Kim
2015-01-28 15:04 ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-12-22 4:44 ` [PATCH 2/7] perf report: Show progress bar for output resorting Namhyung Kim
2015-01-01 21:28 ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2014-12-22 4:44 ` Namhyung Kim [this message]
2015-01-01 21:28 ` [tip:perf/urgent] perf ui/tui: Print backtrace symbols when segfault occurs tip-bot for Namhyung Kim
2014-12-22 4:44 ` [PATCH 4/7] perf diff: Fix to sort by baseline field by default Namhyung Kim
2014-12-22 14:45 ` Arnaldo Carvalho de Melo
2014-12-23 4:12 ` Namhyung Kim
2014-12-23 13:30 ` Arnaldo Carvalho de Melo
2014-12-22 4:44 ` [PATCH 5/7] perf diff: Get rid of hists__compute_resort() Namhyung Kim
2014-12-22 4:44 ` [PATCH 6/7] perf tools: Append callchains only when requested Namhyung Kim
2015-01-01 21:29 ` [tip:perf/urgent] perf callchain: " tip-bot for Namhyung Kim
2015-01-03 2:25 ` [PATCH 6/7] perf tools: " Arnaldo Carvalho de Melo
2015-01-03 15:01 ` Namhyung Kim
2015-01-05 12:49 ` Arnaldo Carvalho de Melo
2015-01-07 7:28 ` Namhyung Kim
2014-12-22 4:44 ` [PATCH 7/7] perf tools: Set attr.task bit for a tracking event Namhyung Kim
2014-12-22 14:49 ` Arnaldo Carvalho de Melo
2014-12-23 4:06 ` Namhyung Kim
2014-12-23 13:28 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1419223455-4362-4-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).