mirror of https://gitee.com/openkylin/linux.git
perf probe: Fix bug with global variables handling
There are missing curly braces which causes find_variable() return wrong value when probing with global variables. This problem can be reproduced as following: $ perf probe -v --add='generic_perform_write global_variable_for_test' ... Try to find probe point from debuginfo. Probe point found: generic_perform_write+0 Searching 'global_variable_for_test' variable in context. An error occurred in debuginfo analysis (-2). Error: Failed to add events. Reason: No such file or directory (Code: -2) After this patch: $ perf probe -v --add='generic_perform_write global_variable_for_test' ... Converting variable global_variable_for_test into trace event. global_variable_for_test type is int. Found 1 probe_trace_events. Opening /sys/kernel/debug/tracing/kprobe_events write=1 Added new event: Writing event: p:probe/generic_perform_write _stext+1237464 global_variable_for_test=@global_variable_for_test+0:s32 probe:generic_perform_write (on generic_perform_write with global_variable_for_test) You can now use it in all perf tools, such as: perf record -e probe:generic_perform_write -aR sleep 1 Signed-off-by: He Kuang <hekuang@huawei.com> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1429949338-18678-1-git-send-email-hekuang@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
c671835021
commit
d13855ef18
|
@ -578,10 +578,12 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
|
|||
/* Search child die for local variables and parameters. */
|
||||
if (!die_find_variable_at(sc_die, pf->pvar->var, pf->addr, &vr_die)) {
|
||||
/* Search again in global variables */
|
||||
if (!die_find_variable_at(&pf->cu_die, pf->pvar->var, 0, &vr_die))
|
||||
if (!die_find_variable_at(&pf->cu_die, pf->pvar->var,
|
||||
0, &vr_die)) {
|
||||
pr_warning("Failed to find '%s' in this function.\n",
|
||||
pf->pvar->var);
|
||||
ret = -ENOENT;
|
||||
}
|
||||
}
|
||||
if (ret >= 0)
|
||||
ret = convert_variable(&vr_die, pf);
|
||||
|
|
Loading…
Reference in New Issue