Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions pkgs/development/tools/misc/gdb/debug-info-from-env.patch
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
diff -ur a/gdb/main.c b/gdb/main.c
--- a/gdb/main.c 2020-02-08 13:50:14.000000000 +0100
+++ b/gdb/main.c 2020-02-24 10:02:07.731806739 +0100
@@ -567,9 +567,17 @@
gdb_sysroot = xstrdup (TARGET_SYSROOT_PREFIX);
}
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -708,8 +708,12 @@ captured_main_1 (struct captured_main_args *context)
if (gdb_sysroot.empty ())
gdb_sysroot = TARGET_SYSROOT_PREFIX;

- debug_file_directory
- = xstrdup (relocate_gdb_directory (DEBUGDIR,
- DEBUGDIR_RELOCATABLE).c_str ());
+ debug_file_directory = getenv ("NIX_DEBUG_INFO_DIRS");
+ if (debug_file_directory != NULL)
+ // This might be updated later using
+ // $ set debug-file-directory /to/some/path
+ // which will use xfree. We must then have a xmallocated
+ // copy of the string that can be xfeed later.
+ debug_file_directory = xstrdup (debug_file_directory);
- = relocate_gdb_directory (DEBUGDIR, DEBUGDIR_RELOCATABLE);
+ const char * nix_debug = getenv ("NIX_DEBUG_INFO_DIRS");
+ if (nix_debug != NULL)
+ debug_file_directory = nix_debug;
+ else
+ debug_file_directory
+ = xstrdup (relocate_gdb_directory (DEBUGDIR,
+ DEBUGDIR_RELOCATABLE).c_str ());
+ = relocate_gdb_directory (DEBUGDIR, DEBUGDIR_RELOCATABLE);

gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
GDB_DATADIR_RELOCATABLE);
43 changes: 25 additions & 18 deletions pkgs/development/tools/misc/gdb/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib, stdenv, targetPackages

# Build time
, fetchurl, fetchpatch, pkg-config, perl, texinfo, setupDebugInfoDirs, buildPackages
, fetchurl, pkg-config, perl, texinfo, setupDebugInfoDirs, buildPackages

# Run time
, ncurses, readline, gmp, mpfr, expat, libipt, zlib, dejagnu, sourceHighlight
Expand All @@ -15,6 +15,7 @@
# targetPackages so we get the right libc when cross-compiling and using buildPackages.gdb
targetPackages.stdenv.cc.cc.lib
]
, writeScript
}:

let
Expand All @@ -27,36 +28,28 @@ assert pythonSupport -> python3 != null;

stdenv.mkDerivation rec {
pname = targetPrefix + basename;
version = "11.2";
version = "12.1";

src = fetchurl {
url = "mirror://gnu/gdb/${basename}-${version}.tar.xz";
hash = "sha256-FJfDanGIG4ZxqahKDuQPqreIyjDXuhnYRjw8x4cVLjI=";
hash = "sha256-DheTv48rVNU/Rt6oTM/URvSPgbKXsoxPf8AXuBjWn+0=";
};

postPatch = if stdenv.isDarwin then ''
postPatch = lib.optionalString stdenv.isDarwin ''
substituteInPlace gdb/darwin-nat.c \
--replace '#include "bfd/mach-o.h"' '#include "mach-o.h"'
'' else if stdenv.hostPlatform.isMusl then ''
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
substituteInPlace sim/erc32/erc32.c --replace sys/fcntl.h fcntl.h
substituteInPlace sim/erc32/interf.c --replace sys/fcntl.h fcntl.h
substituteInPlace sim/erc32/sis.c --replace sys/fcntl.h fcntl.h
substituteInPlace sim/ppc/emul_unix.c --replace sys/termios.h termios.h
'' else null;
'';

patches = [
./debug-info-from-env.patch

# Pull upstream fix for gcc-12. Will be included in gdb-12.
(fetchpatch {
name = "gcc-12.patch";
url = "https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=e97436b1b789dcdb6ffb502263f4c86f8bc22996";
sha256 = "1mpgw6s9qgnwhwyg3hagc6vhqhvia0l1s8nr22bcahwqxi3wvzcw";
})
] ++ lib.optionals stdenv.isDarwin [
./darwin-target-match.patch
] ++ lib.optional stdenv.hostPlatform.isMusl (fetchpatch {
name = "musl-fix-pagesize-page_size.patch";
url = "https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=fd0975b96b16d96010dce439af9620d3dfb65426";
hash = "sha256-M3U7uIIFJnYu0g8/sMLJPhm02q7cGOi6pLjgsUUjeKI=";
});
];

nativeBuildInputs = [ pkg-config texinfo perl setupDebugInfoDirs ];

Expand Down Expand Up @@ -115,6 +108,20 @@ stdenv.mkDerivation rec {
# TODO: Investigate & fix the test failures.
doCheck = false;

passthru = {
updateScript = writeScript "update-gdb" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl pcre common-updater-scripts

set -eu -o pipefail

# Expect the text in format of '<h3>GDB version 12.1</h3>'
new_version="$(curl -s https://www.sourceware.org/gdb/ |
pcregrep -o1 '<h3>GDB version ([0-9.]+)</h3>')"
update-source-version ${pname} "$new_version"
'';
};

meta = with lib; {
description = "The GNU Project debugger";

Expand Down