Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing debug symbols in statically linked binary

I'm building statically linked binary using stack and I try to add debug symbols to it (following: https://downloads.haskell.org/~ghc/master/users-guide/debug-info.html). However GDB reports: no debugging symbols found.

What am I missing?

I've added to the ghc-options in the .cabal file: -g -rtsopts and to the ld-options: -static. I am building using stack with the following command:

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

GDB is invoked as follows: gdb --args nodebug-exe +RTS -V0

GHC 8.2.1

Whole source code is here: https://github.com/carbolymer/haskell-missing-debug-symbols

like image 499
carbolymer Avatar asked Nov 17 '17 21:11

carbolymer


People also ask

What does no debugging symbols mean?

The most frequent cause of "no debugging symbols found" when -g is present is that there is some "stray" -s or -S argument somewhere on the link line. From man ld : -s --strip-all Omit all symbol information from the output file.

What is debug symbols in C?

A debug symbol is a special kind of symbol that attaches additional information to the symbol table of an object file, such as a shared library or an executable.

What is debug symbols in IOS?

It allows you to symbolicate your crash log, else it's just meaningless memory adress. It's kind of a link between the builded code and the source code.

How do I get rid of debug symbols?

To remove debugging symbols from a binary (which must be an a. out or ELF binary), run strip --strip-debug filename. Wildcards can be used to treat multiple files (use something like strip --strip-debug $LFS/tools/bin/*).


1 Answers

--no-strip prevents debugging information being removed in the stack build.

From the 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.

like image 97
Zpalmtree Avatar answered Oct 12 '22 00:10

Zpalmtree