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