Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277361
b: refs/heads/master
c: efad141
h: refs/heads/master
i:
  277359: 25dd0ab
v: v3
  • Loading branch information
Robert Richter authored and Arnaldo Carvalho de Melo committed Dec 23, 2011
1 parent 2012479 commit 364a472
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1b5495043d5bc058def21f9b66fd8feaa794eb44
refs/heads/master: efad14150a0b4429f37da7245001a8096ef7ee38
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-annotate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OPTIONS
-------
-i::
--input=::
Input file name. (default: perf.data)
Input file name. (default: perf.data unless stdin is a fifo)

-d::
--dsos=<dso[,dso...]>::
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-buildid-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ OPTIONS
Show only DSOs with hits.
-i::
--input=::
Input file name. (default: perf.data)
Input file name. (default: perf.data unless stdin is a fifo)
-f::
--force::
Don't do ownership validation.
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-evlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ OPTIONS
-------
-i::
--input=::
Input file name. (default: perf.data)
Input file name. (default: perf.data unless stdin is a fifo)

SEE ALSO
--------
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-kmem.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ OPTIONS
-------
-i <file>::
--input=<file>::
Select the input file (default: perf.data)
Select the input file (default: perf.data unless stdin is a fifo)

--caller::
Show per-callsite statistics
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ COMMON OPTIONS

-i::
--input=<file>::
Input file name.
Input file name. (default: perf.data unless stdin is a fifo)

-v::
--verbose::
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ OPTIONS
-------
-i::
--input=::
Input file name. (default: perf.data)
Input file name. (default: perf.data unless stdin is a fifo)

-v::
--verbose::
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-sched.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ OPTIONS
-------
-i::
--input=<file>::
Input file name. (default: perf.data)
Input file name. (default: perf.data unless stdin is a fifo)

-v::
--verbose::
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ OPTIONS

-i::
--input=::
Input file name.
Input file name. (default: perf.data unless stdin is a fifo)

-d::
--debug-mode::
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-timechart.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ OPTIONS
Select the output file (default: output.svg)
-i::
--input=::
Select the input file (default: perf.data)
Select the input file (default: perf.data unless stdin is a fifo)
-w::
--width=::
Select the width of the SVG file (default: 1000)
Expand Down
3 changes: 1 addition & 2 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
}

if (total_nr_samples == 0) {
ui__warning("The %s file has no samples!\n", ann->input_name);
ui__warning("The %s file has no samples!\n", session->filename);
goto out_delete;
}
out_delete:
Expand Down Expand Up @@ -250,7 +250,6 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used)
.ordered_samples = true,
.ordering_requires_timestamps = true,
},
.input_name = "perf.data",
};
const struct option options[] = {
OPT_STRING('i', "input", &annotate.input_name, "file",
Expand Down
19 changes: 10 additions & 9 deletions trunk/tools/perf/builtin-buildid-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <libelf.h>

static char const *input_name = "perf.data";
static const char *input_name;
static bool force;
static bool show_kernel;
static bool with_hits;
Expand Down Expand Up @@ -71,16 +71,24 @@ static int perf_session__list_build_ids(void)
{
struct perf_session *session;

elf_version(EV_CURRENT);

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))
goto out;

if (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);
return 0;
}
Expand All @@ -90,13 +98,6 @@ static int __cmd_buildid_list(void)
if (show_kernel)
return sysfs__fprintf_build_id(stdout);

elf_version(EV_CURRENT);
/*
* See if this is an ELF file first:
*/
if (filename__fprintf_build_id(input_name, stdout))
return 0;

return perf_session__list_build_ids();
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/builtin-evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "util/parse-options.h"
#include "util/session.h"

static char const *input_name = "perf.data";
static const char *input_name;

static int __cmd_evlist(void)
{
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
struct alloc_stat;
typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);

static char const *input_name = "perf.data";
static const char *input_name;

static int alloc_flag;
static int caller_flag;
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static struct lock_stat *lock_stat_findnew(void *addr, const char *name)
die("memory allocation failed\n");
}

static char const *input_name = "perf.data";
static const char *input_name;

struct raw_event_sample {
u32 size;
Expand Down
13 changes: 10 additions & 3 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ static int __cmd_report(struct perf_report *rep)
}

if (nr_samples == 0) {
ui__warning("The %s file has no samples!\n",
rep->input_name);
ui__warning("The %s file has no samples!\n", session->filename);
goto out_delete;
}

Expand Down Expand Up @@ -430,6 +429,7 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)

int cmd_report(int argc, const char **argv, const char *prefix __used)
{
struct stat st;
char callchain_default_opt[] = "fractal,0.5,callee";
const char * const report_usage[] = {
"perf report [<options>]",
Expand All @@ -451,7 +451,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
.ordered_samples = true,
.ordering_requires_timestamps = true,
},
.input_name = "perf.data",
.pretty_printing_style = "normal",
};
const struct option options[] = {
Expand Down Expand Up @@ -531,10 +530,18 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
if (report.inverted_callchain)
callchain_param.order = ORDER_CALLER;

if (!report.input_name || !strlen(report.input_name)) {
if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
report.input_name = "-";
else
report.input_name = "perf.data";
}

if (strcmp(report.input_name, "-") != 0)
setup_browser(true);
else
use_browser = 0;

/*
* Only in the newt browser we are doing integrated annotation,
* so don't allocate extra space that won't be used in the stdio
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <pthread.h>
#include <math.h>

static char const *input_name = "perf.data";
static const char *input_name;

static char default_sort_order[] = "avg, max, switch, runtime";
static const char *sort_order = default_sort_order;
Expand Down
4 changes: 2 additions & 2 deletions trunk/tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ static int cleanup_scripting(void)
return scripting_ops->stop_script();
}

static char const *input_name = "perf.data";
static const char *input_name;

static int process_sample_event(struct perf_tool *tool __used,
union perf_event *event,
Expand Down Expand Up @@ -1316,7 +1316,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
return -1;
}

input = open(input_name, O_RDONLY);
input = open(session->filename, O_RDONLY); /* input_name */
if (input < 0) {
perror("failed to open file");
exit(-1);
Expand Down
4 changes: 2 additions & 2 deletions trunk/tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#define PWR_EVENT_EXIT -1


static char const *input_name = "perf.data";
static char const *output_name = "output.svg";
static const char *input_name;
static const char *output_name = "output.svg";

static unsigned int numcpus;
static u64 min_freq; /* Lowest CPU frequency seen */
Expand Down
15 changes: 13 additions & 2 deletions trunk/tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,19 @@ struct perf_session *perf_session__new(const char *filename, int mode,
bool force, bool repipe,
struct perf_tool *tool)
{
size_t len = filename ? strlen(filename) : 0;
struct perf_session *self = zalloc(sizeof(*self) + len);
struct perf_session *self;
struct stat st;
size_t len;

if (!filename || !strlen(filename)) {
if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
filename = "-";
else
filename = "perf.data";
}

len = strlen(filename);
self = zalloc(sizeof(*self) + len);

if (self == NULL)
goto out;
Expand Down

0 comments on commit 364a472

Please sign in to comment.