diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-06-27 12:08:42 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-06-27 12:08:42 -0400 |
commit | da3789628f88684d3f0fb4e6a6bc086c395ac3cb (patch) | |
tree | f1573d6b2c8fa4e46f47c5558135a0a56d4397ef /tools/perf/util/scripting-engines/trace-event-python.c | |
parent | 7a25b2d32b9cb0b813d56ee6109acf90f3c9f1e5 (diff) |
perf tools: Stop using a global trace events description list
The pevent thing is per perf.data file, so I made it stop being static
and become a perf_session member, so tools processing perf.data files
use perf_session and _there_ we read the trace events description into
session->pevent and then change everywhere to stop using that single
global pevent variable and use the per session one.
Note that it _doesn't_ fall backs to trace__event_id, as we're not
interested at all in what is present in the
/sys/kernel/debug/tracing/events in the workstation doing the analysis,
just in what is in the perf.data file.
This patch also introduces perf_session__set_tracepoints_handlers that
is the perf perf.data/session way to associate handlers to tracepoint
events by resolving their IDs using the events descriptions stored in a
perf.data file. Make 'perf sched' use it.
Reported-by: Dmitry Antipov <dmitry.antipov@linaro.org>
Tested-by: Dmitry Antipov <dmitry.antipov@linaro.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linaro-dev@lists.linaro.org
Cc: patches@linaro.org
Link: http://lkml.kernel.org/r/20120625232016.GA28525@infradead.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-python.c')
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 21 |
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 acb9795286c4..a8ca2f8179a9 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c | |||
@@ -190,7 +190,8 @@ static void define_event_symbols(struct event_format *event, | |||
190 | define_event_symbols(event, ev_name, args->next); | 190 | define_event_symbols(event, ev_name, args->next); |
191 | } | 191 | } |
192 | 192 | ||
193 | static inline struct event_format *find_cache_event(int type) | 193 | static inline |
194 | struct event_format *find_cache_event(struct pevent *pevent, int type) | ||
194 | { | 195 | { |
195 | static char ev_name[256]; | 196 | static char ev_name[256]; |
196 | struct event_format *event; | 197 | struct event_format *event; |
@@ -198,7 +199,7 @@ static inline struct event_format *find_cache_event(int type) | |||
198 | if (events[type]) | 199 | if (events[type]) |
199 | return events[type]; | 200 | return events[type]; |
200 | 201 | ||
201 | events[type] = event = trace_find_event(type); | 202 | events[type] = event = pevent_find_event(pevent, type); |
202 | if (!event) | 203 | if (!event) |
203 | return NULL; | 204 | return NULL; |
204 | 205 | ||
@@ -209,7 +210,8 @@ static inline struct event_format *find_cache_event(int type) | |||
209 | return event; | 210 | return event; |
210 | } | 211 | } |
211 | 212 | ||
212 | static void python_process_event(union perf_event *pevent __unused, | 213 | static void python_process_event(union perf_event *perf_event __unused, |
214 | struct pevent *pevent, | ||
213 | struct perf_sample *sample, | 215 | struct perf_sample *sample, |
214 | struct perf_evsel *evsel __unused, | 216 | struct perf_evsel *evsel __unused, |
215 | struct machine *machine __unused, | 217 | struct machine *machine __unused, |
@@ -233,13 +235,13 @@ static void python_process_event(union perf_event *pevent __unused, | |||
233 | if (!t) | 235 | if (!t) |
234 | Py_FatalError("couldn't create Python tuple"); | 236 | Py_FatalError("couldn't create Python tuple"); |
235 | 237 | ||
236 | type = trace_parse_common_type(data); | 238 | type = trace_parse_common_type(pevent, data); |
237 | 239 | ||
238 | event = find_cache_event(type); | 240 | event = find_cache_event(pevent, type); |
239 | if (!event) | 241 | if (!event) |
240 | die("ug! no event found for type %d", type); | 242 | die("ug! no event found for type %d", type); |
241 | 243 | ||
242 | pid = trace_parse_common_pid(data); | 244 | pid = trace_parse_common_pid(pevent, data); |
243 | 245 | ||
244 | sprintf(handler_name, "%s__%s", event->system, event->name); | 246 | sprintf(handler_name, "%s__%s", event->system, event->name); |
245 | 247 | ||
@@ -284,7 +286,8 @@ static void python_process_event(union perf_event *pevent __unused, | |||
284 | offset = field->offset; | 286 | offset = field->offset; |
285 | obj = PyString_FromString((char *)data + offset); | 287 | obj = PyString_FromString((char *)data + offset); |
286 | } else { /* FIELD_IS_NUMERIC */ | 288 | } else { /* FIELD_IS_NUMERIC */ |
287 | val = read_size(data + field->offset, field->size); | 289 | val = read_size(pevent, data + field->offset, |
290 | field->size); | ||
288 | if (field->flags & FIELD_IS_SIGNED) { | 291 | if (field->flags & FIELD_IS_SIGNED) { |
289 | if ((long long)val >= LONG_MIN && | 292 | if ((long long)val >= LONG_MIN && |
290 | (long long)val <= LONG_MAX) | 293 | (long long)val <= LONG_MAX) |
@@ -438,7 +441,7 @@ out: | |||
438 | return err; | 441 | return err; |
439 | } | 442 | } |
440 | 443 | ||
441 | static int python_generate_script(const char *outfile) | 444 | static int python_generate_script(struct pevent *pevent, const char *outfile) |
442 | { | 445 | { |
443 | struct event_format *event = NULL; | 446 | struct event_format *event = NULL; |
444 | struct format_field *f; | 447 | struct format_field *f; |
@@ -487,7 +490,7 @@ static int python_generate_script(const char *outfile) | |||
487 | fprintf(ofp, "def trace_end():\n"); | 490 | fprintf(ofp, "def trace_end():\n"); |
488 | fprintf(ofp, "\tprint \"in trace_end\"\n\n"); | 491 | fprintf(ofp, "\tprint \"in trace_end\"\n\n"); |
489 | 492 | ||
490 | while ((event = trace_find_next_event(event))) { | 493 | while ((event = trace_find_next_event(pevent, event))) { |
491 | fprintf(ofp, "def %s__%s(", event->system, event->name); | 494 | fprintf(ofp, "def %s__%s(", event->system, event->name); |
492 | fprintf(ofp, "event_name, "); | 495 | fprintf(ofp, "event_name, "); |
493 | fprintf(ofp, "context, "); | 496 | fprintf(ofp, "context, "); |