1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017, 2019 Eric Bavier <bavier@member.fsf.org>
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>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages debug)
24 #:use-module (guix packages)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix utils)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system cmake)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages attr)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages base)
35 #:use-module (gnu packages bash)
36 #:use-module (gnu packages bison)
37 #:use-module (gnu packages code)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages flex)
40 #:use-module (gnu packages gdb)
41 #:use-module (gnu packages glib)
42 #:use-module (gnu packages gtk)
43 #:use-module (gnu packages golang)
44 #:use-module (gnu packages image)
45 #:use-module (gnu packages linux)
46 #:use-module (gnu packages llvm)
47 #:use-module (gnu packages ncurses)
48 #:use-module (gnu packages ninja)
49 #:use-module (gnu packages perl)
50 #:use-module (gnu packages pkg-config)
51 #:use-module (gnu packages pretty-print)
52 #:use-module (gnu packages python)
53 #:use-module (gnu packages python-xyz)
54 #:use-module (gnu packages readline)
55 #:use-module (gnu packages serialization)
56 #:use-module (gnu packages virtualization)
57 #:use-module (gnu packages xdisorg)
58 #:use-module (ice-9 match)
59 #:use-module (srfi srfi-1))
64 (version "2006.08.03")
69 (string-append "mirror://debian/pool/main/d/delta/"
70 "delta_" version ".orig.tar.gz")
71 ;; This uri seems to send guix download into an infinite loop
72 (string-append "http://delta.tigris.org/files/documents/3103/"
73 "33566/delta-" version ".tar.gz")))
76 "184wh35pf2ddx97319s6sgkzpz48xxkbwzcjpycv009bm53lh61q"))))
77 (build-system gnu-build-system)
78 (inputs ;Installed programs are perl scripts
82 (modify-phases %standard-phases
84 (lambda* (#:key outputs #:allow-other-keys)
85 ;; Makefile contains no install target
86 (let* ((out (assoc-ref outputs "out"))
87 (bin (string-append out "/bin"))
88 (doc (string-append out "/share/doc/delta-" ,version)))
92 `("License.txt" ,@(find-files "www" ".*\\.html")))
95 `("delta" "multidelta" "topformflat"))))
97 (delete 'configure)))) ; no configure script
98 (home-page "http://delta.tigris.org/")
99 (synopsis "Heuristical file minimizer")
101 "Delta assists you in minimizing \"interesting\" files subject to a test
102 of their interestingness. A common such situation is when attempting to
103 isolate a small failure-inducing substring of a large input that causes your
104 program to exhibit a bug.")
105 ;; See License.txt, which is a bsd-3 license, despite the project's
106 ;; home-page pointing to a bsd-2 license.
107 (license license:bsd-3)))
109 (define-public c-reduce
117 (string-append "http://embed.cs.utah.edu/creduce/"
118 "creduce-" version ".tar.gz")))
120 (base32 "0qx0zq8jxzx2as2zf0740g7kvgq163ayn3041di4vwk77490y76v"))))
121 (build-system gnu-build-system)
129 ("exporter-lite" ,perl-exporter-lite)
130 ("file-which" ,perl-file-which)
131 ("getopt-tabular" ,perl-getopt-tabular)
132 ("regex-common" ,perl-regexp-common)
133 ("term-readkey" ,perl-term-readkey)))
136 (modify-phases %standard-phases
139 (with-directory-excursion "tests"
140 ;; Running all tests can take a looong time, and tests 4 and 5
141 ;; require frama-c or kcc. So run just one for sanity.
142 (invoke "./run_tests" "1"))))
143 (add-after 'install 'set-load-paths
144 (lambda* (#:key inputs outputs #:allow-other-keys)
145 ;; Tell creduce where to find the perl modules it needs.
146 (let* ((out (assoc-ref outputs "out"))
147 (prog (string-append out "/bin/creduce")))
150 `("PERL5LIB" ":" prefix
152 (string-append (assoc-ref inputs p)
153 "/lib/perl5/site_perl/"
154 ,(package-version perl)))
155 '("term-readkey" "exporter-lite"
156 "file-which" "getopt-tabular"
159 (home-page "https://embed.cs.utah.edu/creduce")
160 (synopsis "Reducer for interesting code")
162 "C-Reduce is a tool that takes a large C or C++ program that has a
163 property of interest (such as triggering a compiler bug) and automatically
164 produces a much smaller C/C++ program that has the same property. It is
165 intended for use by people who discover and report bugs in compilers and other
166 tools that process C/C++ code.")
167 (license license:ncsa)))
169 (define-public american-fuzzy-lop
170 (let ((machine (match (or (%current-target-system)
172 ("x86_64-linux" "x86_64")
173 ("i686-linux" "i386")
174 ("aarch64-linux" "aarch64")
175 ("armhf-linux" "arm")
176 ("mips64el-linux" "mips64el")
177 ;; Prevent errors when querying this package on unsupported
178 ;; platforms, e.g. when running "guix package --search="
181 (name "american-fuzzy-lop")
182 (version "2.56b") ;It seems all releases have the 'b' suffix
187 (url "https://github.com/google/AFL")
188 (commit (string-append "v" version))))
190 (base32 "1q1g59gkm48aa4cg9h70jx4i2gapmypgp5rzs156b2avd95vwkn1"))
191 (file-name (git-file-name name version))))
192 (build-system gnu-build-system)
194 `(("qemu" ,qemu-for-american-fuzzy-lop)))
196 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
197 (string-append "DOC_PATH=$(PREFIX)/share/doc/"
200 #:phases (modify-phases %standard-phases
201 (add-after 'unpack 'make-git-checkout-writable
203 (for-each make-file-writable (find-files "."))
206 ,@(if (string=? (%current-system) (or "x86_64-linux"
209 '((add-before 'build 'set-afl-flag
210 (lambda _ (setenv "AFL_NO_X86" "1") #t))
211 (add-after 'install 'remove-x86-programs
212 (lambda* (#:key outputs #:allow-other-keys)
213 (let* ((out (assoc-ref outputs "out"))
214 (bin (string-append out "/bin/")))
215 (delete-file (string-append bin "afl-gcc"))
216 (delete-file (string-append bin "afl-g++"))
217 (delete-file (string-append bin "afl-clang"))
218 (delete-file (string-append bin "afl-clang++")))
221 ;; TODO: Build and install the afl-llvm tool.
222 'install 'install-qemu
223 (lambda* (#:key inputs outputs #:allow-other-keys)
224 (let ((qemu (assoc-ref inputs "qemu"))
225 (out (assoc-ref outputs "out")))
226 (symlink (string-append qemu "/bin/qemu-" ,machine)
227 (string-append out "/bin/afl-qemu-trace"))
229 (delete 'check)))) ; tests are run during 'install phase
230 (home-page "https://lcamtuf.coredump.cx/afl/")
231 (synopsis "Security-oriented fuzzer")
233 "American fuzzy lop is a security-oriented fuzzer that employs a novel
234 type of compile-time instrumentation and genetic algorithms to automatically
235 discover clean, interesting test cases that trigger new internal states in the
236 targeted binary. This substantially improves the functional coverage for the
237 fuzzed code. The compact synthesized corpora produced by the tool are also
238 useful for seeding other, more labor- or resource-intensive testing regimes
240 (license license:asl2.0))))
242 (define-public qemu-for-american-fuzzy-lop
243 ;; afl only supports using a single afl-qemu-trace executable, so
244 ;; we only build qemu for the native target.
245 (let ((machine (match (or (%current-target-system)
247 ("x86_64-linux" "x86_64")
248 ("i686-linux" "i386")
249 ("aarch64-linux" "aarch64")
250 ("armhf-linux" "arm")
251 ("mips64el-linux" "mips64el")
252 ;; Prevent errors when querying this package on unsupported
253 ;; platforms, e.g. when running "guix package --search="
261 (uri (string-append "https://download.qemu.org/qemu-"
265 "17w21spvaxaidi2am5lpsln8yjpyp2zi3s3gc6nsxj5arlgamzgw"))
267 (search-patches "qemu-glibc-2.27.patch"))))
268 (build-system gnu-build-system)
270 `(;; Running tests in parallel can occasionally lead to failures, like:
271 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
274 (list (string-append "--target-list=" ,machine "-linux-user"))
275 #:make-flags '("V=1")
277 (modify-phases %standard-phases
279 (lambda* (#:key inputs outputs (configure-flags '())
281 ;; The `configure' script doesn't understand some of the
282 ;; GNU options. Thus, add a new phase that's compatible.
283 (let ((out (assoc-ref outputs "out")))
284 (setenv "SHELL" (which "bash"))
286 ;; While we're at it, patch for tests.
287 (substitute* "tests/libqtest.c"
288 (("/bin/sh") (which "sh")))
290 ;; The binaries need to be linked against -lrt.
291 (setenv "LDFLAGS" "-lrt")
294 ,(string-append "--cc=" (which "gcc"))
295 ;; Some architectures insist on using HOST_CC
296 ,(string-append "--host-cc=" (which "gcc"))
297 "--disable-debug-info" ; save build space
298 "--enable-virtfs" ; just to be sure
299 ,(string-append "--prefix=" out)
300 ,(string-append "--sysconfdir=/etc")
301 ,@configure-flags)))))
303 'unpack 'apply-afl-patches
304 (lambda* (#:key inputs #:allow-other-keys)
305 (let* ((afl-src (assoc-ref inputs "afl-source"))
306 (patch-dir "qemu_mode/patches"))
307 (copy-recursively (string-append afl-src "/"
311 (string-append patch-dir
312 "/afl-qemu-cpu-inl.h")
314 (copy-file (string-append afl-src "/config.h")
316 (install-file (string-append afl-src "/types.h")
318 (substitute* "afl-qemu-cpu-inl.h"
319 (("\\.\\./\\.\\./config.h") "afl-config.h"))
320 (substitute* (string-append patch-dir
322 (("\\.\\./patches/") ""))
324 ;; These were already applied to qemu-minimal-2.10.
325 (for-each (lambda (obsolete-patch)
326 (delete-file (string-append
329 (list "configure.diff"
332 (for-each (lambda (patch-file)
333 (invoke "patch" "--force" "-p1"
334 "--input" patch-file))
335 (find-files patch-dir
338 (add-before 'check 'disable-unusable-tests
339 (lambda* (#:key inputs outputs #:allow-other-keys)
340 (substitute* "tests/Makefile.include"
341 ;; Comment out the test-qga test, which needs /sys and
342 ;; fails within the build environment.
343 (("check-unit-.* tests/test-qga" all)
344 (string-append "# " all)))
345 (substitute* "tests/Makefile.include"
346 ;; Comment out the test-char test, which needs networking and
347 ;; fails within the build environment.
348 (("check-unit-.* tests/test-char" all)
349 (string-append "# " all)))
352 `(("python-2" ,python-2) ; QEMU 2 needs Python 2
353 ("glib:bin" ,glib "bin")
357 ("pkg-config" ,pkg-config)))
359 `(("afl-source" ,(package-source american-fuzzy-lop))
360 ("alsa-lib" ,alsa-lib)
366 ("libjpeg" ,libjpeg-turbo)
370 ("util-linux" ,util-linux)
372 (home-page "https://www.qemu.org")
373 (synopsis "Machine emulator and virtualizer (without GUI) for american fuzzy lop")
375 "QEMU is a generic machine emulator and virtualizer. This package
376 of QEMU is used only by the american fuzzy lop package.
378 When used as a machine emulator, QEMU can run OSes and programs made for one
379 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
380 using dynamic translation, it achieves very good performance.
382 When used as a virtualizer, QEMU achieves near native performances by
383 executing the guest code directly on the host CPU. QEMU supports
384 virtualization when executing under the Xen hypervisor or using
385 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
386 server and embedded PowerPC, and S390 guests.")
387 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
388 (license license:gpl2)
389 ;; Several tests fail on MIPS.
390 (supported-systems (delete "mips64el-linux" %supported-systems))))))
392 (define-public stress-make
393 (let ((commit "9e92dff8f0157f012aaf31de5b8b8112ad720100")
394 (revision "1")) ;No official source distribution
397 (version (git-version "1.0" revision commit))
402 (url "https://github.com/lanl/stress-make.git")
404 (file-name (git-file-name name version))
407 "1z1yiwnqyzv3v6152fnjbfh2lr8q8fi5xxfdclnr8l8sd4c1rasp"))))
408 (build-system gnu-build-system)
410 `(("autoconf" ,autoconf)
411 ("automake" ,automake)
414 `(("make-source" ,(package-source gnu-make))))
416 ;; stress-make's configure script insists on having a tarball and does
417 ;; not accept a directory name instead. To let the gnu-build-system's
418 ;; patch-* phases work properly, we unpack the source first, then
419 ;; repack before the configure phase.
420 (let ((make-dir (string-append "make-" (package-version gnu-make))))
421 `(#:configure-flags '("--with-make-tar=./make.tar.xz"
422 "make_cv_sys_gnu_glob=yes")
424 (modify-phases %standard-phases
425 (add-after 'unpack 'unpack-make
426 (lambda* (#:key inputs #:allow-other-keys)
427 (invoke "tar" "xf" (assoc-ref inputs "make-source"))))
428 (add-after 'unpack-make 'set-default-shell
430 ;; Taken mostly directly from (@ (gnu packages base) gnu-make)
431 (substitute* (string-append ,make-dir "/job.c")
432 (("default_shell = .*$")
433 (format #f "default_shell = \"~a\";\n"
435 (add-before 'configure 'repack-make
437 (invoke "tar" "cJf" "./make.tar.xz" ,make-dir)))
438 (add-before 'build 'setup-go
439 ;; The Go cache is required starting in Go 1.12, and it needs
441 (lambda _ (setenv "GOCACHE" "/tmp/go-cache") #t))))))
442 (home-page "https://github.com/lanl/stress-make")
443 (synopsis "Expose race conditions in Makefiles")
445 "Stress Make is a customized GNU Make that explicitly manages the order
446 in which concurrent jobs are run to provoke erroneous behavior into becoming
447 manifest. It can run jobs in the order in which they're launched, in backwards
448 order, or in random order. The thought is that if code builds correctly with
449 Stress Make, then it is likely that the @code{Makefile} contains no race
451 ;; stress-make wrapper is under BSD-3-modifications-must-be-indicated,
452 ;; and patched GNU Make is under its own license.
453 (license (list (license:non-copyleft "LICENSE.md")
464 "https://github.com/samhocevar/zzuf/releases/download/v"
465 version "/" name "-" version ".tar.gz"))
466 (file-name (string-append name "-" version ".tar.gz"))
469 "1mpzjaksc2qg2hzqflf39pl06p53qam2dn3hkhkcv6p00d2n4kx3"))))
470 (build-system gnu-build-system)
471 (home-page "https://github.com/samhocevar/zzuf")
472 (synopsis "Transparent application input fuzzer")
473 (description "Zzuf is a transparent application input fuzzer. It works by
474 intercepting file operations and changing random bits in the program's
475 input. Zzuf's behaviour is deterministic, making it easy to reproduce bugs.")
476 (license license:wtfpl2)))
478 (define-public scanmem
486 (url "https://github.com/scanmem/scanmem")
487 (commit (string-append "v" version))))
488 (file-name (git-file-name name version))
491 "17p8sh0rj8yqz36ria5bp48c8523zzw3y9g8sbm2jwq7sc27i7s9"))))
492 (build-system gnu-build-system)
494 `(#:configure-flags '("--enable-gui")
496 (modify-phases %standard-phases
497 (add-before 'configure 'hardcode-python
498 (lambda* (#:key inputs outputs #:allow-other-keys)
499 (substitute* "gui/GameConqueror.py"
500 (("/usr/bin/env python")
501 (string-append (assoc-ref %build-inputs
502 "python-wrapper") "/bin/python")))
504 (add-after 'install 'wrap-gameconqueror
505 (lambda* (#:key inputs outputs #:allow-other-keys)
506 (let ((out (assoc-ref outputs "out"))
507 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
508 (python-path (getenv "PYTHONPATH")))
509 (wrap-program (string-append out "/share/gameconqueror/GameConqueror.py")
510 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
511 `("PYTHONPATH" ":" prefix (,python-path))))
514 `(("libtool" ,libtool)
515 ("python-wrapper" ,python-wrapper)
516 ("gobject-introspection" ,gobject-introspection)
518 ("intltool" ,intltool)
519 ("automake" ,automake)
520 ("autoconf" ,autoconf)))
522 `(("readline" ,readline)))
524 `(("python-pygobject" ,python-pygobject)))
525 (home-page "https://github.com/scanmem/scanmem")
526 (synopsis "Memory scanner")
527 (description "Scanmem is a debugging utility designed to isolate the
528 address of an arbitrary variable in an executing process. Scanmem simply
529 needs to be told the pid of the process and the value of the variable at
530 several different times. After several scans of the process, scanmem isolates
531 the position of the variable and allows you to modify its value.")
532 ;; The library is covered by LGPLv3 or later; the application is covered
533 ;; by GPLv3 or later.
534 (license (list license:lgpl3+ license:gpl3+))))
543 (url "https://github.com/mozilla/rr")
547 "1x6l1xsdksnhz9v50p4r7hhmr077cq20kaywqy1jzdklvkjqzf64"))
548 (file-name (git-file-name name version))))
549 (build-system cmake-build-system)
552 ;; The 'rr_exec_stub' is a static binary, which leads CMake to fail
555 ;; file RPATH_CHANGE could not write new RPATH:
557 ;; Clear CMAKE_INSTALL_RPATH to avoid that problem.
558 (list "-DCMAKE_INSTALL_RPATH="
559 ,@(if (and (not (%current-target-system))
560 (member (%current-system)
561 '("x86_64-linux" "aarch64-linux")))
562 ;; The toolchain doesn't support '-m32'.
563 '("-Ddisable32bit=ON")
566 ;; XXX: Most tests fail with:
568 ;; rr needs /proc/sys/kernel/perf_event_paranoid <= 1, but it is 2.
570 ;; This setting cannot be changed from the build environment, so skip
574 #:phases (modify-phases %standard-phases
575 (add-before 'check 'set-home
577 ;; Some tests expect 'HOME' to be set.
578 (setenv "HOME" (getcwd))
581 `(("pkg-config" ,pkg-config)
586 ("cpanproto" ,capnproto)
588 ("python-pexpect" ,python-pexpect)))
589 (home-page "https://rr-project.org/")
590 (synopsis "Record and reply debugging framework")
592 "rr is a lightweight tool for recording, replaying and debugging
593 execution of applications (trees of processes and threads). Debugging extends
594 GDB with very efficient reverse-execution, which in combination with standard
595 GDB/x86 features like hardware data watchpoints, makes debugging much more
597 (license license:expat)))