summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-01-12 23:36:23 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2023-01-12 23:36:23 +0100
commit27abb1cc73606741e7f54133f789d86fcff10dcb (patch)
tree441e165257c36834759b63eaa41cbd3fab219362 /src
parent20a18716e494d7d83d498cfc4bfd96fa11d6b8ce (diff)
GDB: use non-stop mode
Avoids issues caused by stopping already running inferiors when attaching new one.
Diffstat (limited to 'src')
-rw-r--r--src/GDB.hs10
1 files changed, 9 insertions, 1 deletions
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