diff options
Diffstat (limited to 'pkgs/development/tools/misc/gdb')
-rw-r--r-- | pkgs/development/tools/misc/gdb/32-bit-BFD_VMA-format.patch | 68 | ||||
-rw-r--r-- | pkgs/development/tools/misc/gdb/debug-info-from-env.patch | 27 | ||||
-rw-r--r-- | pkgs/development/tools/misc/gdb/default.nix | 47 |
3 files changed, 107 insertions, 35 deletions
diff --git a/pkgs/development/tools/misc/gdb/32-bit-BFD_VMA-format.patch b/pkgs/development/tools/misc/gdb/32-bit-BFD_VMA-format.patch new file mode 100644 index 00000000000..41ce4540d2d --- /dev/null +++ b/pkgs/development/tools/misc/gdb/32-bit-BFD_VMA-format.patch @@ -0,0 +1,68 @@ +Fix iWerror=format build for 32-bit systems. +https://sourceware.org/pipermail/gdb-patches/2022-May/189288.html +--- a/sim/cris/sim-if.c ++++ b/sim/cris/sim-if.c +@@ -257,7 +257,8 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_write_fn do_write) + + if (verbose) + sim_io_printf (sd, +- "Loading segment at 0x%" BFD_VMA_FMT "x, size 0x%lx\n", ++ "Loading segment at 0x%" BFD_VMA_FMT "x, " ++ "size 0x%" BFD_VMA_FMT "x\n", + lma, phdr[i].p_filesz); + + if (bfd_seek (abfd, phdr[i].p_offset, SEEK_SET) != 0 +@@ -265,7 +266,7 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_write_fn do_write) + { + sim_io_eprintf (sd, + "%s: could not read segment at 0x%" BFD_VMA_FMT "x, " +- "size 0x%lx\n", ++ "size 0x%" BFD_VMA_FMT "x\n", + STATE_MY_NAME (sd), lma, phdr[i].p_filesz); + free (buf); + return FALSE; +@@ -275,7 +276,7 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_write_fn do_write) + { + sim_io_eprintf (sd, + "%s: could not load segment at 0x%" BFD_VMA_FMT "x, " +- "size 0x%lx\n", ++ "size 0x%" BFD_VMA_FMT "x\n", + STATE_MY_NAME (sd), lma, phdr[i].p_filesz); + free (buf); + return FALSE; +@@ -572,7 +573,8 @@ cris_handle_interpreter (SIM_DESC sd, struct bfd *abfd) + memory area, so we go via a temporary area. Luckily, the + interpreter is supposed to be small, less than 0x40000 + bytes. */ +- sim_do_commandf (sd, "memory region 0x%" BFD_VMA_FMT "x,0x%lx", ++ sim_do_commandf (sd, "memory region 0x%" BFD_VMA_FMT "x," ++ "0x%" BFD_VMA_FMT "x", + interp_load_addr, interpsiz); + + /* Now that memory for the interpreter is defined, load it. */ +--- a/sim/m32c/syscalls.c ++++ b/sim/m32c/syscalls.c +@@ -299,8 +299,8 @@ m32c_syscall (int id) + + rv = gettimeofday (&tv, 0); + if (trace) +- printf ("gettimeofday: %ld sec %ld usec to 0x%x\n", tv.tv_sec, +- tv.tv_usec, tvaddr); ++ printf ("gettimeofday: %lld sec %lld usec to 0x%x\n", ++ (long long)tv.tv_sec, (long long)tv.tv_usec, tvaddr); + mem_put_si (tvaddr, tv.tv_sec); + mem_put_si (tvaddr + 4, tv.tv_usec); + put_reg (r0, rv); +--- a/sim/rx/syscalls.c ++++ b/sim/rx/syscalls.c +@@ -270,8 +270,8 @@ rx_syscall (int id) + + rv = gettimeofday (&tv, 0); + if (trace) +- printf ("gettimeofday: %ld sec %ld usec to 0x%x\n", tv.tv_sec, +- tv.tv_usec, tvaddr); ++ printf ("gettimeofday: %lld sec %lld usec to 0x%x\n", ++ (long long)tv.tv_sec, (long long)tv.tv_usec, tvaddr); + mem_put_si (tvaddr, tv.tv_sec); + mem_put_si (tvaddr + 4, tv.tv_usec); + put_reg (1, rv); diff --git a/pkgs/development/tools/misc/gdb/debug-info-from-env.patch b/pkgs/development/tools/misc/gdb/debug-info-from-env.patch index de59bd2d17b..7a3d78da077 100644 --- a/pkgs/development/tools/misc/gdb/debug-info-from-env.patch +++ b/pkgs/development/tools/misc/gdb/debug-info-from-env.patch @@ -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); diff --git a/pkgs/development/tools/misc/gdb/default.nix b/pkgs/development/tools/misc/gdb/default.nix index f21808b1bf7..d9b56428f5c 100644 --- a/pkgs/development/tools/misc/gdb/default.nix +++ b/pkgs/development/tools/misc/gdb/default.nix @@ -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 @@ -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 @@ -27,36 +28,32 @@ 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="; - }); + # Does not nave to be conditional. We apply it conditionally + # to speed up inclusion to nearby nixos release. + ] ++ lib.optionals stdenv.is32bit [ + ./32-bit-BFD_VMA-format.patch + ]; nativeBuildInputs = [ pkg-config texinfo perl setupDebugInfoDirs ]; @@ -115,6 +112,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"; |