mirror of https://gitee.com/openkylin/linux.git
perf probe: Fix to die_entrypc() returns error correctly
Fix die_entrypc() to return error correctly if the DIE has no
DW_AT_ranges attribute. Since dwarf_ranges() will treat the case as an
empty ranges and return 0, we have to check it by ourselves.
Fixes: 91e2f539ee
("perf probe: Fix to show function entry line as probe-able")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Link: http://lore.kernel.org/lkml/160645612634.2824037.5284932731175079426.stgit@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
c0ee1d5ae8
commit
ab4200c17b
|
@ -373,6 +373,7 @@ bool die_is_func_def(Dwarf_Die *dw_die)
|
||||||
int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr)
|
int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr)
|
||||||
{
|
{
|
||||||
Dwarf_Addr base, end;
|
Dwarf_Addr base, end;
|
||||||
|
Dwarf_Attribute attr;
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -380,6 +381,13 @@ int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr)
|
||||||
if (dwarf_entrypc(dw_die, addr) == 0)
|
if (dwarf_entrypc(dw_die, addr) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since the dwarf_ranges() will return 0 if there is no
|
||||||
|
* DW_AT_ranges attribute, we should check it first.
|
||||||
|
*/
|
||||||
|
if (!dwarf_attr(dw_die, DW_AT_ranges, &attr))
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0;
|
return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue