aboutsummaryrefslogtreecommitdiffstats
path: root/tracecmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'tracecmd.py')
-rw-r--r--tracecmd.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/tracecmd.py b/tracecmd.py
index e7ea5f6..6b05e23 100644
--- a/tracecmd.py
+++ b/tracecmd.py
@@ -75,6 +75,9 @@ class Event(object):
75 return val 75 return val
76 76
77 77
78class FileFormatError(Exception):
79 pass
80
78class Trace(object): 81class Trace(object):
79 """ 82 """
80 Trace object represents the trace file it is created with. 83 Trace object represents the trace file it is created with.
@@ -83,18 +86,15 @@ class Trace(object):
83 used to manage the trace and extract events from it. 86 used to manage the trace and extract events from it.
84 """ 87 """
85 def __init__(self, filename): 88 def __init__(self, filename):
86 self.handle = None 89 self.handle = tracecmd_open(filename)
87 self.pe = None 90
88 91 if tracecmd_read_headers(self.handle):
89 try: 92 raise FileFormatError("Invalid headers")
90 self.handle = tracecmd_open(filename) 93
91 #FIXME: check if these throw exceptions automatically or if we have 94 if tracecmd_init_data(self.handle):
92 # to check return codes manually 95 raise FileFormatError("Failed to init data")
93 tracecmd_read_headers(self.handle) 96
94 tracecmd_init_data(self.handle) 97 self.pe = tracecmd_get_pevent(self.handle)
95 self.pe = tracecmd_get_pevent(self.handle)
96 except:
97 return None
98 98
99 @property 99 @property
100 def cpus(self): 100 def cpus(self):