aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/scripting-engines/trace-event-python.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2014-05-27 12:14:34 -0400
committerJiri Olsa <jolsa@kernel.org>2014-06-27 05:15:02 -0400
commit8ac631cd502d6b31fd29f6d019305305b479fa3e (patch)
tree0ede6411a6e0b2abf11adb3dc07e4437237d3374 /tools/perf/util/scripting-engines/trace-event-python.c
parent33058b948e545a911e388e69b8be7274da158fb6 (diff)
perf script: Handle the num array type in python properly
The raw_syscalls:sys_enter tracer for instance passes has one argument named 'arg' which is an array of 6 integers. Right the python scripts gets only 0 passed as an argument. The reason is that pevent_read_number() can not handle data types of 48 and returns always 0. This patch changes this by passing num array as list of nums which fit the description. As a result python will now see a list named arg which contains 6 (integer) items. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/n/1401207274-8170-2-git-send-email-bigeasy@linutronix.de Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-python.c')
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 99c253604231..e55b65a65558 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -234,22 +234,41 @@ static inline struct event_format *find_cache_event(struct perf_evsel *evsel)
234static PyObject *get_field_numeric_entry(struct event_format *event, 234static PyObject *get_field_numeric_entry(struct event_format *event,
235 struct format_field *field, void *data) 235 struct format_field *field, void *data)
236{ 236{
237 PyObject *obj; 237 bool is_array = field->flags & FIELD_IS_ARRAY;
238 PyObject *obj, *list = NULL;
238 unsigned long long val; 239 unsigned long long val;
240 unsigned int item_size, n_items, i;
239 241
240 val = read_size(event, data + field->offset, field->size); 242 if (is_array) {
241 if (field->flags & FIELD_IS_SIGNED) { 243 list = PyList_New(field->arraylen);
242 if ((long long)val >= LONG_MIN && 244 item_size = field->size / field->arraylen;
243 (long long)val <= LONG_MAX) 245 n_items = field->arraylen;
244 obj = PyInt_FromLong(val);
245 else
246 obj = PyLong_FromLongLong(val);
247 } else { 246 } else {
248 if (val <= LONG_MAX) 247 item_size = field->size;
249 obj = PyInt_FromLong(val); 248 n_items = 1;
250 else 249 }
251 obj = PyLong_FromUnsignedLongLong(val); 250
251 for (i = 0; i < n_items; i++) {
252
253 val = read_size(event, data + field->offset + i * item_size,
254 item_size);
255 if (field->flags & FIELD_IS_SIGNED) {
256 if ((long long)val >= LONG_MIN &&
257 (long long)val <= LONG_MAX)
258 obj = PyInt_FromLong(val);
259 else
260 obj = PyLong_FromLongLong(val);
261 } else {
262 if (val <= LONG_MAX)
263 obj = PyInt_FromLong(val);
264 else
265 obj = PyLong_FromUnsignedLongLong(val);
266 }
267 if (is_array)
268 PyList_SET_ITEM(list, i, obj);
252 } 269 }
270 if (is_array)
271 obj = list;
253 return obj; 272 return obj;
254} 273}
255 274