diff options
-rw-r--r-- | ctracecmd.i | 20 | ||||
-rw-r--r-- | tracecmd.py | 15 |
2 files changed, 14 insertions, 21 deletions
diff --git a/ctracecmd.i b/ctracecmd.i index 20a681c..a9d3ca5 100644 --- a/ctracecmd.i +++ b/ctracecmd.i | |||
@@ -6,19 +6,21 @@ | |||
6 | #include "trace-cmd.h" | 6 | #include "trace-cmd.h" |
7 | %} | 7 | %} |
8 | 8 | ||
9 | /* typemaps must come before the implementation of wrapped functions */ | 9 | %typemap(out) unsigned long long { |
10 | extern int pevent_read_number_field_32(struct format_field *f, void *data, | 10 | $result = PyLong_FromUnsignedLongLong((unsigned long long) $1); |
11 | unsigned long *OUTPUT, unsigned long *OUTPUT); | 11 | } |
12 | 12 | ||
13 | %inline %{ | 13 | %inline %{ |
14 | int pevent_read_number_field_32(struct format_field *f, void *data, unsigned long *hi, unsigned long *lo) | 14 | PyObject *pevent_read_number_field_py(struct format_field *f, void *data) |
15 | { | 15 | { |
16 | unsigned long long val64; | 16 | unsigned long long val; |
17 | int ret; | 17 | int ret; |
18 | ret = pevent_read_number_field(f, data, &val64); | 18 | |
19 | *hi = (unsigned long)(val64>>32); | 19 | ret = pevent_read_number_field(f, data, &val); |
20 | *lo = (unsigned long)((val64<<32)>>32); | 20 | if (ret) |
21 | return ret; | 21 | Py_RETURN_NONE; |
22 | else | ||
23 | return PyLong_FromUnsignedLongLong(val); | ||
22 | } | 24 | } |
23 | %} | 25 | %} |
24 | 26 | ||
diff --git a/tracecmd.py b/tracecmd.py index 6520a48..f9a2708 100644 --- a/tracecmd.py +++ b/tracecmd.py | |||
@@ -31,13 +31,6 @@ and it is recommended applications not use it directly. | |||
31 | TODO: consider a complete class hierarchy of ftrace events... | 31 | TODO: consider a complete class hierarchy of ftrace events... |
32 | """ | 32 | """ |
33 | 33 | ||
34 | def _pevent_read_number_field(field, data): | ||
35 | ret,hi,lo = pevent_read_number_field_32(field, data) | ||
36 | if ret == 0: | ||
37 | return ret,long(long(hi).__lshift__(32)+lo) | ||
38 | return ret,None | ||
39 | |||
40 | |||
41 | class Event(object): | 34 | class Event(object): |
42 | def __init__(self, trace, record): | 35 | def __init__(self, trace, record): |
43 | self.trace = trace | 36 | self.trace = trace |
@@ -46,8 +39,8 @@ class Event(object): | |||
46 | self.ec = pevent_data_event_from_type(trace.pe, type) | 39 | self.ec = pevent_data_event_from_type(trace.pe, type) |
47 | 40 | ||
48 | def __str__(self): | 41 | def __str__(self): |
49 | return "%f %s: pid=%d comm=%s type=%d" % \ | 42 | return "%d.%d %s: pid=%d comm=%s type=%d" % \ |
50 | (self.ts, self.name, self.num_field("common_pid"), self.comm, self.type) | 43 | (self.ts/1000000000, self.ts%1000000000, self.name, self.num_field("common_pid"), self.comm, self.type) |
51 | 44 | ||
52 | 45 | ||
53 | # TODO: consider caching the results of the properties | 46 | # TODO: consider caching the results of the properties |
@@ -65,7 +58,6 @@ class Event(object): | |||
65 | 58 | ||
66 | @property | 59 | @property |
67 | def ts(self): | 60 | def ts(self): |
68 | # FIXME: this currently returns a float instead of a 64bit nsec value | ||
69 | return record_ts_get(self.rec) | 61 | return record_ts_get(self.rec) |
70 | 62 | ||
71 | @property | 63 | @property |
@@ -73,9 +65,8 @@ class Event(object): | |||
73 | return pevent_data_type(self.trace.pe, self.rec) | 65 | return pevent_data_type(self.trace.pe, self.rec) |
74 | 66 | ||
75 | def num_field(self, name): | 67 | def num_field(self, name): |
76 | # FIXME: need to find an elegant way to handle 64bit fields | ||
77 | f = pevent_find_any_field(self.ec, name) | 68 | f = pevent_find_any_field(self.ec, name) |
78 | ret,val = _pevent_read_number_field(f, record_data_get(self.rec)) | 69 | val = pevent_read_number_field_py(f, record_data_get(self.rec)) |
79 | return val | 70 | return val |
80 | 71 | ||
81 | 72 | ||