Read tracer version and keep it in the automaton
authorAntoine Busque <abusque@efficios.com>
Mon, 14 Dec 2015 11:21:54 +0000 (06:21 -0500)
committerAntoine Busque <abusque@efficios.com>
Mon, 14 Dec 2015 11:28:03 +0000 (06:28 -0500)
Signed-off-by: Antoine Busque <abusque@efficios.com>
lttnganalyses/cli/command.py
lttnganalyses/linuxautomaton/automaton.py

index c4929c078354b88257f05ce6257098a745aab13e..ef9d32f3161036306738b3fb3a6369725122e365 100644 (file)
@@ -163,6 +163,7 @@ class Command:
         self._handles = handles
         self._traces = traces
         self._process_date_args()
+        self._read_tracer_version()
         if not self._args.skip_validation:
             self._check_lost_events()
 
@@ -170,6 +171,27 @@ class Command:
         for handle in self._handles.values():
             self._traces.remove_trace(handle)
 
+    def _read_tracer_version(self):
+        try:
+            metadata = subprocess.getoutput(
+                'babeltrace -o ctf-metadata "%s"' % self._args.path)
+        except subprocess.CalledProcessError:
+            self._gen_error('Cannot run babeltrace on the trace, cannot read'
+                            ' tracer version')
+
+        major_match = re.search(r'tracer_major = (\d+)', metadata)
+        minor_match = re.search(r'tracer_minor = (\d+)', metadata)
+        patch_match = re.search(r'tracer_patchlevel = (\d+)', metadata)
+
+        if not major_match or not minor_match or not patch_match:
+            self._gen_error('Malformed metadata, cannot read tracer version')
+
+        self.state.tracer_version = version_utils.Version(
+            int(major_match.group(1)),
+            int(minor_match.group(1)),
+            int(patch_match.group(1)),
+        )
+
     def _check_lost_events(self):
         self._print('Checking the trace for lost events...')
         try:
index fc2c08f6e6427e33ed2dffdfc2828f11523b7874..22618dafc1460bba43c0fd17669cae4599b2ad15 100644 (file)
@@ -39,6 +39,9 @@ class State:
         self.disks = {}
         self.mm = MemoryManagement()
         self._notification_cbs = {}
+        # State changes can be handled differently depending on
+        # version of tracer used, so keep track of it.
+        self._tracer_version = None
 
     def register_notification_cbs(self, cbs):
         for name in cbs:
This page took 0.026056 seconds and 5 git commands to generate.