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 | |
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')
-rw-r--r-- | ghc/Main.hs | 18 | ||||
-rw-r--r-- | ghc/ghc-bin.cabal.in | 9 |
2 files changed, 25 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 () diff --git a/ghc/ghc-bin.cabal.in b/ghc/ghc-bin.cabal.in index 88e559048c..5cde07bc6a 100644 --- a/ghc/ghc-bin.cabal.in +++ b/ghc/ghc-bin.cabal.in @@ -22,6 +22,11 @@ Flag internal-interpreter Default: False Manual: True +Flag ghc-debug + Description: Build with support for ghc-debug. + Default: False + Manual: True + Flag threaded Description: Link the ghc executable against the threaded RTS Default: True @@ -42,6 +47,10 @@ Executable ghc ghc-boot == @ProjectVersionMunged@, ghc == @ProjectVersionMunged@ + if flag(ghc-debug) + build-depends: ghc-debug-stub + CPP-OPTIONS: -DGHC_DEBUG + if os(windows) Build-Depends: Win32 >= 2.3 && < 2.14 else |