diff options
| author | Darren Hart <dvhltc@us.ibm.com> | 2009-12-28 12:36:30 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-29 14:06:52 -0500 |
| commit | 554aae82850b51e86167322bd946343d98a1ebfd (patch) | |
| tree | cb11a94256b53d606c2c44e3d2f5c278f439b5ec /tracecmd.py | |
| parent | db89240bf8f2455ef0b88dffd414f69f43201acb (diff) | |
trace-cmd: Cleanup 64-bit handling for python wrapper
Wrap pevent_read_number_field() with a more intelligent wrapper that
returns None on error and a python long on success. Eliminate the hi/lo
64 bit marshalling junk.
Use a typemap to get automatic struct accessors (ie record_ts_get()) to
return a python long for unsigned long long fields rather than
truncating to 32-bits.
Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
LKML-Reference: <4B38F21B.2020504@us.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tracecmd.py')
| -rw-r--r-- | tracecmd.py | 15 |
1 files changed, 3 insertions, 12 deletions
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 | ||
