Skip to content

Commit

Permalink
perf probe: Fix to die_entrypc() returns error correctly
Browse files Browse the repository at this point in the history
Source: Kernel.org
MR: 107406
Type: Integration
Disposition: Backport from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable linux-5.4.y
ChangeID: 5849e7dc560bbd04cc3ecdb00fd4ee0142f21dc5
Description:

[ 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>
Signed-off-by: Armin Kuster <akuster@mvista.com>
  • Loading branch information
mhiramat authored and mvakuster committed Dec 17, 2020
1 parent 5cf5576 commit 6f2b656
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/perf/util/dwarf-aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,21 @@ bool die_is_func_def(Dwarf_Die *dw_die)
int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr)
{
Dwarf_Addr base, end;
Dwarf_Attribute attr;

if (!addr)
return -EINVAL;

if (dwarf_entrypc(dw_die, addr) == 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;
}

Expand Down

0 comments on commit 6f2b656

Please sign in to comment.