From 27abb1cc73606741e7f54133f789d86fcff10dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 12 Jan 2023 23:36:23 +0100 Subject: GDB: use non-stop mode Avoids issues caused by stopping already running inferiors when attaching new one. --- src/GDB.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/GDB.hs b/src/GDB.hs index 8cd6e10..f738bec 100644 --- a/src/GDB.hs +++ b/src/GDB.hs @@ -98,6 +98,7 @@ gdbStart onCrash = do gdbCommand gdb "-gdb-set schedule-multiple on" gdbCommand gdb "-gdb-set mi-async on" + gdbCommand gdb "-gdb-set non-stop on" gdbCommand gdb "-gdb-set print symbol-loading off" return gdb @@ -115,7 +116,14 @@ gdbLine gdb rline = either (outProc OutputError (gdbProcess gdb) . T.pack . erro | Just (MiString "signal-received") <- lookup "reason" params , Just (MiString tid) <- lookup "thread-id" params , Just inf <- find (elem tid . infThreads) infs - -> liftIO $ gdbOnCrash gdb $ infProcess inf + -> do + -- It is needed to switch thread manually in non-stop mode, + -- fork to avoid blocking further input and reply processing. + out <- getOutput + void $ liftIO $ forkIO $ do + flip runReaderT out $ do + gdbCommand gdb $ "-thread-select " <> tid + gdbOnCrash gdb $ infProcess inf _ -> return () StatusAsyncOutput cls params -> outProc OutputChildInfo (gdbProcess gdb) $ "status: " <> cls <> " " <> T.pack (show params) NotifyAsyncOutput cls params -> case cls of -- cgit v1.2.3