Skip to content

Commit b7d9b68

Browse files
committed
runDebugger: empty import lists
To pick up any DebugView orphan instances we want to import the modules from hdv and debugee units, however we can do so with empty import lists to avoid bringing any symbols in scope. One downside, maybe, is that this affects function breakpoints. Since only the Prelude is in scope at the beginning only fully qualified names are accepted.
1 parent 53b8234 commit b7d9b68

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

haskell-debugger/GHC/Debugger/Monad.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ runDebuggerAction l rootDir extraGhcArgs conf loadHomeUnit (Debugger action) = f
412412
setExposedInUnit interactiveGhcDebuggerUnitId . graphUnits . hsc_mod_graph =<< getSession
413413

414414
-- Set interactive context to import all loaded modules
415-
let preludeImp = GHC.IIDecl . GHC.simpleImportDecl $ GHC.mkModuleName "Prelude"
415+
let preludeImp = GHC.simpleImportDecl $ GHC.mkModuleName "Prelude"
416416

417417
hsc_env_new <- getSession
418418

@@ -431,9 +431,12 @@ runDebuggerAction l rootDir extraGhcArgs conf loadHomeUnit (Debugger action) = f
431431

432432
let
433433
imports
434-
= preludeImp :
434+
= map GHC.IIDecl $ preludeImp :
435+
[ i { ideclImportList = Just (Exactly, L noAnn []) }
436+
| i <- instancesOnly ]
437+
instancesOnly =
435438
dbgViewImps ++
436-
[ packageImportDecl pkgName (moduleName modl)
439+
[ (packageImportDecl pkgName (moduleName modl))
437440
| modl <- map GHC.ms_mod mss
438441
, let uid = moduleUnitId modl
439442
, let pkgName = fromMaybe (error $ "No package name for: " ++ unitIdString uid) $ lookupUnitPackageName hsc_env_new uid

haskell-debugger/GHC/Debugger/Session.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import qualified GHC.Unit.Home.Graph as HUG
8282
import qualified Data.Set as Set
8383
import Data.Maybe
8484
import GHC.Types.Target (InputFileBuffer)
85-
import GHC (SingleStep, ExecResult, ModSummary (ms_hspp_opts), ideclPkgQual)
85+
import GHC (SingleStep, ExecResult, ModSummary (ms_hspp_opts), ideclPkgQual, ImportDecl, GhcPs)
8686
import Data.Set (Set)
8787
import qualified GHC.Unit as GHC
8888
import GHC.Unit.Module.Graph (mg_mss, ModuleGraphNode (..), mnKey)
@@ -433,8 +433,8 @@ lookupUnitPackageName env uid = home_unit_name <|> ext_unit_name
433433
home_unit_name = PackageQualifier . mkFastString <$> (thisPackageName =<< home_unit_dflags env uid)
434434
ext_unit_name = const (PackageQualifier (unitIdFS uid)) <$> lookupUnitId (hsc_units env) uid
435435

436-
packageImportDecl :: PackageQualifier -> ModuleName -> GHC.InteractiveImport
437-
packageImportDecl (PackageQualifier pkgName) mn = GHC.IIDecl $
436+
packageImportDecl :: PackageQualifier -> ModuleName -> ImportDecl GhcPs
437+
packageImportDecl (PackageQualifier pkgName) mn =
438438
(GHC.simpleImportDecl $ mn)
439439
{ ideclPkgQual = RawPkgQual
440440
StringLiteral

test/golden/T169/T169b.hdb-stdin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
break --name main
1+
break --name Main.main
22
run
33
next
44
next

test/golden/self-debug-cli/self-debug-cli.hdb-stdin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
break --name runDebugger
1+
break --name GHC.Debugger.Monad.runDebugger
22
run cli test/golden/self-debug-cli/Main.hs
33
print import GHC.Data.FastString
44
print mkFastString "this FastString should be displayed pretty as a string (SHOULD NOT SEE ITS FULL INTERNALS)."

test/haskell/Test/Integration/SelfDebug.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ selfDebugDAPTest = do
4949
waitFiltering_ EventTy "initialized"
5050

5151
_ <- sync $ setFunctionBreakpointsRequest @_ @Value $ object
52-
[ "breakpoints" .= [ object [ "name" .= ("runDebugger" :: String) ] ] ]
52+
[ "breakpoints" .= [ object [ "name" .= ("GHC.Debugger.Monad.runDebugger" :: String) ] ] ]
5353

5454
_ <- sync configurationDone
5555

0 commit comments

Comments
 (0)