我正在Haskell中进行低级IO(用于库绑定)并且遇到了段错误.我想使用GHCi :break来弄清楚发生了什么,但是接下来会发生什么:
> import SDL
> :break SDL.setPaletteColors
cannot set breakpoint on setPaletteColors: module SDL.Video.Renderer is not interpreted
Run Code Online (Sandbox Code Playgroud)
由于违规代码不在我自己的模块中,而是在外部包中的模块内部,因此它作为已编译的代码加载,显然我不能使用:打破已编译的模块.
GHCi手册证实了这一点,并提供了一个提示:
有一个主要限制:断点和单步仅在解释模块中可用; 编译后的代码对调试器是不可见的[5].
[5]请注意,包只包含已编译的代码,因此调试包需要查找其源并直接加载它.
我们直接尝试一下:
> :load some_path/sdl2/src/SDL/Video/Renderer.hs
some_path/sdl2/src/SDL/Video/Renderer.hs:101:8:
Could not find module ‘Control.Monad.IO.Class’
It is a member of the hidden package ‘transformers-0.3.0.0’.
Perhaps you need to add ‘transformers’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
Run Code Online (Sandbox Code Playgroud)
我可以将依赖项添加到我的.cabal文件中,但这已经错了.一旦我这样做了:
> :load some_path/sdl2/src/SDL/Video/Renderer.hs
some_path/sdl2/src/SDL/Video/Renderer.hs:119:8:
Could not find module ‘SDL.Internal.Numbered’ …Run Code Online (Sandbox Code Playgroud)