From: John Jacques <[email protected]>

Signed-off-by: John Jacques <[email protected]>
---
 tools/build/Makefile           |  4 ++--
 tools/build/Makefile.include   |  3 +++
 tools/perf/Makefile.config     |  2 +-
 tools/perf/Makefile.perf       |  4 ++--
 tools/perf/util/auxtrace.c     |  4 ++--
 tools/perf/util/cs-etm.c       | 11 +++--------
 tools/perf/util/probe-event.c  | 45 +++++++++++++++---------------------------
 tools/perf/util/probe-finder.c | 15 +++++++-------
 tools/perf/util/probe-finder.h |  3 ---
 9 files changed, 37 insertions(+), 54 deletions(-)

diff --git a/tools/build/Makefile b/tools/build/Makefile
index 8332959..edbb358 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -35,8 +35,8 @@ all: $(OUTPUT)fixdep
 
 clean:
        $(call QUIET_CLEAN, fixdep)
-       $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name 
'\.*.d' -delete
-       $(Q)rm -f fixdep
+       $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name 
'\.*.cmd' -delete -o -name '\.*.d' -delete
+       $(Q)rm -f $(OUTPUT)fixdep
 
 $(OUTPUT)fixdep-in.o: FORCE
        $(Q)$(MAKE) $(build)=fixdep
diff --git a/tools/build/Makefile.include b/tools/build/Makefile.include
index ad22e4e..d360f39a4 100644
--- a/tools/build/Makefile.include
+++ b/tools/build/Makefile.include
@@ -3,4 +3,7 @@ build := -f $(srctree)/tools/build/Makefile.build dir=. obj
 fixdep:
        $(Q)$(MAKE) -C $(srctree)/tools/build CFLAGS= LDFLAGS= $(OUTPUT)fixdep
 
+fixdep-clean:
+       $(Q)$(MAKE) -C $(srctree)/tools/build clean
+
 .PHONY: fixdep
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index fe465b5..4a82626 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -535,7 +535,7 @@ strip-libs = $(filter-out -l%,$(1))
 
 ifdef CSTRACE_PATH
   ifeq (${IS_64_BIT}, 1)
-    CSTRACE_LNX = linux64
+    CSTRACE_LNX = linux-arm64
   else
     CSTRACE_LNX = linux
   endif
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 2b8678a..f3f9f14 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -753,13 +753,13 @@ config-clean:
        $(call QUIET_CLEAN, config)
        $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if 
