| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | (define-module (gnu packages debug)
|
| 20 | #:use-module (guix packages)
|
| 21 | #:use-module (guix licenses)
|
| 22 | #:use-module (guix download)
|
| 23 | #:use-module (guix utils)
|
| 24 | #:use-module (guix build-system gnu)
|
| 25 | #:use-module (gnu packages bash)
|
| 26 | #:use-module (gnu packages flex)
|
| 27 | #:use-module (gnu packages indent)
|
| 28 | #:use-module (gnu packages llvm)
|
| 29 | #:use-module (gnu packages perl)
|
| 30 | #:use-module (gnu packages pretty-print)
|
| 31 | #:use-module (gnu packages qemu)
|
| 32 | #:use-module (ice-9 match)
|
| 33 | #:use-module (srfi srfi-1))
|
| 34 |
|
| 35 | (define-public delta
|
| 36 | (package
|
| 37 | (name "delta")
|
| 38 | (version "2006.08.03")
|
| 39 | (source
|
| 40 | (origin
|
| 41 | (method url-fetch)
|
| 42 | (uri (list
|
| 43 | (string-append "http://ftp.de.debian.org/debian/pool/main/d/delta/"
|
| 44 | "delta_" version ".orig.tar.gz")
|
| 45 | |
| 46 | (string-append "http://delta.tigris.org/files/documents/3103/"
|
| 47 | "33566/delta-" version ".tar.gz")))
|
| 48 | (sha256
|
| 49 | (base32
|
| 50 | "184wh35pf2ddx97319s6sgkzpz48xxkbwzcjpycv009bm53lh61q"))))
|
| 51 | (build-system gnu-build-system)
|
| 52 | (inputs |
| 53 | `(("perl" ,perl)))
|
| 54 | (arguments
|
| 55 | `(#:phases
|
| 56 | (alist-replace
|
| 57 | 'install
|
| 58 | (lambda* (#:key outputs #:allow-other-keys)
|
| 59 | |
| 60 | (let* ((out (assoc-ref outputs "out"))
|
| 61 | (bin (string-append out "/bin"))
|
| 62 | (doc (string-append out "/share/doc/delta-" ,version)))
|
| 63 | (begin
|
| 64 | (mkdir-p bin)
|
| 65 | (mkdir-p doc)
|
| 66 | (for-each (lambda (h)
|
| 67 | (copy-file h (string-append doc "/" (basename h))))
|
| 68 | `("License.txt" ,@(find-files "www" ".*\\.html")))
|
| 69 | (for-each (lambda (b)
|
| 70 | (copy-file b (string-append bin "/" b)))
|
| 71 | `("delta" "multidelta" "topformflat")))))
|
| 72 | (alist-delete 'configure %standard-phases))))
|
| 73 | (home-page "http://delta.tigris.org/")
|
| 74 | (synopsis "Heuristical file minimizer")
|
| 75 | (description
|
| 76 | "Delta assists you in minimizing \"interesting\" files subject to a test
|
| 77 | of their interestingness. A common such situation is when attempting to
|
| 78 | isolate a small failure-inducing substring of a large input that causes your
|
| 79 | program to exhibit a bug.")
|
| 80 | |
| 81 | |
| 82 | (license bsd-3)))
|
| 83 |
|
| 84 | (define-public c-reduce
|
| 85 | (package
|
| 86 | (name "c-reduce")
|
| 87 | (version "2.3.0")
|
| 88 | (source
|
| 89 | (origin
|
| 90 | (method url-fetch)
|
| 91 | (uri (list
|
| 92 | (string-append "http://embed.cs.utah.edu/creduce/"
|
| 93 | "creduce-" version ".tar.gz")))
|
| 94 | (sha256
|
| 95 | (base32
|
| 96 | "0r9lvnifjcnsrkrk8k4mha1kmmb93jya7alm523ck59y3173bpi0"))
|
| 97 | (modules '((guix build utils)))
|
| 98 | (snippet
|
| 99 | '(substitute* "clang_delta/TransformationManager.cpp"
|
| 100 | (("llvm/Config/config.h") "llvm/Config/llvm-config.h")))))
|
| 101 | (build-system gnu-build-system)
|
| 102 | (inputs
|
| 103 | `(("astyle" ,astyle)
|
| 104 | ("delta" ,delta)
|
| 105 | ("llvm" ,llvm)
|
| 106 | ("clang" ,clang)
|
| 107 | ("flex" ,flex)
|
| 108 | ("indent" ,indent)
|
| 109 | ("perl" ,perl)
|
| 110 | ("benchmark-timer" ,perl-benchmark-timer)
|
| 111 | ("exporter-lite" ,perl-exporter-lite)
|
| 112 | ("file-which" ,perl-file-which)
|
| 113 | ("getopt-tabular" ,perl-getopt-tabular)
|
| 114 | ("regex-common" ,perl-regexp-common)
|
| 115 | ("sys-cpu" ,perl-sys-cpu)))
|
| 116 | (arguments
|
| 117 | `(#:phases (alist-cons-after
|
| 118 | 'install 'set-load-paths
|
| 119 | (lambda* (#:key inputs outputs #:allow-other-keys)
|
| 120 | |
| 121 | (let* ((out (assoc-ref outputs "out"))
|
| 122 | (prog (string-append out "/bin/creduce")))
|
| 123 | (wrap-program
|
| 124 | prog
|
| 125 | `("PERL5LIB" ":" prefix
|
| 126 | ,(map (lambda (p)
|
| 127 | (string-append (assoc-ref inputs p)
|
| 128 | "/lib/perl5/site_perl/"
|
| 129 | ,(package-version perl)))
|
| 130 | '("benchmark-timer" "exporter-lite"
|
| 131 | "file-which" "getopt-tabular"
|
| 132 | "regex-common" "sys-cpu"))))))
|
| 133 | %standard-phases)))
|
| 134 | (home-page "http://embed.cs.utah.edu/creduce")
|
| 135 | (synopsis "Reducer for interesting code")
|
| 136 | (description
|
| 137 | "C-Reduce is a tool that takes a large C or C++ program that has a
|
| 138 | property of interest (such as triggering a compiler bug) and automatically
|
| 139 | produces a much smaller C/C++ program that has the same property. It is
|
| 140 | intended for use by people who discover and report bugs in compilers and other
|
| 141 | tools that process C/C++ code.")
|
| 142 | (license ncsa)))
|
| 143 |
|
| 144 | (define qemu-2.3.0
|
| 145 | (package
|
| 146 | (inherit qemu-minimal)
|
| 147 | (version "2.3.0")
|
| 148 | (source (origin
|
| 149 | (method url-fetch)
|
| 150 | (uri (string-append
|
| 151 | "http://wiki.qemu-project.org/download/qemu-"
|
| 152 | version ".tar.bz2"))
|
| 153 | (sha256
|
| 154 | (base32
|
| 155 | "120m53c3p28qxmfzllicjzr8syjv6v4d9rsyrgkp7gnmcgvvgfmn"))))
|
| 156 | (arguments
|
| 157 | |
| 158 | |
| 159 | `(#:tests? #f
|
| 160 | ,@(package-arguments qemu-minimal)))))
|
| 161 |
|
| 162 | (define-public american-fuzzy-lop
|
| 163 | (let ((machine (match (or (%current-target-system)
|
| 164 | (%current-system))
|
| 165 | ("x86_64-linux" "x86_64")
|
| 166 | ("i686-linux" "i386")
|
| 167 | |
| 168 | |
| 169 | (_ "UNSUPPORTED"))))
|
| 170 | (package
|
| 171 | (name "american-fuzzy-lop")
|
| 172 | (version "2.15b") |
| 173 | (source
|
| 174 | (origin
|
| 175 | (method url-fetch)
|
| 176 | (uri (string-append "http://lcamtuf.coredump.cx/afl/releases/"
|
| 177 | "afl-" version ".tgz"))
|
| 178 | (sha256
|
| 179 | (base32
|
| 180 | "04n2jfkchpz6a07w694b0im1vcmc3220ryqcaasa7vix7784wzs2"))))
|
| 181 | (build-system gnu-build-system)
|
| 182 | (inputs
|
| 183 | `(("custom-qemu"
|
| 184 | |
| 185 | ,(package (inherit qemu-2.3.0)
|
| 186 | (name "afl-qemu")
|
| 187 | (inputs
|
| 188 | `(("afl-src" ,source)
|
| 189 | ,@(package-inputs qemu-2.3.0)))
|
| 190 | |
| 191 | |
| 192 | (arguments
|
| 193 | `(#:modules ((srfi srfi-1)
|
| 194 | ,@%gnu-build-system-modules)
|
| 195 | ,@(substitute-keyword-arguments (package-arguments qemu-2.3.0)
|
| 196 | ((#:configure-flags config-flags)
|
| 197 | ``(,(string-append "--target-list=" ,machine "-linux-user")
|
| 198 | ,@(remove (λ (f) (string-prefix? "--target-list=" f))
|
| 199 | ,config-flags)))
|
| 200 | ((#:phases qemu-phases)
|
| 201 | `(modify-phases ,qemu-phases
|
| 202 | (add-after
|
| 203 | 'unpack 'apply-afl-patches
|
| 204 | (lambda* (#:key inputs #:allow-other-keys)
|
| 205 | (let* ((afl-dir (string-append "afl-" ,version))
|
| 206 | (patch-dir
|
| 207 | (string-append afl-dir
|
| 208 | "/qemu_mode/patches")))
|
| 209 | (unless (zero?
|
| 210 | (system* "tar" "xf"
|
| 211 | (assoc-ref inputs "afl-src")))
|
| 212 | (error "tar failed to unpack afl-src"))
|
| 213 | (copy-file (string-append patch-dir
|
| 214 | "/afl-qemu-cpu-inl.h")
|
| 215 | "./afl-qemu-cpu-inl.h")
|
| 216 | (copy-file (string-append afl-dir "/config.h")
|
| 217 | "./afl-config.h")
|
| 218 | (copy-file (string-append afl-dir "/types.h")
|
| 219 | "./types.h")
|
| 220 | (substitute* "afl-qemu-cpu-inl.h"
|
| 221 | (("\\.\\./\\.\\./config.h") "afl-config.h"))
|
| 222 | (substitute* (string-append patch-dir
|
| 223 | "/cpu-exec.diff")
|
| 224 | (("\\.\\./patches/") ""))
|
| 225 | (every (lambda (patch-file)
|
| 226 | (zero? (system* "patch" "--force" "-p1"
|
| 227 | "--input" patch-file)))
|
| 228 | (find-files patch-dir
|
| 229 | "\\.diff$"))))))))))))))
|
| 230 | (arguments
|
| 231 | `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
|
| 232 | "CC=gcc")
|
| 233 | #:phases (modify-phases %standard-phases
|
| 234 | (delete 'configure)
|
| 235 | (add-after
|
| 236 | |
| 237 | 'install 'install-qemu
|
| 238 | (lambda* (#:key inputs outputs #:allow-other-keys)
|
| 239 | (let ((qemu (assoc-ref inputs "custom-qemu"))
|
| 240 | (out (assoc-ref outputs "out")))
|
| 241 | (symlink (string-append qemu "/bin/qemu-" ,machine)
|
| 242 | (string-append out "/bin/afl-qemu-trace"))
|
| 243 | #t)))
|
| 244 | (delete 'check))))
|
| 245 | (supported-systems (fold delete
|
| 246 | %supported-systems
|
| 247 | '("armhf-linux" "mips64el-linux")))
|
| 248 | (home-page "http://lcamtuf.coredump.cx/afl")
|
| 249 | (synopsis "Security-oriented fuzzer")
|
| 250 | (description
|
| 251 | "American fuzzy lop is a security-oriented fuzzer that employs a novel
|
| 252 | type of compile-time instrumentation and genetic algorithms to automatically
|
| 253 | discover clean, interesting test cases that trigger new internal states in the
|
| 254 | targeted binary. This substantially improves the functional coverage for the
|
| 255 | fuzzed code. The compact synthesized corpora produced by the tool are also
|
| 256 | useful for seeding other, more labor- or resource-intensive testing regimes
|
| 257 | down the road.")
|
| 258 | (license asl2.0))))
|