git.iko.soy/typeable/nixpkgs
on master help sign in
elfutils: Respect $NIX_DEBUG_INFO_DIRS

This makes eu-stack and eu-addr2line do the right thing in a nix-shell (if the appropriate debug outputs are present).

commitcc9bfd2cf8dd9aeb2f625ba2f4506e1e8c67d47c authorEelco Dolstra <edolstra@gmail.com> dateFri 28 Jul 2017, 16:10 (9 years ago) parent340bd1e
2 files changed+32−1
pkgs/development/tools/misc/elfutils/debug-info-from-env.patch+27 pkgs/development/tools/misc/elfutils/default.nix+5−1
pkgs/development/tools/misc/elfutils/debug-info-from-env.patchnew file+27
@@ -0,0 +1,27 @@
1+Look up .build-id files relative to the directories in the
2+colon-separated environment variable NIX_DEBUG_INFO_DIRS, unless
3+overriden by --debuginfo-path.
4+
5+diff -ru elfutils-0.169-orig/libdwfl/argp-std.c elfutils-0.169/libdwfl/argp-std.c
6+--- elfutils-0.169-orig/libdwfl/argp-std.c 2017-05-02 23:05:52.000000000 +0200
7++++ elfutils-0.169/libdwfl/argp-std.c 2017-07-28 16:08:06.739558106 +0200
8+@@ -376,5 +376,7 @@
9+ const struct argp *
10+ dwfl_standard_argp (void)
11+ {
12++ debuginfo_path = getenv("NIX_DEBUG_INFO_DIRS");
13++
14+ return &libdwfl_argp;
15+ }
16+diff -ru elfutils-0.169-orig/src/stack.c elfutils-0.169/src/stack.c
17+--- elfutils-0.169-orig/src/stack.c 2017-02-24 11:55:28.000000000 +0100
18++++ elfutils-0.169/src/stack.c 2017-07-28 15:50:06.743196696 +0200
19+@@ -631,6 +631,8 @@
20+ /* Set locale. */
21+ (void) setlocale (LC_ALL, "");
22+
23++ debuginfo_path = getenv("NIX_DEBUG_INFO_DIRS");
24++
25+ const struct argp_option options[] =
26+ {
27+ { NULL, 0, NULL, 0, N_("Input selection options:"), 0 },
pkgs/development/tools/misc/elfutils/default.nix+5−1
@@ -1,4 +1,4 @@
1−{ lib, stdenv, fetchurl, m4, zlib, bzip2, bison, flex, gettext, xz }:
1+{ lib, stdenv, fetchurl, m4, zlib, bzip2, bison, flex, gettext, xz, setupDebugInfoDirs }:
22
33# TODO: Look at the hardcoded paths to kernel, modules etc.
44stdenv.mkDerivation rec {
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
1010 sha256 = "1hiv1yqig3292dwqhrwsxwk3qjalxp5fpl8yphwbfwh8ng3zl4ll";
1111 };
1212
13+ patches = ./debug-info-from-env.patch;
14+
1315 hardeningDisable = [ "format" ];
1416
1517 # We need bzip2 in NativeInputs because otherwise we can't unpack the src,
@@ -17,6 +19,8 @@ stdenv.mkDerivation rec {
1719 nativeBuildInputs = [ m4 bison flex gettext bzip2 ];
1820 buildInputs = [ zlib bzip2 xz ];
1921
22+ propagatedNativeBuildInputs = [ setupDebugInfoDirs ];
23+
2024 configureFlags =
2125 [ "--program-prefix=eu-" # prevent collisions with binutils
2226 "--enable-deterministic-archives"