debug.scm 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014, 2015, 2016, 2017, 2019-2022 Eric Bavier <bavier@posteo.net>
  3. ;;; Copyright © 2016, 2017, 2018, 2020, 2021 Efraim Flashner <efraim@flashner.co.il>
  4. ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2018, 2019 Rutger Helling <rhelling@mykolab.com>
  6. ;;; Copyright © 2019 Pkill -9 <pkill9@runbox.com>
  7. ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
  8. ;;; Copyright © 2020, 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
  9. ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  10. ;;; Copyright © 2021 Felix Gruber <felgru@posteo.net>
  11. ;;; Copyright © 2021 Foo Chuan Wei <chuanwei.foo@hotmail.com>
  12. ;;; Copyright © 2022 Michael Rohleder <mike@rohleder.de>
  13. ;;; Copyright © 2022 Matthew James Kraai <kraai@ftbfs.org>
  14. ;;; Copyright © 2023 Andy Tai <atai@atai.org>
  15. ;;; Copyright © 2023 Ricardo Wurmus <rekado@elephly.net>
  16. ;;;
  17. ;;; This file is part of GNU Guix.
  18. ;;;
  19. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  20. ;;; under the terms of the GNU General Public License as published by
  21. ;;; the Free Software Foundation; either version 3 of the License, or (at
  22. ;;; your option) any later version.
  23. ;;;
  24. ;;; GNU Guix is distributed in the hope that it will be useful, but
  25. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  26. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. ;;; GNU General Public License for more details.
  28. ;;;
  29. ;;; You should have received a copy of the GNU General Public License
  30. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  31. (define-module (gnu packages debug)
  32. #:use-module (guix packages)
  33. #:use-module ((guix licenses) #:prefix license:)
  34. #:use-module (guix download)
  35. #:use-module (guix git-download)
  36. #:use-module (guix utils)
  37. #:use-module (guix build-system gnu)
  38. #:use-module (guix build-system cmake)
  39. #:use-module (guix build-system go)
  40. #:use-module (guix gexp)
  41. #:use-module (gnu packages)
  42. #:use-module (gnu packages attr)
  43. #:use-module (gnu packages autotools)
  44. #:use-module (gnu packages base)
  45. #:use-module (gnu packages bash)
  46. #:use-module (gnu packages bison)
  47. #:use-module (gnu packages c)
  48. #:use-module (gnu packages check)
  49. #:use-module (gnu packages code)
  50. #:use-module (gnu packages compression)
  51. #:use-module (gnu packages flex)
  52. #:use-module (gnu packages gdb)
  53. #:use-module (gnu packages glib)
  54. #:use-module (gnu packages gtk)
  55. #:use-module (gnu packages golang)
  56. #:use-module (gnu packages image)
  57. #:use-module (gnu packages lesstif)
  58. #:use-module (gnu packages libusb)
  59. #:use-module (gnu packages linux)
  60. #:use-module (gnu packages llvm)
  61. #:use-module (gnu packages ncurses)
  62. #:use-module (gnu packages ninja)
  63. #:use-module (gnu packages perl)
  64. #:use-module (gnu packages pkg-config)
  65. #:use-module (gnu packages pretty-print)
  66. #:use-module (gnu packages python)
  67. #:use-module (gnu packages python-check)
  68. #:use-module (gnu packages python-xyz)
  69. #:use-module (gnu packages qt)
  70. #:use-module (gnu packages readline)
  71. #:use-module (gnu packages serialization)
  72. #:use-module (gnu packages texinfo)
  73. #:use-module (gnu packages virtualization)
  74. #:use-module (gnu packages xdisorg)
  75. #:use-module (gnu packages xorg)
  76. #:use-module (ice-9 match)
  77. #:use-module (srfi srfi-1))
  78. (define-public delta
  79. (package
  80. (name "delta")
  81. (version "2006.08.03")
  82. (source
  83. (origin
  84. (method url-fetch)
  85. (uri (list
  86. (string-append "mirror://debian/pool/main/d/delta/"
  87. "delta_" version ".orig.tar.gz")
  88. ;; This uri seems to send guix download into an infinite loop
  89. (string-append "http://delta.tigris.org/files/documents/3103/"
  90. "33566/delta-" version ".tar.gz")))
  91. (sha256
  92. (base32
  93. "184wh35pf2ddx97319s6sgkzpz48xxkbwzcjpycv009bm53lh61q"))))
  94. (build-system gnu-build-system)
  95. (inputs ;Installed programs are perl scripts
  96. (list perl))
  97. (arguments
  98. `(#:phases
  99. (modify-phases %standard-phases
  100. (replace 'install
  101. (lambda* (#:key outputs #:allow-other-keys)
  102. ;; Makefile contains no install target
  103. (let* ((out (assoc-ref outputs "out"))
  104. (bin (string-append out "/bin"))
  105. (doc (string-append out "/share/doc/delta-" ,version)))
  106. (begin
  107. (for-each (lambda (h)
  108. (install-file h doc))
  109. `("License.txt" ,@(find-files "www" ".*\\.html")))
  110. (for-each (lambda (b)
  111. (install-file b bin))
  112. `("delta" "multidelta" "topformflat"))))
  113. #t))
  114. (delete 'configure)))) ; no configure script
  115. (home-page "http://delta.tigris.org/")
  116. (synopsis "Heuristical file minimizer")
  117. (description
  118. "Delta assists you in minimizing \"interesting\" files subject to a test
  119. of their interestingness. A common such situation is when attempting to
  120. isolate a small failure-inducing substring of a large input that causes your
  121. program to exhibit a bug.")
  122. ;; See License.txt, which is a bsd-3 license, despite the project's
  123. ;; home-page pointing to a bsd-2 license.
  124. (license license:bsd-3)))
  125. (define-public c-reduce
  126. (package
  127. (name "c-reduce")
  128. (version "2.10.0")
  129. (source
  130. (origin
  131. (method url-fetch)
  132. (uri (list
  133. (string-append "http://embed.cs.utah.edu/creduce/"
  134. "creduce-" version ".tar.gz")))
  135. (sha256
  136. (base32 "0qx0zq8jxzx2as2zf0740g7kvgq163ayn3041di4vwk77490y76v"))))
  137. (build-system gnu-build-system)
  138. (native-inputs (list flex))
  139. (inputs
  140. `(("astyle" ,astyle)
  141. ("llvm" ,llvm-9)
  142. ("clang" ,clang-9)
  143. ("indent" ,indent)
  144. ("perl" ,perl)
  145. ("exporter-lite" ,perl-exporter-lite)
  146. ("file-which" ,perl-file-which)
  147. ("getopt-tabular" ,perl-getopt-tabular)
  148. ("regex-common" ,perl-regexp-common)
  149. ("term-readkey" ,perl-term-readkey)))
  150. (arguments
  151. `(#:phases
  152. (modify-phases %standard-phases
  153. (replace 'check
  154. (lambda _
  155. (with-directory-excursion "tests"
  156. ;; Running all tests can take a looong time, and tests 4 and 5
  157. ;; require frama-c or kcc. So run just one for sanity.
  158. (invoke "./run_tests" "1"))))
  159. (add-after 'install 'set-load-paths
  160. (lambda* (#:key inputs outputs #:allow-other-keys)
  161. ;; Tell creduce where to find the perl modules it needs.
  162. (let* ((out (assoc-ref outputs "out"))
  163. (prog (string-append out "/bin/creduce")))
  164. (wrap-program
  165. prog
  166. `("PERL5LIB" ":" prefix
  167. ,(map (lambda (p)
  168. (string-append (assoc-ref inputs p)
  169. "/lib/perl5/site_perl/"
  170. ,(package-version perl)))
  171. '("term-readkey" "exporter-lite"
  172. "file-which" "getopt-tabular"
  173. "regex-common")))))
  174. #t)))))
  175. (home-page "https://embed.cs.utah.edu/creduce")
  176. (synopsis "Reducer for interesting code")
  177. (description
  178. "C-Reduce is a tool that takes a large C or C++ program that has a
  179. property of interest (such as triggering a compiler bug) and automatically
  180. produces a much smaller C/C++ program that has the same property. It is
  181. intended for use by people who discover and report bugs in compilers and other
  182. tools that process C/C++ code.")
  183. (license license:ncsa)))
  184. (define-public c-vise
  185. (package
  186. (name "c-vise")
  187. (version "2.4.0")
  188. (source
  189. (origin
  190. (method git-fetch)
  191. (uri (git-reference
  192. (url "https://github.com/marxin/cvise")
  193. (commit (string-append "v" version))))
  194. (sha256
  195. (base32 "1i2z5q2pcwh1gpdqc24x1a2q5vzwhblzzq021nzwf304di7m18vl"))
  196. (file-name (git-file-name name version))))
  197. (build-system cmake-build-system)
  198. (native-inputs
  199. (list flex python-pytest python-pytest-flake8))
  200. (inputs
  201. (list bash-minimal clang llvm unifdef
  202. python python-pebble python-psutil python-chardet))
  203. (arguments
  204. `(#:phases
  205. (modify-phases %standard-phases
  206. (add-after 'unpack 'fix-linkage
  207. (lambda _
  208. (substitute* "clang_delta/CMakeLists.txt"
  209. (("\\$\\{LLVM_LINK_LLVM_DYLIB\\}") "True")
  210. ((" LLVM") " LLVMSupport"))))
  211. (add-before 'build 'hardcode-paths
  212. (lambda _
  213. (substitute* "cvise.py"
  214. (("/bin/bash") (which "bash"))
  215. (("(.*)# Special case for clang-format" & >)
  216. (string-append > "# Special case for unifdef\n"
  217. > "programs['unifdef'] = '" (which "unifdef") "'\n"
  218. &)))))
  219. (add-after 'install 'wrap
  220. (lambda* (#:key outputs #:allow-other-keys)
  221. (let ((out (assoc-ref outputs "out"))
  222. (python-path (getenv "GUIX_PYTHONPATH")))
  223. (wrap-program (string-append out "/bin/cvise")
  224. `("PYTHONPATH" ":" prefix (,python-path)))
  225. #t))))))
  226. (home-page "https://github.com/marxin/cvise")
  227. (synopsis "Reducer for interesting code")
  228. (description
  229. "C-Vise is a Python port of the C-Reduce tool that is fully compatible
  230. and uses the same efficient LLVM-based C/C++ @code{clang_delta} reduction
  231. tool.")
  232. (license license:ncsa)))
  233. (define-public american-fuzzy-lop
  234. (let ((machine (match (or (%current-target-system)
  235. (%current-system))
  236. ("x86_64-linux" "x86_64")
  237. ("i686-linux" "i386")
  238. ("aarch64-linux" "aarch64")
  239. ("armhf-linux" "arm")
  240. ("mips64el-linux" "mips64el")
  241. ("powerpc-linux" "ppc")
  242. ;; Prevent errors when querying this package on unsupported
  243. ;; platforms, e.g. when running "guix package --search="
  244. (_ "UNSUPPORTED"))))
  245. (package
  246. (name "american-fuzzy-lop")
  247. (version "2.57b") ;It seems all releases have the 'b' suffix
  248. (source
  249. (origin
  250. (method git-fetch)
  251. (uri (git-reference
  252. (url "https://github.com/google/AFL")
  253. (commit (string-append "v" version))))
  254. (sha256
  255. (base32 "0ks0s8iizp7mpc9mlpv126rsny0dkljfsw68689g9jiisjz2z530"))
  256. (file-name (git-file-name name version))))
  257. (build-system gnu-build-system)
  258. (inputs
  259. (list qemu-for-american-fuzzy-lop))
  260. (arguments
  261. `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
  262. (string-append "DOC_PATH=$(PREFIX)/share/doc/"
  263. ,name "-" ,version)
  264. "CC=gcc")
  265. #:phases (modify-phases %standard-phases
  266. (add-after 'unpack 'make-git-checkout-writable
  267. (lambda _
  268. (for-each make-file-writable (find-files "."))
  269. #t))
  270. (delete 'configure)
  271. ,@(if (string=? (%current-system) (or "x86_64-linux"
  272. "i686-linux"))
  273. '()
  274. '((add-before 'build 'set-afl-flag
  275. (lambda _ (setenv "AFL_NO_X86" "1") #t))
  276. (add-after 'install 'remove-x86-programs
  277. (lambda* (#:key outputs #:allow-other-keys)
  278. (let* ((out (assoc-ref outputs "out"))
  279. (bin (string-append out "/bin/")))
  280. (delete-file (string-append bin "afl-gcc"))
  281. (delete-file (string-append bin "afl-g++"))
  282. (delete-file (string-append bin "afl-clang"))
  283. (delete-file (string-append bin "afl-clang++")))
  284. #t))))
  285. (add-after
  286. ;; TODO: Build and install the afl-llvm tool.
  287. 'install 'install-qemu
  288. (lambda* (#:key inputs outputs #:allow-other-keys)
  289. (let ((qemu (assoc-ref inputs "qemu"))
  290. (out (assoc-ref outputs "out")))
  291. (symlink (string-append qemu "/bin/qemu-" ,machine)
  292. (string-append out "/bin/afl-qemu-trace"))
  293. #t)))
  294. (delete 'check)))) ; tests are run during 'install phase
  295. (home-page "https://lcamtuf.coredump.cx/afl/")
  296. (synopsis "Security-oriented fuzzer")
  297. (description
  298. "American fuzzy lop is a security-oriented fuzzer that employs a novel
  299. type of compile-time instrumentation and genetic algorithms to automatically
  300. discover clean, interesting test cases that trigger new internal states in the
  301. targeted binary. This substantially improves the functional coverage for the
  302. fuzzed code. The compact synthesized corpora produced by the tool are also
  303. useful for seeding other, more labor- or resource-intensive testing regimes
  304. down the road.")
  305. (license license:asl2.0))))
  306. (define-public qemu-for-american-fuzzy-lop
  307. ;; afl only supports using a single afl-qemu-trace executable, so
  308. ;; we only build qemu for the native target.
  309. (let ((machine (match (or (%current-target-system)
  310. (%current-system))
  311. ("x86_64-linux" "x86_64")
  312. ("i686-linux" "i386")
  313. ("aarch64-linux" "aarch64")
  314. ("armhf-linux" "arm")
  315. ("mips64el-linux" "mips64el")
  316. ("powerpc-linux" "ppc")
  317. ;; Prevent errors when querying this package on unsupported
  318. ;; platforms, e.g. when running "guix package --search="
  319. (_ "UNSUPPORTED"))))
  320. (hidden-package
  321. (package
  322. (name "qemu")
  323. (version "2.10.2")
  324. (source (origin
  325. (method url-fetch)
  326. (uri (string-append "https://download.qemu.org/qemu-"
  327. version ".tar.xz"))
  328. (sha256
  329. (base32
  330. "17w21spvaxaidi2am5lpsln8yjpyp2zi3s3gc6nsxj5arlgamzgw"))
  331. (patches
  332. (search-patches "qemu-glibc-2.27.patch"
  333. "qemu-glibc-2.30.patch"))))
  334. (build-system gnu-build-system)
  335. (arguments
  336. `(;; Running tests in parallel can occasionally lead to failures, like:
  337. ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
  338. #:parallel-tests? #f
  339. #:configure-flags
  340. (list (string-append "--target-list=" ,machine "-linux-user"))
  341. #:make-flags '("V=1")
  342. #:phases
  343. (modify-phases %standard-phases
  344. (replace 'configure
  345. (lambda* (#:key inputs outputs (configure-flags '())
  346. #:allow-other-keys)
  347. ;; The `configure' script doesn't understand some of the
  348. ;; GNU options. Thus, add a new phase that's compatible.
  349. (let ((out (assoc-ref outputs "out")))
  350. (setenv "SHELL" (which "bash"))
  351. ;; While we're at it, patch for tests.
  352. (substitute* "tests/libqtest.c"
  353. (("/bin/sh") (which "sh")))
  354. ;; The binaries need to be linked against -lrt.
  355. (setenv "LDFLAGS" "-lrt")
  356. (apply invoke
  357. `("./configure"
  358. ,(string-append "--cc=" (which "gcc"))
  359. ;; Some architectures insist on using HOST_CC
  360. ,(string-append "--host-cc=" (which "gcc"))
  361. "--disable-debug-info" ; save build space
  362. "--enable-virtfs" ; just to be sure
  363. ,(string-append "--prefix=" out)
  364. ,(string-append "--sysconfdir=/etc")
  365. ,@configure-flags)))))
  366. (add-after
  367. 'unpack 'apply-afl-patches
  368. (lambda* (#:key inputs #:allow-other-keys)
  369. (let* ((afl-src (assoc-ref inputs "afl-source"))
  370. (patch-dir "qemu_mode/patches"))
  371. (copy-recursively (string-append afl-src "/"
  372. patch-dir)
  373. patch-dir)
  374. (install-file
  375. (string-append patch-dir
  376. "/afl-qemu-cpu-inl.h")
  377. ".")
  378. (copy-file (string-append afl-src "/config.h")
  379. "./afl-config.h")
  380. (install-file (string-append afl-src "/types.h")
  381. ".")
  382. (substitute* "afl-qemu-cpu-inl.h"
  383. (("\\.\\./\\.\\./config.h") "afl-config.h"))
  384. (substitute* (string-append patch-dir
  385. "/cpu-exec.diff")
  386. (("\\.\\./patches/") ""))
  387. ;; These were already applied to qemu-minimal-2.10.
  388. (for-each (lambda (obsolete-patch)
  389. (delete-file (string-append
  390. patch-dir "/"
  391. obsolete-patch)))
  392. (list "configure.diff"
  393. "memfd.diff"))
  394. (for-each (lambda (patch-file)
  395. (invoke "patch" "--force" "-p1"
  396. "--input" patch-file))
  397. (find-files patch-dir
  398. "\\.diff$"))
  399. #t)))
  400. (add-before 'check 'disable-unusable-tests
  401. (lambda* (#:key inputs outputs #:allow-other-keys)
  402. (substitute* "tests/Makefile.include"
  403. ;; Comment out the test-qga test, which needs /sys and
  404. ;; fails within the build environment.
  405. (("check-unit-.* tests/test-qga" all)
  406. (string-append "# " all)))
  407. (substitute* "tests/Makefile.include"
  408. ;; Comment out the test-char test, which needs networking and
  409. ;; fails within the build environment.
  410. (("check-unit-.* tests/test-char" all)
  411. (string-append "# " all)))
  412. #t)))))
  413. (native-inputs
  414. `(("python-2" ,python-2) ; QEMU 2 needs Python 2
  415. ("glib:bin" ,glib "bin")
  416. ("perl" ,perl)
  417. ("flex" ,flex)
  418. ("bison" ,bison)
  419. ("pkg-config" ,pkg-config)))
  420. (inputs
  421. `(("afl-source" ,(package-source american-fuzzy-lop))
  422. ("alsa-lib" ,alsa-lib)
  423. ("attr" ,attr)
  424. ("glib" ,glib)
  425. ("libaio" ,libaio)
  426. ("libattr" ,attr)
  427. ("libcap" ,libcap)
  428. ("libjpeg" ,libjpeg-turbo)
  429. ("libpng" ,libpng)
  430. ("ncurses" ,ncurses)
  431. ("pixman" ,pixman)
  432. ("util-linux" ,util-linux)
  433. ("zlib" ,zlib)))
  434. (home-page "https://www.qemu.org")
  435. (synopsis "Machine emulator and virtualizer (without GUI) for american fuzzy lop")
  436. (description
  437. "QEMU is a generic machine emulator and virtualizer. This package
  438. of QEMU is used only by the american fuzzy lop package.
  439. When used as a machine emulator, QEMU can run OSes and programs made for one
  440. machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
  441. using dynamic translation, it achieves very good performance.
  442. When used as a virtualizer, QEMU achieves near native performances by
  443. executing the guest code directly on the host CPU. QEMU supports
  444. virtualization when executing under the Xen hypervisor or using
  445. the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
  446. server and embedded PowerPC, and S390 guests.")
  447. ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
  448. (license license:gpl2)
  449. ;; Several tests fail on MIPS.
  450. (supported-systems (delete "mips64el-linux" %supported-systems))))))
  451. (define-public stress-make
  452. (let ((commit "97815bed8060de33952475b3498767c91f59ffd9")
  453. (revision "2")) ;No official source distribution
  454. (package
  455. (name "stress-make")
  456. (version (git-version "1.0" revision commit))
  457. (source
  458. (origin
  459. (method git-fetch)
  460. (uri (git-reference
  461. (url "https://github.com/lanl/stress-make")
  462. (commit commit)))
  463. (file-name (git-file-name name version))
  464. (sha256
  465. (base32
  466. "0k55cy7x0hlc6rgpascl6ibhcfxaash3p9r9r8kwvbm3zag1rmac"))))
  467. (build-system gnu-build-system)
  468. (native-inputs
  469. (list autoconf automake go))
  470. (inputs
  471. `(("make-source" ,(package-source gnu-make))))
  472. (arguments
  473. ;; stress-make's configure script insists on having a tarball and does
  474. ;; not accept a directory name instead. To let the gnu-build-system's
  475. ;; patch-* phases work properly, we unpack the source first, then
  476. ;; repack before the configure phase.
  477. (let ((make-dir (string-append "make-" (package-version gnu-make))))
  478. `(#:configure-flags '("--with-make-tar=./make.tar.xz"
  479. "make_cv_sys_gnu_glob=yes")
  480. #:phases
  481. (modify-phases %standard-phases
  482. (add-after 'unpack 'unpack-make
  483. (lambda* (#:key inputs #:allow-other-keys)
  484. (invoke "tar" "xf" (assoc-ref inputs "make-source"))))
  485. (add-after 'unpack-make 'set-default-shell
  486. (lambda _
  487. ;; Taken mostly directly from (@ (gnu packages base) gnu-make)
  488. (substitute* (string-append ,make-dir "/src/job.c")
  489. (("default_shell = .*$")
  490. (format #f "default_shell = \"~a\";\n"
  491. (which "sh"))))))
  492. (add-before 'configure 'repack-make
  493. (lambda _
  494. (invoke "tar" "cJf" "./make.tar.xz" ,make-dir)))
  495. (add-before 'build 'setup-go
  496. ;; The Go cache is required starting in Go 1.12, and it needs
  497. ;; to be writable.
  498. (lambda _ (setenv "GOCACHE" "/tmp/go-cache") #t))))))
  499. (home-page "https://github.com/lanl/stress-make")
  500. (synopsis "Expose race conditions in Makefiles")
  501. (description
  502. "Stress Make is a customized GNU Make that explicitly manages the order
  503. in which concurrent jobs are run to provoke erroneous behavior into becoming
  504. manifest. It can run jobs in the order in which they're launched, in backwards
  505. order, or in random order. The thought is that if code builds correctly with
  506. Stress Make, then it is likely that the @code{Makefile} contains no race
  507. conditions.")
  508. ;; stress-make wrapper is under BSD-3-modifications-must-be-indicated,
  509. ;; and patched GNU Make is under its own license.
  510. (license (list (license:non-copyleft "LICENSE.md")
  511. license:gpl3+)))))
  512. (define-public zzuf
  513. (package
  514. (name "zzuf")
  515. (version "0.15")
  516. (source
  517. (origin
  518. (method url-fetch)
  519. (uri (string-append
  520. "https://github.com/samhocevar/zzuf/releases/download/v"
  521. version "/" name "-" version ".tar.gz"))
  522. (file-name (string-append name "-" version ".tar.gz"))
  523. (sha256
  524. (base32
  525. "1mpzjaksc2qg2hzqflf39pl06p53qam2dn3hkhkcv6p00d2n4kx3"))))
  526. (build-system gnu-build-system)
  527. (home-page "https://github.com/samhocevar/zzuf")
  528. (synopsis "Transparent application input fuzzer")
  529. (description "Zzuf is a transparent application input fuzzer. It works by
  530. intercepting file operations and changing random bits in the program's
  531. input. Zzuf's behaviour is deterministic, making it easy to reproduce bugs.")
  532. (license license:wtfpl2)))
  533. (define-public scanmem
  534. (package
  535. (name "scanmem")
  536. (version "0.17")
  537. (source
  538. (origin
  539. (method git-fetch)
  540. (uri (git-reference
  541. (url "https://github.com/scanmem/scanmem")
  542. (commit (string-append "v" version))))
  543. (file-name (git-file-name name version))
  544. (sha256
  545. (base32
  546. "17p8sh0rj8yqz36ria5bp48c8523zzw3y9g8sbm2jwq7sc27i7s9"))))
  547. (build-system gnu-build-system)
  548. (arguments
  549. `(#:configure-flags '("--enable-gui")
  550. #:phases
  551. (modify-phases %standard-phases
  552. (add-before 'configure 'hardcode-python
  553. (lambda* (#:key inputs outputs #:allow-other-keys)
  554. (substitute* "gui/GameConqueror.py"
  555. (("/usr/bin/env python")
  556. (search-input-file inputs "/bin/python")))))
  557. (add-after 'install 'wrap-gameconqueror
  558. (lambda* (#:key inputs outputs #:allow-other-keys)
  559. (let ((out (assoc-ref outputs "out"))
  560. (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
  561. (python-path (getenv "GUIX_PYTHONPATH")))
  562. (wrap-program (string-append out "/share/gameconqueror/GameConqueror.py")
  563. `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
  564. `("GUIX_PYTHONPATH" ":" prefix (,python-path))))
  565. #t)))))
  566. (native-inputs
  567. (list libtool
  568. python-wrapper
  569. gobject-introspection
  570. gtk+
  571. intltool
  572. automake
  573. autoconf))
  574. (inputs
  575. (list readline))
  576. (propagated-inputs
  577. (list python-pygobject))
  578. (home-page "https://github.com/scanmem/scanmem")
  579. (synopsis "Memory scanner")
  580. (description "Scanmem is a debugging utility designed to isolate the
  581. address of an arbitrary variable in an executing process. Scanmem simply
  582. needs to be told the pid of the process and the value of the variable at
  583. several different times. After several scans of the process, scanmem isolates
  584. the position of the variable and allows you to modify its value.")
  585. ;; The library is covered by LGPLv3 or later; the application is covered
  586. ;; by GPLv3 or later.
  587. (license (list license:lgpl3+ license:gpl3+))))
  588. (define-public remake
  589. (package (inherit gnu-make)
  590. (name "remake")
  591. (version "4.3-1.6")
  592. (source (origin
  593. (method url-fetch)
  594. (uri (let ((upstream-version
  595. (match (string-split version #\-)
  596. ((ver sub) (string-append ver "%2Bdbg-" sub)))))
  597. (string-append "mirror://sourceforge/bashdb/"
  598. "remake/" upstream-version "/"
  599. "remake-" upstream-version ".tar.gz")))
  600. (file-name (string-append "remake-" version ".tar.gz"))
  601. (sha256
  602. (base32
  603. "11vvch8bi0yhjfz7gn92b3xmmm0cgi3qfiyhbnnj89frkhbwd87n"))
  604. (patches (search-patches "remake-impure-dirs.patch"))))
  605. (inputs
  606. (modify-inputs (package-inputs gnu-make)
  607. (prepend readline)))
  608. (home-page "https://bashdb.sourceforge.net/remake/")
  609. (description "Remake is an enhanced version of GNU Make that adds improved
  610. error reporting, better tracing, profiling, and a debugger.")
  611. (license license:gpl3+)))
  612. (define-public rr
  613. (package
  614. (name "rr")
  615. (version "5.6.0")
  616. (source (origin
  617. (method git-fetch)
  618. (uri (git-reference
  619. (url "https://github.com/mozilla/rr")
  620. (commit version)))
  621. (sha256
  622. (base32
  623. "0sdpsd7bcbmx9gmp7lv71znzxz708wm8qxq5apbyc6hh80z4fzqz"))
  624. (file-name (git-file-name name version))))
  625. (build-system cmake-build-system)
  626. (arguments
  627. `(#:configure-flags
  628. ;; The 'rr_exec_stub' is a static binary, which leads CMake to fail
  629. ;; with ‘file RPATH_CHANGE could not write new RPATH: ...’.
  630. ;; Clear CMAKE_INSTALL_RPATH to avoid that problem.
  631. (list "-DCMAKE_INSTALL_RPATH="
  632. ;; Satisfy the ‘validate-runpath’ phase. This isn't a direct
  633. ;; consequence of clearing CMAKE_INSTALL_RPATH.
  634. (string-append "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath="
  635. (assoc-ref %build-inputs "capnproto")
  636. "/lib,-rpath=" (assoc-ref %build-inputs "zlib")
  637. "/lib")
  638. ,@(if (and (not (%current-target-system))
  639. (member (%current-system)
  640. '("x86_64-linux" "aarch64-linux")))
  641. ;; The toolchain doesn't support '-m32'.
  642. '("-Ddisable32bit=ON")
  643. '()))
  644. ;; XXX: Most tests fail with:
  645. ;;
  646. ;; rr needs /proc/sys/kernel/perf_event_paranoid <= 1, but it is 2.
  647. ;;
  648. ;; This setting cannot be changed from the build environment, so skip
  649. ;; the tests.
  650. #:tests? #f
  651. #:phases (modify-phases %standard-phases
  652. (add-before 'check 'set-home
  653. (lambda _
  654. ;; Some tests expect 'HOME' to be set.
  655. (setenv "HOME" (getcwd))
  656. #t)))))
  657. (native-inputs
  658. (list pkg-config ninja which))
  659. (inputs
  660. (list gdb capnproto python python-pexpect zlib))
  661. (home-page "https://rr-project.org/")
  662. (synopsis "Record and reply debugging framework")
  663. (description
  664. "rr is a lightweight tool for recording, replaying and debugging
  665. execution of applications (trees of processes and threads). Debugging extends
  666. GDB with very efficient reverse-execution, which in combination with standard
  667. GDB/x86 features like hardware data watchpoints, makes debugging much more
  668. fun.")
  669. (license license:expat)))
  670. (define-public libbacktrace
  671. ;; There are no releases nor tags.
  672. (let ((revision "2")
  673. (commit "cdb64b688dda93bbbacbc2b1ccf50ce9329d4748"))
  674. (package
  675. (name "libbacktrace")
  676. (version (git-version "1.0" revision commit))
  677. (source (origin
  678. (method git-fetch)
  679. (uri (git-reference
  680. (url "https://github.com/ianlancetaylor/libbacktrace")
  681. (commit commit)))
  682. (file-name (git-file-name name version))
  683. (sha256
  684. (base32
  685. "0iwd41pgr2nxlmghqdfwfwxac27jbqxwxp07jihhq85a8s3igjgr"))))
  686. (build-system gnu-build-system)
  687. (arguments
  688. `(#:parallel-tests? #f ;spurious failures when testing in parallel
  689. #:make-flags '("CFLAGS=-fPIC")))
  690. (home-page "https://github.com/ianlancetaylor/libbacktrace")
  691. (synopsis "C library for producing symbolic backtraces")
  692. (description "The @code{libbacktrace} library can be linked into a C/C++
  693. program to produce symbolic backtraces.")
  694. (license license:bsd-3))))
  695. (define-public libleak
  696. (package
  697. (name "libleak")
  698. (version "0.3.5")
  699. (source (origin
  700. (method git-fetch)
  701. (uri (git-reference
  702. (url "https://github.com/WuBingzheng/libleak")
  703. (commit (string-append "v" version))))
  704. (file-name (git-file-name name version))
  705. (sha256
  706. (base32
  707. "1p8mb0hcfp8hdv1klv6rrpkn2zlhjxgkxbbjsk8kszxv7ijln87d"))))
  708. (build-system gnu-build-system)
  709. (arguments
  710. `(#:tests? #f ;no test suite
  711. #:parallel-build? #f ;jobserver unavailable
  712. #:phases (modify-phases %standard-phases
  713. (add-after 'unpack 'unbundle-libwuya
  714. (lambda _
  715. (substitute* "Makefile"
  716. ((".*make -C libwuya.*") ""))
  717. #t))
  718. (add-before 'build 'set-CC
  719. (lambda _
  720. (setenv "CC" "gcc")
  721. #t))
  722. (delete 'configure) ;no configure script
  723. (replace 'install
  724. (lambda* (#:key outputs #:allow-other-keys)
  725. (let* ((out (assoc-ref outputs "out")))
  726. (install-file "libleak.so" (string-append out "/lib"))
  727. #t))))))
  728. (inputs (list libbacktrace libwuya))
  729. (home-page "https://github.com/WuBingzheng/libleak")
  730. (synopsis "Memory leaks detection tool")
  731. (description "The libleak tool detects memory leaks by hooking memory
  732. functions such as @code{malloc}. It comes as a shared object to be pre-loaded
  733. via @code{LD_PRELOAD} when launching the application. It prints the full call
  734. stack at suspicious memory leak points. Modifying or recompiling the target
  735. program is not required, and the detection can be enabled or disabled while
  736. the target application is running. The overhead incurred by libleak is
  737. smaller than that of other tools such as Valgrind, and it aims to be easier to
  738. use than similar tools like @command{mtrace}.")
  739. (license license:gpl2+)))
  740. (define-public cgdb
  741. (package
  742. (name "cgdb")
  743. (version "0.8.0")
  744. (source
  745. (origin
  746. (method url-fetch)
  747. (uri (string-append "https://cgdb.me/files/cgdb-" version ".tar.gz"))
  748. (sha256
  749. (base32 "1w8ib2vg3pg68d9hh97fw5042c73i9nqavdddc87n9bpscjbaf0d"))))
  750. (build-system gnu-build-system)
  751. (inputs
  752. (list bash-minimal ncurses readline gdb))
  753. (native-inputs
  754. (list flex texinfo))
  755. (arguments
  756. `(#:configure-flags
  757. (list
  758. (string-append "ac_cv_rl_version=" ,(package-version readline))
  759. "ac_cv_file__dev_ptmx=no"
  760. "ac_cv_file__proc_self_status=no"
  761. "ac_cv_func_setpgrp_void=no")
  762. #:phases
  763. (modify-phases %standard-phases
  764. (add-after 'unpack 'fix-paths
  765. (lambda* (#:key inputs #:allow-other-keys)
  766. (let ((gdb (search-input-file inputs "bin/gdb"))
  767. (sh (search-input-file inputs "bin/sh")))
  768. (substitute* "lib/util/fork_util.cpp"
  769. (("GDB = \"gdb\"") (string-append "GDB = \"" gdb "\"")))
  770. (substitute* "cgdb/cgdb.cpp" (("/bin/sh") sh))))))))
  771. (home-page "https://cgdb.github.io")
  772. (synopsis "Console front-end to the GNU debugger")
  773. (description
  774. "@code{cgdb} is a lightweight curses (terminal-based) interface to the
  775. GNU Debugger (GDB). In addition to the standard gdb console, cgdb provides
  776. a split screen view that displays the source code as it executes. The
  777. keyboard interface is modeled after vim, so vim users should feel at home
  778. using cgdb.")
  779. (license license:gpl2+)))
  780. (define-public mspdebug
  781. ;; Last official release was 24 July 2017
  782. (let ((commit "4c4d94e43bc4a18ecf82070ff81cd38dd5641e3b")
  783. (revision "0"))
  784. (package
  785. (name "mspdebug")
  786. (version (git-version "0.25" revision commit))
  787. (source (origin
  788. (method git-fetch)
  789. (uri (git-reference
  790. (url "https://github.com/dlbeer/mspdebug")
  791. (commit commit)))
  792. (file-name (git-file-name name version))
  793. (sha256
  794. (base32 "1lgw1dsc1aglyja610ichadvgs5b0df3wlarinczb0ykf431gjln"))))
  795. (build-system gnu-build-system)
  796. (arguments
  797. `(#:tests? #f ; no test suite
  798. #:phases
  799. (modify-phases %standard-phases
  800. (delete 'configure)) ; no configure script
  801. #:make-flags
  802. (list (string-append "CC=" ,(cc-for-target))
  803. "INSTALL=install"
  804. (string-append "PREFIX=" %output))))
  805. (inputs
  806. (list libusb-compat readline))
  807. (synopsis "Debugging tool for MSP430 MCUs")
  808. (description "MspDebug supports FET430UIF, eZ430, RF2500 and Olimex
  809. MSP430-JTAG-TINY programmers, as well as many other compatible
  810. devices. It can be used as a proxy for gdb or as an independent
  811. debugger with support for programming, disassembly and reverse
  812. engineering.")
  813. (home-page "https://github.com/dlbeer/mspdebug")
  814. (license license:gpl2+))))
  815. (define-public seer-gdb
  816. (package
  817. (name "seer-gdb")
  818. (version "1.16")
  819. (source (origin
  820. (method git-fetch)
  821. (uri (git-reference
  822. (url "https://github.com/epasveer/seer.git")
  823. (commit (string-append "v" version))))
  824. (file-name (string-append name "-" version "-checkout"))
  825. (sha256
  826. (base32
  827. "0jdvyg2jab1pvf36pvkyrfsg2wyy8zp1qx0v2ksclgrnr1hja6k6"))))
  828. (build-system cmake-build-system)
  829. (arguments
  830. `(#:tests? #f ; Those are strangely manual
  831. #:phases
  832. (modify-phases %standard-phases
  833. (add-after 'unpack 'chdir
  834. (lambda _
  835. (chdir "src"))))))
  836. (inputs
  837. (list qtbase-5 qtcharts))
  838. (synopsis "GUI frontend for GDB")
  839. (description "This package provides a frontend to GDB, the GNU debugger.")
  840. (home-page "https://github.com/epasveer/seer")
  841. ;; Note: Some icons in src/resources are creative commons 3.0 and/or 4.0.
  842. (license license:gpl3+)))
  843. (define-public ddd
  844. (package
  845. (name "ddd")
  846. (version "3.4.0")
  847. (source (origin
  848. (method url-fetch)
  849. (uri (string-append "mirror://gnu/ddd/ddd-" version ".tar.gz"))
  850. (sha256
  851. (base32
  852. "03sqsfiri5p130cmmzh2wikg0gisql496rvdhr1qaidh1f5bqk2x"))))
  853. (build-system gnu-build-system)
  854. (arguments
  855. (list #:tests? #f ;tests require manual intervention
  856. ;; Avoid "friend declaration specifies default arguments and isn’t
  857. ;; a definition" errors.
  858. #:configure-flags #~(list "CXXFLAGS=-fpermissive")))
  859. (native-inputs
  860. (list pkg-config))
  861. (inputs
  862. (list motif ncurses gdb))
  863. (synopsis "Graphical front-end for GDB and other debuggers")
  864. (description "GNU DDD, the Data Display Debugger, is a graphical front-end
  865. for command-line debuggers. Many back-end debuggers are supported, notably
  866. the GNU debugger, GDB. In addition to usual debugging features such as
  867. viewing the source files, DDD has additional graphical, interactive features
  868. to aid in debugging.")
  869. (home-page "https://www.gnu.org/software/ddd/")
  870. (license license:gpl3+)))
  871. (define-public delve
  872. (package
  873. (name "delve")
  874. (version "1.9.1")
  875. (source
  876. (origin
  877. (method git-fetch)
  878. (uri (git-reference
  879. (url "https://github.com/go-delve/delve")
  880. (commit (string-append "v" version))))
  881. (file-name (git-file-name name version))
  882. (sha256
  883. (base32
  884. "07jch3yd1pgqviyy18amn23gazbzi7l51f210c3vmc707v3vbbqr"))))
  885. (build-system go-build-system)
  886. (arguments
  887. (list #:import-path "github.com/go-delve/delve/cmd/dlv"
  888. #:unpack-path "github.com/go-delve/delve"
  889. #:install-source? #f
  890. #:phases #~(modify-phases %standard-phases (delete 'check))))
  891. (propagated-inputs (list go))
  892. (home-page "https://github.com/go-delve/delve")
  893. (synopsis "Debugger for the Go programming language")
  894. (description "Delve is a debugger for the Go programming language.")
  895. (license license:expat)))