kernel_optimize_test/tools/perf/util
Dima Kogan f7380c12ec perf script perl: Perl scripts now get a backtrace, like the python ones
We have some infrastructure to use perl or python to analyze logs
generated by perf.  Prior to this patch, only the python tools had
access to backtrace information.  This patch makes this information
available to perl scripts as well.  Example:

  Let's look at malloc() calls made by the seq utility.  First we
  create a probe point:

      $ perf probe -x /lib/x86_64-linux-gnu/libc.so.6 malloc
      Added new events:
      ...

  Now we run seq, while monitoring malloc() calls with perf

      $ perf record --call-graph=dwarf -e probe_libc:malloc seq 5
      1
      2
      3
      4
      5
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.064 MB perf.data (6 samples) ]

  We can use perf to look at its log to see the malloc calls and the backtrace

      $ perf script
      seq 14195 [000] 1927993.748254: probe_libc:malloc: (7f9ff8edd320) bytes=0x22
                  7f9ff8edd320 malloc (/lib/x86_64-linux-gnu/libc-2.22.so)
                  7f9ff8e8eab0 set_binding_values.part.0 (/lib/x86_64-linux-gnu/libc-2.22.so)
                  7f9ff8e8eda1 __bindtextdomain (/lib/x86_64-linux-gnu/libc-2.22.so)
                        401b22 main (/usr/bin/seq)
                  7f9ff8e82610 __libc_start_main (/lib/x86_64-linux-gnu/libc-2.22.so)
                        402799 _start (/usr/bin/seq)
      ...

  We can also use the scripting facilities.  We create a skeleton perl
  script that simply prints out the events

      $ perf script -g perl
      generated Perl script: perf-script.pl

  We can then use this script to see the malloc() calls with a
  backtrace.  Prior to this patch, the backtrace was not available to
  the perl scripts.

      $ perf script -s perf-script.pl
      probe_libc::malloc  0 1927993.748254260  14195 seq   __probe_ip=140325052863264, bytes=34
              [7f9ff8edd320] malloc
              [7f9ff8e8eab0] set_binding_values.part.0
              [7f9ff8e8eda1] __bindtextdomain
              [401b22] main
              [7f9ff8e82610] __libc_start_main
              [402799] _start
      ...

Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: http://lkml.kernel.org/r/87mvphzld0.fsf@secretsauce.net
Signed-off-by: Dima Kogan <dima@secretsauce.net>
2016-03-30 11:14:09 -03:00
..
include tools lib: Move bitmap.[ch] from tools/perf/ to tools/{lib,include}/ 2016-01-08 12:35:46 -03:00
intel-pt-decoder perf intel-pt: Make logging slightly more efficient 2015-09-28 16:45:26 -03:00
scripting-engines perf script perl: Perl scripts now get a backtrace, like the python ones 2016-03-30 11:14:09 -03:00
alias.c
annotate.c perf annotate: ARM support 2015-12-07 18:13:00 -03:00
annotate.h perf tools: Remove misplaced __maybe_unused 2016-03-23 12:03:04 -03:00
auxtrace.c perf auxtrace: Add perf_evlist pointer to *info_priv_size() 2016-01-29 17:14:30 -03:00
auxtrace.h perf tools: Remove misplaced __maybe_unused 2016-03-23 12:03:04 -03:00
bpf-loader.c perf tools: Introduce bpf-output event 2016-02-22 14:37:21 -03:00
bpf-loader.h perf tools: Support setting different slots in a BPF map separately 2016-02-22 12:48:50 -03:00
bpf-prologue.c perf bpf: Add prologue for BPF programs for fetching arguments 2015-11-18 17:51:04 -03:00
bpf-prologue.h perf bpf: Add prologue for BPF programs for fetching arguments 2015-11-18 17:51:04 -03:00
Build perf llvm: Use realpath to canonicalize paths 2016-03-23 17:39:19 -03:00
build-id.c perf tools: Add cpumode to struct perf_sample 2016-03-23 12:03:07 -03:00
build-id.h perf symbols: Fix symbols searching for module in buildid-cache 2016-02-12 10:54:47 -03:00
cache.h perf llvm: Use realpath to canonicalize paths 2016-03-23 17:39:19 -03:00
callchain.c perf callchain: Check return value of append_chain_children() 2016-02-19 19:15:01 -03:00
callchain.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
cgroup.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
cgroup.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
cloexec.c
cloexec.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
color.c perf config: Bring perf_default_config to the very beginning at main() 2016-02-26 19:49:16 -03:00
color.h
comm.c
comm.h
config.c perf config: Rename 'v' to 'home' in set_buildid_dir() 2016-03-30 11:14:09 -03:00
counts.c
counts.h
cpumap.c perf cpumap: Auto initialize cpu__max_{node,cpu} 2016-01-26 16:08:36 -03:00
cpumap.h perf cpumap: Auto initialize cpu__max_{node,cpu} 2016-01-26 16:08:36 -03:00
ctype.c perf ui/stdio: Align column header for hierarchy output 2016-02-24 20:21:12 -03:00
data-convert-bt.c perf tools: Remove misplaced __maybe_unused 2016-03-23 12:03:04 -03:00
data-convert-bt.h
data.c
data.h
db-export.c perf thread: Rename perf_event__preprocess_sample_addr to thread__resolve 2016-03-23 12:03:08 -03:00
db-export.h
debug.c perf tools: Make binary data printer code in trace_event public available 2016-02-24 11:38:01 -03:00
debug.h perf tools: Initialize libapi debug output 2016-02-16 17:12:59 -03:00
demangle-java.c perf symbols: add Java demangling support 2016-02-05 09:46:45 -03:00
demangle-java.h perf symbols: add Java demangling support 2016-02-05 09:46:45 -03:00
dso.c perf symbols: Do not read symbols/data from device files 2016-01-26 11:52:43 -03:00
dso.h perf tools: Remove misplaced __maybe_unused 2016-03-23 12:03:04 -03:00
dwarf-aux.c perf probe: No need to use formatting strbuf method 2016-03-23 16:53:05 -03:00
dwarf-aux.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
env.c perf tools: Add perf data cache feature 2016-02-16 17:13:00 -03:00
env.h perf tools: Add perf data cache feature 2016-02-16 17:13:00 -03:00
event.c perf tools: Add missing initialization of perf_sample.cpumode in synthesized samples 2016-03-29 20:03:56 -03:00
event.h perf thread: Rename perf_event__preprocess_sample_addr to thread__resolve 2016-03-23 12:03:08 -03:00
evlist.c perf tools: Only set filter for tracepoints events 2016-02-26 19:50:01 -03:00
evlist.h perf tools: Enable passing event to BPF object 2016-02-22 12:30:50 -03:00
evsel.c perf tools: Add cpumode to struct perf_sample 2016-03-23 12:03:07 -03:00
evsel.h perf tools: Fix perf script python database export crash 2016-03-09 10:31:02 -03:00
find-vdso-map.c
genelf_debug.c perf jit: add source line info support 2016-02-05 12:33:09 -03:00
genelf.c perf jit: add source line info support 2016-02-05 12:33:09 -03:00
genelf.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
generate-cmdlist.sh perf tools: Do not show trace command if it's not compiled in 2016-01-08 12:46:17 -03:00
header.c perf test: Remove 'core_id' check in topo test 2016-03-11 13:45:04 -03:00
header.h perf tools: Remove misplaced __maybe_unused 2016-03-23 12:03:04 -03:00
help-unknown-cmd.c perf config: Bring perf_default_config to the very beginning at main() 2016-02-26 19:49:16 -03:00
help-unknown-cmd.h perf tools: Move help_unknown_cmd() to its own file 2015-12-14 12:30:37 -03:00
hist.c perf tools: Make hists__collapse_insert_entry static 2016-03-30 11:14:07 -03:00
hist.h perf tools: Make hists__collapse_insert_entry static 2016-03-30 11:14:07 -03:00
intel-bts.c perf tools: Add missing initialization of perf_sample.cpumode in synthesized samples 2016-03-29 20:03:56 -03:00
intel-bts.h
intel-pt.c perf tools: Add missing initialization of perf_sample.cpumode in synthesized samples 2016-03-29 20:03:56 -03:00
intel-pt.h
intlist.c
intlist.h
jit.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
jitdump.c perf tools: Add missing initialization of perf_sample.cpumode in synthesized samples 2016-03-29 20:03:56 -03:00
jitdump.h perf inject: Add jitdump mmap injection support 2016-02-05 09:46:45 -03:00
kvm-stat.h perf kvm/powerpc: Port perf kvm stat to powerpc 2016-01-29 17:49:54 -03:00
levenshtein.c
levenshtein.h
llvm-utils.c perf llvm: Use strerror_r instead of the thread unsafe strerror one 2016-03-23 17:42:21 -03:00
llvm-utils.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
lzma.c
machine.c perf tools: Add cpumode to struct perf_sample 2016-03-23 12:03:07 -03:00
machine.h perf tools: Remove misplaced __maybe_unused 2016-03-23 12:03:04 -03:00
map.c perf tools: Fix maps__fixup_overlappings to put used maps 2015-12-09 13:42:00 -03:00
map.h perf maps: Introduce maps__find_symbol_by_name() 2015-09-30 18:34:25 -03:00
mem-events.c perf script: Display data_src values 2016-02-24 10:32:11 -03:00
mem-events.h perf script: Display data_src values 2016-02-24 10:32:11 -03:00
ordered-events.c
ordered-events.h
parse-branch-options.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
parse-branch-options.h
parse-events.c perf tools: Apply tracepoint event definition options to BPF script 2016-02-22 13:02:44 -03:00
parse-events.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
parse-events.l perf tools: Introduce bpf-output event 2016-02-22 14:37:21 -03:00
parse-events.y perf tools: Explicitly declare inc_group_count as a void function 2016-03-08 10:11:16 +01:00
parse-regs-options.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
parse-regs-options.h
path.c perf tools: Remove unused perf_pathdup, xstrdup functions 2016-03-23 15:27:33 -03:00
perf_regs.c perf tools: Fix build break on powerpc due to sample_reg_masks 2015-09-30 18:34:27 -03:00
perf_regs.h perf tools: Fix build break on powerpc due to sample_reg_masks 2015-09-30 18:34:27 -03:00
PERF-VERSION-GEN
pmu.c perf tools: Omit unnecessary cast in perf_pmu__parse_scale 2016-03-09 10:42:22 -03:00
pmu.h
pmu.l
pmu.y
probe-event.c perf probe: No need to use formatting strbuf method 2016-03-23 16:53:05 -03:00
probe-event.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
probe-file.c perf probe: Verify parameters in two functions 2015-11-11 18:41:32 -03:00
probe-file.h
probe-finder.c perf probe: No need to use formatting strbuf method 2016-03-23 16:53:05 -03:00
probe-finder.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
pstack.c
pstack.h
python-ext-sources tools lib: Move bitmap.[ch] from tools/perf/ to tools/{lib,include}/ 2016-01-08 12:35:46 -03:00
python.c perf python: Support the PERF_RECORD_SWITCH event 2015-10-07 19:41:50 -03:00
quote.c
quote.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
rblist.c
rblist.h
record.c
session.c perf tools: Add cpumode to struct perf_sample 2016-03-23 12:03:07 -03:00
session.h perf tools: Make perf_session__register_idle_thread drop the refcount 2015-12-10 16:28:58 -03:00
setup.py perf tools: Fix python extension build 2016-02-29 11:18:25 -03:00
sort.c perf tools: Remove misplaced __maybe_unused 2016-03-23 12:03:04 -03:00
sort.h perf tools: Add sort__has_comm variable 2016-03-10 16:47:19 -03:00
srcline.c
stat-shadow.c perf tools: Remove misplaced __maybe_unused 2016-03-23 12:03:04 -03:00
stat.c Merge branch 'perf/urgent' into perf/core, to pick up fixes 2016-02-04 08:57:44 +01:00
stat.h perf stat: Check for frontend stalled for metrics 2016-03-03 11:10:40 -03:00
strbuf.c perf tools: Unexport some methods unused outside strbuf.c 2016-03-23 17:09:53 -03:00
strbuf.h perf tools: Unexport some methods unused outside strbuf.c 2016-03-23 17:09:53 -03:00
strfilter.c
strfilter.h
string.c tools: Adopt memdup() from tools/perf, moving it to tools/lib/string.c 2015-11-18 17:51:02 -03:00
strlist.c perf tools: Add file_only config option to strlist 2016-01-12 12:42:07 -03:00
strlist.h perf tools: Add file_only config option to strlist 2016-01-12 12:42:07 -03:00
svghelper.c
svghelper.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
symbol-elf.c perf symbols: Record text offset in dso to calculate objdump address 2016-03-18 14:23:59 -03:00
symbol-minimal.c perf symbols: Fix type error when reading a build-id 2015-10-28 10:02:00 -03:00
symbol.c perf symbols: Fix symbols searching for module in buildid-cache 2016-02-12 10:54:47 -03:00
symbol.h perf tools: Remove needless 'extern' from function prototypes 2016-03-23 15:06:35 -03:00
target.c
target.h
term.c perf tools: Move term functions out of util.c 2015-12-09 13:42:02 -03:00
term.h perf tools: Move term functions out of util.c 2015-12-09 13:42:02 -03:00
thread_map.c perf thread_map: Add thread_map__new_event function 2015-12-17 14:38:16 -03:00
thread_map.h perf thread_map: Add thread_map__new_event function 2015-12-17 14:38:16 -03:00
thread-stack.c
thread-stack.h
thread.c perf thread: Fix reference count initial state 2015-12-14 12:08:55 -03:00
thread.h
tool.h perf tools: Add event_update user level event 2015-12-17 15:10:16 -03:00
top.c
top.h
trace-event-info.c
trace-event-parse.c irq_poll: make blk-iopoll available outside the block layer 2015-12-11 11:52:24 -08:00
trace-event-read.c
trace-event-scripting.c
trace-event.c tools lib api fs: Adopt filename__read_str from perf 2016-02-16 17:12:56 -03:00
trace-event.h perf script: Add process_stat/process_stat_interval scripting interface 2016-01-06 20:11:15 -03:00
tsc.c perf tools: Use 64-bit shifts with (TSC) time conversion 2016-03-08 10:11:18 +01:00
tsc.h
unwind-libdw.c perf libdw: Check for mmaps also in MAP__VARIABLE tree 2016-01-08 14:16:57 -03:00
unwind-libdw.h perf callchain: Add order support for libdw DWARF unwinder 2015-11-23 18:31:13 -03:00
unwind-libunwind.c perf unwind: Check for mmaps also in MAP__VARIABLE tree 2016-01-08 14:16:34 -03:00
unwind.h
usage.c perf tools: Simplify die() mechanism 2016-03-23 12:32:31 -03:00
util.c perf tools: Make binary data printer code in trace_event public available 2016-02-24 11:38:01 -03:00
util.h perf tools: Remove unused perf_pathdup, xstrdup functions 2016-03-23 15:27:33 -03:00
values.c
values.h
vdso.c
vdso.h
wrapper.c perf tools: Remove unused perf_pathdup, xstrdup functions 2016-03-23 15:27:33 -03:00
xyarray.c
xyarray.h
zlib.c