Toggle whether the RTS gets build with debugger support for ghci
authorPepe Iborra <mnislaih@gmail.com>
Mon, 11 Dec 2006 18:13:07 +0000 (18:13 +0000)
committerPepe Iborra <mnislaih@gmail.com>
Mon, 11 Dec 2006 18:13:07 +0000 (18:13 +0000)
Specifically, this disables the special support in the RTS for looking up the datacon name corresponding to an address.
Correspondingly, the debugging commads in GHCi will not be available, and neither will the '-fdebugging' flag

compiler/Makefile
compiler/deSugar/DsBreakpoint.lhs
compiler/ghci/Debugger.hs
compiler/ghci/InteractiveUI.hs
compiler/main/DynFlags.hs
compiler/typecheck/TcSplice.lhs
mk/config.mk.in
rts/Linker.c
rts/Makefile

index 70a0e72..aac594d 100644 (file)
@@ -413,10 +413,12 @@ ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
 
 # Yes, include the interepreter, readline, and Template Haskell extensions
 SRC_HC_OPTS += -DGHCI -package template-haskell
-# -DBREAKPOINT causes a loop in stage2
-# SRC_HC_OPTS += -DGHCI -DBREAKPOINT -package template-haskell
 PKG_DEPENDS += template-haskell
 
+# Should the debugger commands be enabled?
+ifeq "$(GhciWithDebugger)" "YES"
+SRC_HC_OPTS += -DDEBUGGER
+endif
 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
 # or not?
 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
index f6c7d9e..c714a5e 100644 (file)
@@ -45,7 +45,7 @@ import CoreUtils        ( exprType )
 import Outputable
 import ErrUtils         ( debugTraceMsg )
 import FastString       ( mkFastString, unpackFS )
