perf probe: Fix to handle optimized not-inlined functions
[linux-drm-fsl-dcu.git] / tools / perf / util / probe-finder.c
index c7918f83b300086649f522bc5f663d9a5a88a5dc..d14193518e4d09d2b57954ef449e4e9238eb5c4c 100644 (file)
@@ -915,17 +915,13 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data)
                dwarf_decl_line(sp_die, &pf->lno);
                pf->lno += pp->line;
                param->retval = find_probe_point_by_line(pf);
-       } else if (!dwarf_func_inline(sp_die)) {
+       } else if (die_is_func_instance(sp_die)) {
+               /* Instances always have the entry address */
+               dwarf_entrypc(sp_die, &pf->addr);
                /* Real function */
                if (pp->lazy_line)
                        param->retval = find_probe_point_lazy(sp_die, pf);
                else {
-                       if (dwarf_entrypc(sp_die, &pf->addr) != 0) {
-                               pr_warning("Failed to get entry address of "
-                                          "%s.\n", dwarf_diename(sp_die));
-                               param->retval = -ENOENT;
-                               return DWARF_CB_ABORT;
-                       }
                        pf->addr += pp->offset;
                        /* TODO: Check the address in this function */
                        param->retval = call_probe_finder(sp_die, pf);
@@ -989,8 +985,24 @@ static int debuginfo__find_probes(struct debuginfo *dbg,
        int ret = 0;
 
 #if _ELFUTILS_PREREQ(0, 142)
+       Elf *elf;
+       GElf_Ehdr ehdr;
+       GElf_Shdr shdr;
+
        /* Get the call frame information from this dwarf */
-       pf->cfi = dwarf_getcfi_elf(dwarf_getelf(dbg->dbg));
+       elf = dwarf_getelf(dbg->dbg);
+       if (elf == NULL)
+               return -EINVAL;
+
+       if (gelf_getehdr(elf, &ehdr) == NULL)
+               return -EINVAL;
+
+       if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
+           shdr.sh_type == SHT_PROGBITS) {
+               pf->cfi = dwarf_getcfi_elf(elf);
+       } else {
+               pf->cfi = dwarf_getcfi(dbg->dbg);
+       }
 #endif
 
        off = 0;
@@ -1520,7 +1532,7 @@ static int line_range_search_cb(Dwarf_Die *sp_die, void *data)
                pr_debug("New line range: %d to %d\n", lf->lno_s, lf->lno_e);
                lr->start = lf->lno_s;
                lr->end = lf->lno_e;
-               if (dwarf_func_inline(sp_die))
+               if (!die_is_func_instance(sp_die))
                        param->retval = die_walk_instances(sp_die,
                                                line_range_inline_cb, lf);
                else