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