I'm trying to check for a certain chain of events in an LTTNG event log using Babeltrace 1. The LTTNG log is loaded using a Babeltrace collection:
import babeltrace
my_collection = babeltrace.TraceCollection()
my_collection.add_traces_recursive(trace_path, 'ctf')
The special events I'm looking for are almost indistinguishable from the normal events happening, except there is a few extra events once the chain have already started. So I need to look for these special events, and then search backward for the actual start.
The problem is that Babeltrace only lets me go forward in the event list. The simple solution seemed to be to create a clone of the events in my own list:
events = [e for e in my_collection.events]
The problem with this is that all events in the list now reference the last event. Which indicates that Babeltrace reuses the same object over and over and the generator only returns a reference to this single object.
I have tried to use copy.copy
:
events = [copy.copy(e) for e in my_collection.events]
This didn't help, and copy.deepcopy
doesn't work at all. I've also tried itertools.tee
:
events = list(itertools.tee(my_collection.events))
But this returns a list of _tee
object which can't be used as proper event objects.
Is there a way to search backward using the Babeltrace event collection generator? Or is there a way to clone the event object properly to create my own list?