]> Pileus Git - ~andy/linux/commitdiff
perf buildid-list: We need to check if a file is ELF first
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 5 Dec 2012 19:24:05 +0000 (16:24 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sun, 9 Dec 2012 11:46:07 +0000 (08:46 -0300)
I.e. before we try to use it as a perf.data file by calling
perf_session__new, otherwise we lose the feature that shows the
build id for the given ELF file, this one:

[root@sandy redhat-perfdata-mtech-15]# perf buildid-list -i /root/.debug/.build-id/97/54896de655b6ac088ec2bf5113b35c06f72709
9754896de655b6ac088ec2bf5113b35c06f72709
[root@sandy redhat-perfdata-mtech-15]# perf buildid-list -i /lib/libc-2.12.so
38adaeff4f7c21899b13b28c1a2e6c199ca4c744
[root@sandy redhat-perfdata-mtech-15]#

Regression introduced in:

efad1415 "perf report: Accept fifos as input file"

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-3ktgyg83fwpqyfpoj0t2ezp0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-buildid-list.c

index a82d99fec83e2b2f9b1e9ea1d941847baa5243fc..4c770d252fd2eea1996c46d8b6baf6bee3955be4 100644 (file)
@@ -49,18 +49,16 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
        struct perf_session *session;
 
        symbol__elf_init();
-
-       session = perf_session__new(input_name, O_RDONLY, force, false,
-                                   &build_id__mark_dso_hit_ops);
-       if (session == NULL)
-               return -1;
-
        /*
         * See if this is an ELF file first:
         */
-       if (filename__fprintf_build_id(session->filename, stdout))
+       if (filename__fprintf_build_id(input_name, stdout))
                goto out;
 
+       session = perf_session__new(input_name, O_RDONLY, force, false,
+                                   &build_id__mark_dso_hit_ops);
+       if (session == NULL)
+               return -1;
        /*
         * in pipe-mode, the only way to get the buildids is to parse
         * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID
@@ -69,8 +67,8 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
                perf_session__process_events(session, &build_id__mark_dso_hit_ops);
 
        perf_session__fprintf_dsos_buildid(session, stdout, with_hits);
-out:
        perf_session__delete(session);
+out:
        return 0;
 }