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