| ... |
... |
@@ -13,7 +13,7 @@ module GHC.Runtime.Eval ( |
|
13
|
13
|
Resume(..), History(..),
|
|
14
|
14
|
execStmt, execStmt', ExecOptions(..), execOptions, ExecResult(..), resumeExec,
|
|
15
|
15
|
runDecls, runDeclsWithLocation, runParsedDecls,
|
|
16
|
|
- parseImportDecl, SingleStep(..),
|
|
|
16
|
+ parseImportDecl, SingleStep(..), ThreadBreaksIsolationMode(..),
|
|
17
|
17
|
abandon, abandonAll,
|
|
18
|
18
|
getResumeContext,
|
|
19
|
19
|
getHistorySpan,
|
| ... |
... |
@@ -184,8 +184,8 @@ execOptions = ExecOptions |
|
184
|
184
|
, execSourceFile = "<interactive>"
|
|
185
|
185
|
, execLineNumber = 1
|
|
186
|
186
|
, execWrap = EvalThis -- just run the statement, don't wrap it in anything
|
|
187
|
|
- , execIsolateBreaks = True
|
|
188
|
|
- -- by default we just care about breakpoints hit in this "main" thread
|
|
|
187
|
+ , execIsolateMode = SingleThreadedBreaks
|
|
|
188
|
+ -- by default we just care about breakpoints hit in this eval thread
|
|
189
|
189
|
}
|
|
190
|
190
|
|
|
191
|
191
|
-- | Run a statement in the current interactive context.
|
| ... |
... |
@@ -211,7 +211,7 @@ execStmt input exec_opts@ExecOptions{..} = do |
|
211
|
211
|
-- doing preprocessing on the AST before execution, e.g. in GHCi (see
|
|
212
|
212
|
-- GHCi.UI.runStmt).
|
|
213
|
213
|
execStmt' :: GhcMonad m => GhciLStmt GhcPs -> String -> ExecOptions -> m ExecResult
|
|
214
|
|
-execStmt' stmt stmt_text opts@ExecOptions{..} = do
|
|
|
214
|
+execStmt' stmt stmt_text ExecOptions{..} = do
|
|
215
|
215
|
hsc_env <- getSession
|
|
216
|
216
|
let interp = hscInterp hsc_env
|
|
217
|
217
|
|
| ... |
... |
@@ -232,8 +232,8 @@ execStmt' stmt stmt_text opts@ExecOptions{..} = do |
|
232
|
232
|
|
|
233
|
233
|
status <-
|
|
234
|
234
|
liftIO $ do
|
|
235
|
|
- let eval_opts = initEvalOpts idflags' (enableGhcStepMode execSingleStep)
|
|
236
|
|
- { isolateThreadBreaks = execIsolateThreadBreaks }
|
|
|
235
|
+ let eval_opts = (initEvalOpts idflags' (enableGhcStepMode execSingleStep))
|
|
|
236
|
+ { isolateThreadBreaks = enableIsolateThreadBreaks execIsolateMode }
|
|
237
|
237
|
evalStmt interp eval_opts (execWrap hval)
|
|
238
|
238
|
|
|
239
|
239
|
let ic = hsc_IC hsc_env
|
| ... |
... |
@@ -241,7 +241,7 @@ execStmt' stmt stmt_text opts@ExecOptions{..} = do |
|
241
|
241
|
|
|
242
|
242
|
size = ghciHistSize idflags'
|
|
243
|
243
|
|
|
244
|
|
- handleRunStatus opts stmt_text bindings ids
|
|
|
244
|
+ handleRunStatus execSingleStep execIsolateMode stmt_text bindings ids
|
|
245
|
245
|
status (emptyHistory size)
|
|
246
|
246
|
|
|
247
|
247
|
runDecls :: GhcMonad m => String -> m [Name]
|
| ... |
... |
@@ -293,15 +293,15 @@ emptyHistory size = nilBL size |
|
293
|
293
|
-- breakpoint if we don't care about that breakpoint (e.g. if using :steplocal
|
|
294
|
294
|
-- or :stepmodule, rather than :step, we only care about certain breakpoints).
|
|
295
|
295
|
handleRunStatus :: GhcMonad m
|
|
296
|
|
- => ExecOptions
|
|
|
296
|
+ => SingleStep
|
|
|
297
|
+ -> ThreadBreaksIsolationMode
|
|
297
|
298
|
-> String
|
|
298
|
299
|
-> ResumeBindings
|
|
299
|
300
|
-> [Id]
|
|
300
|
301
|
-> EvalStatus_ [ForeignHValue] [HValueRef]
|
|
301
|
302
|
-> BoundedList History
|
|
302
|
303
|
-> m ExecResult
|
|
303
|
|
-handleRunStatus ExecOptions{execSingleStep = step, execIsolateThreadBreaks}
|
|
304
|
|
- expr bindings final_ids status history0 = do
|
|
|
304
|
+handleRunStatus step isolateMode expr bindings final_ids status history0 = do
|
|
305
|
305
|
hsc_env <- getSession
|
|
306
|
306
|
let
|
|
307
|
307
|
interp = hscInterp hsc_env
|
| ... |
... |
@@ -395,22 +395,25 @@ handleRunStatus ExecOptions{execSingleStep = step, execIsolateThreadBreaks} |
|
395
|
395
|
return (ExecBreak names (Just ibi))
|
|
396
|
396
|
else do
|
|
397
|
397
|
-- resume with the same step type
|
|
398
|
|
- let eval_opts = initEvalOpts dflags (enableGhcStepMode step)
|
|
399
|
|
- { isolateThreadBreaks = execIsolateThreadBreaks }
|
|
|
398
|
+ let eval_opts = (initEvalOpts dflags (enableGhcStepMode step))
|
|
|
399
|
+ { isolateThreadBreaks = enableIsolateThreadBreaks isolateMode }
|
|
400
|
400
|
status <- liftIO $ GHCi.resumeStmt interp eval_opts resume_ctxt_fhv
|
|
401
|
401
|
history <- if not tracing then pure history0 else do
|
|
402
|
402
|
history1 <- liftIO $ mkHistory hug apStack_fhv ibi
|
|
403
|
403
|
let !history' = history1 `consBL` history0
|
|
404
|
404
|
-- history is strict, otherwise our BoundedList is pointless.
|
|
405
|
405
|
return history'
|
|
406
|
|
- handleRunStatus step expr bindings final_ids status history
|
|
|
406
|
+ handleRunStatus step isolateMode expr bindings final_ids status history
|
|
407
|
407
|
where
|
|
408
|
408
|
tracing | RunAndLogSteps <- step = True
|
|
409
|
409
|
| otherwise = False
|
|
410
|
410
|
|
|
411
|
|
-resumeExec :: GhcMonad m => SingleStep -> Maybe Int
|
|
|
411
|
+resumeExec :: GhcMonad m
|
|
|
412
|
+ => SingleStep
|
|
|
413
|
+ -> ThreadBreaksIsolationMode
|
|
|
414
|
+ -> Maybe Int
|
|
412
|
415
|
-> m ExecResult
|
|
413
|
|
-resumeExec step mbCnt
|
|
|
416
|
+resumeExec step isolateMode mbCnt
|
|
414
|
417
|
= do
|
|
415
|
418
|
hsc_env <- getSession
|
|
416
|
419
|
let ic = hsc_IC hsc_env
|
| ... |
... |
@@ -455,7 +458,8 @@ resumeExec step mbCnt |
|
455
|
458
|
(Just brkpt, Just cnt) -> setupBreakpoint interp brkpt cnt
|
|
456
|
459
|
_ -> return ()
|
|
457
|
460
|
|
|
458
|
|
- let eval_opts = initEvalOpts dflags (enableGhcStepMode step)
|
|
|
461
|
+ let eval_opts = (initEvalOpts dflags (enableGhcStepMode step))
|
|
|
462
|
+ { isolateThreadBreaks = enableIsolateThreadBreaks isolateMode }
|
|
459
|
463
|
status <- liftIO $ GHCi.resumeStmt interp eval_opts fhv
|
|
460
|
464
|
let prevHistoryLst = fromListBL 50 hist
|
|
461
|
465
|
hug = hsc_HUG hsc_env
|
| ... |
... |
@@ -466,7 +470,7 @@ resumeExec step mbCnt |
|
466
|
470
|
hist1 <- liftIO (mkHistory hug apStack bi)
|
|
467
|
471
|
return $ hist1 `consBL` fromListBL 50 hist
|
|
468
|
472
|
| otherwise -> pure prevHistoryLst
|
|
469
|
|
- handleRunStatus step expr bindings final_ids status =<< hist'
|
|
|
473
|
+ handleRunStatus step isolateMode expr bindings final_ids status =<< hist'
|
|
470
|
474
|
|
|
471
|
475
|
setupBreakpoint :: GhcMonad m => Interp -> InternalBreakpointId -> Int -> m () -- #19157
|
|
472
|
476
|
setupBreakpoint interp ibi cnt = do
|