linux/tools/perf/util
Masami Hiramatsu fb7345bbf7 perf probe: Support basic dwarf-based operations on uprobe events
Support basic dwarf(debuginfo) based operations for uprobe events.  With
this change, perf probe can analyze debuginfo of user application binary
to set up new uprobe event.

This allows perf-probe --add(with local variables, line numbers) and
--line works with -x option.  (Actually, --vars has already accepted -x
option)

For example, the following command shows the probe-able lines of a given
user space function. Something that so far was only available in the
'perf probe' tool for kernel space functions:

  # ./perf probe -x perf --line map__load
  <map__load@/home/fedora/ksrc/linux-2.6/tools/perf/util/map.c:0>
        0  int map__load(struct map *map, symbol_filter_t filter)
        1  {
        2         const char *name = map->dso->long_name;
                  int nr;

        5         if (dso__loaded(map->dso, map->type))
        6                 return 0;

        8         nr = dso__load(map->dso, map, filter);
        9         if (nr < 0) {
       10                 if (map->dso->has_build_id) {

And this shows the available variables at the given line of the
function.

  # ./perf probe -x perf --vars map__load:8
  Available variables at map__load:8
          @<map__load+96>
                  char*   name
                  struct map*     map
                  symbol_filter_t filter
          @<map__find_symbol+112>
                  char*   name
                  symbol_filter_t filter
          @<map__find_symbol_by_name+136>
                  char*   name
                  symbol_filter_t filter
          @<map_groups__find_symbol_by_name+176>
                  char*   name
                  struct map*     map
                  symbol_filter_t filter

And lastly, we can now define probe(s) with all available
variables on the given line:

  # ./perf probe -x perf --add 'map__load:8 $vars'

  Added new events:
    probe_perf:map__load (on map__load:8 with $vars)
    probe_perf:map__load_1 (on map__load:8 with $vars)
    probe_perf:map__load_2 (on map__load:8 with $vars)
    probe_perf:map__load_3 (on map__load:8 with $vars)

  You can now use it in all perf tools, such as:

          perf record -e probe_perf:map__load_3 -aR sleep 1

  Changes from previous version:
   - Add examples in the patch description.
   - Use .text section start address and dwarf symbol address
     for calculating the offset of given symbol, instead of
     searching the symbol in symtab again.
     With this change, we can safely handle multiple local
     function instances (e.g. scnprintf in perf).

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: David A. Long <dave.long@linaro.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: systemtap@sourceware.org
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20131226054152.22364.47021.stgit@kbuild-fedora.novalocal
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-12-26 11:22:01 -03:00
..
include perf fs: Add procfs support 2013-11-05 15:15:07 -03:00
scripting-engines perf symbols: Add 'machine' member to struct addr_location 2013-12-19 17:38:27 -03:00
abspath.c
alias.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
annotate.c perf annotate: Make symbol__inc_addr_samples private 2013-12-19 11:34:33 -03:00
annotate.h perf annotate: Make symbol__inc_addr_samples private 2013-12-19 11:34:33 -03:00
bitmap.c perf tools: Add bitmap_or function into bitmap object 2012-02-13 23:28:10 -02:00
build-id.c perf symbols: Constify some DSO methods parameters 2013-12-10 16:51:10 -03:00
build-id.h perf symbols: Constify some DSO methods parameters 2013-12-10 16:51:10 -03:00
cache.h tools/perf: Turn strlcpy() into a __weak function 2013-10-09 08:48:49 +02:00
callchain.c perf callchain: Convert children list to rbtree 2013-10-21 17:33:23 -03:00
callchain.h perf tools: Rename 'perf_record_opts' to 'record_opts 2013-12-19 14:43:45 -03:00
cgroup.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
cgroup.h
color.c perf tools: Remove cast of non-variadic function to variadic 2013-11-01 10:40:51 -03:00
color.h perf tools: Remove cast of non-variadic function to variadic 2013-11-01 10:40:51 -03:00
comm.c perf tools: Get current comm instead of last one 2013-11-04 12:16:39 -03:00
comm.h perf tools: Get current comm instead of last one 2013-11-04 12:16:39 -03:00
config.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
cpumap.c perf fs: Rename NAME_find_mountpoint() to NAME__mountpoint() 2013-11-05 15:15:00 -03:00
cpumap.h perf tools: Rename cpu_map__all() to cpu_map__empty() 2013-07-12 13:45:44 -03:00
ctype.c perf tools: ctype.c only wants util.h 2012-02-13 23:17:40 -02:00
data.c perf tools: Add perf_data_file__write interface 2013-12-02 09:22:46 -03:00
data.h perf tools: Add perf_data_file__write interface 2013-12-02 09:22:46 -03:00
debug.c perf tools: Get rid of a duplicate va_end() in error reporting routine 2013-12-19 11:38:42 -03:00
debug.h perf tools: Overload pr_stat traceevent print function 2013-12-04 15:23:55 -03:00
dso.c perf symbols: Use consistent name for the DSO binary type member 2013-12-17 16:34:08 -03:00
dso.h perf symbols: Use consistent name for the DSO binary type member 2013-12-17 16:34:08 -03:00
dwarf-aux.c perf probe: Fix to find line information for probe list 2013-10-04 15:16:05 -03:00
dwarf-aux.h perf probe: Fix to find line information for probe list 2013-10-04 15:16:05 -03:00
environment.c
event.c perf tools: Do not synthesize the treads of default guest. 2013-12-23 16:49:51 -03:00
event.h perf record: Synthesize non-exec MMAP records when --data used 2013-11-11 15:56:39 -03:00
evlist.c tools/: Convert to new topic libraries 2013-12-16 16:03:27 -03:00
evlist.h perf tools: Rename 'perf_record_opts' to 'record_opts 2013-12-19 14:43:45 -03:00
evsel.c perf tools: Rename 'perf_record_opts' to 'record_opts 2013-12-19 14:43:45 -03:00
evsel.h perf tools: Rename 'perf_record_opts' to 'record_opts 2013-12-19 14:43:45 -03:00
exec_cmd.c
exec_cmd.h
fs.c perf fs: Add procfs support 2013-11-05 15:15:07 -03:00
fs.h perf fs: Add procfs support 2013-11-05 15:15:07 -03:00
generate-cmdlist.sh tools/perf: Standardize feature support define names to: HAVE_{FEATURE}_SUPPORT 2013-10-09 08:48:28 +02:00
header.c perf header: Allow header->data_offset to be predetermined 2013-12-13 10:30:20 -03:00
header.h perf header: Recognize version number for perf data file 2013-07-17 17:04:00 -03:00
help.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
help.h
hist.c perf annotate: Adopt methods from hists 2013-12-19 11:34:27 -03:00
hist.h perf annotate: Adopt methods from hists 2013-12-19 11:34:27 -03:00
hweight.c
intlist.c perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
intlist.h perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
levenshtein.c
levenshtein.h
machine.c tools lib symbol: Start carving out symbol parsing routines from perf 2013-12-13 10:30:20 -03:00
machine.h perf target: Shorten perf_target__ to target__ 2013-11-12 16:51:03 -03:00
map.c perf script: Add an option to print the source line number 2013-12-09 14:47:15 -03:00
map.h perf script: Add an option to print the source line number 2013-12-09 14:47:15 -03:00
pager.c perf tools: Fix pager on minimal-install embedded systems 2012-05-30 15:10:39 -03:00
parse-events.c tools/: Convert to new topic libraries 2013-12-16 16:03:27 -03:00
parse-events.h perf parse events: Demystify memory allocations 2013-07-12 13:52:05 -03:00
parse-events.l perf tools: Move start conditions to start of the flex file 2013-10-11 12:17:31 -03:00
parse-events.y perf parse events: Demystify memory allocations 2013-07-12 13:52:05 -03:00
parse-options.c perf tools: Add option macro OPT_BOOLEAN_SET 2013-11-27 14:58:36 -03:00
parse-options.h perf tools: Add option macro OPT_BOOLEAN_SET 2013-11-27 14:58:36 -03:00
path.c tools/perf: Turn strlcpy() into a __weak function 2013-10-09 08:48:49 +02:00
PERF-VERSION-GEN perf tools: Fix version when building out of tree 2013-11-07 10:40:47 -03:00
perf_regs.h tools/perf: Standardize feature support define names to: HAVE_{FEATURE}_SUPPORT 2013-10-09 08:48:28 +02:00
pmu.c tools/perf/stat: Add event unit and scale support 2013-11-27 11:16:39 +01:00
pmu.h tools/perf/stat: Add event unit and scale support 2013-11-27 11:16:39 +01:00
pmu.l perf tools: Add perf pmu object to access pmu format definition 2012-03-16 14:29:35 -03:00
pmu.y perf tools: Fix build with bison 2.3 and older. 2013-02-14 16:12:34 -03:00
probe-event.c perf probe: Support basic dwarf-based operations on uprobe events 2013-12-26 11:22:01 -03:00
probe-event.h perf probe: Support basic dwarf-based operations on uprobe events 2013-12-26 11:22:01 -03:00
probe-finder.c perf probe: Support basic dwarf-based operations on uprobe events 2013-12-26 11:22:01 -03:00
probe-finder.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
pstack.c perf tools: Stop using 'self' in pstack 2012-11-14 16:50:38 -03:00
pstack.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
python-ext-sources perf tools: Add trace-event object 2013-12-04 15:20:52 -03:00
python.c Merge branch 'perf/urgent' into perf/core 2013-10-29 11:23:32 +01:00
quote.c
quote.h
rblist.c perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
rblist.h perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
record.c perf tools: Rename 'perf_record_opts' to 'record_opts 2013-12-19 14:43:45 -03:00
run-command.c
run-command.h
session.c perf kvm: Fix kvm report without guestmount. 2013-12-23 16:49:48 -03:00
session.h perf symbols: Add 'machine' member to struct addr_location 2013-12-19 17:38:27 -03:00
setup.py tools/: Convert to new topic libraries 2013-12-16 16:03:27 -03:00
sigchain.c
sigchain.h
sort.c perf sort: Do not compare dso again 2013-12-18 14:43:04 -03:00
sort.h perf tools: Remove unneeded include 2013-11-07 11:51:19 -03:00
srcline.c perf symbols: Constify dso->long_name 2013-12-10 16:51:09 -03:00
stat.c perf stats: Add max and min stats 2013-08-07 17:35:26 -03:00
stat.h perf stats: Add max and min stats 2013-08-07 17:35:26 -03:00
strbuf.c perf tools: Fix strbuf_addf() when the buffer needs to grow 2012-10-30 10:32:56 -02:00
strbuf.h
strfilter.c perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
strfilter.h perf tools: Finish the removal of 'self' arguments 2013-11-05 15:32:36 -03:00
string.c perf tools: Default to cpu// for events v5 2013-07-12 13:53:52 -03:00
strlist.c perf probe: Fix segfault 2013-03-13 17:00:33 -03:00
strlist.h perf tools: Stop using 'self' in strlist 2013-01-25 12:49:28 -03:00
svghelper.c perf timechart: Add --highlight option 2013-12-17 16:33:55 -03:00
svghelper.h perf timechart: Add --highlight option 2013-12-17 16:33:55 -03:00
symbol-elf.c tools lib symbol: Start carving out symbol parsing routines from perf 2013-12-13 10:30:20 -03:00
symbol-minimal.c perf symbols: Fix random fd closing with no libelf 2013-12-04 15:08:19 -03:00
symbol.c perf symbols: Use consistent name for the DSO binary type member 2013-12-17 16:34:08 -03:00
symbol.h perf symbols: Add 'machine' member to struct addr_location 2013-12-19 17:38:27 -03:00
target.c perf record: Make per-cpu mmaps the default. 2013-11-27 14:58:36 -03:00
target.h perf target: Move the checking of which map function to call into function. 2013-12-04 13:46:37 -03:00
thread.c perf tools: Fix inverted error verification bug in thread__fork 2013-12-13 10:30:21 -03:00
thread.h perf thread: Move comm_list check into function 2013-11-27 14:58:37 -03:00
thread_map.c perf tools: fix thread_map__new_by_pid_str() memory leak in error path 2012-05-25 11:40:59 -03:00
thread_map.h perf evlist: Add thread_map__nr() helper 2013-03-15 13:06:02 -03:00
tool.h perf tools: Add attr->mmap2 support 2013-09-11 10:09:32 -03:00
top.c perf tools: Rename 'perf_record_opts' to 'record_opts 2013-12-19 14:43:45 -03:00
top.h perf tools: Rename 'perf_record_opts' to 'record_opts 2013-12-19 14:43:45 -03:00
trace-event-info.c tools/: Convert to new topic libraries 2013-12-16 16:03:27 -03:00
trace-event-parse.c perf tools: Add trace-event object 2013-12-04 15:20:52 -03:00
trace-event-read.c perf tools: Add trace-event object 2013-12-04 15:20:52 -03:00
trace-event-scripting.c perf symbols: Add 'machine' member to struct addr_location 2013-12-19 17:38:27 -03:00
trace-event.c perf tools: Add trace-event global object for tracepoint interface 2013-12-04 15:21:25 -03:00
trace-event.h perf symbols: Add 'machine' member to struct addr_location 2013-12-19 17:38:27 -03:00
types.h perf tools: Add union u64_swap type for swapping u64 data 2012-05-22 12:50:25 -03:00
unwind.c perf symbols: Limit max callchain using max_stack on DWARF unwinding too 2013-11-14 16:00:23 -03:00
unwind.h perf symbols: Limit max callchain using max_stack on DWARF unwinding too 2013-11-14 16:00:23 -03:00
usage.c perf target: Introduce perf_target__parse_uid() 2012-05-07 16:46:48 -03:00
util.c perf tools: Move mem_bswap32/64 to util.c 2013-12-13 10:30:21 -03:00
util.h tools/: Convert to new topic libraries 2013-12-16 16:03:27 -03:00
values.c perf tools: Fix a memory leak on perf_read_values_destroy 2011-12-20 13:41:34 -02:00
values.h
vdso.c perf symbols: Remove open coded management of long_name_allocated member 2013-12-10 16:51:09 -03:00
vdso.h perf tools: Back [vdso] DSO with real data 2012-09-11 12:08:30 -03:00
wrapper.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
xyarray.c
xyarray.h