aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/Documentation/perf-annotate.txt2
-rw-r--r--tools/perf/Documentation/perf-buildid-list.txt2
-rw-r--r--tools/perf/Documentation/perf-evlist.txt2
-rw-r--r--tools/perf/Documentation/perf-kmem.txt2
-rw-r--r--tools/perf/Documentation/perf-lock.txt2
-rw-r--r--tools/perf/Documentation/perf-report.txt2
-rw-r--r--tools/perf/Documentation/perf-sched.txt2
-rw-r--r--tools/perf/Documentation/perf-script.txt2
-rw-r--r--tools/perf/Documentation/perf-timechart.txt2
-rw-r--r--tools/perf/builtin-annotate.c3
-rw-r--r--tools/perf/builtin-buildid-list.c19
-rw-r--r--tools/perf/builtin-evlist.c2
-rw-r--r--tools/perf/builtin-kmem.c2
-rw-r--r--tools/perf/builtin-lock.c2
-rw-r--r--tools/perf/builtin-report.c13
-rw-r--r--tools/perf/builtin-sched.c2
-rw-r--r--tools/perf/builtin-script.c4
-rw-r--r--tools/perf/builtin-timechart.c4
-rw-r--r--tools/perf/util/session.c15
19 files changed, 51 insertions, 33 deletions
diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index 476029d30621..c89f9e1453f7 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -22,7 +22,7 @@ OPTIONS
22------- 22-------
23-i:: 23-i::
24--input=:: 24--input=::
25 Input file name. (default: perf.data) 25 Input file name. (default: perf.data unless stdin is a fifo)
26 26
27-d:: 27-d::
28--dsos=<dso[,dso...]>:: 28--dsos=<dso[,dso...]>::
diff --git a/tools/perf/Documentation/perf-buildid-list.txt b/tools/perf/Documentation/perf-buildid-list.txt
index cc22325ffd1b..25c52efcc7f0 100644
--- a/tools/perf/Documentation/perf-buildid-list.txt
+++ b/tools/perf/Documentation/perf-buildid-list.txt
@@ -26,7 +26,7 @@ OPTIONS
26 Show only DSOs with hits. 26 Show only DSOs with hits.
27-i:: 27-i::
28--input=:: 28--input=::
29 Input file name. (default: perf.data) 29 Input file name. (default: perf.data unless stdin is a fifo)
30-f:: 30-f::
31--force:: 31--force::
32 Don't do ownership validation. 32 Don't do ownership validation.
diff --git a/tools/perf/Documentation/perf-evlist.txt b/tools/perf/Documentation/perf-evlist.txt
index 0cada9e053dc..0507ec7bad71 100644
--- a/tools/perf/Documentation/perf-evlist.txt
+++ b/tools/perf/Documentation/perf-evlist.txt
@@ -18,7 +18,7 @@ OPTIONS
18------- 18-------
19-i:: 19-i::
20--input=:: 20--input=::
21 Input file name. (default: perf.data) 21 Input file name. (default: perf.data unless stdin is a fifo)
22 22
23SEE ALSO 23SEE ALSO
24-------- 24--------
diff --git a/tools/perf/Documentation/perf-kmem.txt b/tools/perf/Documentation/perf-kmem.txt
index a52fcde894c7..7c8fbbf3f61c 100644
--- a/tools/perf/Documentation/perf-kmem.txt
+++ b/tools/perf/Documentation/perf-kmem.txt
@@ -23,7 +23,7 @@ OPTIONS
23------- 23-------
24-i <file>:: 24-i <file>::
25--input=<file>:: 25--input=<file>::
26 Select the input file (default: perf.data) 26 Select the input file (default: perf.data unless stdin is a fifo)
27 27
28--caller:: 28--caller::
29 Show per-callsite statistics 29 Show per-callsite statistics
diff --git a/tools/perf/Documentation/perf-lock.txt b/tools/perf/Documentation/perf-lock.txt
index 4a26a2f3a6a3..d6b2a4f2108b 100644
--- a/tools/perf/Documentation/perf-lock.txt
+++ b/tools/perf/Documentation/perf-lock.txt
@@ -29,7 +29,7 @@ COMMON OPTIONS
29 29
30-i:: 30-i::
31--input=<file>:: 31--input=<file>::
32 Input file name. 32 Input file name. (default: perf.data unless stdin is a fifo)
33 33
34-v:: 34-v::
35--verbose:: 35--verbose::
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 35af0dc8ccb4..9b430e98712e 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -19,7 +19,7 @@ OPTIONS
19------- 19-------
20-i:: 20-i::
21--input=:: 21--input=::
22 Input file name. (default: perf.data) 22 Input file name. (default: perf.data unless stdin is a fifo)
23 23
24-v:: 24-v::
25--verbose:: 25--verbose::
diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/perf-sched.txt
index 5b212b57f70b..8ff4df956951 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -40,7 +40,7 @@ OPTIONS
40------- 40-------
41-i:: 41-i::
42--input=<file>:: 42--input=<file>::
43 Input file name. (default: perf.data) 43 Input file name. (default: perf.data unless stdin is a fifo)
44 44
45-v:: 45-v::
46--verbose:: 46--verbose::
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 7f61eaaf9ab8..2f6cef43da25 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -106,7 +106,7 @@ OPTIONS
106 106
107-i:: 107-i::
108--input=:: 108--input=::
109 Input file name. 109 Input file name. (default: perf.data unless stdin is a fifo)
110 110
111-d:: 111-d::
112--debug-mode:: 112--debug-mode::
diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
index d7b79e2ba2ad..1632b0efc757 100644
--- a/tools/perf/Documentation/perf-timechart.txt
+++ b/tools/perf/Documentation/perf-timechart.txt
@@ -27,7 +27,7 @@ OPTIONS
27 Select the output file (default: output.svg) 27 Select the output file (default: output.svg)
28-i:: 28-i::
29--input=:: 29--input=::
30 Select the input file (default: perf.data) 30 Select the input file (default: perf.data unless stdin is a fifo)
31-w:: 31-w::
32--width=:: 32--width=::
33 Select the width of the SVG file (default: 1000) 33 Select the width of the SVG file (default: 1000)
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index d449645c5ef1..214ba7f9f577 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -215,7 +215,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
215 } 215 }
216 216
217 if (total_nr_samples == 0) { 217 if (total_nr_samples == 0) {
218 ui__warning("The %s file has no samples!\n", ann->input_name); 218 ui__warning("The %s file has no samples!\n", session->filename);
219 goto out_delete; 219 goto out_delete;
220 } 220 }
221out_delete: 221out_delete:
@@ -250,7 +250,6 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used)
250 .ordered_samples = true, 250 .ordered_samples = true,
251 .ordering_requires_timestamps = true, 251 .ordering_requires_timestamps = true,
252 }, 252 },
253 .input_name = "perf.data",
254 }; 253 };
255 const struct option options[] = { 254 const struct option options[] = {
256 OPT_STRING('i', "input", &annotate.input_name, "file", 255 OPT_STRING('i', "input", &annotate.input_name, "file",
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
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 4c5e9e04a41f..26760322c4f4 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -15,7 +15,7 @@
15#include "util/parse-options.h" 15#include "util/parse-options.h"
16#include "util/session.h" 16#include "util/session.h"
17 17
18static char const *input_name = "perf.data"; 18static const char *input_name;
19 19
20static int __cmd_evlist(void) 20static int __cmd_evlist(void)
21{ 21{
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 886174e9525b..fe1ad8f21961 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -19,7 +19,7 @@
19struct alloc_stat; 19struct alloc_stat;
20typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *); 20typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
21 21
22static char const *input_name = "perf.data"; 22static const char *input_name;
23 23
24static int alloc_flag; 24static int alloc_flag;
25static int caller_flag; 25static int caller_flag;
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 4db5e5293067..2296c391d0f5 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -326,7 +326,7 @@ alloc_failed:
326 die("memory allocation failed\n"); 326 die("memory allocation failed\n");
327} 327}
328 328
329static char const *input_name = "perf.data"; 329static const char *input_name;
330 330
331struct raw_event_sample { 331struct raw_event_sample {
332 u32 size; 332 u32 size;
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 9051f6bfaa7e..25d34d483e49 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -321,8 +321,7 @@ static int __cmd_report(struct perf_report *rep)
321 } 321 }
322 322
323 if (nr_samples == 0) { 323 if (nr_samples == 0) {
324 ui__warning("The %s file has no samples!\n", 324 ui__warning("The %s file has no samples!\n", session->filename);
325 rep->input_name);
326 goto out_delete; 325 goto out_delete;
327 } 326 }
328 327
@@ -430,6 +429,7 @@ setup:
430 429
431int cmd_report(int argc, const char **argv, const char *prefix __used) 430int cmd_report(int argc, const char **argv, const char *prefix __used)
432{ 431{
432 struct stat st;
433 char callchain_default_opt[] = "fractal,0.5,callee"; 433 char callchain_default_opt[] = "fractal,0.5,callee";
434 const char * const report_usage[] = { 434 const char * const report_usage[] = {
435 "perf report [<options>]", 435 "perf report [<options>]",
@@ -451,7 +451,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
451 .ordered_samples = true, 451 .ordered_samples = true,
452 .ordering_requires_timestamps = true, 452 .ordering_requires_timestamps = true,
453 }, 453 },
454 .input_name = "perf.data",
455 .pretty_printing_style = "normal", 454 .pretty_printing_style = "normal",
456 }; 455 };
457 const struct option options[] = { 456 const struct option options[] = {
@@ -531,10 +530,18 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
531 if (report.inverted_callchain) 530 if (report.inverted_callchain)
532 callchain_param.order = ORDER_CALLER; 531 callchain_param.order = ORDER_CALLER;
533 532
533 if (!report.input_name || !strlen(report.input_name)) {
534 if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
535 report.input_name = "-";
536 else
537 report.input_name = "perf.data";
538 }
539
534 if (strcmp(report.input_name, "-") != 0) 540 if (strcmp(report.input_name, "-") != 0)
535 setup_browser(true); 541 setup_browser(true);
536 else 542 else
537 use_browser = 0; 543 use_browser = 0;
544
538 /* 545 /*
539 * Only in the newt browser we are doing integrated annotation, 546 * Only in the newt browser we are doing integrated annotation,
540 * so don't allocate extra space that won't be used in the stdio 547 * so don't allocate extra space that won't be used in the stdio
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 6284ed2317f2..fb8b5f83b4a0 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -22,7 +22,7 @@
22#include <pthread.h> 22#include <pthread.h>
23#include <math.h> 23#include <math.h>
24 24
25static char const *input_name = "perf.data"; 25static const char *input_name;
26 26
27static char default_sort_order[] = "avg, max, switch, runtime"; 27static char default_sort_order[] = "avg, max, switch, runtime";
28static const char *sort_order = default_sort_order; 28static const char *sort_order = default_sort_order;
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index d71b745da06e..3d4c0c7b576e 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -434,7 +434,7 @@ static int cleanup_scripting(void)
434 return scripting_ops->stop_script(); 434 return scripting_ops->stop_script();
435} 435}
436 436
437static char const *input_name = "perf.data"; 437static const char *input_name;
438 438
439static int process_sample_event(struct perf_tool *tool __used, 439static int process_sample_event(struct perf_tool *tool __used,
440 union perf_event *event, 440 union perf_event *event,
@@ -1316,7 +1316,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
1316 return -1; 1316 return -1;
1317 } 1317 }
1318 1318
1319 input = open(input_name, O_RDONLY); 1319 input = open(session->filename, O_RDONLY); /* input_name */
1320 if (input < 0) { 1320 if (input < 0) {
1321 perror("failed to open file"); 1321 perror("failed to open file");
1322 exit(-1); 1322 exit(-1);
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 135376a37f97..3b75b2e21ea5 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -38,8 +38,8 @@
38#define PWR_EVENT_EXIT -1 38#define PWR_EVENT_EXIT -1
39 39
40 40
41static char const *input_name = "perf.data"; 41static const char *input_name;
42static char const *output_name = "output.svg"; 42static const char *output_name = "output.svg";
43 43
44static unsigned int numcpus; 44static unsigned int numcpus;
45static u64 min_freq; /* Lowest CPU frequency seen */ 45static u64 min_freq; /* Lowest CPU frequency seen */
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index ea17dfb85baa..cc5e6be46d86 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -107,8 +107,19 @@ struct perf_session *perf_session__new(const char *filename, int mode,
107 bool force, bool repipe, 107 bool force, bool repipe,
108 struct perf_tool *tool) 108 struct perf_tool *tool)
109{ 109{
110 size_t len = filename ? strlen(filename) : 0; 110 struct perf_session *self;
111 struct perf_session *self = zalloc(sizeof(*self) + len); 111 struct stat st;
112 size_t len;
113
114 if (!filename || !strlen(filename)) {
115 if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
116 filename = "-";
117 else
118 filename = "perf.data";
119 }
120
121 len = strlen(filename);
122 self = zalloc(sizeof(*self) + len);
112 123
113 if (self == NULL) 124 if (self == NULL)
114 goto out; 125 goto out;