Skip to content

Commit

Permalink
perf probe: Fix to find range-only function instance
Browse files Browse the repository at this point in the history
Fix die_is_func_instance() to find range-only function instance.

In some case, a function instance can be made without any low PC or
entry PC, but only with address ranges by optimization.  (e.g. cold text
partially in "text.unlikely" section) To find such function instance, we
have to check the range attribute too.

Fixes: e1ecbbc ("perf probe: Fix to handle optimized not-inlined functions")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lore.kernel.org/lkml/157190835669.1859.8368628035930950596.stgit@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Masami Hiramatsu authored and Arnaldo Carvalho de Melo committed Nov 6, 2019
1 parent 4bfbcf3 commit b77afa1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/perf/util/dwarf-aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,14 @@ bool die_is_func_def(Dwarf_Die *dw_die)
bool die_is_func_instance(Dwarf_Die *dw_die)
{
Dwarf_Addr tmp;
Dwarf_Attribute attr_mem;

/* Actually gcc optimizes non-inline as like as inlined */
return !dwarf_func_inline(dw_die) && dwarf_entrypc(dw_die, &tmp) == 0;
return !dwarf_func_inline(dw_die) &&
(dwarf_entrypc(dw_die, &tmp) == 0 ||
dwarf_attr(dw_die, DW_AT_ranges, &attr_mem) != NULL);
}

/**
* die_get_data_member_location - Get the data-member offset
* @mb_die: a DIE of a member of a data structure
Expand Down

0 comments on commit b77afa1

Please sign in to comment.