Skip to content

Commit

Permalink
perf script: Change process_event prototype
Browse files Browse the repository at this point in the history
Prepare for handling of samples for any event type.

Acked-by: Frederic Weisbecker <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: David Ahern <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
David Ahern authored and acmel committed Mar 14, 2011
1 parent cfd748a commit be6d842
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
25 changes: 16 additions & 9 deletions tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ static u64 last_timestamp;
static u64 nr_unordered;
extern const struct option record_options[];

static void process_event(union perf_event *event __unused,
struct perf_sample *sample,
struct perf_session *session __unused,
struct thread *thread)
{
/*
* FIXME: better resolve from pid from the struct trace_entry
* field, although it should be the same than this perf
* event pid
*/
print_event(sample->cpu, sample->raw_data, sample->raw_size,
sample->time, thread->comm);
}

static int default_start_script(const char *script __unused,
int argc __unused,
const char **argv __unused)
Expand All @@ -40,7 +54,7 @@ static int default_generate_script(const char *outfile __unused)
static struct scripting_ops default_scripting_ops = {
.start_script = default_start_script,
.stop_script = default_stop_script,
.process_event = print_event,
.process_event = process_event,
.generate_script = default_generate_script,
};

Expand Down Expand Up @@ -86,14 +100,7 @@ static int process_sample_event(union perf_event *event,
last_timestamp = sample->time;
return 0;
}
/*
* FIXME: better resolve from pid from the struct trace_entry
* field, although it should be the same than this perf
* event pid
*/
scripting_ops->process_event(sample->cpu, sample->raw_data,
sample->raw_size,
sample->time, thread->comm);
scripting_ops->process_event(event, sample, session, thread);
}

session->hists.stats.total_period += sample->period;
Expand Down
11 changes: 8 additions & 3 deletions tools/perf/util/scripting-engines/trace-event-perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,10 @@ static inline struct event *find_cache_event(int type)
return event;
}

static void perl_process_event(int cpu, void *data,
int size __unused,
unsigned long long nsecs, char *comm)
static void perl_process_event(union perf_event *pevent __unused,
struct perf_sample *sample,
struct perf_session *session __unused,
struct thread *thread)
{
struct format_field *field;
static char handler[256];
Expand All @@ -256,6 +257,10 @@ static void perl_process_event(int cpu, void *data,
struct event *event;
int type;
int pid;
int cpu = sample->cpu;
void *data = sample->raw_data;
unsigned long long nsecs = sample->time;
char *comm = thread->comm;

dSP;

Expand Down
11 changes: 8 additions & 3 deletions tools/perf/util/scripting-engines/trace-event-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ static inline struct event *find_cache_event(int type)
return event;
}

static void python_process_event(int cpu, void *data,
int size __unused,
unsigned long long nsecs, char *comm)
static void python_process_event(union perf_event *pevent __unused,
struct perf_sample *sample,
struct perf_session *session __unused,
struct thread *thread)
{
PyObject *handler, *retval, *context, *t, *obj, *dict = NULL;
static char handler_name[256];
Expand All @@ -217,6 +218,10 @@ static void python_process_event(int cpu, void *data,
unsigned n = 0;
int type;
int pid;
int cpu = sample->cpu;
void *data = sample->raw_data;
unsigned long long nsecs = sample->time;
char *comm = thread->comm;

t = PyTuple_New(MAX_FIELDS);
if (!t)
Expand Down
9 changes: 4 additions & 5 deletions tools/perf/util/trace-event-scripting.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ static int stop_script_unsupported(void)
return 0;
}

static void process_event_unsupported(int cpu __unused,
void *data __unused,
int size __unused,
unsigned long long nsecs __unused,
char *comm __unused)
static void process_event_unsupported(union perf_event *event __unused,
struct perf_sample *sample __unused,
struct perf_session *session __unused,
struct thread *thread __unused)
{
}

Expand Down
7 changes: 5 additions & 2 deletions tools/perf/util/trace-event.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stdbool.h>
#include "parse-events.h"
#include "session.h"

#define __unused __attribute__((unused))

Expand Down Expand Up @@ -278,8 +279,10 @@ struct scripting_ops {
const char *name;
int (*start_script) (const char *script, int argc, const char **argv);
int (*stop_script) (void);
void (*process_event) (int cpu, void *data, int size,
unsigned long long nsecs, char *comm);
void (*process_event) (union perf_event *event,
struct perf_sample *sample,
struct perf_session *session,
struct thread *thread);
int (*generate_script) (const char *outfile);
};

Expand Down

0 comments on commit be6d842

Please sign in to comment.