Skip to content

Commit 5849e7d

Browse files
mhiramatgregkh
authored andcommitted
perf probe: Fix to die_entrypc() returns error correctly
[ Upstream commit ab4200c ] 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: 91e2f53 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 27193c4 commit 5849e7d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎tools/perf/util/dwarf-aux.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,21 @@ bool die_is_func_def(Dwarf_Die *dw_die)
319319
int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr)
320320
{
321321
Dwarf_Addr base, end;
322+
Dwarf_Attribute attr;
322323

323324
if (!addr)
324325
return -EINVAL;
325326

326327
if (dwarf_entrypc(dw_die, addr) == 0)
327328
return 0;
328329

330+
/*
331+
* Since the dwarf_ranges() will return 0 if there is no
332+
* DW_AT_ranges attribute, we should check it first.
333+
*/
334+
if (!dwarf_attr(dw_die, DW_AT_ranges, &attr))
335+
return -ENOENT;
336+
329337
return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0;
330338
}
331339

0 commit comments

Comments
 (0)