diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-01-08 11:26:17 +0000 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2023-03-09 11:28:14 +0000 |
commit | 325c124eb817b157476b305265a0f8361df92d3d (patch) | |
tree | d012439db89d97ec31ce0e9fabbd743bdec3c5bb /ghc/Main.hs | |
parent | bed3a292df532935426987e1f0c5eaa4f605407e (diff) | |
download | haskell-wip/ghc-with-debug.tar.gz |
Add support for ghc-debug to ghc executablewip/ghc-with-debug
Diffstat (limited to 'ghc/Main.hs')
-rw-r--r-- | ghc/Main.hs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index ae862a7014..5f854b6565 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -32,6 +32,7 @@ import GHC.Driver.Backpack ( doBackpack ) import GHC.Driver.Plugins import GHC.Driver.Config.Logger (initLogFlags) import GHC.Driver.Config.Diagnostic +import GHC.Driver.Monad import GHC.Platform import GHC.Platform.Ways @@ -99,6 +100,10 @@ import Data.Bifunctor import GHC.Data.Graph.Directed import qualified Data.List.NonEmpty as NE +#if defined(GHC_DEBUG) +import GHC.Debug.Stub +#endif + ----------------------------------------------------------------------------- -- ToDo: @@ -111,6 +116,13 @@ import qualified Data.List.NonEmpty as NE ----------------------------------------------------------------------------- -- GHC's command-line interface +debugWrapper :: IO a -> IO a +#if defined(GHC_DEBUG) +debugWrapper = withGhcDebug +#else +debugWrapper = id +#endif + main :: IO () main = do hSetBuffering stdout LineBuffering @@ -159,8 +171,10 @@ main = do ShowGhcUsage -> showGhcUsage dflags ShowGhciUsage -> showGhciUsage dflags PrintWithDynFlags f -> putStrLn (f dflags) - Right postLoadMode -> - main' postLoadMode units dflags argv3 flagWarnings + Right postLoadMode -> do + reifyGhc $ \session -> debugWrapper $ + reflectGhc (main' postLoadMode units dflags argv3 flagWarnings) session + main' :: PostLoadMode -> [String] -> DynFlags -> [Located String] -> [Warn] -> Ghc () |