From 37346fe1b1de570964c550c1bda2fe24fb1cc891 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 26 Apr 2022 14:30:04 +0100 Subject: [PATCH] instruments/trace_cmd: Handle setup failure In the case that the trace_cmd collector fails to initialise, do not attempt to use the collector in subsequent methods. --- wa/instruments/trace_cmd.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wa/instruments/trace_cmd.py b/wa/instruments/trace_cmd.py index 8fb3f4c6..14f1df98 100644 --- a/wa/instruments/trace_cmd.py +++ b/wa/instruments/trace_cmd.py @@ -190,17 +190,22 @@ class TraceCmdInstrument(Instrument): signal.connect(self.mark_stop, signal.AFTER_WORKLOAD_EXECUTION, priority=11) def setup(self, context): - self.collector.reset() + if self.collector: + self.collector.reset() @very_slow def start(self, context): - self.collector.start() + if self.collector: + self.collector.start() @very_slow def stop(self, context): - self.collector.stop() + if self.collector: + self.collector.stop() def update_output(self, context): # NOQA pylint: disable=R0912 + if not self.collector: + return self.logger.info('Extracting trace from target...') outfile = os.path.join(context.output_directory, 'trace.dat') self.collector.set_output(outfile)