phoityne / haskell-debug-adapter

Debug Adapter for Haskell debugging system.
https://hackage.haskell.org/package/haskell-debug-adapter
BSD 3-Clause "New" or "Revised" License
54 stars 8 forks source link

Exception has occured "end of file" #6

Closed mouse07410 closed 5 years ago

mouse07410 commented 5 years ago

MacOS 10.14.4, everything current.

Attempt to debug the tests from your example (after all the components have been successfully re-installed) causes this failure:

Screen Shot 2019-05-08 at 4 45 54 PM

Here's the log:

Configuration read.
Starting GHCi.
Wait for a moment.
[DEBUG][APP] ["stack","ghci","--test","--no-load","--no-build","--main-is","TARGET","--ghci-options","-fprint-evld-with-show"]
[INFO][APP] "--with-ghc" option not found. adding "--with-ghc=ghci-dap"
CWD:/Users/ur20980/src/Str3Split
CMD:stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show

Warning: /Users/ur20980/src/Str3Split/Str3Split.cabal was modified manually. Ignoring
         /Users/ur20980/src/Str3Split/package.yaml in favor of the cabal file. If you want to use
         the package.yaml file instead of the cabal file, then please delete the cabal file.
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded -Werror -O2
Configuring GHCi with the following packages: Str3Split
[DAP][INFO] start ghci-dap-0.0.12.0.
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Prelude>
:set prompt "<<DAP_CMD_END2>>\nH>>= "
H>>=
:set prompt-cont "<<DAP_CMD_END2>>\nH>>= "
H>>=
:dap-launch ...
[DEBUG][APP] :dap-launch LaunchRequestArguments {noDebugLaunchRequestArguments = Nothing, nameLaunchRequestArguments = "test-haskell-debug-adapter", typeLaunchRequestArguments = "ghc", requestLaunchRequestArguments = "launch", startupLaunchRequestArguments = "/Users/ur20980/src/Str3Split/test/Spec.hs", workspaceLaunchRequestArguments = "/Users/ur20980/src/Str3Split", logFileLaunchRequestArguments = "/Users/ur20980/src/Str3Split/.vscode/phoityne.log", logLevelLaunchRequestArguments = "DEBUG", ghciPromptLaunchRequestArguments = "H>>= ", ghciCmdLaunchRequestArguments = "stack ghci --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show", stopOnEntryLaunchRequestArguments = False, mainArgsLaunchRequestArguments = Just "", ghciEnvLaunchRequestArguments = fromList [], ghciInitialPromptLaunchRequestArguments = Just "Prelude>", startupFuncLaunchRequestArguments = Just "main", startupArgsLaunchRequestArguments = Just "", forceInspectLaunchRequestArguments = Just False}
<<DAP>>Right ()
H>>=
:load /Users/ur20980/src/Str3Split/test/Spec.hs
[1 of 4] Compiling Phoityne.Example.Math ( /Users/ur20980/src/Str3Split/src/Phoityne/Example/Math.hs, interpreted )
[2 of 4] Compiling SpecHelper       ( /Users/ur20980/src/Str3Split/test/SpecHelper.hs, interpreted )
[3 of 4] Compiling Phoityne.Example.MathSpec ( /Users/ur20980/src/Str3Split/test/Phoityne/Example/MathSpec.hs, interpreted )
[4 of 4] Compiling Main             ( /Users/ur20980/src/Str3Split/test/Spec.hs, interpreted )
Ok, four modules loaded.
H>>=
:dap-set-function-breakpoints ...
[DEBUG][APP] :dap-set-function-breakpoints SetFunctionBreakpointsRequestArguments {breakpointsSetFunctionBreakpointsRequestArguments = []}
[DAP][DEBUG]<dapSetFunctionBreakpointsCommand> delete func bps []
[DEBUG][APP] <<DAP>>Right (SetFunctionBreakpointsResponseBody {breakpointsSetFunctionBreakpointsResponseBody = []})
H>>=
:set -fbreak-on-exception
H>>=
:set -fbreak-on-error
H>>=
:dap-continue ...
[DEBUG][APP] :dap-continue ContinueRequestArguments {threadIdContinueRequestArguments = 0, exprContinueRequestArguments = Just "main"}
Stopped in <exception thrown>, <unknown>
_exception :: e = _
[DAP][DEBUG]stopped by exception
[DAP][WARN]ghci says,
Couldn't match kind ‘Constraint’ with ‘*’
When matching types
  a0 :: *
  Typeable IOException :: Constraint

