From 025733b8367d9108e8992b2db3dbb9f80cad4fa9 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Thu, 11 Jan 2007 13:13:59 +0000 Subject: [PATCH] Added the new :breakpoint continue option Previously, when in a breakpoint, :quit was used to continue execution. This is not the right thing to do, so this patch restores :quit to its original meaning whether or not ghci is in an inferior session. The continue behavior is now provided by ":breakpoint continue". I added a synonim command in :continue because it is much shorter, but this is optional --- compiler/ghci/Debugger.hs | 16 ++++++++++------ compiler/ghci/GhciMonad.hs | 2 ++ compiler/ghci/InteractiveUI.hs | 26 +++++++++++++++++++++----- compiler/main/GHC.hs | 10 ++++++++-- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/compiler/ghci/Debugger.hs b/compiler/ghci/Debugger.hs index b158d33..0817259 100644 --- a/compiler/ghci/Debugger.hs +++ b/compiler/ghci/Debugger.hs @@ -297,11 +297,19 @@ stripUnknowns _ id = id ----------------------------- -- | The :breakpoint command ----------------------------- -bkptOptions :: String -> GHCi () +bkptOptions :: String -> GHCi Bool +bkptOptions "continue" = -- We want to quit if in an inferior session + liftM not isTopLevel +bkptOptions "stop" = do + inside_break <- liftM not isTopLevel + when inside_break $ throwDyn StopChildSession + return False + bkptOptions cmd = do dflags <- getDynFlags bt <- getBkptTable bkptOptions' (words cmd) bt + return False where bkptOptions' ["list"] bt = do let msgs = [ ppr mod <+> colon <+> ppr coords @@ -313,10 +321,6 @@ bkptOptions cmd = do else vcat num_msgs io$ putStrLn msg - bkptOptions' ["stop"] bt = do - inside_break <- liftM not isTopLevel - when inside_break $ throwDyn StopChildSession - bkptOptions' ("add":cmds) bt | [mod_name,line]<- cmds , [(lineNum,[])] <- reads line @@ -373,7 +377,7 @@ bkptOptions cmd = do io$ putStrLn delMsg bkptOptions' _ _ = throwDyn $ CmdLineError $ - "syntax: :breakpoint (list|stop|add|del)" + "syntax: :breakpoint (list|continue|stop|add|del)" -- Error messages handleBkptEx :: Module -> Debugger.BkptException -> a diff --git a/compiler/ghci/GhciMonad.hs b/compiler/ghci/GhciMonad.hs index e536841..df5b119 100644 --- a/compiler/ghci/GhciMonad.hs +++ b/compiler/ghci/GhciMonad.hs @@ -124,6 +124,8 @@ showForUser doc = do data InfSessionException = StopChildSession -- A child session requests to be stopped + | StopParentSession -- A child session requests to be stopped + -- AND that the parent session quits after that | ChildSessionStopped String -- A child session has stopped deriving Typeable diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index c2fb51d..d2ed976 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -114,6 +114,11 @@ builtin_commands :: [Command] builtin_commands = [ ("add", tlC$ keepGoingPaths addModule, False, completeFilename), ("browse", keepGoing browseCmd, False, completeModule), +#ifdef DEBUGGER + -- I think that :c should mean :continue rather than :cd, makes more sense + -- (pepe 01.11.07) + ("continue", const(bkptOptions "continue"), False, completeNone), +#endif ("cd", tlC$ keepGoing changeDirectory, False, completeFilename), ("def", keepGoing defineMacro, False, completeIdentifier), ("e", keepGoing editFile, False, completeFilename), @@ -136,7 +141,7 @@ builtin_commands = [ ("print", keepGoing (pprintClosureCommand True False), False, completeIdentifier), ("sprint", keepGoing (pprintClosureCommand False False),False, completeIdentifier), ("force", keepGoing (pprintClosureCommand False True), False, completeIdentifier), - ("breakpoint",keepGoing bkptOptions, False, completeBkpt), + ("breakpoint",bkptOptions, False, completeBkpt), #endif ("kind", keepGoing kindOfType, False, completeIdentifier), ("unset", keepGoing unsetOptions, True, completeSetOptions), @@ -169,6 +174,7 @@ helpText = " :breakpoint