debug.scm 35 KB

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