-import DynFlags         ( GhcMode(..), DynFlag(Opt_Debugging, Opt_IgnoreBreakpoints) )
+import DynFlags         ( GhcMode(..), DynFlag(..) )
  
 import DsMonad 
 import {-#SOURCE#-}DsExpr ( dsLExpr ) 
@@ -104,10 +104,14 @@ mkBreakpointExpr loc bkptFuncId = do
           instrumenting = idName bkptFuncId == breakpointAutoName
 
 debug_enabled :: DsM Bool
+#if defined(GHCI) && defined(DEBUGGER)
 debug_enabled = do
     debugging      <- doptDs Opt_Debugging
     b_enabled      <- breakpoints_enabled
     return (debugging && b_enabled)
+#else
+debug_enabled = return False
+#endif
 
 maybeInsertBreakpoint :: LHsExpr Id -> Type ->  DsM (LHsExpr Id)
 --maybeInsertBreakpoint e | pprTrace("insertBreakpoint at" (ppr e) False = undefined
index 7135359..99b14c9 100644 (file)
@@ -534,7 +534,7 @@ refreshBkptTable :: [ModSummary] -> GHCi ()
 refreshBkptTable [] = return ()
 refreshBkptTable (ms:mod_sums) = do
     sess   <- getSession
-    when (Opt_Debugging `elem` flags (GHC.ms_hspp_opts ms)) $ do
+    when isDebugging $ do
       old_table <- getBkptTable
       new_table <- addModuleGHC sess old_table (GHC.ms_mod ms)
       setBkptTable new_table
@@ -547,3 +547,8 @@ refreshBkptTable (ms:mod_sums) = do
                 (ppr mod <> text ": inserted " <> int (length sites) <>
                  text " breakpoints")
           return$ addModule mod sites bt
+#if defined(GHCI) && defined(DEBUGGER)
+        isDebugging = Opt_Debugging `elem` flags (GHC.ms_hspp_opts ms)
+#else
+        isDebugging = False
+#endif
\ No newline at end of file
index 980dcd9..b9b82ac 100644 (file)
@@ -131,7 +131,7 @@ builtin_commands = [
   ("etags",    keepGoing createETagsFileCmd,   False, completeFilename),
   ("ctags",    keepGoing createCTagsFileCmd,   False, completeFilename),
   ("type",     keepGoing typeOfExpr,           False, completeIdentifier),
-#if defined(GHCI)
+#if defined(DEBUGGER)
   ("print",     keepGoing (pprintClosureCommand True False), False, completeIdentifier),
   ("sprint",    keepGoing (pprintClosureCommand False False),False, completeIdentifier),
   ("force",     keepGoing (pprintClosureCommand False True), False, completeIdentifier),
index 2bd6816..d1226ea 100644 (file)
@@ -201,7 +201,9 @@ data DynFlag
    | Opt_SplitObjs
    | Opt_StgStats
    | Opt_HideAllPackages
+#if defined(GHCI) && defined(DEBUGGER)
    | Opt_Debugging
+#endif
    | Opt_PrintBindResult
    | Opt_Haddock
 
index 56eb637..a99bf8b 100644 (file)
@@ -364,8 +364,11 @@ runMeta :: (SrcSpan -> th_syn -> Either Message hs_syn)
        -> TcM hs_syn           -- Of type t
 runMeta convert expr
   = do {       -- Desugar
+#if defined(GHCI) && defined(DEBUGGER)
          ds_expr <- unsetOptM Opt_Debugging $ initDsTc (dsLExpr expr)
-
+#else 
+         ds_expr <- initDsTc (dsLExpr expr)
+#endif
        -- Compile and link it; might fail if linking fails
        ; hsc_env <- getTopEnv
        ; src_span <- getSrcSpanM
index a1c6a84..3718485 100644 (file)
@@ -315,6 +315,9 @@ BuildingGranSim=$(subst mg,YES,$(filter mg,$(WAYS)))
 
 HscIfaceFileVersion=6
 
+# Building with debugger?
+GhciWithDebugger=YES
+
 #------------------------------------------------------------------------------
 # Options for Libraries
 
index f1ec48a..d0c120b 100644 (file)
@@ -95,7 +95,7 @@ static /*Str*/HashTable *symhash;
 /* Hash table mapping symbol names to StgStablePtr */
 static /*Str*/HashTable *stablehash;
 
-#if defined(GHCI) && defined(BREAKPOINT)
+#if defined(DEBUGGER)
 /* Hash table mapping info table ptrs to DataCon names */
 static HashTable *dchash;
 #endif 
@@ -828,7 +828,7 @@ static void ghciInsertStrHashTable ( char* obj_name,
    if (lookupHashTable(table, (StgWord)key) == NULL)
    {
       insertStrHashTable(table, (StgWord)key, data);
-#if defined(GHCI) && defined(BREAKPOINT)    
+#if defined(DEBUGGER)    
       // Insert the reverse pair in the datacon hash if it is a closure
       {
        if(isSuffixOf(key, "static_info") || isSuffixOf(key, "con_info")) {
@@ -882,7 +882,7 @@ initLinker( void )
 
     stablehash = allocStrHashTable();
     symhash = allocStrHashTable();
-#if defined(GHCI) && defined(BREAKPOINT)
+#if defined(DEBUGGER)
     dchash  = allocHashTable();
 #endif
 
@@ -1103,7 +1103,7 @@ lookupSymbol( char *lbl )
     }
 }
 
-#if defined(GHCI) && defined(BREAKPOINT)
+#if defined(DEBUGGER)
 char * 
 lookupDataCon( StgWord addr ) 
 {
@@ -4397,7 +4397,6 @@ static int machoGetMisalignment( FILE * f )
 
 #endif
 
-#if defined(GHCI) && defined(BREAKPOINT)
 int isSuffixOf(char* x, char* suffix) {
   int suffix_len = strlen (suffix);
   int x_len = strlen (x);
@@ -4412,4 +4411,3 @@ int isSuffixOf(char* x, char* suffix) {
   char* x_suffix = &x[strlen(x)-strlen(suffix)];
   return strcmp(x_suffix, suffix) == 0;
   }
-#endif
index e7df18e..c3c2b82 100644 (file)
@@ -144,6 +144,10 @@ ifeq "$(HaveLibMingwEx)" "YES"
 PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
 endif
 
+ifeq "$(GhciWithDebugger)" "YES"
+STANDARD_OPTS += -DDEBUGGER
+endif
+
 ifeq "$(DotnetSupport)" "YES"
 
 #