aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-event.c
diff options
context:
space:
mode:
authorHe Kuang <hekuang@huawei.com>2015-03-19 21:56:56 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-03-21 13:53:21 -0400
commit0560a0c4a12a45def9700e7ec3215da102cf914b (patch)
treee5ad0604d6e7d278085218ce7509a470ff30a4c5 /tools/perf/util/probe-event.c
parent1c30f546f3b7a1ac8b002dc3b3e8f4e26d195fa0 (diff)
perf probe: Fix failure to add multiple probes without debuginfo
Perf tries to find probe function addresses from map when debuginfo could not be found. To the first added function, the value of ref_reloc_sym was set in maps__set_kallsyms_ref_reloc_sym() and can be obtained from host_machine->kmaps->maps. After that, new maps are added to host_machine->kmaps->maps in dso__load_kcore(), all these new added maps do not have a valid ref_reloc_sym. When adding a second function, get_target_map() may get a map without valid ref_reloc_sym, and raise the error "Relocated base symbol is not found". Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym. This problem can be reproduced as following: $ perf probe --add='sys_write' --add='sys_open' Relocated base symbol is not found! Error: Failed to add events. After this patch: $ perf probe --add='sys_write' --add='sys_open' Added new event: probe:sys_write (on sys_write) You can now use it in all perf tools, such as: perf record -e probe:sys_write -aR sleep 1 Added new event: probe:sys_open (on sys_open) You can now use it in all perf tools, such as: perf record -e probe:sys_open -aR sleep 1 Signed-off-by: He Kuang <hekuang@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426816616-2394-1-git-send-email-hekuang@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r--tools/perf/util/probe-event.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index f272a711ad15..6b95985db5b0 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2507,7 +2507,6 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
2507 int max_tevs, const char *target) 2507 int max_tevs, const char *target)
2508{ 2508{
2509 struct map *map = NULL; 2509 struct map *map = NULL;
2510 struct kmap *kmap = NULL;
2511 struct ref_reloc_sym *reloc_sym = NULL; 2510 struct ref_reloc_sym *reloc_sym = NULL;
2512 struct symbol *sym; 2511 struct symbol *sym;
2513 struct probe_trace_event *tev; 2512 struct probe_trace_event *tev;
@@ -2540,8 +2539,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
2540 } 2539 }
2541 2540
2542 if (!pev->uprobes && !pp->retprobe) { 2541 if (!pev->uprobes && !pp->retprobe) {
2543 kmap = map__kmap(map); 2542 reloc_sym = kernel_get_ref_reloc_sym();
2544 reloc_sym = kmap->ref_reloc_sym;
2545 if (!reloc_sym) { 2543 if (!reloc_sym) {
2546 pr_warning("Relocated base symbol is not found!\n"); 2544 pr_warning("Relocated base symbol is not found!\n");
2547 ret = -EINVAL; 2545 ret = -EINVAL;