aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2010-05-14 16:47:38 -0400
committerJohannes Berg <johannes@sipsolutions.net>2010-05-25 07:17:02 -0400
commit6ec8810ca35509c118ff1dc537d1bd77d7886858 (patch)
tree7c36a69d4c396efc32047e23ee2e451766c76d36
parentb35925c88c357e4459636b53cb6081e9af9f07c3 (diff)
python wrapper: do not pass Trace but pevent
When it will be used for the python plugin, an Event will not have a Trace pointer in python directly available as that would not make a lot of sense since it is used for reading a trace file. But the event also doesn't need a Trace pointer, it just needs the pevent. Acked-by: Darren Hart <dvhltc@us.ibm.com> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
-rw-r--r--tracecmd.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/tracecmd.py b/tracecmd.py
index 4ece0ef..1cc05bb 100644
--- a/tracecmd.py
+++ b/tracecmd.py
@@ -32,12 +32,12 @@ TODO: consider a complete class hierarchy of ftrace events...
32""" 32"""
33 33
34class Event(object): 34class Event(object):
35 def __init__(self, trace, record, cpu): 35 def __init__(self, pevent, record, cpu):
36 self.trace = trace 36 self.pevent = pevent
37 self.rec = record 37 self.rec = record
38 self.cpu = cpu 38 self.cpu = cpu
39 type = pevent_data_type(trace.pe, record) 39 type = pevent_data_type(pevent, record)
40 self.format = pevent_data_event_from_type(trace.pe, type) 40 self.format = pevent_data_event_from_type(pevent, type)
41 41
42 def __str__(self): 42 def __str__(self):
43 return "%d.%d CPU%d %s: pid=%d comm=%s type=%d" % \ 43 return "%d.%d CPU%d %s: pid=%d comm=%s type=%d" % \
@@ -51,7 +51,7 @@ class Event(object):
51 # TODO: consider caching the results of the properties 51 # TODO: consider caching the results of the properties
52 @property 52 @property
53 def comm(self): 53 def comm(self):
54 return self.trace.comm_from_pid(self.pid) 54 return pevent_data_comm_from_pid(self.pevent, self.pid)
55 55
56 @property 56 @property
57 def name(self): 57 def name(self):
@@ -59,7 +59,7 @@ class Event(object):
59 59
60 @property 60 @property
61 def pid(self): 61 def pid(self):
62 return pevent_data_pid(self.trace.pe, self.rec) 62 return pevent_data_pid(self.pevent, self.rec)
63 63
64 @property 64 @property
65 def ts(self): 65 def ts(self):
@@ -67,7 +67,7 @@ class Event(object):
67 67
68 @property 68 @property
69 def type(self): 69 def type(self):
70 return pevent_data_type(self.trace.pe, self.rec) 70 return pevent_data_type(self.pevent, self.rec)
71 71
72 def num_field(self, name): 72 def num_field(self, name):
73 f = pevent_find_any_field(self.format, name) 73 f = pevent_find_any_field(self.format, name)
@@ -105,7 +105,7 @@ class Trace(object):
105 if rec: 105 if rec:
106 #rec.acquire() 106 #rec.acquire()
107 #rec.thisown = 1 107 #rec.thisown = 1
108 return Event(self, rec, cpu) 108 return Event(self.pe, rec, cpu)
109 return None 109 return None
110 110
111 def read_event_at(self, offset): 111 def read_event_at(self, offset):
@@ -116,15 +116,12 @@ class Trace(object):
116 rec,cpu = res 116 rec,cpu = res
117 #rec.acquire() 117 #rec.acquire()
118 #rec.thisown = 1 118 #rec.thisown = 1
119 ev = Event(self, rec, cpu) 119 ev = Event(self.pe, rec, cpu)
120 return ev 120 return ev
121 121
122 def peek_event(self, cpu): 122 def peek_event(self, cpu):
123 pass 123 pass
124 124
125 def comm_from_pid(self, pid):
126 return pevent_data_comm_from_pid(self.pe, pid)
127
128 125
129# Basic builtin test, execute module directly 126# Basic builtin test, execute module directly
130if __name__ == "__main__": 127if __name__ == "__main__":