Skip to content

Commit

Permalink
perf report: Fix --no-call-chain option handling
Browse files Browse the repository at this point in the history
To avoid the funny:

 [root@doppio ~]# perf record -a -f sleep 2s
 [ perf record: Woken up 1 times to write data ]
 [ perf record: Captured and wrote 0.334 MB perf.data (~14572 samples) ]
 [root@doppio ~]# perf report --no-call-graph
 selected -g but no callchain data. Did you call perf record without -g?

And fix the bug reported by peterz when we do indeed record with
callchains and then ask for a report without:

[root@doppio ~]# perf record -a -g -f sleep 2s
[root@doppio ~]# perf report --no-call-graph
Segmentation fault
[root@doppio ~]#

Reported-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1262699685-27820-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Jan 13, 2010
1 parent de17648 commit b9a63b9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static char const *input_name = "perf.data";

static int force;
static bool hide_unresolved;
static bool dont_use_callchains;

static int show_threads;
static struct perf_read_values show_threads_values;
Expand Down Expand Up @@ -172,7 +173,8 @@ static int perf_session__setup_sample_type(struct perf_session *self)
" -g?\n");
return -1;
}
} else if (callchain_param.mode != CHAIN_NONE && !symbol_conf.use_callchain) {
} else if (!dont_use_callchains && callchain_param.mode != CHAIN_NONE &&
!symbol_conf.use_callchain) {
symbol_conf.use_callchain = true;
if (register_callchain_param(&callchain_param) < 0) {
fprintf(stderr, "Can't register callchain"
Expand Down Expand Up @@ -246,11 +248,19 @@ static int __cmd_report(void)

static int
parse_callchain_opt(const struct option *opt __used, const char *arg,
int unset __used)
int unset)
{
char *tok;
char *endptr;

/*
* --no-call-graph
*/
if (unset) {
dont_use_callchains = true;
return 0;
}

symbol_conf.use_callchain = true;

if (!arg)
Expand Down

0 comments on commit b9a63b9

Please sign in to comment.