Debug Symbols: Difference between revisions

imported>Symphorien
explain how to get debug info in gdb. maybe slightly too verbose.
 
imported>Symphorien
Unstripped packages: mention the difference between dontStrip and enableDebugging
Line 7: Line 7:
Two types of packages can provide debug symbols:
Two types of packages can provide debug symbols:
==== Unstripped packages ====
==== Unstripped packages ====
To prevent stripping of a derivation, use the option <code>dontStrip = true;</code>. This still compiles with optimisation;
to compile with <code>-Og -ggdb</code> in addition to disabling stripping, you can use the function <code>enableDebugging</code>.
Let's take the example of <code>socat</code>.
Let's take the example of <code>socat</code>.
If you install socat, then run  
If you install socat, then run  
{{Commands|
{{Commands|
Line 30: Line 31:
you see that you have debugging symbols for neither socat itself nor for dependent libraries.
you see that you have debugging symbols for neither socat itself nor for dependent libraries.


Now, to build an unstripped socat:
Now, build an unstripped socat:
{{Commands|
{{Commands|
$ nix-build -E 'with import <nixpkgs> {}; enableDebugging socat'
$ nix-build -E 'with import <nixpkgs> {}; enableDebugging socat'