$(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null
 
-clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean 
$(LIBSUBCMD)-clean config-clean
+clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean 
$(LIBSUBCMD)-clean config-clean fixdep-clean
        $(call QUIET_CLEAN, core-objs)  $(RM) $(LIB_FILE) $(OUTPUT)perf-archive 
$(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
        $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name 
'\.*.cmd' -delete -o -name '\.*.d' -delete
        $(Q)$(RM) $(OUTPUT).config-detected
        $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf 
perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents
        $(call QUIET_CLEAN, core-gen)   $(RM)  *.spec *.pyc *.pyo */*.pyc 
*/*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE 
$(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
-               $(OUTPUT)util/intel-pt-decoder/inat-tables.c $(OUTPUT)fixdep \
+               $(OUTPUT)util/intel-pt-decoder/inat-tables.c \
                $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
                $(OUTPUT)pmu-events/pmu-events.c
        $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 9113c55..4dbd500 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -1828,7 +1828,7 @@ static int addr_filter__resolve_kernel_syms(struct 
addr_filter *filt)
                filt->addr = start;
                if (filt->range && !filt->size && !filt->sym_to) {
                        filt->size = size;
-                       no_size = !size;
+                       no_size = !!size;
                }
        }
 
@@ -1842,7 +1842,7 @@ static int addr_filter__resolve_kernel_syms(struct 
addr_filter *filt)
                if (err)
                        return err;
                filt->size = start + size - filt->addr;
-               no_size = !size;
+               no_size = !!size;
        }
 
        /* The very last symbol in kallsyms does not imply a particular size */
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 5fcd155..d48b9a4 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -446,8 +446,9 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm,
                if (etm->sampling_mode)
                        if (etm->timeless_decoding)
                                etmq->step_through_buffers = true;
-                       if (etm->timeless_decoding || !etm->have_sched_switch)
-                               etmq->use_buffer_pid_tid = true;
+
+               if (etm->timeless_decoding || !etm->have_sched_switch)
+                       etmq->use_buffer_pid_tid = true;
        }
 
        if (!etmq->on_heap &&
@@ -1259,12 +1260,6 @@ static int cs_etm__process_auxtrace_event(struct 
perf_session *session,
 
 }
 
-static const char * const cs_etm_global_header_fmts[] = {
-  [CS_HEADER_VERSION_0]        = "   Header version            %"PRIx64"\n",
-  [CS_PMU_TYPE_CPUS]   = "   PMU type/num cpus         %"PRIx64"\n",
-  [CS_ETM_SNAPSHOT]    = "   Snapshot                  %"PRIx64"\n",
-};
-
 static const char * const cs_etm_priv_fmts[] = {
   [CS_ETM_MAGIC]       = "   Magic number              %"PRIx64"\n",
   [CS_ETM_CPU]         = "   CPU                       %"PRIx64"\n",
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 6a6f44d..aa8a922 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -698,31 +698,18 @@ static int add_exec_to_probe_trace_events(struct 
probe_trace_event *tevs,
        return ret;
 }
 
-static int
-post_process_module_probe_trace_events(struct probe_trace_event *tevs,
-                                      int ntevs, const char *module,
-                                      struct debuginfo *dinfo)
+static int add_module_to_probe_trace_events(struct probe_trace_event *tevs,
+                                           int ntevs, const char *module)
 {
-       Dwarf_Addr text_offs = 0;
        int i, ret = 0;
        char *mod_name = NULL;
-       struct map *map;
 
        if (!module)
                return 0;
 
-       map = get_target_map(module, false);
-       if (!map || debuginfo__get_text_offset(dinfo, &text_offs, true) < 0) {
-               pr_warning("Failed to get ELF symbols for %s\n", module);
-               return -EINVAL;
-       }
-
        mod_name = find_module_name(module);
+
        for (i = 0; i < ntevs; i++) {
-               ret = post_process_probe_trace_point(&tevs[i].point,
-                                               map, (unsigned long)text_offs);
-               if (ret < 0)
-                       break;
                tevs[i].point.module =
                        strdup(mod_name ? mod_name : module);
                if (!tevs[i].point.module) {
@@ -732,8 +719,6 @@ post_process_module_probe_trace_events(struct 
probe_trace_event *tevs,
        }
 
        free(mod_name);
-       map__put(map);
-
        return ret;
 }
 
@@ -791,7 +776,7 @@ arch__post_process_probe_trace_events(struct 
perf_probe_event *pev __maybe_unuse
 static int post_process_probe_trace_events(struct perf_probe_event *pev,
                                           struct probe_trace_event *tevs,
                                           int ntevs, const char *module,
-                                          bool uprobe, struct debuginfo *dinfo)
+                                          bool uprobe)
 {
        int ret;
 
@@ -799,8 +784,7 @@ static int post_process_probe_trace_events(struct 
perf_probe_event *pev,
                ret = add_exec_to_probe_trace_events(tevs, ntevs, module);
        else if (module)
                /* Currently ref_reloc_sym based probe is not for drivers */
-               ret = post_process_module_probe_trace_events(tevs, ntevs,
-                                                            module, dinfo);
+               ret = add_module_to_probe_trace_events(tevs, ntevs, module);
        else
                ret = post_process_kernel_probe_trace_events(tevs, ntevs);
 
@@ -844,27 +828,30 @@ static int try_to_find_probe_trace_events(struct 
perf_probe_event *pev,
                }
        }
 
+       debuginfo__delete(dinfo);
+
        if (ntevs > 0) {        /* Succeeded to find trace events */
                pr_debug("Found %d probe_trace_events.\n", ntevs);
                ret = post_process_probe_trace_events(pev, *tevs, ntevs,
-                                       pev->target, pev->uprobes, dinfo);
+                                               pev->target, pev->uprobes);
                if (ret < 0 || ret == ntevs) {
-                       pr_debug("Post processing failed or all events are 
skipped. (%d)\n", ret);
                        clear_probe_trace_events(*tevs, ntevs);
                        zfree(tevs);
-                       ntevs = 0;
                }
+               if (ret != ntevs)
+                       return ret < 0 ? ret : ntevs;
+               ntevs = 0;
+               /* Fall through */
        }
 
-       debuginfo__delete(dinfo);
-
        if (ntevs == 0) {       /* No error but failed to find probe point. */
                pr_warning("Probe point '%s' not found.\n",
                           synthesize_perf_probe_point(&pev->point));
                return -ENOENT;
-       } else if (ntevs < 0) {
-               /* Error path : ntevs < 0 */
-               pr_debug("An error occurred in debuginfo analysis (%d).\n", 
ntevs);
+       }
+       /* Error path : ntevs < 0 */
+       pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs);
+       if (ntevs < 0) {
                if (ntevs == -EBADF)
                        pr_warning("Warning: No dwarf info found in the vmlinux 
- "
                                "please rebuild kernel with 
CONFIG_DEBUG_INFO=y.\n");
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 0d9d6e0..df4debe 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1501,8 +1501,7 @@ int debuginfo__find_available_vars_at(struct debuginfo 
*dbg,
 }
 
 /* For the kernel module, we need a special code to get a DIE */
-int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs,
-                               bool adjust_offset)
+static int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs)
 {
        int n, i;
        Elf32_Word shndx;
@@ -1531,8 +1530,6 @@ int debuginfo__get_text_offset(struct debuginfo *dbg, 
Dwarf_Addr *offs,
                        if (!shdr)
                                return -ENOENT;
                        *offs = shdr->sh_addr;
-                       if (adjust_offset)
-                               *offs -= shdr->sh_offset;
                }
        }
        return 0;
@@ -1546,12 +1543,16 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, 
unsigned long addr,
        Dwarf_Addr _addr = 0, baseaddr = 0;
        const char *fname = NULL, *func = NULL, *basefunc = NULL, *tmp;
        int baseline = 0, lineno = 0, ret = 0;
+       bool reloc = false;
 
-       /* We always need to relocate the address for aranges */
-       if (debuginfo__get_text_offset(dbg, &baseaddr, false) == 0)
-               addr += baseaddr;
+retry:
        /* Find cu die */
        if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr, &cudie)) {
+               if (!reloc && debuginfo__get_text_offset(dbg, &baseaddr) == 0) {
+                       addr += baseaddr;
+                       reloc = true;
+                       goto retry;
+               }
                pr_warning("Failed to find debug information for address %lx\n",
                           addr);
                ret = -EINVAL;
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index 2956c51..f1d8558 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -46,9 +46,6 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,
 int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
                                struct perf_probe_point *ppt);
 
-int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs,
-                              bool adjust_offset);
-
 /* Find a line range */
 int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr);
 
-- 
2.7.4

-- 
_______________________________________________
linux-yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to