summaryrefslogtreecommitdiff
path: root/src/GDB.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-10-13 21:05:31 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-10-13 22:16:06 +0200
commit000209c13299f1c046dc60e3649c17e9520680de (patch)
treed0ef2db73b3ed95559cec6037348e03706b116f0 /src/GDB.hs
parented4dcb61f8a13a3cbfee1c30ea2cb12b5fd3c1ec (diff)
Fail test and start gdb session immediately on process crash
Diffstat (limited to 'src/GDB.hs')
-rw-r--r--src/GDB.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/GDB.hs b/src/GDB.hs
index 76c33c1..8e04c42 100644
--- a/src/GDB.hs
+++ b/src/GDB.hs
@@ -12,6 +12,7 @@ import Data.Text.IO qualified as T
import System.IO.Error
import System.Process
+import Output
import Process
gdbCmd :: String
@@ -29,10 +30,14 @@ addInferior gdb i pid = do
send gdb $ T.pack $ "-target-attach --thread-group i" ++ show i ++ " " ++ show pid
send gdb $ T.pack $ "-exec-continue --thread-group i" ++ show i
-gdbSession :: MonadIO m => Process -> m ()
-gdbSession gdb = liftIO $ do
- catchIOError (Just <$> T.getLine) (\e -> if isEOFError e then return Nothing else ioError e) >>= \case
+gdbSession :: MonadOutput m => Process -> m ()
+gdbSession gdb = do
+ outPrompt $ T.pack "gdb> "
+ liftIO loop
+ outClearPrompt
+ where
+ loop = catchIOError (Just <$> T.getLine) (\e -> if isEOFError e then return Nothing else ioError e) >>= \case
Just line -> do
send gdb (T.pack "-interpreter-exec console \"" `T.append` line `T.append` T.pack "\"")
- gdbSession gdb
+ loop
Nothing -> return ()