gnu: libretro-lowresnx: Update to 1.2.
[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, 2021 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 ("powerpc-linux" "ppc")
183 ;; Prevent errors when querying this package on unsupported
184 ;; platforms, e.g. when running "guix package --search="
185 (_ "UNSUPPORTED"))))
186 (package
187 (name "american-fuzzy-lop")
188 (version "2.57b") ;It seems all releases have the 'b' suffix
189 (source
190 (origin
191 (method git-fetch)
192 (uri (git-reference
193 (url "https://github.com/google/AFL")
194 (commit (string-append "v" version))))
195 (sha256
196 (base32 "0ks0s8iizp7mpc9mlpv126rsny0dkljfsw68689g9jiisjz2z530"))
197 (file-name (git-file-name name version))))
198 (build-system gnu-build-system)
199 (inputs
200 `(("qemu" ,qemu-for-american-fuzzy-lop)))
201 (arguments
202 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
203 (string-append "DOC_PATH=$(PREFIX)/share/doc/"
204 ,name "-" ,version)
205 "CC=gcc")
206 #:phases (modify-phases %standard-phases
207 (add-after 'unpack 'make-git-checkout-writable
208 (lambda _
209 (for-each make-file-writable (find-files "."))
210 #t))
211 (delete 'configure)
212 ,@(if (string=? (%current-system) (or "x86_64-linux"
213 "i686-linux"))
214 '()
215 '((add-before 'build 'set-afl-flag
216 (lambda _ (setenv "AFL_NO_X86" "1") #t))
217 (add-after 'install 'remove-x86-programs
218 (lambda* (#:key outputs #:allow-other-keys)
219 (let* ((out (assoc-ref outputs "out"))
220 (bin (string-append out "/bin/")))
221 (delete-file (string-append bin "afl-gcc"))
222 (delete-file (string-append bin "afl-g++"))
223 (delete-file (string-append bin "afl-clang"))
224 (delete-file (string-append bin "afl-clang++")))
225 #t))))
226 (add-after
227 ;; TODO: Build and install the afl-llvm tool.
228 'install 'install-qemu
229 (lambda* (#:key inputs outputs #:allow-other-keys)
230 (let ((qemu (assoc-ref inputs "qemu"))
231 (out (assoc-ref outputs "out")))
232 (symlink (string-append qemu "/bin/qemu-" ,machine)
233 (string-append out "/bin/afl-qemu-trace"))
234 #t)))
235 (delete 'check)))) ; tests are run during 'install phase
236 (home-page "https://lcamtuf.coredump.cx/afl/")
237 (synopsis "Security-oriented fuzzer")
238 (description
239 "American fuzzy lop is a security-oriented fuzzer that employs a novel
240 type of compile-time instrumentation and genetic algorithms to automatically
241 discover clean, interesting test cases that trigger new internal states in the
242 targeted binary. This substantially improves the functional coverage for the
243 fuzzed code. The compact synthesized corpora produced by the tool are also
244 useful for seeding other, more labor- or resource-intensive testing regimes
245 down the road.")
246 (license license:asl2.0))))
247
248 (define-public qemu-for-american-fuzzy-lop
249 ;; afl only supports using a single afl-qemu-trace executable, so
250 ;; we only build qemu for the native target.
251 (let ((machine (match (or (%current-target-system)
252 (%current-system))
253 ("x86_64-linux" "x86_64")
254 ("i686-linux" "i386")
255 ("aarch64-linux" "aarch64")
256 ("armhf-linux" "arm")
257 ("mips64el-linux" "mips64el")
258 ("powerpc-linux" "ppc")
259 ;; Prevent errors when querying this package on unsupported
260 ;; platforms, e.g. when running "guix package --search="
261 (_ "UNSUPPORTED"))))
262 (hidden-package
263 (package
264 (name "qemu")
265 (version "2.10.2")
266 (source (origin
267 (method url-fetch)
268 (uri (string-append "https://download.qemu.org/qemu-"
269 version ".tar.xz"))
270 (sha256
271 (base32
272 "17w21spvaxaidi2am5lpsln8yjpyp2zi3s3gc6nsxj5arlgamzgw"))
273 (patches
274 (search-patches "qemu-glibc-2.27.patch"
275 "qemu-glibc-2.30.patch"))))
276 (build-system gnu-build-system)
277 (arguments
278 `(;; Running tests in parallel can occasionally lead to failures, like:
279 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
280 #:parallel-tests? #f
281 #:configure-flags
282 (list (string-append "--target-list=" ,machine "-linux-user"))
283 #:make-flags '("V=1")
284 #:phases
285 (modify-phases %standard-phases
286 (replace 'configure
287 (lambda* (#:key inputs outputs (configure-flags '())
288 #:allow-other-keys)
289 ;; The `configure' script doesn't understand some of the
290 ;; GNU options. Thus, add a new phase that's compatible.
291 (let ((out (assoc-ref outputs "out")))
292 (setenv "SHELL" (which "bash"))
293
294 ;; While we're at it, patch for tests.
295 (substitute* "tests/libqtest.c"
296 (("/bin/sh") (which "sh")))
297
298 ;; The binaries need to be linked against -lrt.
299 (setenv "LDFLAGS" "-lrt")
300 (apply invoke
301 `("./configure"
302 ,(string-append "--cc=" (which "gcc"))
303 ;; Some architectures insist on using HOST_CC
304 ,(string-append "--host-cc=" (which "gcc"))
305 "--disable-debug-info" ; save build space
306 "--enable-virtfs" ; just to be sure
307 ,(string-append "--prefix=" out)
308 ,(string-append "--sysconfdir=/etc")
309 ,@configure-flags)))))
310 (add-after
311 'unpack 'apply-afl-patches
312 (lambda* (#:key inputs #:allow-other-keys)
313 (let* ((afl-src (assoc-ref inputs "afl-source"))
314 (patch-dir "qemu_mode/patches"))
315 (copy-recursively (string-append afl-src "/"
316 patch-dir)
317 patch-dir)
318 (install-file
319 (string-append patch-dir
320 "/afl-qemu-cpu-inl.h")
321 ".")
322 (copy-file (string-append afl-src "/config.h")
323 "./afl-config.h")
324 (install-file (string-append afl-src "/types.h")
325 ".")
326 (substitute* "afl-qemu-cpu-inl.h"
327 (("\\.\\./\\.\\./config.h") "afl-config.h"))
328 (substitute* (string-append patch-dir
329 "/cpu-exec.diff")
330 (("\\.\\./patches/") ""))
331
332 ;; These were already applied to qemu-minimal-2.10.
333 (for-each (lambda (obsolete-patch)
334 (delete-file (string-append
335 patch-dir "/"
336 obsolete-patch)))
337 (list "configure.diff"
338 "memfd.diff"))
339
340 (for-each (lambda (patch-file)
341 (invoke "patch" "--force" "-p1"
342 "--input" patch-file))
343 (find-files patch-dir
344 "\\.diff$"))
345 #t)))
346 (add-before 'check 'disable-unusable-tests
347 (lambda* (#:key inputs outputs #:allow-other-keys)
348 (substitute* "tests/Makefile.include"
349 ;; Comment out the test-qga test, which needs /sys and
350 ;; fails within the build environment.
351 (("check-unit-.* tests/test-qga" all)
352 (string-append "# " all)))
353 (substitute* "tests/Makefile.include"
354 ;; Comment out the test-char test, which needs networking and
355 ;; fails within the build environment.
356 (("check-unit-.* tests/test-char" all)
357 (string-append "# " all)))
358 #t)))))
359 (native-inputs
360 `(("python-2" ,python-2) ; QEMU 2 needs Python 2
361 ("glib:bin" ,glib "bin")
362 ("perl" ,perl)
363 ("flex" ,flex)
364 ("bison" ,bison)
365 ("pkg-config" ,pkg-config)))
366 (inputs
367 `(("afl-source" ,(package-source american-fuzzy-lop))
368 ("alsa-lib" ,alsa-lib)
369 ("attr" ,attr)
370 ("glib" ,glib)
371 ("libaio" ,libaio)
372 ("libattr" ,attr)
373 ("libcap" ,libcap)
374 ("libjpeg" ,libjpeg-turbo)
375 ("libpng" ,libpng)
376 ("ncurses" ,ncurses)
377 ("pixman" ,pixman)
378 ("util-linux" ,util-linux)
379 ("zlib" ,zlib)))
380 (home-page "https://www.qemu.org")
381 (synopsis "Machine emulator and virtualizer (without GUI) for american fuzzy lop")
382 (description
383 "QEMU is a generic machine emulator and virtualizer. This package
384 of QEMU is used only by the american fuzzy lop package.
385
386 When used as a machine emulator, QEMU can run OSes and programs made for one
387 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
388 using dynamic translation, it achieves very good performance.
389
390 When used as a virtualizer, QEMU achieves near native performances by
391 executing the guest code directly on the host CPU. QEMU supports
392 virtualization when executing under the Xen hypervisor or using
393 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
394 server and embedded PowerPC, and S390 guests.")
395 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
396 (license license:gpl2)
397 ;; Several tests fail on MIPS.
398 (supported-systems (delete "mips64el-linux" %supported-systems))))))
399
400 (define-public stress-make
401 (let ((commit "97815bed8060de33952475b3498767c91f59ffd9")
402 (revision "2")) ;No official source distribution
403 (package
404 (name "stress-make")
405 (version (git-version "1.0" revision commit))
406 (source
407 (origin
408 (method git-fetch)
409 (uri (git-reference
410 (url "https://github.com/lanl/stress-make")
411 (commit commit)))
412 (file-name (git-file-name name version))
413 (sha256
414 (base32
415 "0k55cy7x0hlc6rgpascl6ibhcfxaash3p9r9r8kwvbm3zag1rmac"))))
416 (build-system gnu-build-system)
417 (native-inputs
418 `(("autoconf" ,autoconf)
419 ("automake" ,automake)
420 ("go" ,go)))
421 (inputs
422 `(("make-source" ,(package-source gnu-make))))
423 (arguments
424 ;; stress-make's configure script insists on having a tarball and does
425 ;; not accept a directory name instead. To let the gnu-build-system's
426 ;; patch-* phases work properly, we unpack the source first, then
427 ;; repack before the configure phase.
428 (let ((make-dir (string-append "make-" (package-version gnu-make))))
429 `(#:configure-flags '("--with-make-tar=./make.tar.xz"
430 "make_cv_sys_gnu_glob=yes")
431 #:phases
432 (modify-phases %standard-phases
433 (add-after 'unpack 'unpack-make
434 (lambda* (#:key inputs #:allow-other-keys)
435 (invoke "tar" "xf" (assoc-ref inputs "make-source"))))
436 (add-after 'unpack-make 'set-default-shell
437 (lambda _
438 ;; Taken mostly directly from (@ (gnu packages base) gnu-make)
439 (substitute* (string-append ,make-dir "/src/job.c")
440 (("default_shell = .*$")
441 (format #f "default_shell = \"~a\";\n"
442 (which "sh"))))))
443 (add-before 'configure 'repack-make
444 (lambda _
445 (invoke "tar" "cJf" "./make.tar.xz" ,make-dir)))
446 (add-before 'build 'setup-go
447 ;; The Go cache is required starting in Go 1.12, and it needs
448 ;; to be writable.
449 (lambda _ (setenv "GOCACHE" "/tmp/go-cache") #t))))))
450 (home-page "https://github.com/lanl/stress-make")
451 (synopsis "Expose race conditions in Makefiles")
452 (description
453 "Stress Make is a customized GNU Make that explicitly manages the order
454 in which concurrent jobs are run to provoke erroneous behavior into becoming
455 manifest. It can run jobs in the order in which they're launched, in backwards
456 order, or in random order. The thought is that if code builds correctly with
457 Stress Make, then it is likely that the @code{Makefile} contains no race
458 conditions.")
459 ;; stress-make wrapper is under BSD-3-modifications-must-be-indicated,
460 ;; and patched GNU Make is under its own license.
461 (license (list (license:non-copyleft "LICENSE.md")
462 license:gpl3+)))))
463
464 (define-public zzuf
465 (package
466 (name "zzuf")
467 (version "0.15")
468 (source
469 (origin
470 (method url-fetch)
471 (uri (string-append
472 "https://github.com/samhocevar/zzuf/releases/download/v"
473 version "/" name "-" version ".tar.gz"))
474 (file-name (string-append name "-" version ".tar.gz"))
475 (sha256
476 (base32
477 "1mpzjaksc2qg2hzqflf39pl06p53qam2dn3hkhkcv6p00d2n4kx3"))))
478 (build-system gnu-build-system)
479 (home-page "https://github.com/samhocevar/zzuf")
480 (synopsis "Transparent application input fuzzer")
481 (description "Zzuf is a transparent application input fuzzer. It works by
482 intercepting file operations and changing random bits in the program's
483 input. Zzuf's behaviour is deterministic, making it easy to reproduce bugs.")
484 (license license:wtfpl2)))
485
486 (define-public scanmem
487 (package
488 (name "scanmem")
489 (version "0.17")
490 (source
491 (origin
492 (method git-fetch)
493 (uri (git-reference
494 (url "https://github.com/scanmem/scanmem")
495 (commit (string-append "v" version))))
496 (file-name (git-file-name name version))
497 (sha256
498 (base32
499 "17p8sh0rj8yqz36ria5bp48c8523zzw3y9g8sbm2jwq7sc27i7s9"))))
500 (build-system gnu-build-system)
501 (arguments
502 `(#:configure-flags '("--enable-gui")
503 #:phases
504 (modify-phases %standard-phases
505 (add-before 'configure 'hardcode-python
506 (lambda* (#:key inputs outputs #:allow-other-keys)
507 (substitute* "gui/GameConqueror.py"
508 (("/usr/bin/env python")
509 (string-append (assoc-ref %build-inputs
510 "python-wrapper") "/bin/python")))
511 #t))
512 (add-after 'install 'wrap-gameconqueror
513 (lambda* (#:key inputs outputs #:allow-other-keys)
514 (let ((out (assoc-ref outputs "out"))
515 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
516 (python-path (getenv "PYTHONPATH")))
517 (wrap-program (string-append out "/share/gameconqueror/GameConqueror.py")
518 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
519 `("PYTHONPATH" ":" prefix (,python-path))))
520 #t)))))
521 (native-inputs
522 `(("libtool" ,libtool)
523 ("python-wrapper" ,python-wrapper)
524 ("gobject-introspection" ,gobject-introspection)
525 ("gtk+" ,gtk+)
526 ("intltool" ,intltool)
527 ("automake" ,automake)
528 ("autoconf" ,autoconf)))
529 (inputs
530 `(("readline" ,readline)))
531 (propagated-inputs
532 `(("python-pygobject" ,python-pygobject)))
533 (home-page "https://github.com/scanmem/scanmem")
534 (synopsis "Memory scanner")
535 (description "Scanmem is a debugging utility designed to isolate the
536 address of an arbitrary variable in an executing process. Scanmem simply
537 needs to be told the pid of the process and the value of the variable at
538 several different times. After several scans of the process, scanmem isolates
539 the position of the variable and allows you to modify its value.")
540 ;; The library is covered by LGPLv3 or later; the application is covered
541 ;; by GPLv3 or later.
542 (license (list license:lgpl3+ license:gpl3+))))
543
544 (define-public remake
545 (package (inherit gnu-make)
546 (name "remake")
547 (version "4.3-1.5")
548 (source (origin
549 (method url-fetch)
550 (uri (let ((upstream-version
551 (match (string-split version #\-)
552 ((ver sub) (string-append ver "%2Bdbg-" sub)))))
553 (string-append "mirror://sourceforge/bashdb/"
554 "remake/" upstream-version "/"
555 "remake-" upstream-version ".tar.gz")))
556 (file-name (string-append "remake-" version ".tar.gz"))
557 (sha256
558 (base32
559 "0xlx2485y0israv2pfghmv74lxcv9i5y65agy69mif76yc4vfvif"))
560 (patches (search-patches "remake-impure-dirs.patch"))))
561 (inputs
562 `(("readline" ,readline)
563 ,@(package-inputs gnu-make)))
564 (home-page "http://bashdb.sourceforge.net/remake/")
565 (description "Remake is an enhanced version of GNU Make that adds improved
566 error reporting, better tracing, profiling, and a debugger.")
567 (license license:gpl3+)))
568
569 (define-public rr
570 (package
571 (name "rr")
572 (version "5.4.0")
573 (source (origin
574 (method git-fetch)
575 (uri (git-reference
576 (url "https://github.com/mozilla/rr")
577 (commit version)))
578 (sha256
579 (base32
580 "1sfldgkkmsdyaqa28i5agcykc63gwm3zjihd64g86i852w8al2w6"))
581 (file-name (git-file-name name version))))
582 (build-system cmake-build-system)
583 (arguments
584 `(#:configure-flags
585 ;; The 'rr_exec_stub' is a static binary, which leads CMake to fail
586 ;; with ‘file RPATH_CHANGE could not write new RPATH: ...’.
587 ;; Clear CMAKE_INSTALL_RPATH to avoid that problem.
588 (list "-DCMAKE_INSTALL_RPATH="
589 ;; Satisfy the ‘validate-runpath’ phase. This isn't a direct
590 ;; consequence of clearing CMAKE_INSTALL_RPATH.
591 (string-append "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath="
592 (assoc-ref %build-inputs "capnproto") "/lib")
593 ,@(if (and (not (%current-target-system))
594 (member (%current-system)
595 '("x86_64-linux" "aarch64-linux")))
596 ;; The toolchain doesn't support '-m32'.
597 '("-Ddisable32bit=ON")
598 '()))
599
600 ;; XXX: Most tests fail with:
601 ;;
602 ;; rr needs /proc/sys/kernel/perf_event_paranoid <= 1, but it is 2.
603 ;;
604 ;; This setting cannot be changed from the build environment, so skip
605 ;; the tests.
606 #:tests? #f
607
608 #:phases (modify-phases %standard-phases
609 (add-before 'check 'set-home
610 (lambda _
611 ;; Some tests expect 'HOME' to be set.
612 (setenv "HOME" (getcwd))
613 #t)))))
614 (native-inputs
615 `(("pkg-config" ,pkg-config)
616 ("ninja" ,ninja)
617 ("which" ,which)))
618 (inputs
619 `(("gdb" ,gdb)
620 ("capnproto" ,capnproto)
621 ("python" ,python)
622 ("python-pexpect" ,python-pexpect)))
623 (home-page "https://rr-project.org/")
624 (synopsis "Record and reply debugging framework")
625 (description
626 "rr is a lightweight tool for recording, replaying and debugging
627 execution of applications (trees of processes and threads). Debugging extends
628 GDB with very efficient reverse-execution, which in combination with standard
629 GDB/x86 features like hardware data watchpoints, makes debugging much more
630 fun.")
631 (license license:expat)))
632
633 (define-public libbacktrace
634 ;; There are no releases nor tags.
635 (let ((revision "1")
636 (commit "5009c113981431ae1843ebd29d6ad24eb32fc1b2"))
637 (package
638 (name "libbacktrace")
639 (version (git-version "1.0" revision commit))
640 (source (origin
641 (method git-fetch)
642 (uri (git-reference
643 (url "https://github.com/ianlancetaylor/libbacktrace")
644 (commit commit)))
645 (file-name (git-file-name name version))
646 (sha256
647 (base32
648 "0663zjpfpnsyv9h3pbp7cgmg9gz79n68bqpdl97y6i0jsx93v1zg"))))
649 (build-system gnu-build-system)
650 (arguments
651 `(#:make-flags '("CFLAGS=-fPIC")))
652 (home-page "https://github.com/ianlancetaylor/libbacktrace")
653 (synopsis "C library for producing symbolic backtraces")
654 (description "The @code{libbacktrace} library can be linked into a C/C++
655 program to produce symbolic backtraces.")
656 (license license:bsd-3))))
657
658 (define-public libleak
659 (package
660 (name "libleak")
661 (version "0.3.5")
662 (source (origin
663 (method git-fetch)
664 (uri (git-reference
665 (url "https://github.com/WuBingzheng/libleak")
666 (commit (string-append "v" version))))
667 (file-name (git-file-name name version))
668 (sha256
669 (base32
670 "1p8mb0hcfp8hdv1klv6rrpkn2zlhjxgkxbbjsk8kszxv7ijln87d"))))
671 (build-system gnu-build-system)
672 (arguments
673 `(#:tests? #f ;no test suite
674 #:parallel-build? #f ;jobserver unavailable
675 #:phases (modify-phases %standard-phases
676 (add-after 'unpack 'unbundle-libwuya
677 (lambda _
678 (substitute* "Makefile"
679 ((".*make -C libwuya.*") ""))
680 #t))
681 (add-before 'build 'set-CC
682 (lambda _
683 (setenv "CC" "gcc")
684 #t))
685 (delete 'configure) ;no configure script
686 (replace 'install
687 (lambda* (#:key outputs #:allow-other-keys)
688 (let* ((out (assoc-ref outputs "out")))
689 (install-file "libleak.so" (string-append out "/lib"))
690 #t))))))
691 (inputs `(("libbacktrace" ,libbacktrace)
692 ("libwuya" ,libwuya)))
693 (home-page "https://github.com/WuBingzheng/libleak")
694 (synopsis "Memory leaks detection tool")
695 (description "The libleak tool detects memory leaks by hooking memory
696 functions such as @code{malloc}. It comes as a shared object to be pre-loaded
697 via @code{LD_PRELOAD} when launching the application. It prints the full call
698 stack at suspicious memory leak points. Modifying or recompiling the target
699 program is not required, and the detection can be enabled or disabled while
700 the target application is running. The overhead incurred by libleak is
701 smaller than that of other tools such as Valgrind, and it aims to be easier to
702 use than similar tools like @command{mtrace}.")
703 (license license:gpl2+)))
704
705 (define-public mspdebug
706 (package
707 (name "mspdebug")
708 (version "0.25")
709 (source (origin
710 (method git-fetch)
711 (uri (git-reference
712 (url "https://github.com/dlbeer/mspdebug")
713 (commit (string-append "v" version))))
714 (file-name (git-file-name name version))
715 (sha256
716 (base32 "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"))))
717 (build-system gnu-build-system)
718 (arguments
719 `(#:tests? #f ; no test suite
720 #:phases
721 (modify-phases %standard-phases
722 (delete 'configure)) ; no configure script
723 #:make-flags
724 (list (string-append "CC=" ,(cc-for-target))
725 "INSTALL=install"
726 (string-append "PREFIX=" %output))))
727 (inputs
728 `(("libusb-compat" ,libusb-compat)
729 ("readline" ,readline)))
730 (synopsis "Debugging tool for MSP430 MCUs")
731 (description "MspDebug supports FET430UIF, eZ430, RF2500 and Olimex
732 MSP430-JTAG-TINY programmers, as well as many other compatible
733 devices. It can be used as a proxy for gdb or as an independent
734 debugger with support for programming, disassembly and reverse
735 engineering.")
736 (home-page "https://github.com/dlbeer/mspdebug")
737 (license license:gpl2+)))