From 27532a5bc5e5564a76fb79f8f48a746a2145f989 Mon Sep 17 00:00:00 2001 From: Ryan Slawson Date: Tue, 25 Feb 2025 12:04:01 +0100 Subject: [PATCH] Add a `catch` to the driver function to allow ILA data to be downloaded. --- bittide-shake/src/Clash/Shake/Vivado.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bittide-shake/src/Clash/Shake/Vivado.hs b/bittide-shake/src/Clash/Shake/Vivado.hs index f3d85179c..d02e1936e 100644 --- a/bittide-shake/src/Clash/Shake/Vivado.hs +++ b/bittide-shake/src/Clash/Shake/Vivado.hs @@ -46,7 +46,7 @@ import Clash.Shake.Extra (hexDigestFile) import qualified Clash.Sized.Internal.BitVector as BitVector import Control.Concurrent (threadDelay) import Control.Concurrent.MVar (MVar, modifyMVar, newMVar) -import Control.Exception (try) +import Control.Exception (Exception (displayException), SomeException, catch, try) import Control.Monad.Extra (andM, forM, forM_, orM, unless, when) import Control.Monad.Reader (runReaderT) import Data.Containers.ListUtils (nubOrd) @@ -886,7 +886,13 @@ runHitlTestCase v testCase@HitlTestCase{name, parameters} driverFunc probesFileP testCaseExitCode <- case driverFunc of Just fn -> do putStrLn $ "Running custom driver function for test " <> name - runReaderT (fn name testData) v + let + catchException :: SomeException -> IO ExitCode + catchException e = do + putStrLn $ "Caught exception while running driver function: " <> displayException e + putStrLn "Carrying on to save ILA data." + return $ ExitFailure 3 + catch (runReaderT (fn name testData) v) catchException Nothing -> do putStrLn $ "Running default driver function for test " <> name