perf tools: Introduce dump_stack signal helper
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 24 Feb 2015 18:34:23 +0000 (15:34 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 24 Feb 2015 18:34:23 +0000 (15:34 -0300)
To use in stdio based tools, like 'trace'.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-79kjmerlw6d88csyx1afzwvn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/util.c
tools/perf/util/util.h

index 92db3f156b63d493e798620c8dbe309f0b8d3350..4ee6d0d4c9931752e76abe15dd098468c4e0c01f 100644 (file)
@@ -269,6 +269,13 @@ void dump_stack(void)
 void dump_stack(void) {}
 #endif
 
+void sighandler_dump_stack(int sig)
+{
+       psignal(sig, "perf");
+       dump_stack();
+       exit(sig);
+}
+
 void get_term_dimensions(struct winsize *ws)
 {
        char *s = getenv("LINES");
index 73c2f8e557abf1becc2a8dc51336647e678114c7..fbd598afc606e8f3c73d9b5278a9211aabc3a089 100644 (file)
@@ -277,6 +277,7 @@ char *ltrim(char *s);
 char *rtrim(char *s);
 
 void dump_stack(void);
+void sighandler_dump_stack(int sig);
 
 extern unsigned int page_size;
 extern int cacheline_size;