perf evsel: Add option to limit stack depth in callchain dumps
authorDavid Ahern <dsahern@gmail.com>
Thu, 8 Aug 2013 02:50:53 +0000 (22:50 -0400)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 12 Aug 2013 13:31:08 +0000 (10:31 -0300)
Option is used by upcoming timehist command.

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1375930261-77273-12-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c
tools/perf/util/session.c
tools/perf/util/session.h

index ee5d6f8b74157013aa1e76f981cc6a545ed57dee..33b2d830eabdab42a593d003adb847febc35adf9 100644 (file)
@@ -402,7 +402,8 @@ static void print_sample_bts(union perf_event *event,
                else
                        printf("\n");
                perf_evsel__print_ip(evsel, event, sample, machine,
-                                    output[attr->type].print_ip_opts);
+                                    output[attr->type].print_ip_opts,
+                                    PERF_MAX_STACK_DEPTH);
        }
 
        printf(" => ");
@@ -444,7 +445,8 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
                        printf("\n");
 
                perf_evsel__print_ip(evsel, event, sample, machine,
-                                    output[attr->type].print_ip_opts);
+                                    output[attr->type].print_ip_opts,
+                                    PERF_MAX_STACK_DEPTH);
        }
 
        printf("\n");
index 0d895e7040e4d398a6fd230a2e00bcfcb31fb003..5a8996493d94cb0230c12ba934ea6675e1e27754 100644 (file)
@@ -1489,7 +1489,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
 
 void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
                          struct perf_sample *sample, struct machine *machine,
-                         unsigned int print_opts)
+                         unsigned int print_opts, unsigned int stack_depth)
 {
        struct addr_location al;
        struct callchain_cursor_node *node;
@@ -1517,7 +1517,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
                }
                callchain_cursor_commit(&callchain_cursor);
 
-               while (1) {
+               while (stack_depth) {
                        node = callchain_cursor_current(&callchain_cursor);
                        if (!node)
                                break;
@@ -1544,6 +1544,8 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
                                printf("\n");
 
                        callchain_cursor_advance(&callchain_cursor);
+
+                       stack_depth--;
                }
 
        } else {
index 7c00ccb1173e2f8ee72e3ac89eea5326d461cac4..3aa75fb2225f7129daa12f7e86219f30928e5e42 100644 (file)
@@ -109,7 +109,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
 
 void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
                          struct perf_sample *sample, struct machine *machine,
-                         unsigned int print_opts);
+                         unsigned int print_opts, unsigned int stack_depth);
 
 int perf_session__cpu_bitmap(struct perf_session *session,
                             const char *cpu_list, unsigned long *cpu_bitmap);