1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2020 Eric Bavier <bavier@posteo.net>
3 ;;; Copyright © 2016, 2017, 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2018 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 Morgan Smith <Morgan.J.Smith@outlook.com>
10 ;;; This file is part of GNU Guix.
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.
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.
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/>.
25 (define-module (gnu packages debug)
26 #:use-module (guix packages)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix utils)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system cmake)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages attr)
35 #:use-module (gnu packages autotools)
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages bash)
38 #:use-module (gnu packages bison)
39 #:use-module (gnu packages code)
40 #:use-module (gnu packages compression)
41 #:use-module (gnu packages flex)
42 #:use-module (gnu packages gdb)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages gtk)
45 #:use-module (gnu packages golang)
46 #:use-module (gnu packages image)
47 #:use-module (gnu packages libusb)
48 #:use-module (gnu packages linux)
49 #:use-module (gnu packages llvm)
50 #:use-module (gnu packages ncurses)
51 #:use-module (gnu packages ninja)
52 #:use-module (gnu packages perl)
53 #:use-module (gnu packages pkg-config)
54 #:use-module (gnu packages pretty-print)
55 #:use-module (gnu packages python)
56 #:use-module (gnu packages python-xyz)
57 #:use-module (gnu packages readline)
58 #:use-module (gnu packages serialization)
59 #:use-module (gnu packages virtualization)
60 #:use-module (gnu packages xdisorg)
61 #:use-module (ice-9 match)
62 #:use-module (srfi srfi-1))
67 (version "2006.08.03")
72 (string-append "mirror://debian/pool/main/d/delta/"
73 "delta_" version ".orig.tar.gz")
74 ;; This uri seems to send guix download into an infinite loop
75 (string-append "http://delta.tigris.org/files/documents/3103/"
76 "33566/delta-" version ".tar.gz")))
79 "184wh35pf2ddx97319s6sgkzpz48xxkbwzcjpycv009bm53lh61q"))))
80 (build-system gnu-build-system)
81 (inputs ;Installed programs are perl scripts
85 (modify-phases %standard-phases
87 (lambda* (#:key outputs #:allow-other-keys)
88 ;; Makefile contains no install target
89 (let* ((out (assoc-ref outputs "out"))
90 (bin (string-append out "/bin"))
91 (doc (string-append out "/share/doc/delta-" ,version)))
95 `("License.txt" ,@(find-files "www" ".*\\.html")))
98 `("delta" "multidelta" "topformflat"))))
100 (delete 'configure)))) ; no configure script
101 (home-page "http://delta.tigris.org/")
102 (synopsis "Heuristical file minimizer")
104 "Delta assists you in minimizing \"interesting\" files subject to a test
105 of their interestingness. A common such situation is when attempting to
106 isolate a small failure-inducing substring of a large input that causes your
107 program to exhibit a bug.")
108 ;; See License.txt, which is a bsd-3 license, despite the project's
109 ;; home-page pointing to a bsd-2 license.
110 (license license:bsd-3)))
112 (define-public c-reduce
120 (string-append "http://embed.cs.utah.edu/creduce/"
121 "creduce-" version ".tar.gz")))
123 (base32 "0qx0zq8jxzx2as2zf0740g7kvgq163ayn3041di4vwk77490y76v"))))
124 (build-system gnu-build-system)
125 (native-inputs `(("flex" ,flex)))
132 ("exporter-lite" ,perl-exporter-lite)
133 ("file-which" ,perl-file-which)
134 ("getopt-tabular" ,perl-getopt-tabular)
135 ("regex-common" ,perl-regexp-common)
136 ("term-readkey" ,perl-term-readkey)))
139 (modify-phases %standard-phases
142 (with-directory-excursion "tests"
143 ;; Running all tests can take a looong time, and tests 4 and 5
144 ;; require frama-c or kcc. So run just one for sanity.
145 (invoke "./run_tests" "1"))))
146 (add-after 'install 'set-load-paths
147 (lambda* (#:key inputs outputs #:allow-other-keys)
148 ;; Tell creduce where to find the perl modules it needs.
149 (let* ((out (assoc-ref outputs "out"))
150 (prog (string-append out "/bin/creduce")))
153 `("PERL5LIB" ":" prefix
155 (string-append (assoc-ref inputs p)
156 "/lib/perl5/site_perl/"
157 ,(package-version perl)))
158 '("term-readkey" "exporter-lite"
159 "file-which" "getopt-tabular"
162 (home-page "https://embed.cs.utah.edu/creduce")
163 (synopsis "Reducer for interesting code")
165 "C-Reduce is a tool that takes a large C or C++ program that has a
166 property of interest (such as triggering a compiler bug) and automatically
167 produces a much smaller C/C++ program that has the same property. It is
168 intended for use by people who discover and report bugs in compilers and other
169 tools that process C/C++ code.")
170 (license license:ncsa)))
172 (define-public american-fuzzy-lop
173 (let ((machine (match (or (%current-target-system)
175 ("x86_64-linux" "x86_64")
176 ("i686-linux" "i386")
177 ("aarch64-linux" "aarch64")
178 ("armhf-linux" "arm")
179 ("mips64el-linux" "mips64el")
180 ;; Prevent errors when querying this package on unsupported
181 ;; platforms, e.g. when running "guix package --search="
184 (name "american-fuzzy-lop")
185 (version "2.56b") ;It seems all releases have the 'b' suffix
190 (url "https://github.com/google/AFL")
191 (commit (string-append "v" version))))
193 (base32 "1q1g59gkm48aa4cg9h70jx4i2gapmypgp5rzs156b2avd95vwkn1"))
194 (file-name (git-file-name name version))))
195 (build-system gnu-build-system)
197 `(("qemu" ,qemu-for-american-fuzzy-lop)))
199 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
200 (string-append "DOC_PATH=$(PREFIX)/share/doc/"
203 #:phases (modify-phases %standard-phases
204 (add-after 'unpack 'make-git-checkout-writable
206 (for-each make-file-writable (find-files "."))
209 ,@(if (string=? (%current-system) (or "x86_64-linux"
212 '((add-before 'build 'set-afl-flag
213 (lambda _ (setenv "AFL_NO_X86" "1") #t))
214 (add-after 'install 'remove-x86-programs
215 (lambda* (#:key outputs #:allow-other-keys)
216 (let* ((out (assoc-ref outputs "out"))
217 (bin (string-append out "/bin/")))
218 (delete-file (string-append bin "afl-gcc"))
219 (delete-file (string-append bin "afl-g++"))
220 (delete-file (string-append bin "afl-clang"))
221 (delete-file (string-append bin "afl-clang++")))
224 ;; TODO: Build and install the afl-llvm tool.
225 'install 'install-qemu
226 (lambda* (#:key inputs outputs #:allow-other-keys)
227 (let ((qemu (assoc-ref inputs "qemu"))
228 (out (assoc-ref outputs "out")))
229 (symlink (string-append qemu "/bin/qemu-" ,machine)
230 (string-append out "/bin/afl-qemu-trace"))
232 (delete 'check)))) ; tests are run during 'install phase
233 (home-page "https://lcamtuf.coredump.cx/afl/")
234 (synopsis "Security-oriented fuzzer")
236 "American fuzzy lop is a security-oriented fuzzer that employs a novel
237 type of compile-time instrumentation and genetic algorithms to automatically
238 discover clean, interesting test cases that trigger new internal states in the
239 targeted binary. This substantially improves the functional coverage for the
240 fuzzed code. The compact synthesized corpora produced by the tool are also
241 useful for seeding other, more labor- or resource-intensive testing regimes
243 (license license:asl2.0))))
245 (define-public qemu-for-american-fuzzy-lop
246 ;; afl only supports using a single afl-qemu-trace executable, so
247 ;; we only build qemu for the native target.
248 (let ((machine (match (or (%current-target-system)
250 ("x86_64-linux" "x86_64")
251 ("i686-linux" "i386")
252 ("aarch64-linux" "aarch64")
253 ("armhf-linux" "arm")
254 ("mips64el-linux" "mips64el")
255 ;; Prevent errors when querying this package on unsupported
256 ;; platforms, e.g. when running "guix package --search="
264 (uri (string-append "https://download.qemu.org/qemu-"
268 "17w21spvaxaidi2am5lpsln8yjpyp2zi3s3gc6nsxj5arlgamzgw"))
270 (search-patches "qemu-glibc-2.27.patch"))))
271 (build-system gnu-build-system)
273 `(;; Running tests in parallel can occasionally lead to failures, like:
274 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
277 (list (string-append "--target-list=" ,machine "-linux-user"))
278 #:make-flags '("V=1")
280 (modify-phases %standard-phases
282 (lambda* (#:key inputs outputs (configure-flags '())
284 ;; The `configure' script doesn't understand some of the
285 ;; GNU options. Thus, add a new phase that's compatible.
286 (let ((out (assoc-ref outputs "out")))
287 (setenv "SHELL" (which "bash"))
289 ;; While we're at it, patch for tests.
290 (substitute* "tests/libqtest.c"
291 (("/bin/sh") (which "sh")))
293 ;; The binaries need to be linked against -lrt.
294 (setenv "LDFLAGS" "-lrt")
297 ,(string-append "--cc=" (which "gcc"))
298 ;; Some architectures insist on using HOST_CC
299 ,(string-append "--host-cc=" (which "gcc"))
300 "--disable-debug-info" ; save build space
301 "--enable-virtfs" ; just to be sure
302 ,(string-append "--prefix=" out)
303 ,(string-append "--sysconfdir=/etc")
304 ,@configure-flags)))))
306 'unpack 'apply-afl-patches
307 (lambda* (#:key inputs #:allow-other-keys)
308 (let* ((afl-src (assoc-ref inputs "afl-source"))
309 (patch-dir "qemu_mode/patches"))
310 (copy-recursively (string-append afl-src "/"
314 (string-append patch-dir
315 "/afl-qemu-cpu-inl.h")
317 (copy-file (string-append afl-src "/config.h")
319 (install-file (string-append afl-src "/types.h")
321 (substitute* "afl-qemu-cpu-inl.h"
322 (("\\.\\./\\.\\./config.h") "afl-config.h"))
323 (substitute* (string-append patch-dir
325 (("\\.\\./patches/") ""))
327 ;; These were already applied to qemu-minimal-2.10.
328 (for-each (lambda (obsolete-patch)
329 (delete-file (string-append
332 (list "configure.diff"
335 (for-each (lambda (patch-file)
336 (invoke "patch" "--force" "-p1"
337 "--input" patch-file))
338 (find-files patch-dir
341 (add-before 'check 'disable-unusable-tests
342 (lambda* (#:key inputs outputs #:allow-other-keys)
343 (substitute* "tests/Makefile.include"
344 ;; Comment out the test-qga test, which needs /sys and
345 ;; fails within the build environment.
346 (("check-unit-.* tests/test-qga" all)
347 (string-append "# " all)))
348 (substitute* "tests/Makefile.include"
349 ;; Comment out the test-char test, which needs networking and
350 ;; fails within the build environment.
351 (("check-unit-.* tests/test-char" all)
352 (string-append "# " all)))
355 `(("python-2" ,python-2) ; QEMU 2 needs Python 2
356 ("glib:bin" ,glib "bin")
360 ("pkg-config" ,pkg-config)))
362 `(("afl-source" ,(package-source american-fuzzy-lop))
363 ("alsa-lib" ,alsa-lib)
369 ("libjpeg" ,libjpeg-turbo)
373 ("util-linux" ,util-linux)
375 (home-page "https://www.qemu.org")
376 (synopsis "Machine emulator and virtualizer (without GUI) for american fuzzy lop")
378 "QEMU is a generic machine emulator and virtualizer. This package
379 of QEMU is used only by the american fuzzy lop package.
381 When used as a machine emulator, QEMU can run OSes and programs made for one
382 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
383 using dynamic translation, it achieves very good performance.
385 When used as a virtualizer, QEMU achieves near native performances by
386 executing the guest code directly on the host CPU. QEMU supports
387 virtualization when executing under the Xen hypervisor or using
388 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
389 server and embedded PowerPC, and S390 guests.")
390 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
391 (license license:gpl2)
392 ;; Several tests fail on MIPS.
393 (supported-systems (delete "mips64el-linux" %supported-systems))))))
395 (define-public stress-make
396 (let ((commit "97815bed8060de33952475b3498767c91f59ffd9")
397 (revision "2")) ;No official source distribution
400 (version (git-version "1.0" revision commit))
405 (url "https://github.com/lanl/stress-make")
407 (file-name (git-file-name name version))
410 "0k55cy7x0hlc6rgpascl6ibhcfxaash3p9r9r8kwvbm3zag1rmac"))))
411 (build-system gnu-build-system)
413 `(("autoconf" ,autoconf)
414 ("automake" ,automake)
417 `(("make-source" ,(package-source gnu-make))))
419 ;; stress-make's configure script insists on having a tarball and does
420 ;; not accept a directory name instead. To let the gnu-build-system's
421 ;; patch-* phases work properly, we unpack the source first, then
422 ;; repack before the configure phase.
423 (let ((make-dir (string-append "make-" (package-version gnu-make))))
424 `(#:configure-flags '("--with-make-tar=./make.tar.xz"
425 "make_cv_sys_gnu_glob=yes")
427 (modify-phases %standard-phases
428 (add-after 'unpack 'unpack-make
429 (lambda* (#:key inputs #:allow-other-keys)
430 (invoke "tar" "xf" (assoc-ref inputs "make-source"))))
431 (add-after 'unpack-make 'set-default-shell
433 ;; Taken mostly directly from (@ (gnu packages base) gnu-make)
434 (substitute* (string-append ,make-dir "/src/job.c")
435 (("default_shell = .*$")
436 (format #f "default_shell = \"~a\";\n"
438 (add-before 'configure 'repack-make
440 (invoke "tar" "cJf" "./make.tar.xz" ,make-dir)))
441 (add-before 'build 'setup-go
442 ;; The Go cache is required starting in Go 1.12, and it needs
444 (lambda _ (setenv "GOCACHE" "/tmp/go-cache") #t))))))
445 (home-page "https://github.com/lanl/stress-make")
446 (synopsis "Expose race conditions in Makefiles")
448 "Stress Make is a customized GNU Make that explicitly manages the order
449 in which concurrent jobs are run to provoke erroneous behavior into becoming
450 manifest. It can run jobs in the order in which they're launched, in backwards
451 order, or in random order. The thought is that if code builds correctly with
452 Stress Make, then it is likely that the @code{Makefile} contains no race
454 ;; stress-make wrapper is under BSD-3-modifications-must-be-indicated,
455 ;; and patched GNU Make is under its own license.
456 (license (list (license:non-copyleft "LICENSE.md")
467 "https://github.com/samhocevar/zzuf/releases/download/v"
468 version "/" name "-" version ".tar.gz"))
469 (file-name (string-append name "-" version ".tar.gz"))
472 "1mpzjaksc2qg2hzqflf39pl06p53qam2dn3hkhkcv6p00d2n4kx3"))))
473 (build-system gnu-build-system)
474 (home-page "https://github.com/samhocevar/zzuf")
475 (synopsis "Transparent application input fuzzer")
476 (description "Zzuf is a transparent application input fuzzer. It works by
477 intercepting file operations and changing random bits in the program's
478 input. Zzuf's behaviour is deterministic, making it easy to reproduce bugs.")
479 (license license:wtfpl2)))
481 (define-public scanmem
489 (url "https://github.com/scanmem/scanmem")
490 (commit (string-append "v" version))))
491 (file-name (git-file-name name version))
494 "17p8sh0rj8yqz36ria5bp48c8523zzw3y9g8sbm2jwq7sc27i7s9"))))
495 (build-system gnu-build-system)
497 `(#:configure-flags '("--enable-gui")
499 (modify-phases %standard-phases
500 (add-before 'configure 'hardcode-python
501 (lambda* (#:key inputs outputs #:allow-other-keys)
502 (substitute* "gui/GameConqueror.py"
503 (("/usr/bin/env python")
504 (string-append (assoc-ref %build-inputs
505 "python-wrapper") "/bin/python")))
507 (add-after 'install 'wrap-gameconqueror
508 (lambda* (#:key inputs outputs #:allow-other-keys)
509 (let ((out (assoc-ref outputs "out"))
510 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
511 (python-path (getenv "PYTHONPATH")))
512 (wrap-program (string-append out "/share/gameconqueror/GameConqueror.py")
513 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
514 `("PYTHONPATH" ":" prefix (,python-path))))
517 `(("libtool" ,libtool)
518 ("python-wrapper" ,python-wrapper)
519 ("gobject-introspection" ,gobject-introspection)
521 ("intltool" ,intltool)
522 ("automake" ,automake)
523 ("autoconf" ,autoconf)))
525 `(("readline" ,readline)))
527 `(("python-pygobject" ,python-pygobject)))
528 (home-page "https://github.com/scanmem/scanmem")
529 (synopsis "Memory scanner")
530 (description "Scanmem is a debugging utility designed to isolate the
531 address of an arbitrary variable in an executing process. Scanmem simply
532 needs to be told the pid of the process and the value of the variable at
533 several different times. After several scans of the process, scanmem isolates
534 the position of the variable and allows you to modify its value.")
535 ;; The library is covered by LGPLv3 or later; the application is covered
536 ;; by GPLv3 or later.
537 (license (list license:lgpl3+ license:gpl3+))))
539 (define-public remake
540 (package (inherit gnu-make)
545 (uri (let ((upstream-version
546 (match (string-split version #\-)
547 ((ver sub) (string-append ver "%2Bdbg-" sub)))))
548 (string-append "mirror://sourceforge/bashdb/"
549 "remake/" upstream-version "/"
550 "remake-" upstream-version ".tar.gz")))
551 (file-name (string-append "remake-" version ".tar.gz"))
554 "0xlx2485y0israv2pfghmv74lxcv9i5y65agy69mif76yc4vfvif"))
555 (patches (search-patches "remake-impure-dirs.patch"))))
557 `(("readline" ,readline)
558 ,@(package-inputs gnu-make)))
559 (home-page "http://bashdb.sourceforge.net/remake/")
560 (description "Remake is an enhanced version of GNU Make that adds improved
561 error reporting, better tracing, profiling, and a debugger.")
562 (license license:gpl3+)))
571 (url "https://github.com/mozilla/rr")
575 "1x6l1xsdksnhz9v50p4r7hhmr077cq20kaywqy1jzdklvkjqzf64"))
576 (file-name (git-file-name name version))))
577 (build-system cmake-build-system)
580 ;; The 'rr_exec_stub' is a static binary, which leads CMake to fail
583 ;; file RPATH_CHANGE could not write new RPATH:
585 ;; Clear CMAKE_INSTALL_RPATH to avoid that problem.
586 (list "-DCMAKE_INSTALL_RPATH="
587 ,@(if (and (not (%current-target-system))
588 (member (%current-system)
589 '("x86_64-linux" "aarch64-linux")))
590 ;; The toolchain doesn't support '-m32'.
591 '("-Ddisable32bit=ON")
594 ;; XXX: Most tests fail with:
596 ;; rr needs /proc/sys/kernel/perf_event_paranoid <= 1, but it is 2.
598 ;; This setting cannot be changed from the build environment, so skip
602 #:phases (modify-phases %standard-phases
603 (add-before 'check 'set-home
605 ;; Some tests expect 'HOME' to be set.
606 (setenv "HOME" (getcwd))
609 `(("pkg-config" ,pkg-config)
614 ("cpanproto" ,capnproto)
616 ("python-pexpect" ,python-pexpect)))
617 (home-page "https://rr-project.org/")
618 (synopsis "Record and reply debugging framework")
620 "rr is a lightweight tool for recording, replaying and debugging
621 execution of applications (trees of processes and threads). Debugging extends
622 GDB with very efficient reverse-execution, which in combination with standard
623 GDB/x86 features like hardware data watchpoints, makes debugging much more
625 (license license:expat)))
627 (define-public mspdebug
634 (url "https://github.com/dlbeer/mspdebug")
635 (commit (string-append "v" version))))
636 (file-name (git-file-name name version))
638 (base32 "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"))))
639 (build-system gnu-build-system)
641 `(#:tests? #f ; no test suite
643 (modify-phases %standard-phases
644 (delete 'configure)) ; no configure script
646 (list (string-append "CC=" ,(cc-for-target))
648 (string-append "PREFIX=" %output))))
650 `(("libusb-compat" ,libusb-compat)
651 ("readline" ,readline)))
652 (synopsis "Debugging tool for MSP430 MCUs")
653 (description "MspDebug supports FET430UIF, eZ430, RF2500 and Olimex
654 MSP430-JTAG-TINY programmers, as well as many other compatible
655 devices. It can be used as a proxy for gdb or as an independent
656 debugger with support for programming, disassembly and reverse
658 (home-page "https://github.com/dlbeer/mspdebug")
659 (license license:gpl2+)))