aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-buildid-list.c
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2011-12-07 04:02:54 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-12-23 14:01:03 -0500
commitefad14150a0b4429f37da7245001a8096ef7ee38 (patch)
tree61c41a83384266dca00a2a4c88f43ebf4bdf5b5e /tools/perf/builtin-buildid-list.c
parent1b5495043d5bc058def21f9b66fd8feaa794eb44 (diff)
perf report: Accept fifos as input file
The default input file for perf report is not handled the same way as perf record does it for its output file. This leads to unexpected behavior of perf report, etc. E.g.: # perf record -a -e cpu-cycles sleep 2 | perf report | cat failed to open perf.data: No such file or directory (try 'perf record' first) While perf record writes to a fifo, perf report expects perf.data to be read. This patch changes this to accept fifos as input file. Applies to the following commands: perf annotate perf buildid-list perf evlist perf kmem perf lock perf report perf sched perf script perf timechart Also fixes char const* -> const char* type declaration for filename strings. v2: * Prevent potential null pointer access to input_name in builtin-report.c. Needed due to removal of patch "perf report: Setup browser if stdout is a pipe" Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1323248577-11268-5-git-send-email-robert.richter@amd.com Signed-off-by: Robert Richter <robert.richter@amd.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-buildid-list.c')
-rw-r--r--tools/perf/builtin-buildid-list.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index 4895668577b5..52480467e9ff 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -18,7 +18,7 @@
18 18
19#include <libelf.h> 19#include <libelf.h>
20 20
21static char const *input_name = "perf.data"; 21static const char *input_name;
22static bool force; 22static bool force;
23static bool show_kernel; 23static bool show_kernel;
24static bool with_hits; 24static bool with_hits;
@@ -71,16 +71,24 @@ static int perf_session__list_build_ids(void)
71{ 71{
72 struct perf_session *session; 72 struct perf_session *session;
73 73
74 elf_version(EV_CURRENT);
75
74 session = perf_session__new(input_name, O_RDONLY, force, false, 76 session = perf_session__new(input_name, O_RDONLY, force, false,
75 &build_id__mark_dso_hit_ops); 77 &build_id__mark_dso_hit_ops);
76 if (session == NULL) 78 if (session == NULL)
77 return -1; 79 return -1;
78 80
81 /*
82 * See if this is an ELF file first:
83 */
84 if (filename__fprintf_build_id(session->filename, stdout))
85 goto out;
86
79 if (with_hits) 87 if (with_hits)
80 perf_session__process_events(session, &build_id__mark_dso_hit_ops); 88 perf_session__process_events(session, &build_id__mark_dso_hit_ops);
81 89
82 perf_session__fprintf_dsos_buildid(session, stdout, with_hits); 90 perf_session__fprintf_dsos_buildid(session, stdout, with_hits);
83 91out:
84 perf_session__delete(session); 92 perf_session__delete(session);
85 return 0; 93 return 0;
86} 94}
@@ -90,13 +98,6 @@ static int __cmd_buildid_list(void)
90 if (show_kernel) 98 if (show_kernel)
91 return sysfs__fprintf_build_id(stdout); 99 return sysfs__fprintf_build_id(stdout);
92 100
93 elf_version(EV_CURRENT);
94 /*
95 * See if this is an ELF file first:
96 */
97 if (filename__fprintf_build_id(input_name, stdout))
98 return 0;
99
100 return perf_session__list_build_ids(); 101 return perf_session__list_build_ids();
101} 102}
102 103