静态链接二进制文件中缺少调试符号

Missing debug symbols in statically linked binary

我正在使用堆栈构建静态链接的二进制文件,并尝试向其中添加调试符号(以下:https://downloads.haskell.org/~ghc/master/users-guide/debug-info.html)。但是 GDB 报告:no debugging symbols found.

我错过了什么?

我已将 ghc-options 添加到 .cabal file-g -rtsoptsld-options-static。我正在使用以下命令使用堆栈进行构建:

stack install \
    --install-ghc \
    --split-objs \
    --ghc-options="-fPIC -fllvm -pgmlo opt -pgmlc llc"

GDB调用如下:gdb --args nodebug-exe +RTS -V0

GHC 8.2.1

完整的源代码在这里:https://github.com/carbolymer/haskell-missing-debug-symbols

--no-strip 防止在堆栈构建中删除调试信息。

来自documentation

stack now supports debugging and profiling with DWARF information, using the --no-strip, --no-library-stripping, and --no-executable-stripping flags to disable the default behavior of removing such information from compiled libraries and executables.