X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fghci%2FInteractiveUI.hs;h=bc0b3bc0923d261d26d65266176a671f09030694;hp=159a5ce347e1fb5853689cdda74a936a9846be7b;hb=940524aec90652b5ef81789c9a453c57c0e42cc9;hpb=ab22f4e6456820c1b5169d75f5975a94e61f54ce diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index 159a5ce..bc0b3bc 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -13,44 +13,32 @@ module InteractiveUI ( #include "HsVersions.h" -#if defined(GHCI) && defined(BREAKPOINT) -import GHC.Exts ( Int(..), Ptr(..), int2Addr# ) -import Foreign.StablePtr ( deRefStablePtr, castPtrToStablePtr ) -import System.IO.Unsafe ( unsafePerformIO ) -import Var -import HscTypes -import RdrName -import NameEnv -import TcType -import qualified Id -import IdInfo -import PrelNames -#endif +import GhciMonad +import GhciTags +import Debugger -- The GHC interface import qualified GHC import GHC ( Session, LoadHowMuch(..), Target(..), TargetId(..), - Type, Module, ModuleName, TyThing(..), Phase ) + Type, Module, ModuleName, TyThing(..), Phase, + BreakIndex, Name, SrcSpan, Resume, SingleStep ) import DynFlags import Packages import PackageConfig import UniqFM import PprTyThing -import Outputable - --- for createtags -import Name -import OccName -import SrcLoc +import Outputable hiding (printForUser) +import Module -- for ModuleEnv -- Other random utilities import Digraph -import BasicTypes -import Panic hiding (showException) +import BasicTypes hiding (isTopLevel) +import Panic hiding (showException) import Config import StaticFlags import Linker import Util +import FastString #ifndef mingw32_HOST_OS import System.Posix @@ -71,28 +59,28 @@ import System.Console.Readline as Readline --import SystemExts import Control.Exception as Exception -import Data.Dynamic -- import Control.Concurrent -import Numeric +import qualified Data.ByteString.Char8 as BS import Data.List -import Data.Int ( Int64 ) -import Data.Maybe ( isJust, isNothing, fromMaybe, catMaybes ) +import Data.Maybe import System.Cmd -import System.CPUTime import System.Environment import System.Exit ( exitWith, ExitCode(..) ) import System.Directory import System.IO import System.IO.Error as IO import Data.Char +import Data.Dynamic +import Data.Array import Control.Monad as Monad -import Foreign.StablePtr ( newStablePtr ) +import Text.Printf +import Foreign.StablePtr ( newStablePtr ) import GHC.Exts ( unsafeCoerce# ) import GHC.IOBase ( IOErrorType(InvalidArgument) ) -import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) +import Data.IORef ( IORef, readIORef, writeIORef ) import System.Posix.Internals ( setNonBlockingFD ) @@ -101,9 +89,9 @@ import System.Posix.Internals ( setNonBlockingFD ) ghciWelcomeMsg = " ___ ___ _\n"++ " / _ \\ /\\ /\\/ __(_)\n"++ - " / /_\\// /_/ / / | | GHC Interactive, version " ++ cProjectVersion ++ ", for Haskell 98.\n"++ - "/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n"++ - "\\____/\\/ /_/\\____/|_| Type :? for help.\n" + " / /_\\// /_/ / / | | GHC Interactive, version " ++ cProjectVersion ++ ", for Haskell 98.\n"++ + "/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n"++ + "\\____/\\/ /_/\\____/|_| Type :? for help.\n" type Command = (String, String -> GHCi Bool, Bool, String -> IO [String]) cmdName (n,_,_,_) = n @@ -112,30 +100,43 @@ GLOBAL_VAR(commands, builtin_commands, [Command]) builtin_commands :: [Command] builtin_commands = [ + -- Hugs users are accustomed to :e, so make sure it doesn't overlap + ("?", keepGoing help, False, completeNone), ("add", keepGoingPaths addModule, False, completeFilename), + ("abandon", keepGoing abandonCmd, False, completeNone), + ("break", keepGoing breakCmd, False, completeIdentifier), + ("back", keepGoing backCmd, False, completeNone), ("browse", keepGoing browseCmd, False, completeModule), - ("cd", keepGoing changeDirectory, False, completeFilename), + ("cd", keepGoing changeDirectory, False, completeFilename), + ("check", keepGoing checkModule, False, completeHomeModule), + ("continue", keepGoing continueCmd, False, completeNone), + ("ctags", keepGoing createCTagsFileCmd, False, completeFilename), ("def", keepGoing defineMacro, False, completeIdentifier), + ("delete", keepGoing deleteCmd, False, completeNone), ("e", keepGoing editFile, False, completeFilename), - -- Hugs users are accustomed to :e, so make sure it doesn't overlap ("edit", keepGoing editFile, False, completeFilename), + ("etags", keepGoing createETagsFileCmd, False, completeFilename), + ("force", keepGoing forceCmd, False, completeIdentifier), + ("forward", keepGoing forwardCmd, False, completeNone), ("help", keepGoing help, False, completeNone), - ("?", keepGoing help, False, completeNone), + ("history", keepGoing historyCmd, False, completeNone), ("info", keepGoing info, False, completeIdentifier), - ("load", keepGoingPaths loadModule_, False, completeHomeModuleOrFile), + ("kind", keepGoing kindOfType, False, completeIdentifier), + ("load", keepGoingPaths loadModule_, False, completeHomeModuleOrFile), + ("list", keepGoing listCmd, False, completeNone), ("module", keepGoing setContext, False, completeModule), ("main", keepGoing runMain, False, completeIdentifier), - ("reload", keepGoing reloadModule, False, completeNone), - ("check", keepGoing checkModule, False, completeHomeModule), + ("print", keepGoing printCmd, False, completeIdentifier), + ("quit", quit, False, completeNone), + ("reload", keepGoing reloadModule, False, completeNone), ("set", keepGoing setCmd, True, completeSetOptions), ("show", keepGoing showCmd, False, completeNone), - ("etags", keepGoing createETagsFileCmd, False, completeFilename), - ("ctags", keepGoing createCTagsFileCmd, False, completeFilename), + ("sprint", keepGoing sprintCmd, False, completeIdentifier), + ("step", keepGoing stepCmd, False, completeIdentifier), ("type", keepGoing typeOfExpr, False, completeIdentifier), - ("kind", keepGoing kindOfType, False, completeIdentifier), - ("unset", keepGoing unsetOptions, True, completeSetOptions), + ("trace", keepGoing traceCmd, False, completeIdentifier), ("undef", keepGoing undefineMacro, False, completeMacro), - ("quit", quit, False, completeNone) + ("unset", keepGoing unsetOptions, True, completeSetOptions) ] keepGoing :: (String -> GHCi ()) -> (String -> GHCi Bool) @@ -146,115 +147,76 @@ keepGoingPaths a str = a (toArgs str) >> return False shortHelpText = "use :? for help.\n" --- NOTE: spaces at the end of each line to workaround CPP/string gap bug. helpText = " Commands available from the prompt:\n" ++ "\n" ++ - " evaluate/run \n" ++ + " evaluate/run \n" ++ " :add ... add module(s) to the current target set\n" ++ " :browse [*] display the names defined by \n" ++ " :cd change directory to \n" ++ + " :ctags [] create tags file for Vi (default: \"tags\")\n" ++ " :def define a command :\n" ++ " :edit edit file\n" ++ " :edit edit last module\n" ++ + " :etags [] create tags file for Emacs (default: \"TAGS\")\n" ++ " :help, :? display this list of commands\n" ++ " :info [ ...] display information about the given names\n" ++ + " :kind show the kind of \n" ++ " :load ... load module(s) and their dependents\n" ++ " :module [+/-] [*] ... set the context for expression evaluation\n" ++ " :main [ ...] run the main function with the given arguments\n" ++ + " :quit exit GHCi\n" ++ " :reload reload the current module set\n" ++ + " :type show the type of \n" ++ + " :undef undefine user-defined command :\n" ++ + " :! run the shell command \n" ++ + "\n" ++ + " -- Commands for debugging:\n" ++ + "\n" ++ + " :abandon at a breakpoint, abandon current computation\n" ++ + " :back go back in the history (after :trace)\n" ++ + " :break [] [] set a breakpoint at the specified location\n" ++ + " :break set a breakpoint on the specified function\n" ++ + " :continue resume after a breakpoint\n" ++ + " :delete delete the specified breakpoint\n" ++ + " :delete * delete all breakpoints\n" ++ + " :force print , forcing unevaluated parts\n" ++ + " :forward go forward in the history (after :back)\n" ++ + " :history [] show the last items in the history (after :trace)\n" ++ + " :print [ ...] prints a value without forcing its computation\n" ++ + " :step single-step after stopping at a breakpoint\n"++ + " :step single-step into \n"++ + " :trace trace after stopping at a breakpoint\n"++ + " :trace trace into (remembers breakpoints for :history)\n"++ + " :sprint [ ...] simplifed version of :print\n" ++ + + "\n" ++ + " -- Commands for changing settings:\n" ++ "\n" ++ " :set