From 3979485bd97771373214c44d14b7830ba447ad23 Mon Sep 17 00:00:00 2001 From: Roland Senn Date: Mon, 11 Nov 2019 11:56:59 +0100 Subject: Show breakpoint locations of breakpoints which were ignored during :force (#2950) GHCi is split up into 2 major parts: The user-interface (UI) and the byte-code interpreter. With `-fexternal-interpreter` they even run in different processes. Communication between the UI and the Interpreter (called `iserv`) is done using messages over a pipe. This is called `Remote GHCI` and explained in the Note [Remote GHCi] in `compiler/ghci/GHCi.hs`. To process a `:force` command the UI sends a `Seq` message to the `iserv` process. Then `iserv` does the effective evaluation of the value. When during this process a breakpoint is hit, the `iserv` process has no additional information to enhance the `Ignoring breakpoint` output with the breakpoint location. To be able to print additional breakpoint information, there are 2 possible implementation choices: 1. Store the needed information in the `iserv` process. 2. Print the `Ignoring breakpoint` from the UI process. For option 1 we need to store the breakpoint info redundantely in 2 places and this is bad. Therfore option 2 was implemented in this MR: - The user enters a `force` command - The UI sends a `Seq` message to the `iserv` process. - If processing of the `Seq` message hits a breakpoint, the `iserv` process returns control to the UI process. - The UI looks up the source location of the breakpoint, and prints the enhanced `Ignoring breakpoint` output. - The UI sends a `ResumeSeq` message to the `iserv` process, to continue forcing. --- testsuite/tests/ghci.debugger/scripts/T2950.script | 6 ++++++ testsuite/tests/ghci.debugger/scripts/T2950.stdout | 9 +++++++++ testsuite/tests/ghci.debugger/scripts/T2950M.hs | 4 ++++ testsuite/tests/ghci.debugger/scripts/T2950S.hs | 8 ++++++++ testsuite/tests/ghci.debugger/scripts/all.T | 1 + testsuite/tests/ghci.debugger/scripts/print020.stdout | 2 +- 6 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 testsuite/tests/ghci.debugger/scripts/T2950.script create mode 100644 testsuite/tests/ghci.debugger/scripts/T2950.stdout create mode 100644 testsuite/tests/ghci.debugger/scripts/T2950M.hs create mode 100644 testsuite/tests/ghci.debugger/scripts/T2950S.hs (limited to 'testsuite/tests/ghci.debugger') diff --git a/testsuite/tests/ghci.debugger/scripts/T2950.script b/testsuite/tests/ghci.debugger/scripts/T2950.script new file mode 100644 index 0000000000..bf10ed0d14 --- /dev/null +++ b/testsuite/tests/ghci.debugger/scripts/T2950.script @@ -0,0 +1,6 @@ +:l T2950M.hs +:br 4 19 +:br 4 26 +:br T2950S 3 +main +:force _result diff --git a/testsuite/tests/ghci.debugger/scripts/T2950.stdout b/testsuite/tests/ghci.debugger/scripts/T2950.stdout new file mode 100644 index 0000000000..d2401849e5 --- /dev/null +++ b/testsuite/tests/ghci.debugger/scripts/T2950.stdout @@ -0,0 +1,9 @@ +Breakpoint 0 activated at T2950M.hs:4:19-35 +Breakpoint 1 activated at T2950M.hs:4:26-35 +Breakpoint 2 activated at T2950S.hs:3:11-12 +Stopped in Main.main, T2950M.hs:4:19-35 +_result :: String = _ +*** Ignoring breakpoint [T2950M.hs:4:19-35] +*** Ignoring breakpoint [T2950M.hs:4:26-35] +*** Ignoring breakpoint [T2950S.hs:3:11-12] +_result = "[2,6]" diff --git a/testsuite/tests/ghci.debugger/scripts/T2950M.hs b/testsuite/tests/ghci.debugger/scripts/T2950M.hs new file mode 100644 index 0000000000..fa49cda119 --- /dev/null +++ b/testsuite/tests/ghci.debugger/scripts/T2950M.hs @@ -0,0 +1,4 @@ +import T2950S + +main :: IO () +main = putStrLn $ show $ sort [6,2] diff --git a/testsuite/tests/ghci.debugger/scripts/T2950S.hs b/testsuite/tests/ghci.debugger/scripts/T2950S.hs new file mode 100644 index 0000000000..0685381f9f --- /dev/null +++ b/testsuite/tests/ghci.debugger/scripts/T2950S.hs @@ -0,0 +1,8 @@ +module T2950S where +sort :: Ord a => [a] -> [a] +sort [] = [] +sort (x:xs) = insert x (sort xs) + where + insert x [] = [x] + insert x (y:ys) | x < y = x:y:ys + | otherwise = y:(insert x ys) diff --git a/testsuite/tests/ghci.debugger/scripts/all.T b/testsuite/tests/ghci.debugger/scripts/all.T index d38b3681ad..24939a942e 100644 --- a/testsuite/tests/ghci.debugger/scripts/all.T +++ b/testsuite/tests/ghci.debugger/scripts/all.T @@ -107,6 +107,7 @@ test('hist002', [extra_files(['../Test3.hs']), extra_run_opts('+RTS -I0')], test('T1620', extra_files(['T1620/', 'T1620/T1620.hs']), ghci_script, ['T1620.script']) test('T2740', normal, ghci_script, ['T2740.script']) +test('T2950', normal, ghci_script, ['T2950.script']) test('getargs', extra_files(['../getargs.hs']), ghci_script, ['getargs.script']) test('T7386', normal, ghci_script, ['T7386.script']) diff --git a/testsuite/tests/ghci.debugger/scripts/print020.stdout b/testsuite/tests/ghci.debugger/scripts/print020.stdout index 991ed11c67..3614846f92 100644 --- a/testsuite/tests/ghci.debugger/scripts/print020.stdout +++ b/testsuite/tests/ghci.debugger/scripts/print020.stdout @@ -15,5 +15,5 @@ Breakpoint 13 activated at HappyTest.hs:237:18-35 Stopped in Main.lexer, HappyTest.hs:228:11-19 _result :: Bool = _ c :: Char = '1' -*** Ignoring breakpoint +*** Ignoring breakpoint [HappyTest.hs:228:11-19] _result = False -- cgit v1.2.1