perf evsel: Allow unresolved symbol names to be printed as addresses
[deliverable/linux.git] / tools / perf / util / symbol.c
index ab02209a7cf3b162431bfc006287f5fbd8c68f43..bb162ee433c62bb74eb4c643f5c01e1853a0a889 100644 (file)
@@ -264,8 +264,9 @@ size_t symbol__fprintf(struct symbol *sym, FILE *fp)
                       sym->name);
 }
 
-size_t symbol__fprintf_symname_offs(const struct symbol *sym,
-                                   const struct addr_location *al, FILE *fp)
+size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
+                                     const struct addr_location *al,
+                                     bool unknown_as_addr, FILE *fp)
 {
        unsigned long offset;
        size_t length;
@@ -280,13 +281,29 @@ size_t symbol__fprintf_symname_offs(const struct symbol *sym,
                        length += fprintf(fp, "+0x%lx", offset);
                }
                return length;
-       } else
+       } else if (al && unknown_as_addr)
+               return fprintf(fp, "[%#" PRIx64 "]", al->addr);
+       else
                return fprintf(fp, "[unknown]");
 }
 
+size_t symbol__fprintf_symname_offs(const struct symbol *sym,
+                                   const struct addr_location *al,
+                                   FILE *fp)
+{
+       return __symbol__fprintf_symname_offs(sym, al, false, fp);
+}
+
+size_t __symbol__fprintf_symname(const struct symbol *sym,
+                                const struct addr_location *al,
+                                bool unknown_as_addr, FILE *fp)
+{
+       return __symbol__fprintf_symname_offs(sym, al, unknown_as_addr, fp);
+}
+
 size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp)
 {
-       return symbol__fprintf_symname_offs(sym, NULL, fp);
+       return __symbol__fprintf_symname_offs(sym, NULL, false, fp);
 }
 
 void symbols__delete(struct rb_root *symbols)
@@ -1466,7 +1483,8 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
         * Read the build id if possible. This is required for
         * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
         */
-       if (filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZE) > 0)
+       if (is_regular_file(name) &&
+           filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZE) > 0)
                dso__set_build_id(dso, build_id);
 
        /*
@@ -1487,6 +1505,9 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
                                                   root_dir, name, PATH_MAX))
                        continue;
 
+               if (!is_regular_file(name))
+                       continue;
+
                /* Name is now the name of the next image to try */
                if (symsrc__init(ss, dso, name, symtab_type) < 0)
                        continue;
@@ -1525,6 +1546,10 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
        if (!runtime_ss && syms_ss)
                runtime_ss = syms_ss;
 
+       if (syms_ss && syms_ss->type == DSO_BINARY_TYPE__BUILD_ID_CACHE)
+               if (dso__build_id_is_kmod(dso, name, PATH_MAX))
+                       kmod = true;
+
        if (syms_ss)
                ret = dso__load_sym(dso, map, syms_ss, runtime_ss, filter, kmod);
        else
This page took 0.024523 seconds and 5 git commands to generate.