Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277296
b: refs/heads/master
c: 45694aa
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Nov 28, 2011
1 parent adbd618 commit 4106f54
Show file tree
Hide file tree
Showing 23 changed files with 302 additions and 278 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: 743eb868657bdb1b26c7b24077ca21c67c82c777
refs/heads/master: 45694aa7702bc44d538a3bcb51bb2bb96cf190c0
1 change: 1 addition & 0 deletions trunk/tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ LIB_H += util/strbuf.h
LIB_H += util/strlist.h
LIB_H += util/strfilter.h
LIB_H += util/svghelper.h
LIB_H += util/tool.h
LIB_H += util/run-command.h
LIB_H += util/sigchain.h
LIB_H += util/symbol.h
Expand Down
13 changes: 7 additions & 6 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
#include "util/sort.h"
#include "util/hist.h"
#include "util/session.h"
#include "util/tool.h"

#include <linux/bitmap.h>

struct perf_annotate {
struct perf_event_ops ops;
struct perf_tool tool;
char const *input_name;
bool force, use_tui, use_stdio;
bool full_paths;
Expand Down Expand Up @@ -79,13 +80,13 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return ret;
}

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

if (perf_event__preprocess_sample(event, machine, &al, sample,
Expand Down Expand Up @@ -174,7 +175,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
u64 total_nr_samples;

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

Expand All @@ -185,7 +186,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
goto out_delete;
}

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

Expand Down Expand Up @@ -241,7 +242,7 @@ static const char * const annotate_usage[] = {
int cmd_annotate(int argc, const char **argv, const char *prefix __used)
{
struct perf_annotate annotate = {
.ops = {
.tool = {
.sample = process_sample_event,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
Expand Down
11 changes: 6 additions & 5 deletions trunk/tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "util/hist.h"
#include "util/evsel.h"
#include "util/session.h"
#include "util/tool.h"
#include "util/sort.h"
#include "util/symbol.h"
#include "util/util.h"
Expand All @@ -31,7 +32,7 @@ static int hists__add_entry(struct hists *self,
return -ENOMEM;
}

static int diff__process_sample_event(struct perf_event_ops *ops __used,
static int diff__process_sample_event(struct perf_tool *tool __used,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
Expand All @@ -57,7 +58,7 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used,
return 0;
}

static struct perf_event_ops event_ops = {
static struct perf_tool perf_diff = {
.sample = diff__process_sample_event,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
Expand Down Expand Up @@ -147,13 +148,13 @@ static int __cmd_diff(void)
int ret, i;
struct perf_session *session[2];

session[0] = perf_session__new(input_old, O_RDONLY, force, false, &event_ops);
session[1] = perf_session__new(input_new, O_RDONLY, force, false, &event_ops);
session[0] = perf_session__new(input_old, O_RDONLY, force, false, &perf_diff);
session[1] = perf_session__new(input_new, O_RDONLY, force, false, &perf_diff);
if (session[0] == NULL || session[1] == NULL)
return -ENOMEM;

for (i = 0; i < 2; ++i) {
ret = perf_session__process_events(session[i], &event_ops);
ret = perf_session__process_events(session[i], &perf_diff);
if (ret)
goto out_delete;
}
Expand Down
55 changes: 28 additions & 27 deletions trunk/tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

#include "perf.h"
#include "util/session.h"
#include "util/tool.h"
#include "util/debug.h"

#include "util/parse-options.h"

static char const *input_name = "-";
static bool inject_build_ids;

static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
static int perf_event__repipe_synth(struct perf_tool *tool __used,
union perf_event *event,
struct machine *machine __used)
{
Expand All @@ -37,17 +38,17 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
return 0;
}

static int perf_event__repipe_op2_synth(struct perf_event_ops *ops,
static int perf_event__repipe_op2_synth(struct perf_tool *tool,
union perf_event *event,
struct perf_session *session __used)
{
return perf_event__repipe_synth(ops, event, NULL);
return perf_event__repipe_synth(tool, event, NULL);
}

static int perf_event__repipe_event_type_synth(struct perf_event_ops *ops,
static int perf_event__repipe_event_type_synth(struct perf_tool *tool,
union perf_event *event)
{
return perf_event__repipe_synth(ops, event, NULL);
return perf_event__repipe_synth(tool, event, NULL);
}

static int perf_event__repipe_tracing_data_synth(union perf_event *event,
Expand All @@ -62,45 +63,45 @@ static int perf_event__repipe_attr(union perf_event *event,
return perf_event__repipe_synth(NULL, event, NULL);
}

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

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

static int perf_event__repipe_mmap(struct perf_event_ops *ops,
static int perf_event__repipe_mmap(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
struct machine *machine)
{
int err;

err = perf_event__process_mmap(ops, event, sample, machine);
perf_event__repipe(ops, event, sample, machine);
err = perf_event__process_mmap(tool, event, sample, machine);
perf_event__repipe(tool, event, sample, machine);

return err;
}

static int perf_event__repipe_task(struct perf_event_ops *ops,
static int perf_event__repipe_task(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
struct machine *machine)
{
int err;

err = perf_event__process_task(ops, event, sample, machine);
perf_event__repipe(ops, event, sample, machine);
err = perf_event__process_task(tool, event, sample, machine);
perf_event__repipe(tool, event, sample, machine);

return err;
}
Expand Down Expand Up @@ -130,7 +131,7 @@ static int dso__read_build_id(struct dso *self)
return -1;
}

static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,
struct machine *machine)
{
u16 misc = PERF_RECORD_MISC_USER;
Expand All @@ -144,7 +145,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
if (self->kernel)
misc = PERF_RECORD_MISC_KERNEL;

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

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

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

struct perf_event_ops inject_ops = {
struct perf_tool perf_inject = {
.sample = perf_event__repipe_sample,
.mmap = perf_event__repipe,
.comm = perf_event__repipe,
Expand Down Expand Up @@ -228,17 +229,17 @@ static int __cmd_inject(void)
signal(SIGINT, sig_handler);

if (inject_build_ids) {
inject_ops.sample = perf_event__inject_buildid;
inject_ops.mmap = perf_event__repipe_mmap;
inject_ops.fork = perf_event__repipe_task;
inject_ops.tracing_data = perf_event__repipe_tracing_data;
perf_inject.sample = perf_event__inject_buildid;
perf_inject.mmap = perf_event__repipe_mmap;
perf_inject.fork = perf_event__repipe_task;
perf_inject.tracing_data = perf_event__repipe_tracing_data;
}

session = perf_session__new(input_name, O_RDONLY, false, true, &inject_ops);
session = perf_session__new(input_name, O_RDONLY, false, true, &perf_inject);
if (session == NULL)
return -ENOMEM;

ret = perf_session__process_events(session, &inject_ops);
ret = perf_session__process_events(session, &perf_inject);

perf_session__delete(session);

Expand Down
9 changes: 5 additions & 4 deletions trunk/tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "util/thread.h"
#include "util/header.h"
#include "util/session.h"
#include "util/tool.h"

#include "util/parse-options.h"
#include "util/trace-event.h"
Expand Down Expand Up @@ -303,7 +304,7 @@ static void process_raw_event(union perf_event *raw_event __used, void *data,
}
}

static int process_sample_event(struct perf_event_ops *ops __used,
static int process_sample_event(struct perf_tool *tool __used,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
Expand All @@ -325,7 +326,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
return 0;
}

static struct perf_event_ops event_ops = {
static struct perf_tool perf_kmem = {
.sample = process_sample_event,
.comm = perf_event__process_comm,
.ordered_samples = true,
Expand Down Expand Up @@ -484,7 +485,7 @@ static int __cmd_kmem(void)
{
int err = -EINVAL;
struct perf_session *session = perf_session__new(input_name, O_RDONLY,
0, false, &event_ops);
0, false, &perf_kmem);
if (session == NULL)
return -ENOMEM;

Expand All @@ -495,7 +496,7 @@ static int __cmd_kmem(void)
goto out_delete;

setup_pager();
err = perf_session__process_events(session, &event_ops);
err = perf_session__process_events(session, &perf_kmem);
if (err != 0)
goto out_delete;
sort_result();
Expand Down
5 changes: 3 additions & 2 deletions trunk/tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "util/debug.h"
#include "util/session.h"
#include "util/tool.h"

#include <sys/types.h>
#include <sys/prctl.h>
Expand Down Expand Up @@ -845,7 +846,7 @@ static void dump_info(void)
die("Unknown type of information\n");
}

static int process_sample_event(struct perf_event_ops *ops __used,
static int process_sample_event(struct perf_tool *tool __used,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
Expand All @@ -864,7 +865,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
return 0;
}

static struct perf_event_ops eops = {
static struct perf_tool eops = {
.sample = process_sample_event,
.comm = perf_event__process_comm,
.ordered_samples = true,
Expand Down
Loading

0 comments on commit 4106f54

Please sign in to comment.