|
@@ -231,6 +231,28 @@ static inline struct event_format *find_cache_event(struct perf_evsel *evsel)
|
|
return event;
|
|
return event;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static PyObject *get_field_numeric_entry(struct event_format *event,
|
|
|
|
+ struct format_field *field, void *data)
|
|
|
|
+{
|
|
|
|
+ PyObject *obj;
|
|
|
|
+ unsigned long long val;
|
|
|
|
+
|
|
|
|
+ val = read_size(event, data + field->offset, field->size);
|
|
|
|
+ if (field->flags & FIELD_IS_SIGNED) {
|
|
|
|
+ if ((long long)val >= LONG_MIN &&
|
|
|
|
+ (long long)val <= LONG_MAX)
|
|
|
|
+ obj = PyInt_FromLong(val);
|
|
|
|
+ else
|
|
|
|
+ obj = PyLong_FromLongLong(val);
|
|
|
|
+ } else {
|
|
|
|
+ if (val <= LONG_MAX)
|
|
|
|
+ obj = PyInt_FromLong(val);
|
|
|
|
+ else
|
|
|
|
+ obj = PyLong_FromUnsignedLongLong(val);
|
|
|
|
+ }
|
|
|
|
+ return obj;
|
|
|
|
+}
|
|
|
|
+
|
|
static void python_process_tracepoint(struct perf_sample *sample,
|
|
static void python_process_tracepoint(struct perf_sample *sample,
|
|
struct perf_evsel *evsel,
|
|
struct perf_evsel *evsel,
|
|
struct thread *thread,
|
|
struct thread *thread,
|
|
@@ -239,7 +261,6 @@ static void python_process_tracepoint(struct perf_sample *sample,
|
|
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];
|
|
struct format_field *field;
|
|
struct format_field *field;
|
|
- unsigned long long val;
|
|
|
|
unsigned long s, ns;
|
|
unsigned long s, ns;
|
|
struct event_format *event;
|
|
struct event_format *event;
|
|
unsigned n = 0;
|
|
unsigned n = 0;
|
|
@@ -303,20 +324,7 @@ static void python_process_tracepoint(struct perf_sample *sample,
|
|
offset = field->offset;
|
|
offset = field->offset;
|
|
obj = PyString_FromString((char *)data + offset);
|
|
obj = PyString_FromString((char *)data + offset);
|
|
} else { /* FIELD_IS_NUMERIC */
|
|
} else { /* FIELD_IS_NUMERIC */
|
|
- val = read_size(event, data + field->offset,
|
|
|
|
- field->size);
|
|
|
|
- if (field->flags & FIELD_IS_SIGNED) {
|
|
|
|
- if ((long long)val >= LONG_MIN &&
|
|
|
|
- (long long)val <= LONG_MAX)
|
|
|
|
- obj = PyInt_FromLong(val);
|
|
|
|
- else
|
|
|
|
- obj = PyLong_FromLongLong(val);
|
|
|
|
- } else {
|
|
|
|
- if (val <= LONG_MAX)
|
|
|
|
- obj = PyInt_FromLong(val);
|
|
|
|
- else
|
|
|
|
- obj = PyLong_FromUnsignedLongLong(val);
|
|
|
|
- }
|
|
|
|
|
|
+ obj = get_field_numeric_entry(event, field, data);
|
|
}
|
|
}
|
|
if (handler)
|
|
if (handler)
|
|
PyTuple_SetItem(t, n++, obj);
|
|
PyTuple_SetItem(t, n++, obj);
|