"end of file"
[DEBUG][APP] <<DAP>>Right (StoppedEventBody {reasonStoppedEventBody = "exception", descriptionStoppedEventBody = "\"end of file\"", threadIdStoppedEventBody = 0, textStoppedEventBody = "\"end of file\"", allThreadsStoppedStoppedEventBody = True})
H>>=
:dap-stacktrace ...
[DEBUG][APP] :dap-stacktrace StackTraceRequestArguments {threadIdStackTraceRequestArguments = 0, startFrameStackTraceRequestArguments = Just 0, levelsStackTraceRequestArguments = 20}
-1  : main (/Users/ur20980/src/Str3Split/test/Spec.hs:6:8-17)
<end of history>
[DEBUG][APP] <<DAP>>Right (StackTraceResponseBody {stackFramesStackTraceResponseBody = [StackFrame {idStackFrame = 0, nameStackFrame = "main", sourceStackFrame = Source {nameSource = Nothing, pathSource = "/Users/ur20980/src/Str3Split/test/Spec.hs", sourceReferenceSource = Nothing, origineSource = Nothing}, lineStackFrame = 6, columnStackFrame = 8, endLineStackFrame = 6, endColumnStackFrame = 18}], totalFramesStackTraceResponseBody = 1})
H>>=
:dap-scopes ...
[DEBUG][APP] :dap-scopes ScopesRequestArguments {frameIdScopesRequestArguments = 0}
[DEBUG][APP] <<DAP>>Right (ScopesResponseBody {scopesScopesResponseBody = [Scope {nameScope = "GHCi Local", variablesReferenceScope = 1, namedVariablesScope = Nothing, indexedVariablesScope = Nothing, expensiveScope = False},Scope {nameScope = "GHCi Global", variablesReferenceScope = 2, namedVariablesScope = Nothing, indexedVariablesScope = Nothing, expensiveScope = False}]})
H>>=
:dap-variables ...
[DEBUG][APP] :dap-variables VariablesRequestArguments {variablesReferenceVariablesRequestArguments = 1}
[DEBUG][APP] <<DAP>>Left "Couldn't match kind \8216Constraint\8217 with \8216*\8217\nWhen matching types\n  a0 :: *\n  Typeable IOException :: Constraint\n"
H>>=
:dap-variables ...
[DEBUG][APP] :dap-variables VariablesRequestArguments {variablesReferenceVariablesRequestArguments = 2}
<interactive>: ^^ Could not load '_ghczmprim_GHCziPrim_seq_closure', dependency unresolved. See top entry above.

[DEBUG][APP] <<DAP>>Left "Couldn't match kind \8216Constraint\8217 with \8216*\8217\nWhen matching types\n  a0 :: *\n  Typeable IOException :: Constraint\n"
H>>=

Here's the Spec.hs file that seems to cause "end-of-file" exception:

-- file test/Spec.hs
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}

Here's .hspec:

--failure-report .hspec-failure
--color
--print-cpu-time

and its contents:

FailureReport {failureReportSeed = 280856176, failureReportMaxSuccess = 100, failureReportMaxSize = 100, failureReportMaxDiscardRatio = 10, failureReportPaths = []}

Here's the relevant entry in launch.json:

