gnu: masscan: Cross compile.
[jackhill/guix/guix.git] / gnu / packages / debug.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2020 Eric Bavier <bavier@posteo.net>
3 ;;; Copyright © 2016, 2017, 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2018, 2020 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>
8 ;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
9 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages debug)
27 #:use-module (guix packages)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix download)
30 #:use-module (guix git-download)
31 #:use-module (guix utils)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix build-system cmake)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages attr)
36 #:use-module (gnu packages autotools)
37 #:use-module (gnu packages base)
38 #:use-module (gnu packages bash)
39 #:use-module (gnu packages bison)
40 #:use-module (gnu packages c)
41 #:use-module (gnu packages code)
42 #:use-module (gnu packages compression)
43 #:use-module (gnu packages flex)
44 #:use-module (gnu packages gdb)
45 #:use-module (gnu packages glib)
46 #:use-module (gnu packages gtk)
47 #:use-module (gnu packages golang)
48 #:use-module (gnu packages image)
49 #:use-module (gnu packages libusb)
50 #:use-module (gnu packages linux)
51 #:use-module (gnu packages llvm)
52 #:use-module (gnu packages ncurses)
53 #:use-module (gnu packages ninja)
54 #:use-module (gnu packages perl)
55 #:use-module (gnu packages pkg-config)
56 #:use-module (gnu packages pretty-print)
57 #:use-module (gnu packages python)
58 #:use-module (gnu packages python-xyz)
59 #:use-module (gnu packages readline)
60 #:use-module (gnu packages serialization)
61 #:use-module (gnu packages virtualization)
62 #:use-module (gnu packages xdisorg)
63 #:use-module (ice-9 match)
64 #:use-module (srfi srfi-1))
65
66 (define-public delta
67 (package
68 (name "delta")
69 (version "2006.08.03")
70 (source
71 (origin
72 (method url-fetch)
73 (uri (list
74 (string-append "mirror://debian/pool/main/d/delta/"
75 "delta_" version ".orig.tar.gz")
76 ;; This uri seems to send guix download into an infinite loop
77 (string-append "http://delta.tigris.org/files/documents/3103/"
78 "33566/delta-" version ".tar.gz")))
79 (sha256
80 (base32
81 "184wh35pf2ddx97319s6sgkzpz48xxkbwzcjpycv009bm53lh61q"))))
82 (build-system gnu-build-system)
83 (inputs ;Installed programs are perl scripts
84 `(("perl" ,perl)))
85 (arguments
86 `(#:phases
87 (modify-phases %standard-phases
88 (replace 'install
89 (lambda* (#:key outputs #:allow-other-keys)
90 ;; Makefile contains no install target
91 (let* ((out (assoc-ref outputs "out"))
92 (bin (string-append out "/bin"))
93 (doc (string-append out "/share/doc/delta-" ,version)))
94 (begin
95 (for-each (lambda (h)
96 (install-file h doc))
97 `("License.txt" ,@(find-files "www" ".*\\.html")))
98 (for-each (lambda (b)
99 (install-file b bin))
100 `("delta" "multidelta" "topformflat"))))
101 #t))
102 (delete 'configure)))) ; no configure script
103 (home-page "http://delta.tigris.org/")
104 (synopsis "Heuristical file minimizer")
105 (description
106 "Delta assists you in minimizing \"interesting\" files subject to a test
107 of their interestingness. A common such situation is when attempting to
108 isolate a small failure-inducing substring of a large input that causes your
109 program to exhibit a bug.")
110 ;; See License.txt, which is a bsd-3 license, despite the project's
111 ;; home-page pointing to a bsd-2 license.
112 (license license:bsd-3)))
113
114 (define-public c-reduce
115 (package
116 (name "c-reduce")
117 (version "2.10.0")
118 (source
119 (origin
120 (method url-fetch)
121 (uri (list
122 (string-append "http://embed.cs.utah.edu/creduce/"
123 "creduce-" version ".tar.gz")))
124 (sha256
125 (base32 "0qx0zq8jxzx2as2zf0740g7kvgq163ayn3041di4vwk77490y76v"))))
126 (build-system gnu-build-system)
127 (native-inputs `(("flex" ,flex)))
128 (inputs
129 `(("astyle" ,astyle)
130 ("llvm" ,llvm)
131 ("clang" ,clang)
132 ("indent" ,indent)
133 ("perl" ,perl)
134 ("exporter-lite" ,perl-exporter-lite)
135 ("file-which" ,perl-file-which)
136 ("getopt-tabular" ,perl-getopt-tabular)
137 ("regex-common" ,perl-regexp-common)
138 ("term-readkey" ,perl-term-readkey)))
139 (arguments
140 `(#:phases
141 (modify-phases %standard-phases
142 (replace 'check
143 (lambda _
144 (with-directory-excursion "tests"
145 ;; Running all tests can take a looong time, and tests 4 and 5
146 ;; require frama-c or kcc. So run just one for sanity.
147 (invoke "./run_tests" "1"))))
148 (add-after 'install 'set-load-paths
149 (lambda* (#:key inputs outputs #:allow-other-keys)
150 ;; Tell creduce where to find the perl modules it needs.
151 (let* ((out (assoc-ref outputs "out"))
152 (prog (string-append out "/bin/creduce")))
153 (wrap-program
154 prog
155 `("PERL5LIB" ":" prefix
156 ,(map (lambda (p)
157 (string-append (assoc-ref inputs p)
158 "/lib/perl5/site_perl/"
159 ,(package-version perl)))
160 '("term-readkey" "exporter-lite"
161 "file-which" "getopt-tabular"
162 "regex-common")))))
163 #t)))))
164 (home-page "https://embed.cs.utah.edu/creduce")
165 (synopsis "Reducer for interesting code")
166 (description
167 "C-Reduce is a tool that takes a large C or C++ program that has a
168 property of interest (such as triggering a compiler bug) and automatically
169 produces a much smaller C/C++ program that has the same property. It is
170 intended for use by people who discover and report bugs in compilers and other
171 tools that process C/C++ code.")
172 (license license:ncsa)))
173
174 (define-public american-fuzzy-lop
175 (let ((machine (match (or (%current-target-system)
176 (%current-system))
177 ("x86_64-linux" "x86_64")
178 ("i686-linux" "i386")
179 ("aarch64-linux" "aarch64")
180 ("armhf-linux" "arm")
181 ("mips64el-linux" "mips64el")
182 ;; Prevent errors when querying this package on unsupported
183 ;; platforms, e.g. when running "guix package --search="
184 (_ "UNSUPPORTED"))))
185 (package
186 (name "american-fuzzy-lop")
187 (version "2.56b") ;It seems all releases have the 'b' suffix
188 (source
189 (origin
190 (method git-fetch)
191 (uri (git-reference
192 (url "https://github.com/google/AFL")
193 (commit (string-append "v" version))))
194 (sha256
195 (base32 "1q1g59gkm48aa4cg9h70jx4i2gapmypgp5rzs156b2avd95vwkn1"))
196 (file-name (git-file-name name version))))
197 (build-system gnu-build-system)
198 (inputs
199 `(("qemu" ,qemu-for-american-fuzzy-lop)))
200 (arguments
201 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
202 (string-append "DOC_PATH=$(PREFIX)/share/doc/"
203 ,name "-" ,version)
204 "CC=gcc")
205 #:phases (modify-phases %standard-phases
206 (add-after 'unpack 'make-git-checkout-writable
207 (lambda _
208 (for-each make-file-writable (find-files "."))
209 #t))
210 (delete 'configure)
211 ,@(if (string=? (%current-system) (or "x86_64-linux"
212 "i686-linux"))
213 '()
214 '((add-before 'build 'set-afl-flag
215 (lambda _ (setenv "AFL_NO_X86" "1") #t))
216 (add-after 'install 'remove-x86-programs
217 (lambda* (#:key outputs #:allow-other-keys)
218 (let* ((out (assoc-ref outputs "out"))
219 (bin (string-append out "/bin/")))
220 (delete-file (string-append bin "afl-gcc"))
221 (delete-file (string-append bin "afl-g++"))
222 (delete-file (string-append bin "afl-clang"))
223 (delete-file (string-append bin "afl-clang++")))
224 #t))))
225 (add-after
226 ;; TODO: Build and install the afl-llvm tool.
227 'install 'install-qemu
228 (lambda* (#:key inputs outputs #:allow-other-keys)
229 (let ((qemu (assoc-ref inputs "qemu"))
230 (out (assoc-ref outputs "out")))
231 (symlink (string-append qemu "/bin/qemu-" ,machine)
232 (string-append out "/bin/afl-qemu-trace"))
233 #t)))
234 (delete 'check)))) ; tests are run during 'install phase
235 (home-page "https://lcamtuf.coredump.cx/afl/")
236 (synopsis "Security-oriented fuzzer")
237 (description
238 "American fuzzy lop is a security-oriented fuzzer that employs a novel
239 type of compile-time instrumentation and genetic algorithms to automatically
240 discover clean, interesting test cases that trigger new internal states in the
241 targeted binary. This substantially improves the functional coverage for the
242 fuzzed code. The compact synthesized corpora produced by the tool are also
243 useful for seeding other, more labor- or resource-intensive testing regimes
244 down the road.")
245 (license license:asl2.0))))
246
247 (define-public qemu-for-american-fuzzy-lop
248 ;; afl only supports using a single afl-qemu-trace executable, so
249 ;; we only build qemu for the native target.
250 (let ((machine (match (or (%current-target-system)
251 (%current-system))
252 ("x86_64-linux" "x86_64")
253 ("i686-linux" "i386")
254 ("aarch64-linux" "aarch64")
255 ("armhf-linux" "arm")
256 ("mips64el-linux" "mips64el")
257 ;; Prevent errors when querying this package on unsupported
258 ;; platforms, e.g. when running "guix package --search="
259 (_ "UNSUPPORTED"))))
260 (hidden-package
261 (package
262 (name "qemu")
263 (version "2.10.2")
264 (source (origin
265 (method url-fetch)
266 (uri (string-append "https://download.qemu.org/qemu-"
267 version ".tar.xz"))
268 (sha256
269 (base32
270 "17w21spvaxaidi2am5lpsln8yjpyp2zi3s3gc6nsxj5arlgamzgw"))
271 (patches
272 (search-patches "qemu-glibc-2.27.patch"))))
273 (build-system gnu-build-system)
274 (arguments
275 `(;; Running tests in parallel can occasionally lead to failures, like:
276 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
277 #:parallel-tests? #f
278 #:configure-flags
279 (list (string-append "--target-list=" ,machine "-linux-user"))
280 #:make-flags '("V=1")
281 #:phases
282 (modify-phases %standard-phases
283 (replace 'configure
284 (lambda* (#:key inputs outputs (configure-flags '())
285 #:allow-other-keys)
286 ;; The `configure' script doesn't understand some of the
287 ;; GNU options. Thus, add a new phase that's compatible.
288 (let ((out (assoc-ref outputs "out")))
289 (setenv "SHELL" (which "bash"))
290
291 ;; While we're at it, patch for tests.
292 (substitute* "tests/libqtest.c"
293 (("/bin/sh") (which "sh")))
294
295 ;; The binaries need to be linked against -lrt.
296 (setenv "LDFLAGS" "-lrt")
297 (apply invoke
298 `("./configure"
299 ,(string-append "--cc=" (which "gcc"))
300 ;; Some architectures insist on using HOST_CC
301 ,(string-append "--host-cc=" (which "gcc"))
302 "--disable-debug-info" ; save build space
303 "--enable-virtfs" ; just to be sure
304 ,(string-append "--prefix=" out)
305 ,(string-append "--sysconfdir=/etc")
306 ,@configure-flags)))))
307 (add-after
308 'unpack 'apply-afl-patches
309 (lambda* (#:key inputs #:allow-other-keys)
310 (let* ((afl-src (assoc-ref inputs "afl-source"))
311 (patch-dir "qemu_mode/patches"))
312 (copy-recursively (string-append afl-src "/"
313 patch-dir)
314 patch-dir)
315 (install-file
316 (string-append patch-dir
317 "/afl-qemu-cpu-inl.h")
318 ".")
319 (copy-file (string-append afl-src "/config.h")
320 "./afl-config.h")
321 (install-file (string-append afl-src "/types.h")
322 ".")
323 (substitute* "afl-qemu-cpu-inl.h"
324 (("\\.\\./\\.\\./config.h") "afl-config.h"))
325 (substitute* (string-append patch-dir
326 "/cpu-exec.diff")
327 (("\\.\\./patches/") ""))
328
329 ;; These were already applied to qemu-minimal-2.10.
330 (for-each (lambda (obsolete-patch)
331 (delete-file (string-append
332 patch-dir "/"
333 obsolete-patch)))
334 (list "configure.diff"
335 "memfd.diff"))
336
337 (for-each (lambda (patch-file)
338 (invoke "patch" "--force" "-p1"
339 "--input" patch-file))
340 (find-files patch-dir
341 "\\.diff$"))
342 #t)))
343 (add-before 'check 'disable-unusable-tests
344 (lambda* (#:key inputs outputs #:allow-other-keys)
345 (substitute* "tests/Makefile.include"
346 ;; Comment out the test-qga test, which needs /sys and
347 ;; fails within the build environment.
348 (("check-unit-.* tests/test-qga" all)
349 (string-append "# " all)))
350 (substitute* "tests/Makefile.include"
351 ;; Comment out the test-char test, which needs networking and
352 ;; fails within the build environment.
353 (("check-unit-.* tests/test-char" all)
354 (string-append "# " all)))
355 #t)))))
356 (native-inputs
357 `(("python-2" ,python-2) ; QEMU 2 needs Python 2
358 ("glib:bin" ,glib "bin")
359 ("perl" ,perl)
360 ("flex" ,flex)
361 ("bison" ,bison)
362 ("pkg-config" ,pkg-config)))
363 (inputs
364 `(("afl-source" ,(package-source american-fuzzy-lop))
365 ("alsa-lib" ,alsa-lib)
366 ("attr" ,attr)
367 ("glib" ,glib)
368 ("libaio" ,libaio)
369 ("libattr" ,attr)
370 ("libcap" ,libcap)
371 ("libjpeg" ,libjpeg-turbo)
372 ("libpng" ,libpng)
373 ("ncurses" ,ncurses)
374 ("pixman" ,pixman)
375 ("util-linux" ,util-linux)
376 ("zlib" ,zlib)))
377 (home-page "https://www.qemu.org")
378 (synopsis "Machine emulator and virtualizer (without GUI) for american fuzzy lop")
379 (description
380 "QEMU is a generic machine emulator and virtualizer. This package
381 of QEMU is used only by the american fuzzy lop package.
382
383 When used as a machine emulator, QEMU can run OSes and programs made for one
384 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
385 using dynamic translation, it achieves very good performance.
386
387 When used as a virtualizer, QEMU achieves near native performances by
388 executing the guest code directly on the host CPU. QEMU supports
389 virtualization when executing under the Xen hypervisor or using
390 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
391 server and embedded PowerPC, and S390 guests.")
392 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
393 (license license:gpl2)
394 ;; Several tests fail on MIPS.
395 (supported-systems (delete "mips64el-linux" %supported-systems))))))
396
397 (define-public stress-make
398 (let ((commit "97815bed8060de33952475b3498767c91f59ffd9")
399 (revision "2")) ;No official source distribution
400 (package
401 (name "stress-make")
402 (version (git-version "1.0" revision commit))
403 (source
404 (origin
405 (method git-fetch)
406 (uri (git-reference
407 (url "https://github.com/lanl/stress-make")
408 (commit commit)))
409 (file-name (git-file-name name version))
410 (sha256
411 (base32
412 "0k55cy7x0hlc6rgpascl6ibhcfxaash3p9r9r8kwvbm3zag1rmac"))))
413 (build-system gnu-build-system)
414 (native-inputs
415 `(("autoconf" ,autoconf)
416 ("automake" ,automake)
417 ("go" ,go)))
418 (inputs
419 `(("make-source" ,(package-source gnu-make))))
420 (arguments
421 ;; stress-make's configure script insists on having a tarball and does
422 ;; not accept a directory name instead. To let the gnu-build-system's
423 ;; patch-* phases work properly, we unpack the source first, then
424 ;; repack before the configure phase.
425 (let ((make-dir (string-append "make-" (package-version gnu-make))))
426 `(#:configure-flags '("--with-make-tar=./make.tar.xz"
427 "make_cv_sys_gnu_glob=yes")
428 #:phases
429 (modify-phases %standard-phases
430 (add-after 'unpack 'unpack-make
431 (lambda* (#:key inputs #:allow-other-keys)
432 (invoke "tar" "xf" (assoc-ref inputs "make-source"))))
433 (add-after 'unpack-make 'set-default-shell
434 (lambda _
435 ;; Taken mostly directly from (@ (gnu packages base) gnu-make)
436 (substitute* (string-append ,make-dir "/src/job.c")
437 (("default_shell = .*$")
438 (format #f "default_shell = \"~a\";\n"
439 (which "sh"))))))
440 (add-before 'configure 'repack-make
441 (lambda _
442 (invoke "tar" "cJf" "./make.tar.xz" ,make-dir)))
443 (add-before 'build 'setup-go
444 ;; The Go cache is required starting in Go 1.12, and it needs
445 ;; to be writable.
446 (lambda _ (setenv "GOCACHE" "/tmp/go-cache") #t))))))
447 (home-page "https://github.com/lanl/stress-make")
448 (synopsis "Expose race conditions in Makefiles")
449 (description
450 "Stress Make is a customized GNU Make that explicitly manages the order
451 in which concurrent jobs are run to provoke erroneous behavior into becoming
452 manifest. It can run jobs in the order in which they're launched, in backwards
453 order, or in random order. The thought is that if code builds correctly with
454 Stress Make, then it is likely that the @code{Makefile} contains no race
455 conditions.")
456 ;; stress-make wrapper is under BSD-3-modifications-must-be-indicated,
457 ;; and patched GNU Make is under its own license.
458 (license (list (license:non-copyleft "LICENSE.md")
459 license:gpl3+)))))
460
461 (define-public zzuf
462 (package
463 (name "zzuf")
464 (version "0.15")
465 (source
466 (origin
467 (method url-fetch)
468 (uri (string-append
469 "https://github.com/samhocevar/zzuf/releases/download/v"
470 version "/" name "-" version ".tar.gz"))
471 (file-name (string-append name "-" version ".tar.gz"))
472 (sha256
473 (base32
474 "1mpzjaksc2qg2hzqflf39pl06p53qam2dn3hkhkcv6p00d2n4kx3"))))
475 (build-system gnu-build-system)
476 (home-page "https://github.com/samhocevar/zzuf")
477 (synopsis "Transparent application input fuzzer")
478 (description "Zzuf is a transparent application input fuzzer. It works by
479 intercepting file operations and changing random bits in the program's
480 input. Zzuf's behaviour is deterministic, making it easy to reproduce bugs.")
481 (license license:wtfpl2)))
482
483 (define-public scanmem
484 (package
485 (name "scanmem")
486 (version "0.17")
487 (source
488 (origin
489 (method git-fetch)
490 (uri (git-reference
491 (url "https://github.com/scanmem/scanmem")
492 (commit (string-append "v" version))))
493 (file-name (git-file-name name version))
494 (sha256
495 (base32
496 "17p8sh0rj8yqz36ria5bp48c8523zzw3y9g8sbm2jwq7sc27i7s9"))))
497 (build-system gnu-build-system)
498 (arguments
499 `(#:configure-flags '("--enable-gui")
500 #:phases
501 (modify-phases %standard-phases
502 (add-before 'configure 'hardcode-python
503 (lambda* (#:key inputs outputs #:allow-other-keys)
504 (substitute* "gui/GameConqueror.py"
505 (("/usr/bin/env python")
506 (string-append (assoc-ref %build-inputs
507 "python-wrapper") "/bin/python")))
508 #t))
509 (add-after 'install 'wrap-gameconqueror
510 (lambda* (#:key inputs outputs #:allow-other-keys)
511 (let ((out (assoc-ref outputs "out"))
512 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
513 (python-path (getenv "PYTHONPATH")))
514 (wrap-program (string-append out "/share/gameconqueror/GameConqueror.py")
515 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
516 `("PYTHONPATH" ":" prefix (,python-path))))
517 #t)))))
518 (native-inputs
519 `(("libtool" ,libtool)
520 ("python-wrapper" ,python-wrapper)
521 ("gobject-introspection" ,gobject-introspection)
522 ("gtk+" ,gtk+)
523 ("intltool" ,intltool)
524 ("automake" ,automake)
525 ("autoconf" ,autoconf)))
526 (inputs
527 `(("readline" ,readline)))
528 (propagated-inputs
529 `(("python-pygobject" ,python-pygobject)))
530 (home-page "https://github.com/scanmem/scanmem")
531 (synopsis "Memory scanner")
532 (description "Scanmem is a debugging utility designed to isolate the
533 address of an arbitrary variable in an executing process. Scanmem simply
534 needs to be told the pid of the process and the value of the variable at
535 several different times. After several scans of the process, scanmem isolates
536 the position of the variable and allows you to modify its value.")
537 ;; The library is covered by LGPLv3 or later; the application is covered
538 ;; by GPLv3 or later.
539 (license (list license:lgpl3+ license:gpl3+))))
540
541 (define-public remake
542 (package (inherit gnu-make)
543 (name "remake")
544 (version "4.3-1.5")
545 (source (origin
546 (method url-fetch)
547 (uri (let ((upstream-version
548 (match (string-split version #\-)
549 ((ver sub) (string-append ver "%2Bdbg-" sub)))))
550 (string-append "mirror://sourceforge/bashdb/"
551 "remake/" upstream-version "/"
552 "remake-" upstream-version ".tar.gz")))
553 (file-name (string-append "remake-" version ".tar.gz"))
554 (sha256
555 (base32
556 "0xlx2485y0israv2pfghmv74lxcv9i5y65agy69mif76yc4vfvif"))
557 (patches (search-patches "remake-impure-dirs.patch"))))
558 (inputs
559 `(("readline" ,readline)
560 ,@(package-inputs gnu-make)))
561 (home-page "http://bashdb.sourceforge.net/remake/")
562 (description "Remake is an enhanced version of GNU Make that adds improved
563 error reporting, better tracing, profiling, and a debugger.")
564 (license license:gpl3+)))
565
566 (define-public rr
567 (package
568 (name "rr")
569 (version "5.4.0")
570 (source (origin
571 (method git-fetch)
572 (uri (git-reference
573 (url "https://github.com/mozilla/rr")
574 (commit version)))
575 (sha256
576 (base32
577 "1sfldgkkmsdyaqa28i5agcykc63gwm3zjihd64g86i852w8al2w6"))
578 (file-name (git-file-name name version))))
579 (build-system cmake-build-system)
580 (arguments
581 `(#:configure-flags
582 ;; The 'rr_exec_stub' is a static binary, which leads CMake to fail
583 ;; with ‘file RPATH_CHANGE could not write new RPATH: ...’.
584 ;; Clear CMAKE_INSTALL_RPATH to avoid that problem.
585 (list "-DCMAKE_INSTALL_RPATH="
586 ;; Satisfy the ‘validate-runpath’ phase. This isn't a direct
587 ;; consequence of clearing CMAKE_INSTALL_RPATH.
588 (string-append "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath="
589 (assoc-ref %build-inputs "capnproto") "/lib")
590 ,@(if (and (not (%current-target-system))
591 (member (%current-system)
592 '("x86_64-linux" "aarch64-linux")))
593 ;; The toolchain doesn't support '-m32'.
594 '("-Ddisable32bit=ON")
595 '()))
596
597 ;; XXX: Most tests fail with:
598 ;;
599 ;; rr needs /proc/sys/kernel/perf_event_paranoid <= 1, but it is 2.
600 ;;
601 ;; This setting cannot be changed from the build environment, so skip
602 ;; the tests.
603 #:tests? #f
604
605 #:phases (modify-phases %standard-phases
606 (add-before 'check 'set-home
607 (lambda _
608 ;; Some tests expect 'HOME' to be set.
609 (setenv "HOME" (getcwd))
610 #t)))))
611 (native-inputs
612 `(("pkg-config" ,pkg-config)
613 ("ninja" ,ninja)
614 ("which" ,which)))
615 (inputs
616 `(("gdb" ,gdb)
617 ("capnproto" ,capnproto)
618 ("python" ,python)
619 ("python-pexpect" ,python-pexpect)))
620 (home-page "https://rr-project.org/")
621 (synopsis "Record and reply debugging framework")
622 (description
623 "rr is a lightweight tool for recording, replaying and debugging
624 execution of applications (trees of processes and threads). Debugging extends
625 GDB with very efficient reverse-execution, which in combination with standard
626 GDB/x86 features like hardware data watchpoints, makes debugging much more
627 fun.")
628 (license license:expat)))
629
630 (define-public libbacktrace
631 ;; There are no releases nor tags.
632 (let ((revision "1")
633 (commit "5009c113981431ae1843ebd29d6ad24eb32fc1b2"))
634 (package
635 (name "libbacktrace")
636 (version (git-version "1.0" revision commit))
637 (source (origin
638 (method git-fetch)
639 (uri (git-reference
640 (url "https://github.com/ianlancetaylor/libbacktrace")
641 (commit commit)))
642 (file-name (git-file-name name version))
643 (sha256
644 (base32
645 "0663zjpfpnsyv9h3pbp7cgmg9gz79n68bqpdl97y6i0jsx93v1zg"))))
646 (build-system gnu-build-system)
647 (arguments
648 `(#:make-flags '("CFLAGS=-fPIC")))
649 (home-page "https://github.com/ianlancetaylor/libbacktrace")
650 (synopsis "C library for producing symbolic backtraces")
651 (description "The @code{libbacktrace} library can be linked into a C/C++
652 program to produce symbolic backtraces.")
653 (license license:bsd-3))))
654
655 (define-public libleak
656 (package
657 (name "libleak")
658 (version "0.3.5")
659 (source (origin
660 (method git-fetch)
661 (uri (git-reference
662 (url "https://github.com/WuBingzheng/libleak")
663 (commit (string-append "v" version))))
664 (file-name (git-file-name name version))
665 (sha256
666 (base32
667 "1p8mb0hcfp8hdv1klv6rrpkn2zlhjxgkxbbjsk8kszxv7ijln87d"))))
668 (build-system gnu-build-system)
669 (arguments
670 `(#:tests? #f ;no test suite
671 #:parallel-build? #f ;jobserver unavailable
672 #:phases (modify-phases %standard-phases
673 (add-after 'unpack 'unbundle-libwuya
674 (lambda _
675 (substitute* "Makefile"
676 ((".*make -C libwuya.*") ""))
677 #t))
678 (add-before 'build 'set-CC
679 (lambda _
680 (setenv "CC" "gcc")
681 #t))
682 (delete 'configure) ;no configure script
683 (replace 'install
684 (lambda* (#:key outputs #:allow-other-keys)
685 (let* ((out (assoc-ref outputs "out")))
686 (install-file "libleak.so" (string-append out "/lib"))
687 #t))))))
688 (inputs `(("libbacktrace" ,libbacktrace)
689 ("libwuya" ,libwuya)))
690 (home-page "https://github.com/WuBingzheng/libleak")
691 (synopsis "Memory leaks detection tool")
692 (description "The libleak tool detects memory leaks by hooking memory
693 functions such as @code{malloc}. It comes as a shared object to be pre-loaded
694 via @code{LD_PRELOAD} when launching the application. It prints the full call
695 stack at suspicious memory leak points. Modifying or recompiling the target
696 program is not required, and the detection can be enabled or disabled while
697 the target application is running. The overhead incurred by libleak is
698 smaller than that of other tools such as Valgrind, and it aims to be easier to
699 use than similar tools like @command{mtrace}.")
700 (license license:gpl2+)))
701
702 (define-public mspdebug
703 (package
704 (name "mspdebug")
705 (version "0.25")
706 (source (origin
707 (method git-fetch)
708 (uri (git-reference
709 (url "https://github.com/dlbeer/mspdebug")
710 (commit (string-append "v" version))))
711 (file-name (git-file-name name version))
712 (sha256
713 (base32 "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"))))
714 (build-system gnu-build-system)
715 (arguments
716 `(#:tests? #f ; no test suite
717 #:phases
718 (modify-phases %standard-phases
719 (delete 'configure)) ; no configure script
720 #:make-flags
721 (list (string-append "CC=" ,(cc-for-target))
722 "INSTALL=install"
723 (string-append "PREFIX=" %output))))
724 (inputs
725 `(("libusb-compat" ,libusb-compat)
726 ("readline" ,readline)))
727 (synopsis "Debugging tool for MSP430 MCUs")
728 (description "MspDebug supports FET430UIF, eZ430, RF2500 and Olimex
729 MSP430-JTAG-TINY programmers, as well as many other compatible
730 devices. It can be used as a proxy for gdb or as an independent
731 debugger with support for programming, disassembly and reverse
732 engineering.")
733 (home-page "https://github.com/dlbeer/mspdebug")
734 (license license:gpl2+)))