aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/scripting-engines/trace-event-python.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-python.c')
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index ce4d1b0c3862..8006978d8398 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -27,6 +27,7 @@
27#include <errno.h> 27#include <errno.h>
28 28
29#include "../../perf.h" 29#include "../../perf.h"
30#include "../evsel.h"
30#include "../util.h" 31#include "../util.h"
31#include "../event.h" 32#include "../event.h"
32#include "../thread.h" 33#include "../thread.h"
@@ -194,16 +195,21 @@ static void define_event_symbols(struct event_format *event,
194 define_event_symbols(event, ev_name, args->next); 195 define_event_symbols(event, ev_name, args->next);
195} 196}
196 197
197static inline 198static inline struct event_format *find_cache_event(struct perf_evsel *evsel)
198struct event_format *find_cache_event(struct pevent *pevent, int type)
199{ 199{
200 static char ev_name[256]; 200 static char ev_name[256];
201 struct event_format *event; 201 struct event_format *event;
202 int type = evsel->attr.config;
202 203
204 /*
205 * XXX: Do we really need to cache this since now we have evsel->tp_format
206 * cached already? Need to re-read this "cache" routine that as well calls
207 * define_event_symbols() :-\
208 */
203 if (events[type]) 209 if (events[type])
204 return events[type]; 210 return events[type];
205 211
206 events[type] = event = pevent_find_event(pevent, type); 212 events[type] = event = evsel->tp_format;
207 if (!event) 213 if (!event)
208 return NULL; 214 return NULL;
209 215
@@ -217,7 +223,7 @@ struct event_format *find_cache_event(struct pevent *pevent, int type)
217static void python_process_event(union perf_event *perf_event __unused, 223static void python_process_event(union perf_event *perf_event __unused,
218 struct pevent *pevent, 224 struct pevent *pevent,
219 struct perf_sample *sample, 225 struct perf_sample *sample,
220 struct perf_evsel *evsel __unused, 226 struct perf_evsel *evsel,
221 struct machine *machine __unused, 227 struct machine *machine __unused,
222 struct thread *thread) 228 struct thread *thread)
223{ 229{
@@ -228,7 +234,6 @@ static void python_process_event(union perf_event *perf_event __unused,
228 unsigned long s, ns; 234 unsigned long s, ns;
229 struct event_format *event; 235 struct event_format *event;
230 unsigned n = 0; 236 unsigned n = 0;
231 int type;
232 int pid; 237 int pid;
233 int cpu = sample->cpu; 238 int cpu = sample->cpu;
234 void *data = sample->raw_data; 239 void *data = sample->raw_data;
@@ -239,11 +244,9 @@ static void python_process_event(union perf_event *perf_event __unused,
239 if (!t) 244 if (!t)
240 Py_FatalError("couldn't create Python tuple"); 245 Py_FatalError("couldn't create Python tuple");
241 246
242 type = trace_parse_common_type(pevent, data); 247 event = find_cache_event(evsel);
243
244 event = find_cache_event(pevent, type);
245 if (!event) 248 if (!event)
246 die("ug! no event found for type %d", type); 249 die("ug! no event found for type %d", (int)evsel->attr.config);
247 250
248 pid = trace_parse_common_pid(pevent, data); 251 pid = trace_parse_common_pid(pevent, data);
249 252