{
            "type": "ghc",
            "request": "launch",
            "name": "test-haskell-debug-adapter",
            "internalConsoleOptions": "openOnSessionStart",
            "workspace": "${workspaceRoot}",
            "startup": "${workspaceRoot}/test/Spec.hs",
            "startupFunc": "main",
            "startupArgs": "",
            "stopOnEntry": false,
            "mainArgs": "",
            "ghciPrompt": "H>>= ",
            "ghciInitialPrompt": "Prelude>",
            //"ghciCmd": "stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show",
            "ghciCmd": "stack ghci --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show",
            "ghciEnv": {},
            "logFile": "${workspaceRoot}/.vscode/phoityne.log",
            "logLevel": "DEBUG",
            "forceInspect": false
        },

(uncommenting the line with --with-ghc=... did not change anything)

mouse07410 commented 5 years ago

Changing --with-ghc=ghci-dap to --with-ghc=haskell-dap did not improve the situation. Actually, it claims that it cannot use --with-ghc=haskell-dap, removes it, and then adds --with-ghc=ghci-dap instead:

Screen Shot 2019-05-08 at 21 24 58
Configuration read.
Starting GHCi.
Wait for a moment.
[DEBUG][APP] ["stack","ghci","--with-ghc=haskell-dap","--test","--no-load","--no-build","--main-is","TARGET","--ghci-options","-fprint-evld-with-show"]
[INFO][APP] can not use haskell-dap. deleting "--with-ghc=haskell-dap"
[INFO][APP] "--with-ghc" option not found. adding "--with-ghc=ghci-dap"
CWD:/Users/ur20980/src/Str3Split
CMD:stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show

Warning: /Users/ur20980/src/Str3Split/Str3Split.cabal was modified manually. Ignoring
         /Users/ur20980/src/Str3Split/package.yaml in favor of the cabal file. If you want to use
         the package.yaml file instead of the cabal file, then please delete the cabal file.
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded -Werror -O2
Configuring GHCi with the following packages: Str3Split
[DAP][INFO] start ghci-dap-0.0.12.0.
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Prelude>
:set prompt "<<DAP_CMD_END2>>\nH>>= "
H>>=
:set prompt-cont "<<DAP_CMD_END2>>\nH>>= "
H>>=
:dap-launch ...
[DEBUG][APP] :dap-launch LaunchRequestArguments {noDebugLaunchRequestArguments = Nothing, nameLaunchRequestArguments = "test-haskell-debug-adapter", typeLaunchRequestArguments = "ghc", requestLaunchRequestArguments = "launch", startupLaunchRequestArguments = "/Users/ur20980/src/Str3Split/test/Spec.hs", workspaceLaunchRequestArguments = "/Users/ur20980/src/Str3Split", logFileLaunchRequestArguments = "/Users/ur20980/src/Str3Split/.vscode/phoityne.log", logLevelLaunchRequestArguments = "DEBUG", ghciPromptLaunchRequestArguments = "H>>= ", ghciCmdLaunchRequestArguments = "stack ghci --with-ghc=haskell-dap --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show", stopOnEntryLaunchRequestArguments = False, mainArgsLaunchRequestArguments = Just "", ghciEnvLaunchRequestArguments = fromList [], ghciInitialPromptLaunchRequestArguments = Just "Prelude>", startupFuncLaunchRequestArguments = Just "main", startupArgsLaunchRequestArguments = Just "", forceInspectLaunchRequestArguments = Just False}
<<DAP>>Right ()
H>>=
:load /Users/ur20980/src/Str3Split/test/Spec.hs
[1 of 4] Compiling Phoityne.Example.Math ( /Users/ur20980/src/Str3Split/src/Phoityne/Example/Math.hs, interpreted )
[2 of 4] Compiling SpecHelper       ( /Users/ur20980/src/Str3Split/test/SpecHelper.hs, interpreted )
[3 of 4] Compiling Phoityne.Example.MathSpec ( /Users/ur20980/src/Str3Split/test/Phoityne/Example/MathSpec.hs, interpreted )
[4 of 4] Compiling Main             ( /Users/ur20980/src/Str3Split/test/Spec.hs, interpreted )
Ok, four modules loaded.
H>>=
:dap-set-function-breakpoints ...
[DEBUG][APP] :dap-set-function-breakpoints SetFunctionBreakpointsRequestArguments {breakpointsSetFunctionBreakpointsRequestArguments = []}
[DAP][DEBUG]<dapSetFunctionBreakpointsCommand> delete func bps []
[DEBUG][APP] <<DAP>>Right (SetFunctionBreakpointsResponseBody {breakpointsSetFunctionBreakpointsResponseBody = []})
H>>=
:set -fbreak-on-exception
H>>=
:set -fbreak-on-error
H>>=
:dap-continue ...
[DEBUG][APP] :dap-continue ContinueRequestArguments {threadIdContinueRequestArguments = 0, exprContinueRequestArguments = Just "main"}
Stopped in <exception thrown>, <unknown>
_exception :: e = _
[DAP][DEBUG]stopped by exception
[DAP][WARN]ghci says,
Couldn't match kind ‘Constraint’ with ‘*’
When matching types
  a0 :: *
  Typeable IOException :: Constraint

