From fb7345bbf7fad9bf72ef63a19c707970b9685812 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Thu, 26 Dec 2013 05:41:53 +0000 Subject: 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 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 @ char* name struct map* map symbol_filter_t filter @ char* name symbol_filter_t filter @ char* name symbol_filter_t filter @ 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 Cc: David Ahern Cc: David A. Long Cc: Ingo Molnar Cc: Namhyung Kim Cc: Oleg Nesterov Cc: Srikar Dronamraju Cc: Steven Rostedt 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 --- tools/perf/util/probe-finder.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tools/perf/util/probe-finder.c') diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index ffb657f..7db7e05 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -729,6 +729,7 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod, return -ENOENT; } tp->offset = (unsigned long)(paddr - sym.st_value); + tp->address = (unsigned long)paddr; tp->symbol = strdup(symbol); if (!tp->symbol) return -ENOMEM; -- cgit v1.1