summary refs log tree commit diff
path: root/pkgs/development/tools/misc/gdb
diff options
context:
space:
mode:
authorSergei Trofimovich <slyich@gmail.com>2022-05-21 08:05:07 +0100
committerSergei Trofimovich <slyich@gmail.com>2022-05-21 21:18:21 +0100
commit63d81ddf9f45b727fc3cf0f2d5ae8bbdc3fc8ad3 (patch)
tree69807657bc7bb936735bf3848869a8f5b91b73a5 /pkgs/development/tools/misc/gdb
parent77bded3c433fbd36e2d834c6416150f20de2ae2e (diff)
downloadnixpkgs-63d81ddf9f45b727fc3cf0f2d5ae8bbdc3fc8ad3.tar
nixpkgs-63d81ddf9f45b727fc3cf0f2d5ae8bbdc3fc8ad3.tar.gz
nixpkgs-63d81ddf9f45b727fc3cf0f2d5ae8bbdc3fc8ad3.tar.bz2
nixpkgs-63d81ddf9f45b727fc3cf0f2d5ae8bbdc3fc8ad3.tar.lz
nixpkgs-63d81ddf9f45b727fc3cf0f2d5ae8bbdc3fc8ad3.tar.xz
nixpkgs-63d81ddf9f45b727fc3cf0f2d5ae8bbdc3fc8ad3.tar.zst
nixpkgs-63d81ddf9f45b727fc3cf0f2d5ae8bbdc3fc8ad3.zip
pkgsi686Linux.gdb: fix formatting for 32-bit systems
A few rare targets don't have clean format strings on 32-bit systems:
https://github.com/NixOS/nixpkgs/pull/171216#issuecomment-1133541978

    /build/gdb-12.1/_build/sim/../../sim/cris/sim-if.c:575:28:
      error: format '%lx' expects argument of type 'long unsigned int',
        but argument 4 has type 'bfd_size_type' {aka 'long long unsigned int'} [-Werror=format=]

We pull in patch pending upstream inclusion.
Diffstat (limited to 'pkgs/development/tools/misc/gdb')
-rw-r--r--pkgs/development/tools/misc/gdb/32-bit-BFD_VMA-format.patch68
-rw-r--r--pkgs/development/tools/misc/gdb/default.nix4
2 files changed, 72 insertions, 0 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/default.nix b/pkgs/development/tools/misc/gdb/default.nix
index f2dd043b14a..d9b56428f5c 100644
--- a/pkgs/development/tools/misc/gdb/default.nix
+++ b/pkgs/development/tools/misc/gdb/default.nix
@@ -49,6 +49,10 @@ stdenv.mkDerivation rec {
     ./debug-info-from-env.patch
   ] ++ lib.optionals stdenv.isDarwin [
     ./darwin-target-match.patch
+  # 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 ];