"end of file"
[DEBUG][APP] <<DAP>>Right (StoppedEventBody {reasonStoppedEventBody = "exception", descriptionStoppedEventBody = "\"end of file\"", threadIdStoppedEventBody = 0, textStoppedEventBody = "\"end of file\"", allThreadsStoppedStoppedEventBody = True})
H>>=
:dap-stacktrace ...
[DEBUG][APP] :dap-stacktrace StackTraceRequestArguments {threadIdStackTraceRequestArguments = 0, startFrameStackTraceRequestArguments = Just 0, levelsStackTraceRequestArguments = 20}
-1  : main (/Users/ur20980/src/Str3Split/test/Spec.hs:6:8-17)
<end of history>
[DEBUG][APP] <<DAP>>Right (StackTraceResponseBody {stackFramesStackTraceResponseBody = [StackFrame {idStackFrame = 0, nameStackFrame = "main", sourceStackFrame = Source {nameSource = Nothing, pathSource = "/Users/ur20980/src/Str3Split/test/Spec.hs", sourceReferenceSource = Nothing, origineSource = Nothing}, lineStackFrame = 6, columnStackFrame = 8, endLineStackFrame = 6, endColumnStackFrame = 18}], totalFramesStackTraceResponseBody = 1})
H>>=
:dap-scopes ...
[DEBUG][APP] :dap-scopes ScopesRequestArguments {frameIdScopesRequestArguments = 0}
[DEBUG][APP] <<DAP>>Right (ScopesResponseBody {scopesScopesResponseBody = [Scope {nameScope = "GHCi Local", variablesReferenceScope = 1, namedVariablesScope = Nothing, indexedVariablesScope = Nothing, expensiveScope = False},Scope {nameScope = "GHCi Global", variablesReferenceScope = 2, namedVariablesScope = Nothing, indexedVariablesScope = Nothing, expensiveScope = False}]})
H>>=
:dap-variables ...
[DEBUG][APP] :dap-variables VariablesRequestArguments {variablesReferenceVariablesRequestArguments = 1}
[DEBUG][APP] <<DAP>>Left "Couldn't match kind \8216Constraint\8217 with \8216*\8217\nWhen matching types\n  a0 :: *\n  Typeable IOException :: Constraint\n"
H>>=

This is for Main.hs (not Spec.hs) - note how it changed to =ghci-dap there, despite what launch.json says:

Configuration read.
Starting GHCi.
Wait for a moment.
CWD:/Users/ur20980/src/Str3Split
CMD:stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show

