]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf probe: Fix to find range-only function instance
authorMasami Hiramatsu <mhiramat@kernel.org>
Thu, 24 Oct 2019 09:12:36 +0000 (18:12 +0900)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 11 Feb 2020 20:03:30 +0000 (20:03 +0000)
commit b77afa1f810f37bd8a36cb1318178dfe2d7af6b6 upstream.

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: e1ecbbc3fa83 ("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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
tools/perf/util/dwarf-aux.c

index 79ff5209d01262eea41fc8a28146232b3fbb6bab..8284c49c6dc1b739d2eaeacb11b8d893a28d856c 100644 (file)
@@ -288,10 +288,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