gnu: Prefix licenses in (gnu packages debug).
[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, 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 ;;;
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) #: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 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 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 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.56b") ;It seems all releases have the 'b' suffix
175 (source
176 (origin
177 (method git-fetch)
178 (uri (git-reference
179 (url "https://github.com/google/AFL")
180 (commit (string-append "v" version))))
181 (sha256
182 (base32 "1q1g59gkm48aa4cg9h70jx4i2gapmypgp5rzs156b2avd95vwkn1"))
183 (file-name (git-file-name name version))))
184 (build-system gnu-build-system)
185 (inputs
186 `(("custom-qemu"
187 ;; The afl-qemu tool builds qemu 2.10.0 with a few patches applied.
188 ,(package (inherit qemu-minimal-2.10)
189 (name "afl-qemu")
190 (inputs
191 `(("afl-src" ,source)
192 ,@(package-inputs qemu-minimal)))
193 ;; afl only supports using a single afl-qemu-trace executable, so
194 ;; we only build qemu for the native target.
195 (arguments
196 `(#:modules ((srfi srfi-1)
197 ,@%gnu-build-system-modules)
198 ,@(substitute-keyword-arguments (package-arguments qemu-minimal)
199 ((#:configure-flags config-flags)
200 ``(,(string-append "--target-list=" ,machine "-linux-user")
201 ,@(remove (λ (f) (string-prefix? "--target-list=" f))
202 ,config-flags)))
203 ((#:phases qemu-phases)
204 `(modify-phases ,qemu-phases
205 (add-after
206 'unpack 'apply-afl-patches
207 (lambda* (#:key inputs #:allow-other-keys)
208 (let* ((afl-src (assoc-ref inputs "afl-src"))
209 (patch-dir "qemu_mode/patches"))
210 (copy-recursively (string-append afl-src "/"
211 patch-dir)
212 patch-dir)
213 (install-file
214 (string-append patch-dir
215 "/afl-qemu-cpu-inl.h")
216 ".")
217 (copy-file (string-append afl-src "/config.h")
218 "./afl-config.h")
219 (install-file (string-append afl-src "/types.h")
220 ".")
221 (substitute* "afl-qemu-cpu-inl.h"
222 (("\\.\\./\\.\\./config.h") "afl-config.h"))
223 (substitute* (string-append patch-dir
224 "/cpu-exec.diff")
225 (("\\.\\./patches/") ""))
226
227 ;; These were already applied to qemu-minimal-2.10.
228 (for-each (lambda (obsolete-patch)
229 (delete-file (string-append
230 patch-dir "/"
231 obsolete-patch)))
232 (list "configure.diff"
233 "memfd.diff"))
234
235 (for-each (lambda (patch-file)
236 (invoke "patch" "--force" "-p1"
237 "--input" patch-file))
238 (find-files patch-dir
239 "\\.diff$"))
240 #t))))))))))))
241 (arguments
242 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
243 (string-append "DOC_PATH=$(PREFIX)/share/doc/"
244 ,name "-" ,version)
245 "CC=gcc")
246 #:phases (modify-phases %standard-phases
247 (add-after 'unpack 'make-git-checkout-writable
248 (lambda _
249 (for-each make-file-writable (find-files "."))
250 #t))
251 (delete 'configure)
252 ,@(if (string=? (%current-system) (or "x86_64-linux"
253 "i686-linux"))
254 '()
255 '((add-before 'build 'set-afl-flag
256 (lambda _ (setenv "AFL_NO_X86" "1") #t))
257 (add-after 'install 'remove-x86-programs
258 (lambda* (#:key outputs #:allow-other-keys)
259 (let* ((out (assoc-ref outputs "out"))
260 (bin (string-append out "/bin/")))
261 (delete-file (string-append bin "afl-gcc"))
262 (delete-file (string-append bin "afl-g++"))
263 (delete-file (string-append bin "afl-clang"))
264 (delete-file (string-append bin "afl-clang++")))
265 #t))))
266 (add-after
267 ;; TODO: Build and install the afl-llvm tool.
268 'install 'install-qemu
269 (lambda* (#:key inputs outputs #:allow-other-keys)
270 (let ((qemu (assoc-ref inputs "custom-qemu"))
271 (out (assoc-ref outputs "out")))
272 (symlink (string-append qemu "/bin/qemu-" ,machine)
273 (string-append out "/bin/afl-qemu-trace"))
274 #t)))
275 (delete 'check)))) ; tests are run during 'install phase
276 (home-page "https://lcamtuf.coredump.cx/afl/")
277 (synopsis "Security-oriented fuzzer")
278 (description
279 "American fuzzy lop is a security-oriented fuzzer that employs a novel
280 type of compile-time instrumentation and genetic algorithms to automatically
281 discover clean, interesting test cases that trigger new internal states in the
282 targeted binary. This substantially improves the functional coverage for the
283 fuzzed code. The compact synthesized corpora produced by the tool are also
284 useful for seeding other, more labor- or resource-intensive testing regimes
285 down the road.")
286 (license license:asl2.0))))
287
288 (define-public stress-make
289 (let ((commit "9e92dff8f0157f012aaf31de5b8b8112ad720100")
290 (revision "1")) ;No official source distribution
291 (package
292 (name "stress-make")
293 (version (git-version "1.0" revision commit))
294 (source
295 (origin
296 (method git-fetch)
297 (uri (git-reference
298 (url "https://github.com/lanl/stress-make.git")
299 (commit commit)))
300 (file-name (git-file-name name version))
301 (sha256
302 (base32
303 "1z1yiwnqyzv3v6152fnjbfh2lr8q8fi5xxfdclnr8l8sd4c1rasp"))))
304 (build-system gnu-build-system)
305 (native-inputs
306 `(("autoconf" ,autoconf)
307 ("automake" ,automake)
308 ("go" ,go)))
309 (inputs
310 `(("make-source" ,(package-source gnu-make))))
311 (arguments
312 ;; stress-make's configure script insists on having a tarball and does
313 ;; not accept a directory name instead. To let the gnu-build-system's
314 ;; patch-* phases work properly, we unpack the source first, then
315 ;; repack before the configure phase.
316 (let ((make-dir (string-append "make-" (package-version gnu-make))))
317 `(#:configure-flags '("--with-make-tar=./make.tar.xz"
318 "make_cv_sys_gnu_glob=yes")
319 #:phases
320 (modify-phases %standard-phases
321 (add-after 'unpack 'unpack-make
322 (lambda* (#:key inputs #:allow-other-keys)
323 (invoke "tar" "xf" (assoc-ref inputs "make-source"))))
324 (add-after 'unpack-make 'set-default-shell
325 (lambda _
326 ;; Taken mostly directly from (@ (gnu packages base) gnu-make)
327 (substitute* (string-append ,make-dir "/job.c")
328 (("default_shell = .*$")
329 (format #f "default_shell = \"~a\";\n"
330 (which "sh"))))))
331 (add-before 'configure 'repack-make
332 (lambda _
333 (invoke "tar" "cJf" "./make.tar.xz" ,make-dir)))
334 (add-before 'build 'setup-go
335 ;; The Go cache is required starting in Go 1.12, and it needs
336 ;; to be writable.
337 (lambda _ (setenv "GOCACHE" "/tmp/go-cache") #t))))))
338 (home-page "https://github.com/lanl/stress-make")
339 (synopsis "Expose race conditions in Makefiles")
340 (description
341 "Stress Make is a customized GNU Make that explicitly manages the order
342 in which concurrent jobs are run to provoke erroneous behavior into becoming
343 manifest. It can run jobs in the order in which they're launched, in backwards
344 order, or in random order. The thought is that if code builds correctly with
345 Stress Make, then it is likely that the @code{Makefile} contains no race
346 conditions.")
347 ;; stress-make wrapper is under BSD-3-modifications-must-be-indicated,
348 ;; and patched GNU Make is under its own license.
349 (license (list (license:non-copyleft "LICENSE.md")
350 license:gpl3+)))))
351
352 (define-public zzuf
353 (package
354 (name "zzuf")
355 (version "0.15")
356 (source
357 (origin
358 (method url-fetch)
359 (uri (string-append
360 "https://github.com/samhocevar/zzuf/releases/download/v"
361 version "/" name "-" version ".tar.gz"))
362 (file-name (string-append name "-" version ".tar.gz"))
363 (sha256
364 (base32
365 "1mpzjaksc2qg2hzqflf39pl06p53qam2dn3hkhkcv6p00d2n4kx3"))))
366 (build-system gnu-build-system)
367 (home-page "https://github.com/samhocevar/zzuf")
368 (synopsis "Transparent application input fuzzer")
369 (description "Zzuf is a transparent application input fuzzer. It works by
370 intercepting file operations and changing random bits in the program's
371 input. Zzuf's behaviour is deterministic, making it easy to reproduce bugs.")
372 (license license:wtfpl2)))
373
374 (define-public scanmem
375 (package
376 (name "scanmem")
377 (version "0.17")
378 (source
379 (origin
380 (method git-fetch)
381 (uri (git-reference
382 (url "https://github.com/scanmem/scanmem")
383 (commit (string-append "v" version))))
384 (file-name (git-file-name name version))
385 (sha256
386 (base32
387 "17p8sh0rj8yqz36ria5bp48c8523zzw3y9g8sbm2jwq7sc27i7s9"))))
388 (build-system gnu-build-system)
389 (arguments
390 `(#:configure-flags '("--enable-gui")
391 #:phases
392 (modify-phases %standard-phases
393 (add-before 'configure 'hardcode-python
394 (lambda* (#:key inputs outputs #:allow-other-keys)
395 (substitute* "gui/GameConqueror.py"
396 (("/usr/bin/env python")
397 (string-append (assoc-ref %build-inputs
398 "python-wrapper") "/bin/python")))
399 #t))
400 (add-after 'install 'wrap-gameconqueror
401 (lambda* (#:key inputs outputs #:allow-other-keys)
402 (let ((out (assoc-ref outputs "out"))
403 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
404 (python-path (getenv "PYTHONPATH")))
405 (wrap-program (string-append out "/share/gameconqueror/GameConqueror.py")
406 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
407 `("PYTHONPATH" ":" prefix (,python-path))))
408 #t)))))
409 (native-inputs
410 `(("libtool" ,libtool)
411 ("python-wrapper" ,python-wrapper)
412 ("gobject-introspection" ,gobject-introspection)
413 ("gtk+" ,gtk+)
414 ("intltool" ,intltool)
415 ("automake" ,automake)
416 ("autoconf" ,autoconf)))
417 (inputs
418 `(("readline" ,readline)))
419 (propagated-inputs
420 `(("python-pygobject" ,python-pygobject)))
421 (home-page "https://github.com/scanmem/scanmem")
422 (synopsis "Memory scanner")
423 (description "Scanmem is a debugging utility designed to isolate the
424 address of an arbitrary variable in an executing process. Scanmem simply
425 needs to be told the pid of the process and the value of the variable at
426 several different times. After several scans of the process, scanmem isolates
427 the position of the variable and allows you to modify its value.")
428 ;; The library is covered by LGPLv3 or later; the application is covered
429 ;; by GPLv3 or later.
430 (license (list license:lgpl3+ license:gpl3+))))
431
432 (define-public rr
433 (package
434 (name "rr")
435 (version "5.3.0")
436 (source (origin
437 (method git-fetch)
438 (uri (git-reference
439 (url "https://github.com/mozilla/rr")
440 (commit version)))
441 (sha256
442 (base32
443 "1x6l1xsdksnhz9v50p4r7hhmr077cq20kaywqy1jzdklvkjqzf64"))
444 (file-name (git-file-name name version))))
445 (build-system cmake-build-system)
446 (arguments
447 `(#:configure-flags
448 ;; The 'rr_exec_stub' is a static binary, which leads CMake to fail
449 ;; with:
450 ;;
451 ;; file RPATH_CHANGE could not write new RPATH:
452 ;;
453 ;; Clear CMAKE_INSTALL_RPATH to avoid that problem.
454 (list "-DCMAKE_INSTALL_RPATH="
455 ,@(if (and (not (%current-target-system))
456 (member (%current-system)
457 '("x86_64-linux" "aarch64-linux")))
458 ;; The toolchain doesn't support '-m32'.
459 '("-Ddisable32bit=ON")
460 '()))
461
462 ;; XXX: Most tests fail with:
463 ;;
464 ;; rr needs /proc/sys/kernel/perf_event_paranoid <= 1, but it is 2.
465 ;;
466 ;; This setting cannot be changed from the build environment, so skip
467 ;; the tests.
468 #:tests? #f
469
470 #:phases (modify-phases %standard-phases
471 (add-before 'check 'set-home
472 (lambda _
473 ;; Some tests expect 'HOME' to be set.
474 (setenv "HOME" (getcwd))
475 #t)))))
476 (native-inputs
477 `(("pkg-config" ,pkg-config)
478 ("ninja" ,ninja)
479 ("which" ,which)))
480 (inputs
481 `(("gdb" ,gdb)
482 ("cpanproto" ,capnproto)
483 ("python" ,python)
484 ("python-pexpect" ,python-pexpect)))
485 (home-page "https://rr-project.org/")
486 (synopsis "Record and reply debugging framework")
487 (description
488 "rr is a lightweight tool for recording, replaying and debugging
489 execution of applications (trees of processes and threads). Debugging extends
490 GDB with very efficient reverse-execution, which in combination with standard
491 GDB/x86 features like hardware data watchpoints, makes debugging much more
492 fun.")
493 (license license:expat)))