gdb.scm 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014, 2015, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
  4. ;;; Copyright © 2015, 2016, 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
  5. ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
  6. ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
  7. ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  8. ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  9. ;;;
  10. ;;; This file is part of GNU Guix.
  11. ;;;
  12. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  13. ;;; under the terms of the GNU General Public License as published by
  14. ;;; the Free Software Foundation; either version 3 of the License, or (at
  15. ;;; your option) any later version.
  16. ;;;
  17. ;;; GNU Guix is distributed in the hope that it will be useful, but
  18. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. ;;; GNU General Public License for more details.
  21. ;;;
  22. ;;; You should have received a copy of the GNU General Public License
  23. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  24. (define-module (gnu packages gdb)
  25. #:use-module (gnu packages)
  26. #:use-module (gnu packages hurd)
  27. #:use-module (gnu packages ncurses)
  28. #:use-module (gnu packages readline)
  29. #:use-module (gnu packages dejagnu)
  30. #:use-module (gnu packages texinfo)
  31. #:use-module (gnu packages multiprecision)
  32. #:use-module (gnu packages xml)
  33. #:use-module (gnu packages guile)
  34. #:use-module (gnu packages pretty-print)
  35. #:use-module (gnu packages python)
  36. #:use-module (gnu packages pkg-config)
  37. #:use-module ((guix licenses) #:select (gpl3+))
  38. #:use-module (guix packages)
  39. #:use-module (guix download)
  40. #:use-module (guix build-system gnu)
  41. #:use-module ((guix build utils) #:select (alist-replace))
  42. #:use-module (srfi srfi-1))
  43. (define-public gdb-10
  44. (package
  45. (name "gdb")
  46. (version "10.2")
  47. (source (origin
  48. (method url-fetch)
  49. (uri (string-append "mirror://gnu/gdb/gdb-"
  50. version ".tar.xz"))
  51. (sha256
  52. (base32
  53. "0aag1c0fw875pvhjg1qp7x8pf6gf92bjv5gcic5716scacyj58da"))
  54. (patches
  55. (search-patches "gdb-hurd.patch"))))
  56. (build-system gnu-build-system)
  57. (arguments
  58. `(#:tests? #f ; FIXME "make check" fails on single-processor systems.
  59. #:out-of-source? #t
  60. #:modules ((srfi srfi-1)
  61. ,@%gnu-build-system-modules)
  62. #:phases (modify-phases %standard-phases
  63. (add-after
  64. 'configure 'post-configure
  65. (lambda _
  66. (for-each patch-makefile-SHELL
  67. (find-files "." "Makefile\\.in"))
  68. #t))
  69. (add-after
  70. 'install 'remove-libs-already-in-binutils
  71. (lambda* (#:key native-inputs inputs outputs
  72. #:allow-other-keys)
  73. ;; Like Binutils, GDB installs libbfd, libopcodes, etc.
  74. ;; However, this leads to collisions when both are
  75. ;; installed, and really is none of its business,
  76. ;; conceptually. So remove them.
  77. (let* ((binutils (or (assoc-ref inputs "binutils")
  78. (assoc-ref native-inputs "binutils")))
  79. (out (assoc-ref outputs "out"))
  80. (files1 (with-directory-excursion binutils
  81. (append (find-files "lib")
  82. (find-files "include"))))
  83. (files2 (with-directory-excursion out
  84. (append (find-files "lib")
  85. (find-files "include"))))
  86. (common (lset-intersection string=?
  87. files1 files2)))
  88. (with-directory-excursion out
  89. (for-each delete-file common)
  90. #t)))))))
  91. (inputs
  92. `(("expat" ,expat)
  93. ("mpfr" ,mpfr)
  94. ("gmp" ,gmp)
  95. ("readline" ,readline)
  96. ("ncurses" ,ncurses)
  97. ("guile" ,guile-3.0)
  98. ("python-wrapper" ,python-wrapper)
  99. ("source-highlight" ,source-highlight)
  100. ;; Allow use of XML-formatted syscall information. This enables 'catch
  101. ;; syscall' and similar commands.
  102. ("libxml2" ,libxml2)
  103. ;; The Hurd needs -lshouldbeinlibc.
  104. ,@(if (hurd-target?) `(("hurd" ,hurd)) '())))
  105. (native-inputs
  106. `(("texinfo" ,texinfo)
  107. ("dejagnu" ,dejagnu)
  108. ("pkg-config" ,pkg-config)
  109. ,@(if (hurd-target?)
  110. ;; When cross-compiling from x86_64-linux, make sure to use a
  111. ;; 32-bit MiG because we assume target i586-pc-gnu.
  112. `(("mig" ,(if (%current-target-system)
  113. mig/32-bit
  114. mig)))
  115. '())))
  116. ;; TODO: Add support for the GDB_DEBUG_FILE_DIRECTORY environment
  117. ;; variable in GDB itself instead of relying on some glue code in
  118. ;; the Guix-provided .gdbinit file.
  119. (native-search-paths (list (search-path-specification
  120. (variable "GDB_DEBUG_FILE_DIRECTORY")
  121. (files '("lib/debug")))))
  122. (home-page "https://www.gnu.org/software/gdb/")
  123. (synopsis "The GNU debugger")
  124. (description
  125. "GDB is the GNU debugger. With it, you can monitor what a program is
  126. doing while it runs or what it was doing just before a crash. It allows you
  127. to specify the runtime conditions, to define breakpoints, and to change how
  128. the program is running to try to fix bugs. It can be used to debug programs
  129. written in C, C++, Ada, Objective-C, Pascal and more.")
  130. (license gpl3+)))
  131. ;; This version of GDB is required by some of the Rust compilers, see
  132. ;; <https://github.com/rust-lang/rust/issues/79009>.
  133. (define-public gdb-9.2
  134. (package
  135. (inherit gdb-10)
  136. (version "9.2")
  137. (source (origin
  138. (method url-fetch)
  139. (uri (string-append "mirror://gnu/gdb/gdb-"
  140. version ".tar.xz"))
  141. (patches (search-patches "gdb-9.2-sim-ppc-fno-common.patch"))
  142. (sha256
  143. (base32
  144. "0mf5fn8v937qwnal4ykn3ji1y2sxk0fa1yfqi679hxmpg6pdf31n"))))
  145. (inputs
  146. (alist-replace "guile" (list guile-2.0)
  147. (package-inputs gdb-10)))))
  148. (define-public gdb
  149. ;; This is the fixed version that packages depend on. Update it rarely
  150. ;; enough to avoid massive rebuilds.
  151. gdb-10)
  152. (define-public gdb-minimal
  153. (package/inherit
  154. gdb
  155. (name "gdb-minimal")
  156. (inputs (fold alist-delete (package-inputs gdb)
  157. '("libxml2" "ncurses" "python-wrapper" "source-highlight")))))