summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gnu/packages/debug.scm49
1 files changed, 49 insertions, 0 deletions
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index b55a4010e3..9041cac4e2 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2019 Pkill -9 <pkill9@runbox.com>
 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
 ;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -36,6 +37,7 @@
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages code)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages flex)
@@ -649,6 +651,53 @@ fun.")
 program to produce symbolic backtraces.")
       (license license:expat))))
 
+(define-public libleak
+  (package
+    (name "libleak")
+    (version "0.3.5")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/WuBingzheng/libleak")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1p8mb0hcfp8hdv1klv6rrpkn2zlhjxgkxbbjsk8kszxv7ijln87d"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f                      ;no test suite
+       #:parallel-build? #f             ;jobserver unavailable
+       #:phases (modify-phases %standard-phases
+                  (add-after 'unpack 'unbundle-libwuya
+                    (lambda _
+                      (substitute* "Makefile"
+                        ((".*make -C libwuya.*") ""))
+                      #t))
+                  (add-before 'build 'set-CC
+                    (lambda _
+                      (setenv "CC" "gcc")
+                      #t))
+                  (delete 'configure)   ;no configure script
+                  (replace 'install
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let* ((out (assoc-ref outputs "out")))
+                        (install-file "libleak.so" (string-append out "/lib"))
+                        #t))))))
+    (inputs `(("libbacktrace" ,libbacktrace)
+              ("libwuya" ,libwuya)))
+    (home-page "https://github.com/WuBingzheng/libleak")
+    (synopsis "Memory leaks detection tool")
+    (description "The libleak tool detects memory leaks by hooking memory
+functions such as @code{malloc}.  It comes as a shared object to be pre-loaded
+via @code{LD_PRELOAD} when launching the application.  It prints the full call
+stack at suspicious memory leak points.  Modifying or recompiling the target
+program is not required, and the detection can be enabled or disabled while
+the target application is running.  The overhead incurred by libleak is
+smaller than that of other tools such as Valgrind, and it aims to be easier to
+use than similar tools like @command{mtrace}.")
+    (license license:gpl2+)))
+
 (define-public mspdebug
   (package
     (name "mspdebug")