aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorDavid Ahern <daahern@cisco.com>2011-03-10 00:23:23 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-03-14 16:05:50 -0400
commitbe6d842a65babc54e2b204b382df2529e304be48 (patch)
treed8f3c9fb9f1457dcfa782102d2b27e0212bad009 /tools/perf
parentcfd748ae066e776d45bdce550b47cd00c67d55de (diff)
perf script: Change process_event prototype
Prepare for handling of samples for any event type. Acked-by: Frederic 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: David Ahern <daahern@cisco.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-script.c25
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c11
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c11
-rw-r--r--tools/perf/util/trace-event-scripting.c9
-rw-r--r--tools/perf/util/trace-event.h7
5 files changed, 41 insertions, 22 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 5f40df635dcb..b2bdd5534026 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -20,6 +20,20 @@ static u64 last_timestamp;
20static u64 nr_unordered; 20static u64 nr_unordered;
21extern const struct option record_options[]; 21extern const struct option record_options[];
22 22
23static void process_event(union perf_event *event __unused,
24 struct perf_sample *sample,
25 struct perf_session *session __unused,
26 struct thread *thread)
27{
28 /*
29 * FIXME: better resolve from pid from the struct trace_entry
30 * field, although it should be the same than this perf
31 * event pid
32 */
33 print_event(sample->cpu, sample->raw_data, sample->raw_size,
34 sample->time, thread->comm);
35}
36
23static int default_start_script(const char *script __unused, 37static int default_start_script(const char *script __unused,
24 int argc __unused, 38 int argc __unused,
25 const char **argv __unused) 39 const char **argv __unused)
@@ -40,7 +54,7 @@ static int default_generate_script(const char *outfile __unused)
40static struct scripting_ops default_scripting_ops = { 54static struct scripting_ops default_scripting_ops = {
41 .start_script = default_start_script, 55 .start_script = default_start_script,
42 .stop_script = default_stop_script, 56 .stop_script = default_stop_script,
43 .process_event = print_event, 57 .process_event = process_event,
44 .generate_script = default_generate_script, 58 .generate_script = default_generate_script,
45}; 59};
46 60
@@ -86,14 +100,7 @@ static int process_sample_event(union perf_event *event,
86 last_timestamp = sample->time; 100 last_timestamp = sample->time;
87 return 0; 101 return 0;
88 } 102 }
89 /* 103 scripting_ops->process_event(event, sample, session, thread);
90 * FIXME: better resolve from pid from the struct trace_entry
91 * field, although it should be the same than this perf
92 * event pid
93 */
94 scripting_ops->process_event(sample->cpu, sample->raw_data,
95 sample->raw_size,
96 sample->time, thread->comm);
97 } 104 }
98 105
99 session->hists.stats.total_period += sample->period; 106 session->hists.stats.total_period += sample->period;
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 93680818e244..621427212e86 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -245,9 +245,10 @@ static inline struct event *find_cache_event(int type)
245 return event; 245 return event;
246} 246}
247 247
248static void perl_process_event(int cpu, void *data, 248static void perl_process_event(union perf_event *pevent __unused,
249 int size __unused, 249 struct perf_sample *sample,
250 unsigned long long nsecs, char *comm) 250 struct perf_session *session __unused,
251 struct thread *thread)
251{ 252{
252 struct format_field *field; 253 struct format_field *field;
253 static char handler[256]; 254 static char handler[256];
@@ -256,6 +257,10 @@ static void perl_process_event(int cpu, void *data,
256 struct event *event; 257 struct event *event;
257 int type; 258 int type;
258 int pid; 259 int pid;
260 int cpu = sample->cpu;
261 void *data = sample->raw_data;
262 unsigned long long nsecs = sample->time;
263 char *comm = thread->comm;
259 264
260 dSP; 265 dSP;
261 266
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 2040b8538527..1b85d6055159 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -204,9 +204,10 @@ static inline struct event *find_cache_event(int type)
204 return event; 204 return event;
205} 205}
206 206
207static void python_process_event(int cpu, void *data, 207static void python_process_event(union perf_event *pevent __unused,
208 int size __unused, 208 struct perf_sample *sample,
209 unsigned long long nsecs, char *comm) 209 struct perf_session *session __unused,
210 struct thread *thread)
210{ 211{
211 PyObject *handler, *retval, *context, *t, *obj, *dict = NULL; 212 PyObject *handler, *retval, *context, *t, *obj, *dict = NULL;
212 static char handler_name[256]; 213 static char handler_name[256];
@@ -217,6 +218,10 @@ static void python_process_event(int cpu, void *data,
217 unsigned n = 0; 218 unsigned n = 0;
218 int type; 219 int type;
219 int pid; 220 int pid;
221 int cpu = sample->cpu;
222 void *data = sample->raw_data;
223 unsigned long long nsecs = sample->time;
224 char *comm = thread->comm;
220 225
221 t = PyTuple_New(MAX_FIELDS); 226 t = PyTuple_New(MAX_FIELDS);
222 if (!t) 227 if (!t)
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index f7af2fca965d..66f4b78737ab 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -36,11 +36,10 @@ static int stop_script_unsupported(void)
36 return 0; 36 return 0;
37} 37}
38 38
39static void process_event_unsupported(int cpu __unused, 39static void process_event_unsupported(union perf_event *event __unused,
40 void *data __unused, 40 struct perf_sample *sample __unused,
41 int size __unused, 41 struct perf_session *session __unused,
42 unsigned long long nsecs __unused, 42 struct thread *thread __unused)
43 char *comm __unused)
44{ 43{
45} 44}
46 45
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index b5f12ca24d99..5f7b5139c321 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -3,6 +3,7 @@
3 3
4#include <stdbool.h> 4#include <stdbool.h>
5#include "parse-events.h" 5#include "parse-events.h"
6#include "session.h"
6 7
7#define __unused __attribute__((unused)) 8#define __unused __attribute__((unused))
8 9
@@ -278,8 +279,10 @@ struct scripting_ops {
278 const char *name; 279 const char *name;
279 int (*start_script) (const char *script, int argc, const char **argv); 280 int (*start_script) (const char *script, int argc, const char **argv);
280 int (*stop_script) (void); 281 int (*stop_script) (void);
281 void (*process_event) (int cpu, void *data, int size, 282 void (*process_event) (union perf_event *event,
282 unsigned long long nsecs, char *comm); 283 struct perf_sample *sample,
284 struct perf_session *session,
285 struct thread *thread);
283 int (*generate_script) (const char *outfile); 286 int (*generate_script) (const char *outfile);
284}; 287};
285 288