Merge tag 'drm-misc-next-2021-07-22' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-2.6-microblaze.git] / tools / perf / util / probe-finder.c
index b029c29..50d861a 100644 (file)
@@ -118,12 +118,17 @@ struct debuginfo *debuginfo__new(const char *path)
        char buf[PATH_MAX], nil = '\0';
        struct dso *dso;
        struct debuginfo *dinfo = NULL;
+       struct build_id bid;
 
        /* Try to open distro debuginfo files */
        dso = dso__new(path);
        if (!dso)
                goto out;
 
+       /* Set the build id for DSO_BINARY_TYPE__BUILDID_DEBUGINFO */
+       if (is_regular_file(path) && filename__read_build_id(path, &bid) > 0)
+               dso__set_build_id(dso, &bid);
+
        for (type = distro_dwarf_types;
             !dinfo && *type != DSO_BINARY_TYPE__NOT_FOUND;
             type++) {
@@ -663,7 +668,7 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
        }
 
        tp->offset = (unsigned long)(paddr - eaddr);
-       tp->address = (unsigned long)paddr;
+       tp->address = paddr;
        tp->symbol = strdup(symbol);
        if (!tp->symbol)
                return -ENOMEM;
@@ -1702,7 +1707,7 @@ int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs,
 }
 
 /* Reverse search */
-int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
+int debuginfo__find_probe_point(struct debuginfo *dbg, u64 addr,
                                struct perf_probe_point *ppt)
 {
        Dwarf_Die cudie, spdie, indie;
@@ -1715,14 +1720,14 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
                addr += baseaddr;
        /* Find cu die */
        if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr, &cudie)) {
-               pr_warning("Failed to find debug information for address %lx\n",
+               pr_warning("Failed to find debug information for address %" PRIx64 "\n",
                           addr);
                ret = -EINVAL;
                goto end;
        }
 
        /* Find a corresponding line (filename and lineno) */
-       cu_find_lineinfo(&cudie, addr, &fname, &lineno);
+       cu_find_lineinfo(&cudie, (Dwarf_Addr)addr, &fname, &lineno);
        /* Don't care whether it failed or not */
 
        /* Find a corresponding function (name, baseline and baseaddr) */
@@ -1737,7 +1742,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
                }
 
                fname = dwarf_decl_file(&spdie);
-               if (addr == (unsigned long)baseaddr) {
+               if (addr == baseaddr) {
                        /* Function entry - Relative line number is 0 */
                        lineno = baseline;
                        goto post;
@@ -1783,7 +1788,7 @@ post:
        if (lineno)
                ppt->line = lineno - baseline;
        else if (basefunc) {
-               ppt->offset = addr - (unsigned long)baseaddr;
+               ppt->offset = addr - baseaddr;
                func = basefunc;
        }
 
@@ -1823,8 +1828,7 @@ static int line_range_add_line(const char *src, unsigned int lineno,
 }
 
 static int line_range_walk_cb(const char *fname, int lineno,
-                             Dwarf_Addr addr __maybe_unused,
-                             void *data)
+                             Dwarf_Addr addr, void *data)
 {
        struct line_finder *lf = data;
        const char *__fname;