Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277294
b: refs/heads/master
c: d20deb6
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Nov 28, 2011
1 parent 4b79357 commit 0c01182
Show file tree
Hide file tree
Showing 21 changed files with 521 additions and 374 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: 7009cc34b964939815160d7de64cf0215cdbf8bb
refs/heads/master: d20deb64e0490ee9442b5181bc08a62d2cadcb90
62 changes: 34 additions & 28 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@

#include <linux/bitmap.h>

static struct perf_annotate {
struct perf_annotate {
struct perf_event_ops ops;
char const *input_name;
bool force, use_tui, use_stdio;
bool full_paths;
bool print_line;
const char *sym_hist_filter;
const char *cpu_list;
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
} annotate = {
.input_name = "perf.data",
}, *ann = &annotate;
};

static int perf_evsel__add_sample(struct perf_evsel *evsel,
struct perf_sample *sample,
struct addr_location *al)
struct addr_location *al,
struct perf_annotate *ann)
{
struct hist_entry *he;
int ret;
Expand Down Expand Up @@ -79,11 +79,13 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return ret;
}

static int process_sample_event(union perf_event *event,
static int process_sample_event(struct perf_event_ops *ops,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct perf_session *session)
{
struct perf_annotate *ann = container_of(ops, struct perf_annotate, ops);
struct addr_location al;

if (perf_event__preprocess_sample(event, session, &al, sample,
Expand All @@ -96,7 +98,7 @@ static int process_sample_event(union perf_event *event,
if (ann->cpu_list && !test_bit(sample->cpu, ann->cpu_bitmap))
return 0;

if (!al.filtered && perf_evsel__add_sample(evsel, sample, &al)) {
if (!al.filtered && perf_evsel__add_sample(evsel, sample, &al, ann)) {
pr_warning("problem incrementing symbol count, "
"skipping event\n");
return -1;
Expand All @@ -105,13 +107,15 @@ static int process_sample_event(union perf_event *event,
return 0;
}

static int hist_entry__tty_annotate(struct hist_entry *he, int evidx)
static int hist_entry__tty_annotate(struct hist_entry *he, int evidx,
struct perf_annotate *ann)
{
return symbol__tty_annotate(he->ms.sym, he->ms.map, evidx,
ann->print_line, ann->full_paths, 0, 0);
}

static void hists__find_annotations(struct hists *self, int evidx)
static void hists__find_annotations(struct hists *self, int evidx,
struct perf_annotate *ann)
{
struct rb_node *nd = rb_first(&self->entries), *next;
int key = K_RIGHT;
Expand Down Expand Up @@ -149,7 +153,7 @@ static void hists__find_annotations(struct hists *self, int evidx)
if (next != NULL)
nd = next;
} else {
hist_entry__tty_annotate(he, evidx);
hist_entry__tty_annotate(he, evidx, ann);
nd = rb_next(nd);
/*
* Since we have a hist_entry per IP for the same
Expand All @@ -162,24 +166,15 @@ static void hists__find_annotations(struct hists *self, int evidx)
}
}

static struct perf_event_ops event_ops = {
.sample = process_sample_event,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
.fork = perf_event__process_task,
.ordered_samples = true,
.ordering_requires_timestamps = true,
};

static int __cmd_annotate(void)
static int __cmd_annotate(struct perf_annotate *ann)
{
int ret;
struct perf_session *session;
struct perf_evsel *pos;
u64 total_nr_samples;

session = perf_session__new(ann->input_name, O_RDONLY,
ann->force, false, &event_ops);
ann->force, false, &ann->ops);
if (session == NULL)
return -ENOMEM;

Expand All @@ -190,7 +185,7 @@ static int __cmd_annotate(void)
goto out_delete;
}

ret = perf_session__process_events(session, &event_ops);
ret = perf_session__process_events(session, &ann->ops);
if (ret)
goto out_delete;

Expand All @@ -214,7 +209,7 @@ static int __cmd_annotate(void)
total_nr_samples += nr_samples;
hists__collapse_resort(hists);
hists__output_resort(hists);
hists__find_annotations(hists, pos->idx);
hists__find_annotations(hists, pos->idx, ann);
}
}

Expand Down Expand Up @@ -243,7 +238,20 @@ static const char * const annotate_usage[] = {
NULL
};

static const struct option options[] = {
int cmd_annotate(int argc, const char **argv, const char *prefix __used)
{
struct perf_annotate annotate = {
.ops = {
.sample = process_sample_event,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
.fork = perf_event__process_task,
.ordered_samples = true,
.ordering_requires_timestamps = true,
},
.input_name = "perf.data",
};
const struct option options[] = {
OPT_STRING('i', "input", &annotate.input_name, "file",
"input file name"),
OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
Expand Down Expand Up @@ -275,10 +283,8 @@ static const struct option options[] = {
OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
"Specify disassembler style (e.g. -M intel for intel syntax)"),
OPT_END()
};
};

int cmd_annotate(int argc, const char **argv, const char *prefix __used)
{
argc = parse_options(argc, argv, options, annotate_usage, 0);

if (annotate.use_stdio)
Expand Down Expand Up @@ -312,5 +318,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used)
return -1;
}

return __cmd_annotate();
return __cmd_annotate(&annotate);
}
3 changes: 2 additions & 1 deletion trunk/tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ static int hists__add_entry(struct hists *self,
return -ENOMEM;
}

static int diff__process_sample_event(union perf_event *event,
static int diff__process_sample_event(struct perf_event_ops *ops __used,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *session)
Expand Down
55 changes: 34 additions & 21 deletions trunk/tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
static char const *input_name = "-";
static bool inject_build_ids;

static int perf_event__repipe_synth(union perf_event *event,
static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
union perf_event *event,
struct perf_session *session __used)
{
uint32_t size;
Expand All @@ -36,47 +37,57 @@ static int perf_event__repipe_synth(union perf_event *event,
return 0;
}

static int perf_event__repipe_tracing_data_synth(union perf_event *event,
struct perf_session *session)
{
return perf_event__repipe_synth(NULL, event, session);
}

static int perf_event__repipe_attr(union perf_event *event,
struct perf_evlist **pevlist __used)
{
return perf_event__repipe_synth(event, NULL);
return perf_event__repipe_synth(NULL, event, NULL);
}

static int perf_event__repipe(union perf_event *event,
static int perf_event__repipe(struct perf_event_ops *ops,
union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session)
{
return perf_event__repipe_synth(event, session);
return perf_event__repipe_synth(ops, event, session);
}

static int perf_event__repipe_sample(union perf_event *event,
static int perf_event__repipe_sample(struct perf_event_ops *ops,
union perf_event *event,
struct perf_sample *sample __used,
struct perf_evsel *evsel __used,
struct perf_session *session)
{
return perf_event__repipe_synth(event, session);
return perf_event__repipe_synth(ops, event, session);
}

static int perf_event__repipe_mmap(union perf_event *event,
static int perf_event__repipe_mmap(struct perf_event_ops *ops,
union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
int err;

err = perf_event__process_mmap(event, sample, session);
perf_event__repipe(event, sample, session);
err = perf_event__process_mmap(ops, event, sample, session);
perf_event__repipe(ops, event, sample, session);

return err;
}

static int perf_event__repipe_task(union perf_event *event,
static int perf_event__repipe_task(struct perf_event_ops *ops,
union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
int err;

err = perf_event__process_task(event, sample, session);
perf_event__repipe(event, sample, session);
err = perf_event__process_task(ops, event, sample, session);
perf_event__repipe(ops, event, sample, session);

return err;
}
Expand All @@ -86,7 +97,7 @@ static int perf_event__repipe_tracing_data(union perf_event *event,
{
int err;

perf_event__repipe_synth(event, session);
perf_event__repipe_synth(NULL, event, session);
err = perf_event__process_tracing_data(event, session);

return err;
Expand All @@ -106,7 +117,8 @@ static int dso__read_build_id(struct dso *self)
return -1;
}

static int dso__inject_build_id(struct dso *self, struct perf_session *session)
static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
struct perf_session *session)
{
u16 misc = PERF_RECORD_MISC_USER;
struct machine *machine;
Expand All @@ -126,7 +138,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
if (self->kernel)
misc = PERF_RECORD_MISC_KERNEL;

err = perf_event__synthesize_build_id(self, misc, perf_event__repipe,
err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe,
machine, session);
if (err) {
pr_err("Can't synthesize build_id event for %s\n", self->long_name);
Expand All @@ -136,7 +148,8 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
return 0;
}

static int perf_event__inject_buildid(union perf_event *event,
static int perf_event__inject_buildid(struct perf_event_ops *ops,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *session)
Expand All @@ -161,7 +174,7 @@ static int perf_event__inject_buildid(union perf_event *event,
if (!al.map->dso->hit) {
al.map->dso->hit = 1;
if (map__load(al.map, NULL) >= 0) {
dso__inject_build_id(al.map->dso, session);
dso__inject_build_id(al.map->dso, ops, session);
/*
* If this fails, too bad, let the other side
* account this as unresolved.
Expand All @@ -174,7 +187,7 @@ static int perf_event__inject_buildid(union perf_event *event,
}

repipe:
perf_event__repipe(event, sample, session);
perf_event__repipe(ops, event, sample, session);
return 0;
}

Expand All @@ -189,9 +202,9 @@ struct perf_event_ops inject_ops = {
.throttle = perf_event__repipe,
.unthrottle = perf_event__repipe,
.attr = perf_event__repipe_attr,
.event_type = perf_event__repipe_synth,
.tracing_data = perf_event__repipe_synth,
.build_id = perf_event__repipe_synth,
.event_type = perf_event__repipe_synth,
.tracing_data = perf_event__repipe_tracing_data_synth,
.build_id = perf_event__repipe_synth,
};

extern volatile int session_done;
Expand Down
3 changes: 2 additions & 1 deletion trunk/tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ static void process_raw_event(union perf_event *raw_event __used, void *data,
}
}

static int process_sample_event(union perf_event *event,
static int process_sample_event(struct perf_event_ops *ops __used,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *session)
Expand Down
3 changes: 2 additions & 1 deletion trunk/tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,8 @@ static void dump_info(void)
die("Unknown type of information\n");
}

static int process_sample_event(union perf_event *event,
static int process_sample_event(struct perf_event_ops *ops __used,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *s)
Expand Down
Loading

0 comments on commit 0c01182

Please sign in to comment.