Skip to content

Commit

Permalink
perf symbols: Limit max callchain using max_stack on DWARF unwinding too
Browse files Browse the repository at this point in the history
It was affecting only frame-pointer (fp) based callchain processing.

Usage example:

  perf top --call-graph dwarf,1024 --max-stack 2

Works for any tool that does callchain resolving and provides a
--max-stack option.

Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Waiman Long <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Nov 14, 2013
1 parent d87fcb4 commit 37676af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tools/perf/util/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ int machine__resolve_callchain(struct machine *machine,

return unwind__get_entries(unwind_entry, &callchain_cursor, machine,
thread, evsel->attr.sample_regs_user,
sample);
sample, max_stack);

}

Expand Down
9 changes: 5 additions & 4 deletions tools/perf/util/unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ static unw_accessors_t accessors = {
};

static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
void *arg)
void *arg, int max_stack)
{
unw_addr_space_t addr_space;
unw_cursor_t c;
Expand All @@ -575,7 +575,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
if (ret)
display_error(ret);

while (!ret && (unw_step(&c) > 0)) {
while (!ret && (unw_step(&c) > 0) && max_stack--) {
unw_word_t ip;

unw_get_reg(&c, UNW_REG_IP, &ip);
Expand All @@ -588,7 +588,8 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,

int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct machine *machine, struct thread *thread,
u64 sample_uregs, struct perf_sample *data)
u64 sample_uregs, struct perf_sample *data,
int max_stack)
{
unw_word_t ip;
struct unwind_info ui = {
Expand All @@ -610,5 +611,5 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
if (ret)
return -ENOMEM;

return get_entries(&ui, cb, arg);
return get_entries(&ui, cb, arg, max_stack);
}
5 changes: 3 additions & 2 deletions tools/perf/util/unwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct machine *machine,
struct thread *thread,
u64 sample_uregs,
struct perf_sample *data);
struct perf_sample *data, int max_stack);
int unwind__arch_reg_id(int regnum);
#else
static inline int
Expand All @@ -27,7 +27,8 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
struct machine *machine __maybe_unused,
struct thread *thread __maybe_unused,
u64 sample_uregs __maybe_unused,
struct perf_sample *data __maybe_unused)
struct perf_sample *data __maybe_unused,
int max_stack __maybe_unused)
{
return 0;
}
Expand Down

0 comments on commit 37676af

Please sign in to comment.