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