perf annotate: Allow annotation for decompressed kernel modules
authorJiri Olsa <[email protected]>
Mon, 2 Mar 2015 17:56:12 +0000 (12:56 -0500)
committerArnaldo Carvalho de Melo <[email protected]>
Mon, 23 Mar 2015 15:49:27 +0000 (12:49 -0300)
Decompressing kernel module file for objdump command if needed.
Annotation commands now display annotation for compressed kernel
modules.

Signed-off-by: Jiri Olsa <[email protected]>
Acked-by: Namhyung Kim <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/annotate.c

index 61bf9128e1f28ce40d3d694ef5d9de8bb9cda1f8..b72086eca943e884cc5661bb180277ab39962c83 100644 (file)
@@ -1008,6 +1008,32 @@ fallback:
                        }
                        filename = symfs_filename;
                }
+       } else if (dso__needs_decompress(dso)) {
+               char tmp[PATH_MAX];
+               struct kmod_path m;
+               int fd;
+               bool ret;
+
+               if (kmod_path__parse_ext(&m, symfs_filename))
+                       goto out_free_filename;
+
+               snprintf(tmp, PATH_MAX, "/tmp/perf-kmod-XXXXXX");
+
+               fd = mkstemp(tmp);
+               if (fd < 0) {
+                       free(m.ext);
+                       goto out_free_filename;
+               }
+
+               ret = decompress_to_file(m.ext, symfs_filename, fd);
+
+               free(m.ext);
+               close(fd);
+
+               if (!ret)
+                       goto out_free_filename;
+
+               strcpy(symfs_filename, tmp);
        }
 
        snprintf(command, sizeof(command),
@@ -1027,7 +1053,7 @@ fallback:
 
        file = popen(command, "r");
        if (!file)
-               goto out_free_filename;
+               goto out_remove_tmp;
 
        while (!feof(file))
                if (symbol__parse_objdump_line(sym, map, file, privsize,
@@ -1042,6 +1068,10 @@ fallback:
                delete_last_nop(sym);
 
        pclose(file);
+
+out_remove_tmp:
+       if (dso__needs_decompress(dso))
+               unlink(symfs_filename);
 out_free_filename:
        if (delete_extract)
                kcore_extract__delete(&kce);