Commit 53fb1894 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf script: Enable IP fields for callchains

In case the callchains were deleted in pipe mode, we need to ensure that
the IP fields are enabled, otherwise the callchain is not displayed.

Enabling IP and SYM, which should be enough for callchains.

Committer testing:

Before:

Committer Testing:

before:

  # ls
  # perf record -g -e 'syscalls:*' sleep 0.1 2>/dev/null | perf script | tail
       sleep 5677 [0] 5034.295882:         syscalls:sys_exit_mmap: 0x7fcbcfa74000
       sleep 5677 [0] 5034.295885:       syscalls:sys_enter_close: fd: 0x00000003
       sleep 5677 [0] 5034.295886:        syscalls:sys_exit_close: 0x0
       sleep 5677 [0] 5034.295911:   syscalls:sys_enter_nanosleep: rqtp: 0x7fff775b33a0, rmtp: 0x00000000
       sleep 5677 [0] 5034.396021:    syscalls:sys_exit_nanosleep: 0x0
       sleep 5677 [0] 5034.396027:       syscalls:sys_enter_close: fd: 0x00000001
       sleep 5677 [0] 5034.396028:        syscalls:sys_exit_close: 0x0
       sleep 5677 [0] 5034.396029:       syscalls:sys_enter_close: fd: 0x00000002
       sleep 5677 [0] 5034.396029:        syscalls:sys_exit_close: 0x0
       sleep 5677 [0] 5034.396032:  syscalls:sys_enter_exit_group: error_code: 0x00000000
  #
  # ls
  #

After:

  # perf record --call-graph=dwarf -e 'syscalls:sys_enter*' sleep 0.1 2>/dev/null | perf script | tail -37
  sleep 33010 [000]  5400.625269:              syscalls:sys_enter_nanosleep: rqtp: 0x7fff2d0e7860, rmtp: 0x00000000
  	    7f1406f131a7 __GI___nanosleep (inlined)
  	    561c4f996966 [unknown]
  	    561c4f99673f [unknown]
  	    561c4f9937af [unknown]
  	    7f1406e6c1a2 __libc_start_main
  	    561c4f99388d [unknown]

  sleep 33010 [000]  5400.725391:                  syscalls:sys_enter_close: fd: 0x00000001
  	    7f1406f3c3cb __GI___close_nocancel (inlined)
  	    7f1406ec7d6f _IO_new_file_close_it (inlined)
  	    7f1406ebafa5 _IO_new_fclose (inlined)
  	    561c4f996a40 [unknown]
  	    561c4f993d79 [unknown]
  	    7f1406e83e86 __run_exit_handlers
  	    7f1406e8403f __GI_exit (inlined)
  	    7f1406e6c1a9 __libc_start_main
  	    561c4f99388d [unknown]

  sleep 33010 [000]  5400.725395:                  syscalls:sys_enter_close: fd: 0x00000002
  	    7f1406f3c3cb __GI___close_nocancel (inlined)
  	    7f1406ec7d6f _IO_new_file_close_it (inlined)
  	    7f1406ebafa5 _IO_new_fclose (inlined)
  	    561c4f996a40 [unknown]
  	    561c4f993da2 [unknown]
  	    7f1406e83e86 __run_exit_handlers
  	    7f1406e8403f __GI_exit (inlined)
  	    7f1406e6c1a9 __libc_start_main
  	    561c4f99388d [unknown]

  sleep 33010 [000]  5400.725399:             syscalls:sys_enter_exit_group: error_code: 0x00000000
  	    7f1406f13466 __GI__exit (inlined)
  	    7f1406e83fa1 __run_exit_handlers
  	    7f1406e8403f __GI_exit (inlined)
  	    7f1406e6c1a9 __libc_start_main
  	    561c4f99388d [unknown]
  #

And, if we install coreutils-debuginfo, we'll have those [unknown] resolved,
those are for the /usr/bin/sleep binary, use:

  # dnf debuginfo-install coreutils

On Fedora and derivatives, then:

  # perf record --call-graph=dwarf -e 'syscalls:sys_enter*' sleep 0.1 2>/dev/null | perf script | tail -37
  sleep 33046 [009]  5533.910074:              syscalls:sys_enter_nanosleep: rqtp: 0x7ffea6fa7ab0, rmtp: 0x00000000
  	    7f5f786e81a7 __GI___nanosleep (inlined)
  	    564472454966 rpl_nanosleep
  	    56447245473f xnanosleep
  	    5644724517af main
  	    7f5f786411a2 __libc_start_main
  	    56447245188d _start

  sleep 33046 [009]  5534.010218:                  syscalls:sys_enter_close: fd: 0x00000001
  	    7f5f787113cb __GI___close_nocancel (inlined)
  	    7f5f7869cd6f _IO_new_file_close_it (inlined)
  	    7f5f7868ffa5 _IO_new_fclose (inlined)
  	    564472454a40 close_stream
  	    564472451d79 close_stdout
  	    7f5f78658e86 __run_exit_handlers
  	    7f5f7865903f __GI_exit (inlined)
  	    7f5f786411a9 __libc_start_main
  	    56447245188d _start

  sleep 33046 [009]  5534.010224:                  syscalls:sys_enter_close: fd: 0x00000002
  	    7f5f787113cb __GI___close_nocancel (inlined)
  	    7f5f7869cd6f _IO_new_file_close_it (inlined)
  	    7f5f7868ffa5 _IO_new_fclose (inlined)
  	    564472454a40 close_stream
  	    564472451da2 close_stdout
  	    7f5f78658e86 __run_exit_handlers
  	    7f5f7865903f __GI_exit (inlined)
  	    7f5f786411a9 __libc_start_main
  	    56447245188d _start

  sleep 33046 [009]  5534.010229:             syscalls:sys_enter_exit_group: error_code: 0x00000000
  	    7f5f786e8466 __GI__exit (inlined)
  	    7f5f78658fa1 __run_exit_handlers
  	    7f5f7865903f __GI_exit (inlined)
  	    7f5f786411a9 __libc_start_main
  	    56447245188d _start

  #
Reported-by: default avatarPaul Khuong <pvk@pvk.ca>
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200507095024.2789147-6-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0d71a2b2
......@@ -2118,8 +2118,6 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
return 0;
}
set_print_ip_opts(&evsel->core.attr);
if (evsel->core.attr.sample_type) {
err = perf_evsel__check_attr(evsel, scr->session);
if (err)
......@@ -2132,6 +2130,13 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
*/
sample_type = perf_evlist__combined_sample_type(evlist);
callchain_param_setup(sample_type);
/* Enable fields for callchain entries, if it got enabled. */
if (callchain_param.record_mode != CALLCHAIN_NONE) {
output[output_type(evsel->core.attr.type)].fields |= PERF_OUTPUT_IP |
PERF_OUTPUT_SYM;
}
set_print_ip_opts(&evsel->core.attr);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment