提交 be6d842a 编写于 作者: D David Ahern 提交者: Arnaldo Carvalho de Melo

perf script: Change process_event prototype

Prepare for handling of samples for any event type.
Acked-by: NFrederic Weisbecker <fweisbec@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
LKML-Reference: <1299734608-5223-2-git-send-email-daahern@cisco.com>
Signed-off-by: NDavid Ahern <daahern@cisco.com>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 cfd748ae
...@@ -20,6 +20,20 @@ static u64 last_timestamp; ...@@ -20,6 +20,20 @@ static u64 last_timestamp;
static u64 nr_unordered; static u64 nr_unordered;
extern const struct option record_options[]; 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, static int default_start_script(const char *script __unused,
int argc __unused, int argc __unused,
const char **argv __unused) const char **argv __unused)
...@@ -40,7 +54,7 @@ static int default_generate_script(const char *outfile __unused) ...@@ -40,7 +54,7 @@ static int default_generate_script(const char *outfile __unused)
static struct scripting_ops default_scripting_ops = { static struct scripting_ops default_scripting_ops = {
.start_script = default_start_script, .start_script = default_start_script,
.stop_script = default_stop_script, .stop_script = default_stop_script,
.process_event = print_event, .process_event = process_event,
.generate_script = default_generate_script, .generate_script = default_generate_script,
}; };
...@@ -86,14 +100,7 @@ static int process_sample_event(union perf_event *event, ...@@ -86,14 +100,7 @@ static int process_sample_event(union perf_event *event,
last_timestamp = sample->time; last_timestamp = sample->time;
return 0; return 0;
} }
/* scripting_ops->process_event(event, sample, session, thread);
* 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);
} }
session->hists.stats.total_period += sample->period; session->hists.stats.total_period += sample->period;
......
...@@ -245,9 +245,10 @@ static inline struct event *find_cache_event(int type) ...@@ -245,9 +245,10 @@ static inline struct event *find_cache_event(int type)
return event; return event;
} }
static void perl_process_event(int cpu, void *data, static void perl_process_event(union perf_event *pevent __unused,
int size __unused, struct perf_sample *sample,
unsigned long long nsecs, char *comm) struct perf_session *session __unused,
struct thread *thread)
{ {
struct format_field *field; struct format_field *field;
static char handler[256]; static char handler[256];
...@@ -256,6 +257,10 @@ static void perl_process_event(int cpu, void *data, ...@@ -256,6 +257,10 @@ static void perl_process_event(int cpu, void *data,
struct event *event; struct event *event;
int type; int type;
int pid; int pid;
int cpu = sample->cpu;
void *data = sample->raw_data;
unsigned long long nsecs = sample->time;
char *comm = thread->comm;
dSP; dSP;
......
...@@ -204,9 +204,10 @@ static inline struct event *find_cache_event(int type) ...@@ -204,9 +204,10 @@ static inline struct event *find_cache_event(int type)
return event; return event;
} }
static void python_process_event(int cpu, void *data, static void python_process_event(union perf_event *pevent __unused,
int size __unused, struct perf_sample *sample,
unsigned long long nsecs, char *comm) struct perf_session *session __unused,
struct thread *thread)
{ {
PyObject *handler, *retval, *context, *t, *obj, *dict = NULL; PyObject *handler, *retval, *context, *t, *obj, *dict = NULL;
static char handler_name[256]; static char handler_name[256];
...@@ -217,6 +218,10 @@ static void python_process_event(int cpu, void *data, ...@@ -217,6 +218,10 @@ static void python_process_event(int cpu, void *data,
unsigned n = 0; unsigned n = 0;
int type; int type;
int pid; 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); t = PyTuple_New(MAX_FIELDS);
if (!t) if (!t)
......
...@@ -36,11 +36,10 @@ static int stop_script_unsupported(void) ...@@ -36,11 +36,10 @@ static int stop_script_unsupported(void)
return 0; return 0;
} }
static void process_event_unsupported(int cpu __unused, static void process_event_unsupported(union perf_event *event __unused,
void *data __unused, struct perf_sample *sample __unused,
int size __unused, struct perf_session *session __unused,
unsigned long long nsecs __unused, struct thread *thread __unused)
char *comm __unused)
{ {
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "parse-events.h" #include "parse-events.h"
#include "session.h"
#define __unused __attribute__((unused)) #define __unused __attribute__((unused))
...@@ -278,8 +279,10 @@ struct scripting_ops { ...@@ -278,8 +279,10 @@ struct scripting_ops {
const char *name; const char *name;
int (*start_script) (const char *script, int argc, const char **argv); int (*start_script) (const char *script, int argc, const char **argv);
int (*stop_script) (void); int (*stop_script) (void);
void (*process_event) (int cpu, void *data, int size, void (*process_event) (union perf_event *event,
unsigned long long nsecs, char *comm); struct perf_sample *sample,
struct perf_session *session,
struct thread *thread);
int (*generate_script) (const char *outfile); int (*generate_script) (const char *outfile);
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册