diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2023-01-12 23:36:23 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2023-01-12 23:36:23 +0100 |
commit | 27abb1cc73606741e7f54133f789d86fcff10dcb (patch) | |
tree | 441e165257c36834759b63eaa41cbd3fab219362 | |
parent | 20a18716e494d7d83d498cfc4bfd96fa11d6b8ce (diff) |
GDB: use non-stop mode
Avoids issues caused by stopping already running inferiors when
attaching new one.
-rw-r--r-- | src/GDB.hs | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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 |