Warning: /Users/ur20980/src/Str3Split/Str3Split.cabal was modified manually. Ignoring
         /Users/ur20980/src/Str3Split/package.yaml in favor of the cabal file. If you want to use
         the package.yaml file instead of the cabal file, then please delete the cabal file.
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded -Werror -O2
Configuring GHCi with the following packages: Str3Split
[DAP][INFO] start ghci-dap-0.0.12.0.
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Prelude>
:set prompt "<<DAP_CMD_END2>>\nH>>= "
H>>=
:set prompt-cont "<<DAP_CMD_END2>>\nH>>= "
H>>=
:dap-launch ...
<<DAP>>Right ()
H>>=
:load /Users/ur20980/src/Str3Split/app/Main.hs
[1 of 2] Compiling Lib              ( /Users/ur20980/src/Str3Split/src/Lib.hs, interpreted )
[2 of 2] Compiling Main             ( /Users/ur20980/src/Str3Split/app/Main.hs, interpreted )
Ok, two modules loaded.
H>>=
:dap-set-function-breakpoints ...
H>>=
:set -fbreak-on-exception
H>>=
:set -fbreak-on-error
H>>=
:dap-continue ...
Testing complicated 'foldr'
"2d4 fda 81c 8ce 783 aso meF unc"
Testing my 'chunker' (uses 'unfoldr')
["2d","4f","da","81","c8","ce","78","3a","so","me","Fu","nc"]
Testing "splitMore" using 'unfoldr' and 'intercalate'
"2d 4f da 81 c8 ce 78 3a so me Fu nc"
Testing "splitMore" using 'unfoldr' and 'unwords'
"2d 4f da 81 c8 ce 78 3a so me Fu nc"
debugging completed.
H>>=
:quit
Leaving GHCi.
mouse07410 commented 5 years ago

Update

I think I'm beginning to understand a little. EOF is an exception, but since debugger was set to break on it, it breaks instead of handling that exception. Probably OK. But then I observe this in the log - note panic! (the 'impossible' happened) message:

Configuration read.
Starting GHCi.
Wait for a moment.
CWD:/Users/ur20980/src/Str3Split
CMD:stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show

Warning: /Users/ur20980/src/Str3Split/Str3Split.cabal was modified manually. Ignoring
         /Users/ur20980/src/Str3Split/package.yaml in favor of the cabal file. If you want to use
         the package.yaml file instead of the cabal file, then please delete the cabal file.
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded -Werror -O2
Configuring GHCi with the following packages: Str3Split
[DAP][INFO] start ghci-dap-0.0.12.0.
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Prelude>
:set prompt "<<DAP_CMD_END2>>\nH>>= "
H>>=
:set prompt-cont "<<DAP_CMD_END2>>\nH>>= "
H>>=
:dap-launch ...
<<DAP>>Right ()
H>>=
:load /Users/ur20980/src/Str3Split/test/Spec.hs
[1 of 4] Compiling Phoityne.Example.Math ( /Users/ur20980/src/Str3Split/src/Phoityne/Example/Math.hs, interpreted )
[2 of 4] Compiling SpecHelper       ( /Users/ur20980/src/Str3Split/test/SpecHelper.hs, interpreted )
[3 of 4] Compiling Phoityne.Example.MathSpec ( /Users/ur20980/src/Str3Split/test/Phoityne/Example/MathSpec.hs, interpreted )
[4 of 4] Compiling Main             ( /Users/ur20980/src/Str3Split/test/Spec.hs, interpreted )
Ok, four modules loaded.
H>>=
:dap-set-function-breakpoints ...
H>>=
:set -fbreak-on-exception
H>>=
:set -fbreak-on-error
H>>=
:dap-continue ...
Stopped in <exception thrown>, <unknown>
_exception :: e = _
[DAP][WARN]ghci says,
Couldn't match kind ‘Constraint’ with ‘*’
When matching types
  a0 :: *
  Typeable IOException :: Constraint

