perf symbols: Make sure --symfs usage includes the path separator
[firefly-linux-kernel-4.4.55.git] / tools / perf / util / annotate.c
index 3aa555ff9d89e5d7ede4c6af067170197b9ce0e8..7745fec01a6bc2c0e96f5bdbcf51197d5844fb0e 100644 (file)
@@ -899,10 +899,8 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
        struct kcore_extract kce;
        bool delete_extract = false;
 
-       if (filename) {
-               snprintf(symfs_filename, sizeof(symfs_filename), "%s%s",
-                        symbol_conf.symfs, filename);
-       }
+       if (filename)
+               symbol__join_symfs(symfs_filename, filename);
 
        if (filename == NULL) {
                if (dso->has_build_id) {
@@ -922,8 +920,7 @@ fallback:
                 * DSO is the same as when 'perf record' ran.
                 */
                filename = (char *)dso->long_name;
-               snprintf(symfs_filename, sizeof(symfs_filename), "%s%s",
-                        symbol_conf.symfs, filename);
+               symbol__join_symfs(symfs_filename, filename);
                free_filename = false;
        }
 
@@ -1236,6 +1233,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
        struct dso *dso = map->dso;
        char *filename;
        const char *d_filename;
+       const char *evsel_name = perf_evsel__name(evsel);
        struct annotation *notes = symbol__annotation(sym);
        struct disasm_line *pos, *queue = NULL;
        u64 start = map__rip_2objdump(map, sym->start);
@@ -1243,7 +1241,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
        int more = 0;
        u64 len;
        int width = 8;
-       int namelen;
+       int namelen, evsel_name_len, graph_dotted_len;
 
        filename = strdup(dso->long_name);
        if (!filename)
@@ -1256,14 +1254,17 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 
        len = symbol__size(sym);
        namelen = strlen(d_filename);
+       evsel_name_len = strlen(evsel_name);
 
        if (perf_evsel__is_group_event(evsel))
                width *= evsel->nr_members;
 
-       printf(" %-*.*s|        Source code & Disassembly of %s\n",
-              width, width, "Percent", d_filename);
-       printf("-%-*.*s-------------------------------------\n",
-              width+namelen, width+namelen, graph_dotted_line);
+       printf(" %-*.*s|        Source code & Disassembly of %s for %s\n",
+              width, width, "Percent", d_filename, evsel_name);
+
+       graph_dotted_len = width + namelen + evsel_name_len;
+       printf("-%-*.*s-----------------------------------------\n",
+              graph_dotted_len, graph_dotted_len, graph_dotted_line);
 
        if (verbose)
                symbol__annotate_hits(sym, evsel);