From a8fe4e58f63077e9c99d1c03e00580331f1f91c8 Mon Sep 17 00:00:00 2001
From: Timothee 'TTimo' Besset <ttimo@ttimo.net>
Date: Tue, 9 Jul 2024 10:29:12 -0600
Subject: [PATCH] fix starting gpu-trace on demand, regressed due to gpu-trace
 changes

---
 client/devkit_client/__init__.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/client/devkit_client/__init__.py b/client/devkit_client/__init__.py
index 60afa4d..cfdac6e 100644
--- a/client/devkit_client/__init__.py
+++ b/client/devkit_client/__init__.py
@@ -1454,12 +1454,13 @@ def _obtain_trace(ssh, sftp, args):
     capture_cmd = f'gpu-trace --capture --no-gpuvis -o {remote_trace_file}'
     _, err_text, exit_status = _simple_ssh(ssh, capture_cmd)
 
-    if err_text.find('Capture request failed') != -1 or err_text.find('Failed to capture a perf trace.') != -1:
-        # recognize this error, tell the daemon to start tracing and try again
+    if exit_status != 0 or err_text.find('Failed to capture trace') != -1:
+        # recognize this error, tell the daemon to start tracing
         # (assuming that tracing mode not enabled is the cause .. this is fragile unfortunately)
         logger.info('start tracing and try again')
         start_cmd = 'gpu-trace --start'
         _simple_ssh(ssh, start_cmd)
+        # issue again
         _, err_text, exit_status = _simple_ssh(ssh, capture_cmd)
 
     if exit_status != 0:
-- 
GitLab