"end of file"
H>>=
:dap-stacktrace ...
-1  : main (/Users/ur20980/src/Str3Split/test/Spec.hs:6:8-17)
<end of history>
H>>=
:dap-scopes ...
H>>=
:dap-variables ...
H>>=
:dap-next ...
[DAP][WARN]ghci says,
<interactive>: panic! (the 'impossible' happened)
  (GHC version 8.6.5 for x86_64-apple-darwin):
    enclosingTickSpan UnhelpfulSpan

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

H>>=
:dap-continue ...
Stopped in <exception thrown>, <unknown>
[DAP][WARN]ghci says,
Couldn't match kind ‘Constraint’ with ‘*’
When matching types
  a0 :: *
  Typeable IOException :: Constraint

[DAP][WARN]ghci says,
Couldn't match kind ‘Constraint’ with ‘*’
When matching types
  a0 :: *
  Typeable IOException :: Constraint

"end of file"
H>>=
:dap-stacktrace ...
-1  : main (/Users/ur20980/src/Str3Split/test/Spec.hs:6:8-17)
<end of history>
H>>=
:dap-scopes ...
H>>=
:dap-variables ...
H>>=
phoityne commented 5 years ago

Hi.

About exception breaks, could you check off the "break-on-exception" checkbox ? (in the left breakpoints menu )

hspec throws exceptions internally, then ghci catches them all.

from your log.

H>>= :set -fbreak-on-exception        => will be :set -fno-break-on-exception 
H>>= :set -fbreak-on-error
H>>=
mouse07410 commented 5 years ago

About exception breaks, could you check off the "break-on-exception" checkbox ?

Yes, that helped.

So, the conclusion is - one cannot/shouldn't attempt to catch exceptions when running a test framework. Correct?

Also, it looks like --with-ghc=haskell-dap is no longer supported? Only --with-ghc=ghci-dap?

phoityne commented 5 years ago

So, the conclusion is - one cannot/shouldn't attempt to catch exceptions when running a test framework. Correct?

Yes, shouldn't check on "break-on-exception" with hspec. (because many automatic breaks will be occured.)

Also, it looks like --with-ghc=haskell-dap is no longer supported? Only --with-ghc=ghci-dap?

With haskell-debug-adapter(hda), yes.

mouse07410 commented 5 years ago

Also, it looks like --with-ghc=haskell-dap is no longer supported? Only --with-ghc=ghci-dap?

With haskell-debug-adapter(hda), yes.

  • phoityne-vscode + haskell-dap <-- current version.
  • hda + ghci-dap <-- next version

I have all the four of your components installed:

Does that mean that I "automatically" provided everything necessary for the software to force the "next version"? Because, as I said above, my attempt to specify --with-ghc=haskell-dap failed: it said:

[DEBUG][APP] ["stack","ghci","--with-ghc=haskell-dap","--test","--no-load","--no-build","--main-is","TARGET","--ghci-options","-fprint-evld-with-show"]
[INFO][APP] can not use haskell-dap. deleting "--with-ghc=haskell-dap"
[INFO][APP] "--with-ghc" option not found. adding "--with-ghc=ghci-dap"
phoityne commented 5 years ago

Does that mean that I "automatically" provided everything necessary for the software to force the "next version"?

Yes, right. It is the hda. phoityen vscode extension runs hda if it is installed. This is because of preparation for gradual migration from current to next version.

If you want to run current version, uninstall hda. (just ok renaming haskell-debug-dapter.exe) phoityen vscode extension will run phoityne-vscode.exe

Regards.

mouse07410 commented 5 years ago

Yes, right. It is the hda. phoityen vscode extension runs hda if it is installed.

Excellent, thanks!

If you want to run current version, uninstall hda.

Oh no, no need, thanks. I just wanted to make sure I understand what the code is doing, and why. I'm perfectly happy with it.

Perhaps you want to document this behavior somewhere.