Build a package with debugging information so that you can run it within gdb or run valgrind on it.

Example: xmessageDebug = misc.debugVersion xorg.xmessage

svn path=/nixpkgs/trunk/; revision=21945
This commit is contained in:
Marc Weber
2010-05-23 15:54:10 +00:00
parent 0212a63e07
commit 32edcce80b
2 changed files with 35 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{ pkgs, stdenv } :
let inherit (pkgs) stdenv runCommand perl;
let inherit (pkgs) stdenv runCommand perl lib;
in
@@ -106,4 +106,30 @@ in
echo "''${PATH}" > $target/PATH
'';
};
# build a debug version of a package
debugVersion = pkg: lib.overrideDerivation pkg (attrs: {
prePhases = ["preHook"] ++ lib.optionals (pkgs ? prePhases) pkgs.prePhases;
dontStrip = true;
NIX_STRIP_DEBUG=0;
CFLAGS="-ggdb -O0";
CXXFLAGS="-ggdb -O0";
preHook = ''
s=$out/src
mkdir -p $s; cd $s;
export TMP=$s
export TEMP=$s
for var in CFLAGS CXXFLAGS NIX_CFLAGS_COMPILE; do
declare -x "$var=''${!var} -ggdb -O0"
done
echo "file should tell that executable has not been strippee"
'';
});
}