gnu: american-fuzzy-lop: Fix documentation directory.
[jackhill/guix/guix.git] / gnu / packages / debug.scm
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 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 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
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.
14 ;;;
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.
19 ;;;
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/>.
22
23 (define-module (gnu packages debug)
24 #:use-module (guix packages)
25 #:use-module (guix licenses)
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 autotools)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages bash)
34 #:use-module (gnu packages code)
35 #:use-module (gnu packages flex)
36 #:use-module (gnu packages gdb)
37 #:use-module (gnu packages glib)
38 #:use-module (gnu packages gtk)
39 #:use-module (gnu packages golang)
40 #:use-module (gnu packages llvm)
41 #:use-module (gnu packages ninja)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages pretty-print)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages python-xyz)
47 #:use-module (gnu packages readline)
48 #:use-module (gnu packages serialization)
49 #:use-module (gnu packages virtualization)
50 #:use-module (ice-9 match)
51 #:use-module (srfi srfi-1))
52
53 (define-public delta
54 (package
55 (name "delta")
56 (version "2006.08.03")
57 (source
58 (origin
59 (method url-fetch)
60 (uri (list
61 (string-append "mirror://debian/pool/main/d/delta/"
62 "delta_" version ".orig.tar.gz")
63 ;; This uri seems to send guix download into an infinite loop
64 (string-append "http://delta.tigris.org/files/documents/3103/"
65 "33566/delta-" version ".tar.gz")))
66 (sha256
67 (base32
68 "184wh35pf2ddx97319s6sgkzpz48xxkbwzcjpycv009bm53lh61q"))))
69 (build-system gnu-build-system)
70 (inputs ;Installed programs are perl scripts
71 `(("perl" ,perl)))
72 (arguments
73 `(#:phases
74 (modify-phases %standard-phases
75 (replace 'install
76 (lambda* (#:key outputs #:allow-other-keys)
77 ;; Makefile contains no install target
78 (let* ((out (assoc-ref outputs "out"))
79 (bin (string-append out "/bin"))
80 (doc (string-append out "/share/doc/delta-" ,version)))
81 (begin
82 (for-each (lambda (h)
83 (install-file h doc))
84 `("License.txt" ,@(find-files "www" ".*\\.html")))
85 (for-each (lambda (b)
86 (install-file b bin))
87 `("delta" "multidelta" "topformflat"))))
88 #t))
89 (delete 'configure)))) ; no configure script
90 (home-page "http://delta.tigris.org/")
91 (synopsis "Heuristical file minimizer")
92 (description
93 "Delta assists you in minimizing \"interesting\" files subject to a test
94 of their interestingness. A common such situation is when attempting to
95 isolate a small failure-inducing substring of a large input that causes your
96 program to exhibit a bug.")
97 ;; See License.txt, which is a bsd-3 license, despite the project's
98 ;; home-page pointing to a bsd-2 license.
99 (license bsd-3)))
100
101 (define-public c-reduce
102 (package
103 (name "c-reduce")
104 (version "2.10.0")
105 (source
106 (origin
107 (method url-fetch)
108 (uri (list
109 (string-append "http://embed.cs.utah.edu/creduce/"
110 "creduce-" version ".tar.gz")))
111 (sha256
112 (base32 "0qx0zq8jxzx2as2zf0740g7kvgq163ayn3041di4vwk77490y76v"))))
113 (build-system gnu-build-system)
114 (inputs
115 `(("astyle" ,astyle)
116 ("llvm" ,llvm)
117 ("clang" ,clang)
118 ("flex" ,flex)
119 ("indent" ,indent)
120 ("perl" ,perl)
121 ("exporter-lite" ,perl-exporter-lite)
122 ("file-which" ,perl-file-which)
123 ("getopt-tabular" ,perl-getopt-tabular)
124 ("regex-common" ,perl-regexp-common)
125 ("term-readkey" ,perl-term-readkey)))
126 (arguments
127 `(#:phases
128 (modify-phases %standard-phases
129 (replace 'check
130 (lambda _
131 (with-directory-excursion "tests"
132 ;; Running all tests can take a looong time, and tests 4 and 5
133 ;; require frama-c or kcc. So run just one for sanity.
134 (invoke "./run_tests" "1"))))
135 (add-after 'install 'set-load-paths
136 (lambda* (#:key inputs outputs #:allow-other-keys)
137 ;; Tell creduce where to find the perl modules it needs.
138 (let* ((out (assoc-ref outputs "out"))
139 (prog (string-append out "/bin/creduce")))
140 (wrap-program
141 prog
142 `("PERL5LIB" ":" prefix
143 ,(map (lambda (p)
144 (string-append (assoc-ref inputs p)
145 "/lib/perl5/site_perl/"
146 ,(package-version perl)))
147 '("term-readkey" "exporter-lite"
148 "file-which" "getopt-tabular"
149 "regex-common")))))
150 #t)))))
151 (home-page "https://embed.cs.utah.edu/creduce")
152 (synopsis "Reducer for interesting code")
153 (description
154 "C-Reduce is a tool that takes a large C or C++ program that has a
155 property of interest (such as triggering a compiler bug) and automatically
156 produces a much smaller C/C++ program that has the same property. It is
157 intended for use by people who discover and report bugs in compilers and other
158 tools that process C/C++ code.")
159 (license ncsa)))
160
161 (define-public american-fuzzy-lop
162 (let ((machine (match (or (%current-target-system)
163 (%current-system))
164 ("x86_64-linux" "x86_64")
165 ("i686-linux" "i386")
166 ("aarch64-linux" "aarch64")
167 ("armhf-linux" "arm")
168 ("mips64el-linux" "mips64el")
169 ;; Prevent errors when querying this package on unsupported
170 ;; platforms, e.g. when running "guix package --search="
171 (_ "UNSUPPORTED"))))
172 (package
173 (name "american-fuzzy-lop")
174 (version "2.52b") ;It seems all releases have the 'b' suffix
175 (source
176 (origin
177 (method url-fetch)
178 (uri (string-append "http://lcamtuf.coredump.cx/afl/releases/"
179 "afl-" version ".tgz"))
180 (sha256
181 (base32
182 "0ig0ij4n1pwry5dw1hk4q88801jzzy2cric6y2gd6560j55lnqa3"))))
183 (build-system gnu-build-system)
184 (inputs
185 `(("custom-qemu"
186 ;; The afl-qemu tool builds qemu 2.10.0 with a few patches applied.
187 ,(package (inherit qemu-minimal-2.10)
188 (name "afl-qemu")
189 (inputs
190 `(("afl-src" ,source)
191 ,@(package-inputs qemu-minimal)))
192 ;; afl only supports using a single afl-qemu-trace executable, so
193 ;; we only build qemu for the native target.
194 (arguments
195 `(#:modules ((srfi srfi-1)
196 ,@%gnu-build-system-modules)
197 ,@(substitute-keyword-arguments (package-arguments qemu-minimal)
198 ((#:configure-flags config-flags)
199 ``(,(string-append "--target-list=" ,machine "-linux-user")
200 ,@(remove (λ (f) (string-prefix? "--target-list=" f))
201 ,config-flags)))
202 ((#:phases qemu-phases)
203 `(modify-phases ,qemu-phases
204 (add-after
205 'unpack 'apply-afl-patches
206 (lambda* (#:key inputs #:allow-other-keys)
207 (let* ((afl-dir (string-append "afl-" ,version))
208 (patch-dir
209 (string-append afl-dir
210 "/qemu_mode/patches")))
211 (invoke "tar" "xf"
212 (assoc-ref inputs "afl-src"))
213 (install-file (string-append patch-dir
214 "/afl-qemu-cpu-inl.h")
215 ".")
216 (copy-file (string-append afl-dir "/config.h")
217 "./afl-config.h")
218 (install-file (string-append afl-dir "/types.h")
219 ".")
220 (substitute* "afl-qemu-cpu-inl.h"
221 (("\\.\\./\\.\\./config.h") "afl-config.h"))
222 (substitute* (string-append patch-dir
223 "/cpu-exec.diff")
224 (("\\.\\./patches/") ""))
225 (for-each (lambda (patch-file)
226 (invoke "patch" "--force" "-p1"
227 "--input" patch-file))
228 (find-files patch-dir
229 "\\.diff$"))
230 #t))))))))))))
231 (arguments
232 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
233 (string-append "DOC_PATH=$(PREFIX)/share/doc/"
234 ,name "-" ,version)
235 "CC=gcc")
236 #:phases (modify-phases %standard-phases
237 (delete 'configure)
238 ,@(if (string=? (%current-system) (or "x86_64-linux"
239 "i686-linux"))
240 '()
241 '((add-before 'build 'set-afl-flag
242 (lambda _ (setenv "AFL_NO_X86" "1") #t))
243 (add-after 'install 'remove-x86-programs
244 (lambda* (#:key outputs #:allow-other-keys)
245 (let* ((out (assoc-ref outputs "out"))
246 (bin (string-append out "/bin/")))
247 (delete-file (string-append bin "afl-gcc"))
248 (delete-file (string-append bin "afl-g++"))
249 (delete-file (string-append bin "afl-clang"))
250 (delete-file (string-append bin "afl-clang++")))
251 #t))))
252 (add-after
253 ;; TODO: Build and install the afl-llvm tool.
254 'install 'install-qemu
255 (lambda* (#:key inputs outputs #:allow-other-keys)
256 (let ((qemu (assoc-ref inputs "custom-qemu"))
257 (out (assoc-ref outputs "out")))
258 (symlink (string-append qemu "/bin/qemu-" ,machine)
259 (string-append out "/bin/afl-qemu-trace"))
260 #t)))
261 (delete 'check)))) ; Tests are run during 'install phase.
262 (home-page "http://lcamtuf.coredump.cx/afl")
263 (synopsis "Security-oriented fuzzer")
264 (description
265 "American fuzzy lop is a security-oriented fuzzer that employs a novel
266 type of compile-time instrumentation and genetic algorithms to automatically
267 discover clean, interesting test cases that trigger new internal states in the
268 targeted binary. This substantially improves the functional coverage for the
269 fuzzed code. The compact synthesized corpora produced by the tool are also
270 useful for seeding other, more labor- or resource-intensive testing regimes
271 down the road.")
272 (license asl2.0))))
273
274 (define-public stress-make
275 (let ((commit "9e92dff8f0157f012aaf31de5b8b8112ad720100")
276 (revision "1")) ;No official source distribution
277 (package
278 (name "stress-make")
279 (version (git-version "1.0" revision commit))
280 (source
281 (origin
282 (method git-fetch)
283 (uri (git-reference
284 (url "https://github.com/lanl/stress-make.git")
285 (commit commit)))
286 (file-name (git-file-name name version))
287 (sha256
288 (base32
289 "1z1yiwnqyzv3v6152fnjbfh2lr8q8fi5xxfdclnr8l8sd4c1rasp"))))
290 (build-system gnu-build-system)
291 (native-inputs
292 `(("autoconf" ,autoconf)
293 ("automake" ,automake)
294 ("go" ,go)))
295 (inputs
296 `(("make-source" ,(package-source gnu-make))))
297 (arguments
298 ;; stress-make's configure script insists on having a tarball and does
299 ;; not accept a directory name instead. To let the gnu-build-system's
300 ;; patch-* phases work properly, we unpack the source first, then
301 ;; repack before the configure phase.
302 (let ((make-dir (string-append "make-" (package-version gnu-make))))
303 `(#:configure-flags '("--with-make-tar=./make.tar.xz"
304 "make_cv_sys_gnu_glob=yes")
305 #:phases
306 (modify-phases %standard-phases
307 (add-after 'unpack 'unpack-make
308 (lambda* (#:key inputs #:allow-other-keys)
309 (invoke "tar" "xf" (assoc-ref inputs "make-source"))))
310 (add-after 'unpack-make 'set-default-shell
311 (lambda _
312 ;; Taken mostly directly from (@ (gnu packages base) gnu-make)
313 (substitute* (string-append ,make-dir "/job.c")
314 (("default_shell = .*$")
315 (format #f "default_shell = \"~a\";\n"
316 (which "sh"))))))
317 (add-before 'configure 'repack-make
318 (lambda _
319 (invoke "tar" "cJf" "./make.tar.xz" ,make-dir)))
320 (add-before 'build 'setup-go
321 ;; The Go cache is required starting in Go 1.12, and it needs
322 ;; to be writable.
323 (lambda _ (setenv "GOCACHE" "/tmp/go-cache") #t))))))
324 (home-page "https://github.com/lanl/stress-make")
325 (synopsis "Expose race conditions in Makefiles")
326 (description
327 "Stress Make is a customized GNU Make that explicitly manages the order
328 in which concurrent jobs are run to provoke erroneous behavior into becoming
329 manifest. It can run jobs in the order in which they're launched, in backwards
330 order, or in random order. The thought is that if code builds correctly with
331 Stress Make, then it is likely that the @code{Makefile} contains no race
332 conditions.")
333 ;; stress-make wrapper is under BSD-3-modifications-must-be-indicated,
334 ;; and patched GNU Make is under its own license.
335 (license (list (non-copyleft "LICENSE.md")
336 gpl3+)))))
337
338 (define-public zzuf
339 (package
340 (name "zzuf")
341 (version "0.15")
342 (source
343 (origin
344 (method url-fetch)
345 (uri (string-append
346 "https://github.com/samhocevar/zzuf/releases/download/v"
347 version "/" name "-" version ".tar.gz"))
348 (file-name (string-append name "-" version ".tar.gz"))
349 (sha256
350 (base32
351 "1mpzjaksc2qg2hzqflf39pl06p53qam2dn3hkhkcv6p00d2n4kx3"))))
352 (build-system gnu-build-system)
353 (home-page "https://github.com/samhocevar/zzuf")
354 (synopsis "Transparent application input fuzzer")
355 (description "Zzuf is a transparent application input fuzzer. It works by
356 intercepting file operations and changing random bits in the program's
357 input. Zzuf's behaviour is deterministic, making it easy to reproduce bugs.")
358 (license (non-copyleft "http://www.wtfpl.net/txt/copying/"))))
359
360 (define-public scanmem
361 (package
362 (name "scanmem")
363 (version "0.17")
364 (source
365 (origin
366 (method git-fetch)
367 (uri (git-reference
368 (url "https://github.com/scanmem/scanmem")
369 (commit (string-append "v" version))))
370 (file-name (git-file-name name version))
371 (sha256
372 (base32
373 "17p8sh0rj8yqz36ria5bp48c8523zzw3y9g8sbm2jwq7sc27i7s9"))))
374 (build-system gnu-build-system)
375 (arguments
376 `(#:configure-flags '("--enable-gui")
377 #:phases
378 (modify-phases %standard-phases
379 (add-before 'configure 'hardcode-python
380 (lambda* (#:key inputs outputs #:allow-other-keys)
381 (substitute* "gui/GameConqueror.py"
382 (("/usr/bin/env python")
383 (string-append (assoc-ref %build-inputs
384 "python-wrapper") "/bin/python")))
385 #t))
386 (add-after 'install 'wrap-gameconqueror
387 (lambda* (#:key inputs outputs #:allow-other-keys)
388 (let ((out (assoc-ref outputs "out"))
389 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
390 (python-path (getenv "PYTHONPATH")))
391 (wrap-program (string-append out "/share/gameconqueror/GameConqueror.py")
392 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
393 `("PYTHONPATH" ":" prefix (,python-path))))
394 #t)))))
395 (native-inputs
396 `(("libtool" ,libtool)
397 ("python-wrapper" ,python-wrapper)
398 ("gobject-introspection" ,gobject-introspection)
399 ("gtk+" ,gtk+)
400 ("intltool" ,intltool)
401 ("automake" ,automake)
402 ("autoconf" ,autoconf)))
403 (inputs
404 `(("readline" ,readline)))
405 (propagated-inputs
406 `(("python-pygobject" ,python-pygobject)))
407 (home-page "https://github.com/scanmem/scanmem")
408 (synopsis "Memory scanner")
409 (description "Scanmem is a debugging utility designed to isolate the
410 address of an arbitrary variable in an executing process. Scanmem simply
411 needs to be told the pid of the process and the value of the variable at
412 several different times. After several scans of the process, scanmem isolates
413 the position of the variable and allows you to modify its value.")
414 ;; The library is covered by LGPLv3 or later; the application is covered
415 ;; by GPLv3 or later.
416 (license (list lgpl3+ gpl3+))))
417
418 (define-public rr
419 (package
420 (name "rr")
421 (version "5.3.0")
422 (source (origin
423 (method git-fetch)
424 (uri (git-reference
425 (url "https://github.com/mozilla/rr")
426 (commit version)))
427 (sha256
428 (base32
429 "1x6l1xsdksnhz9v50p4r7hhmr077cq20kaywqy1jzdklvkjqzf64"))
430 (file-name (git-file-name name version))))
431 (build-system cmake-build-system)
432 (arguments
433 `(#:configure-flags
434 ;; The 'rr_exec_stub' is a static binary, which leads CMake to fail
435 ;; with:
436 ;;
437 ;; file RPATH_CHANGE could not write new RPATH:
438 ;;
439 ;; Clear CMAKE_INSTALL_RPATH to avoid that problem.
440 (list "-DCMAKE_INSTALL_RPATH="
441 ,@(if (and (not (%current-target-system))
442 (member (%current-system)
443 '("x86_64-linux" "aarch64-linux")))
444 ;; The toolchain doesn't support '-m32'.
445 '("-Ddisable32bit=ON")
446 '()))
447
448 ;; XXX: Most tests fail with:
449 ;;
450 ;; rr needs /proc/sys/kernel/perf_event_paranoid <= 1, but it is 2.
451 ;;
452 ;; This setting cannot be changed from the build environment, so skip
453 ;; the tests.
454 #:tests? #f
455
456 #:phases (modify-phases %standard-phases
457 (add-before 'check 'set-home
458 (lambda _
459 ;; Some tests expect 'HOME' to be set.
460 (setenv "HOME" (getcwd))
461 #t)))))
462 (native-inputs
463 `(("pkg-config" ,pkg-config)
464 ("ninja" ,ninja)
465 ("which" ,which)))
466 (inputs
467 `(("gdb" ,gdb)
468 ("cpanproto" ,capnproto)
469 ("python" ,python)
470 ("python-pexpect" ,python-pexpect)))
471 (home-page "https://rr-project.org/")
472 (synopsis "Record and reply debugging framework")
473 (description
474 "rr is a lightweight tool for recording, replaying and debugging
475 execution of applications (trees of processes and threads). Debugging extends
476 GDB with very efficient reverse-execution, which in combination with standard
477 GDB/x86 features like hardware data watchpoints, makes debugging much more
478 fun.")
479 (license expat)))