gnu: qtwebengine: Rename to qtwebengine-5.
[jackhill/guix/guix.git] / gnu / packages / instrumentation.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2021 Olivier Dion <olivier.dion@polymtl.ca>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages instrumentation)
20 #:use-module (gnu packages base)
21 #:use-module (gnu packages bison)
22 #:use-module (gnu packages boost)
23 #:use-module (gnu packages datastructures)
24 #:use-module (gnu packages documentation)
25 #:use-module (gnu packages elf)
26 #:use-module (gnu packages engineering)
27 #:use-module (gnu packages flex)
28 #:use-module (gnu packages glib)
29 #:use-module (gnu packages haskell-xyz)
30 #:use-module (gnu packages libunwind)
31 #:use-module (gnu packages linux)
32 #:use-module (gnu packages llvm)
33 #:use-module (gnu packages lua)
34 #:use-module (gnu packages man)
35 #:use-module (gnu packages ncurses)
36 #:use-module (gnu packages perl)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages popt)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages python-xyz)
41 #:use-module (gnu packages sphinx)
42 #:use-module (gnu packages swig)
43 #:use-module (gnu packages tbb)
44 #:use-module (gnu packages xml)
45 #:use-module (guix platform)
46 #:use-module (guix build-system cmake)
47 #:use-module (guix build-system copy)
48 #:use-module (guix build-system gnu)
49 #:use-module (guix download)
50 #:use-module (guix gexp)
51 #:use-module (guix git-download)
52 #:use-module ((guix licenses) #:prefix license:)
53 #:use-module (guix packages)
54 #:use-module (srfi srfi-26)
55 #:use-module (guix utils))
56
57 (define-public babeltrace
58 (package
59 (name "babeltrace")
60 (version "2.0.4")
61 (source (origin
62 (method url-fetch)
63 (uri (string-append "https://www.efficios.com/files/babeltrace/babeltrace2-"
64 version ".tar.bz2"))
65 (sha256
66 (base32 "1jlv925pr7hykc48mdvbmqm4ipy1r11xwzapa6fdpdfshmk12kvp"))))
67
68 (build-system gnu-build-system)
69
70 (arguments
71 `(#:tests? #f ; FIXME - When Python's bindings are enabled, tests do not
72 ; pass.
73 #:make-flags
74 ,#~(list (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib"))
75 #:configure-flags
76 '("--enable-debug-info"
77 "--enable-man-pages"
78 "--enable-python-bindings"
79 "--enable-python-plugins")
80 #:phases
81 (modify-phases %standard-phases
82 ;; These are recommended in the project's README for a development
83 ;; build configuration.
84 (add-before 'configure 'set-environment-variables
85 (lambda _
86 (setenv "BABELTRACE_DEV_MODE" "1")
87 (setenv "BABELTRACE_MINIMAL_LOG_LEVEL" "TRACE"))))))
88 (inputs
89 (list glib))
90 ;; NOTE - elfutils is used for the LTTng debug information filter
91 ;; component class. This can be moved to `native-inputs` if
92 ;; `--enable-debug-info` is replaced by `--disable-debug-info` in
93 ;; `#:configure-flags`.
94 (propagated-inputs
95 (list elfutils))
96 ;; NOTE - python-3 is set here for generating the bindings. Users need to
97 ;; install python-3 in their profile in order to use these bindings.
98 (native-inputs
99 (list asciidoc
100 bison
101 flex
102 pkg-config
103 python-3
104 python-sphinx
105 swig
106 xmltoman))
107 (home-page "https://babeltrace.org/")
108 (synopsis "Trace manipulation toolkit")
109 (description "Babeltrace 2 is a framework for viewing, converting,
110 transforming, and analyzing traces. It is also the reference parser
111 implementation of the Common Trace Format (CTF), produced by tools such as
112 LTTng and barectf. This package provides a library with a C API, Python 3
113 bindings, and the command-line tool @command{babeltrace2}.")
114 (license license:expat)))
115
116 (define-public dyninst
117 (package
118 (name "dyninst")
119 ;; Newer versions are not promoted on main home page.
120 ;; Upgrade to 12.0.1 if anyone require a newer version.
121 (version "10.2.1")
122 (source (origin
123 (method git-fetch)
124 (uri (git-reference
125 (url "https://github.com/dyninst/dyninst")
126 (commit (string-append "v" version))))
127 (file-name (git-file-name name version))
128 (sha256
129 (base32 "1m04pg824rqx647wvk9xl33ri8i6mm0vmrz9924li25dxbr4zqd5"))))
130
131 (build-system cmake-build-system)
132 (arguments
133 `(#:tests? #f
134 ;; STERILE_BUILD: Do not download/build third-party dependencies from
135 ;; source.
136 #:configure-flags
137 (list "-DSTERILE_BUILD=ON")
138 ;; NOTE: dyninst needs to search for shared libraries that are linked
139 ;; against the instrumented binary in order to rebuild the entire
140 ;; program. For this purpose, one can use LD_LIBRARY_PATH or
141 ;; DYNISNT_REWRITER_PATHS environment variables to add paths for dyinst
142 ;; to search. However, dyninst also tries to be smart by executing
143 ;; ldconfig, which is not portable. If ldconfig is not available on
144 ;; the system, dyinst wrongly assumes that the shared libraries can not
145 ;; be found, even though it can. This bad logic is still there with
146 ;; newer versions of dyinst. Thus, this substitution makes the bad
147 ;; code path unreachable.
148 #:phases
149 (modify-phases %standard-phases
150 (add-after 'unpack 'patch-bad-logic
151 (lambda _
152 (substitute* "dyninstAPI/src/linux.C"
153 (("if\\(\\!fgets\\(buffer, 512, ldconfig\\)\\)")
154 "fgets(buffer, 512, ldconfig); if (false)")))))))
155 (propagated-inputs
156 (list elfutils boost tbb-2020))
157 (home-page "https://dyninst.org/")
158 (synopsis "Dynamic instrumentation")
159 (description "Dyninst is a collection of libraries for instrumenting,
160 analyzing and editing binaries. It can attach to an existing program or
161 create a new one out of an ELF file for analysis or modification. It come
162 with a handful of C++ libraries.")
163 (license license:lgpl2.1+)))
164
165 (define-public flamegraph
166 ;; No new version since 2019, but there's still some new important commits.
167 (let ((commit "810687f180f3c4929b5d965f54817a5218c9d89b")
168 (revision "1"))
169 (package
170 (name "flamegraph")
171 (version (git-version "1.0" revision commit))
172 (source (origin
173 (method git-fetch)
174 (uri (git-reference
175 (url "https://github.com/brendangregg/FlameGraph")
176 (commit commit)))
177 (file-name (git-file-name name version))
178 (sha256
179 (base32
180 "1lg02mxzdsm9szn4vcmx76c1bw9gqmxqk8n6v63v03036sc83s22"))))
181 (build-system copy-build-system)
182 (arguments
183 `(#:install-plan
184 ',(map (cut list <> "bin/")
185 '("flamegraph.pl"
186 "stackcollapse.pl"
187 "stackcollapse-perf.pl"
188 "stackcollapse-pmc.pl"
189 "stackcollapse-stap.pl"
190 "stackcollapse-instruments.pl"
191 "stackcollapse-vtune.pl"
192 "stackcollapse-jstack.pl"
193 "stackcollapse-gdb.pl"
194 "stackcollapse-go.pl"
195 "stackcollapse-vsprof.pl"
196 "stackcollapse-wcp.pl"))))
197 (inputs (list perl))
198 (home-page "http://www.brendangregg.com/flamegraphs.html")
199 (synopsis "Stack trace visualizer")
200 (description "Flamegraph is a collection of scripts that generate
201 interactive SVGs out of traces genated from various tracing tools. It comes
202 with the script @command{flamegraph.pl} and many stackcollapse scripts.")
203 (license license:cddl1.0))))
204
205 (define-public lttng-ust
206 (package
207 (name "lttng-ust")
208 (version "2.13.1")
209 (source (origin
210 (method url-fetch)
211 (uri (string-append "https://lttng.org/files/lttng-ust/"
212 "lttng-ust-" version ".tar.bz2"))
213 (sha256
214 (base32
215 "1p7d94r275yvby6zqfxaswdl1q46zxbc8x5rkhnjxrp1d41byrsn"))))
216 (build-system gnu-build-system)
217 (inputs
218 (list numactl))
219 (propagated-inputs
220 (list liburcu)) ;headers of liburcu are used by headers of lttng
221 (native-inputs
222 (list python-3 pkg-config))
223 (home-page "https://lttng.org/")
224 (synopsis "LTTng userspace tracer libraries")
225 (description "The user space tracing library, liblttng-ust, is the LTTng
226 user space tracer. It receives commands from a session daemon, for example to
227 enable and disable specific instrumentation points, and writes event records
228 to ring buffers shared with a consumer daemon.")
229 (license (list license:lgpl2.1 license:expat))))
230
231 (define-public lttng-tools
232 (package
233 (name "lttng-tools")
234 (version "2.13.2")
235 (source (origin
236 (method url-fetch)
237 (uri (string-append "https://lttng.org/files/lttng-tools/"
238 "lttng-tools-" version ".tar.bz2"))
239 (sha256
240 (base32
241 "1gfp9y24lpaiz4lcmbp30yd400jmh99mlay9gb8pz9qd080bmlnf"))))
242 (build-system gnu-build-system)
243 (arguments
244 `( ;; FIXME - Currently there's a segmentation fault by swig when enabling
245 ;; Python's bindings. Thus, bindings are disable here. Replace
246 ;; `disable` by `enable` in #:configure-flags when this is fixed.
247 #:configure-flags '("--disable-python-bindings")
248 ;; FIXME - Tests are disabled for now because one test hangs
249 ;; indefinetely. Also, parallel testing is not possible because of how
250 ;; the lttng-daemon handles sessions. Thus, keep parallel testing
251 ;; disabled even after tests are enabled!
252 #:tests? #f
253 #:parallel-tests? #f
254 #:phases
255 (modify-phases %standard-phases
256 (add-before 'configure 'set-environment-variables
257 (lambda _
258 (setenv "HOME" "/tmp")
259 (setenv "LTTNG_HOME" "/tmp")))
260 ;; We don't put (which "man") here because LTTng uses execlp.
261 (add-after 'unpack 'patch-default-man-path
262 (lambda _
263 (substitute* "src/common/defaults.h"
264 (("/usr/bin/man") "man")))))))
265 ;; NOTE - Users have to install python-3 in their profile to use the
266 ;; bindings. We don't put it in the inputs, because the rest of the tools
267 ;; can work without it.
268 (inputs
269 (list liburcu popt numactl))
270 (propagated-inputs
271 (list kmod module-init-tools))
272 (native-inputs
273 (list pkg-config
274 perl
275 libpfm4
276 python-3
277 swig
278 procps
279 which
280 flex
281 bison
282 asciidoc
283 libxml2
284 lttng-ust))
285 (home-page "https://lttng.org/")
286 (synopsis "LTTng userspace tracer libraries")
287 (description "The lttng-tools project provides a session
288 daemon @code{lttng-sessiond} that acts as a tracing registry, the @command{lttng} command
289 line for tracing control, a @code{lttng-ctl} library for tracing control and a
290 @code{lttng-relayd} for network streaming.")
291 (license (list license:gpl2 license:lgpl2.1))))
292
293 (define-public uftrace
294 (package
295 (name "uftrace")
296 (version "0.11")
297 (source (origin
298 (method git-fetch)
299 (uri (git-reference
300 (url "https://github.com/namhyung/uftrace")
301 (commit (string-append "v" version))))
302 (file-name (git-file-name name version))
303 (sha256
304 (base32 "0gk0hv3rnf5czvazz1prg21rf9qlniz42g5b389n8a29hqj4q6xr"))))
305 (build-system gnu-build-system)
306 (arguments
307 `(#:make-flags
308 (list
309 (string-append "CC=" ,(cc-for-target)))
310 ;; runtest hang at some point -- probably dues to
311 ;; failed socket connection -- but we want to keep the
312 ;; unit tests. Change the target to "test" when fixed.
313 #:test-target "unittest"
314 #:phases
315 (modify-phases %standard-phases
316 (replace 'configure
317 (lambda* (#:key outputs target #:allow-other-keys)
318 (let ((arch ,(platform-linux-architecture
319 (lookup-platform-by-target-or-system
320 (or (%current-target-system)
321 (%current-system))))))
322 (setenv "ARCH"
323 (cond
324 ((string=? arch "arm64") "aarch64")
325 (else arch)))
326 (when target
327 (setenv "CROSS_COMPILE" (string-append target "-"))))
328 (setenv "SHELL" (which "sh"))
329 (invoke "./configure"
330 (string-append "--prefix="
331 (assoc-ref outputs "out"))))))))
332 (inputs
333 (list capstone
334 elfutils
335 libunwind
336 ncurses))
337 (native-inputs
338 (list luajit
339 pandoc
340 pkg-config
341 python-wrapper))
342 (home-page "https://github.com/namhyung/uftrace")
343 (synopsis "Function graph tracer for C/C++/Rust")
344 (description "uftrace is a tool for tracing and analyzing the execution of
345 programs written in C/C++. It is heavily inspired by the ftrace framework of
346 the Linux kernel, while supporting userspace programs. It supports various
347 kind of commands and filters to help analysis of the program execution and
348 performance. It provides the command @command{uftrace}. User that want to do
349 scripting need to install python-3 or luajit in their profile.")
350 (license license:gpl2)))