]> git.ipfire.org Git - thirdparty/util-linux.git/blob - Documentation/howto-debug.txt
libmount: add bpf between pseudo filesystems
[thirdparty/util-linux.git] / Documentation / howto-debug.txt
1 Debugging util-linux programs
2 =============================
3
4 How to deal libtool
5 -------------------
6
7 There are considerations to be made when profiling or debugging some programs
8 found in the util-linux package. Because wrapper scripts are used for the
9 binaries to make sure all library dependencies are met, you cannot use tools
10 such as gdb or valgrind directly with them.
11
12 Let's take for example the mount command:
13
14 $> cd /path/to/util-linux
15 $> file mount/mount
16 mount/mount: Bourne-Again shell script text executable
17
18 The binary itself is located in the mount/.libs/ directory:
19
20 $> file mount/.libs/mount
21 mount/.libs/mount: ELF 64-bit LSB executable, x86-64, version 1 \
22 (SYSV), dynamically linked (uses shared libs) [...]
23
24 When this command is run, there's a library dependency error:
25
26 $> mount/.libs/mount
27 mount/.libs/mount: /lib/libblkid.so.1: version `BLKID_2.20' not found \
28 (required by mount/.libs/mount)
29
30 To overcome this we need set the LD_LIBRARY_PATH variable to read the path of
31 the shared lib found in the sources, and not system-wide:
32
33 $> export LD_LIBRARY_PATH=$PWD/libblkid/src/.libs/:$LD_LIBRARY_PATH
34
35 Now external debugging tools can be run on the binary.
36
37 Happy hacking!
38 Davidlohr Bueso, August 2011
39
40
41 The libmount & libblkid
42 -----------------------
43
44 Both of the libraries can be debugged by setting an environment variable
45 consisting of a number. The number will be used as a bit mask, so the more 1 the
46 higher the debugging level. Search for `DEBUG' from files
47
48 libblkid/src/blkidP.h
49 libmount/src/mountP.h
50
51 to see what the different bits mean. At the time of writing this the following
52 enabled full debug.
53
54 export LIBBLKID_DEBUG=all
55 export LIBMOUNT_DEBUG=all
56 export LIBFDISK_DEBUG=all
57 export LIBSMARTCOLS_DEBUG=all
58
59 The libblkid reads by default /etc/blkid.conf which can be overridden by the
60 environment variable BLKID_CONF. See manual libblkid/libblkid.3 for details
61 about the configuration file.
62
63 Block device information is normally kept in a cache file (see blkid man page
64 for more information about the cache file location) that can be overridden by
65 the environment variable BLKID_FILE.
66
67 To libmount uses three paths, which can be overridden by using environment
68 variables. Notice that these environment variables are ignored for non-root
69 users.
70
71 env variable if not set defaults to
72 LIBMOUNT_FSTAB /etc/fstab
73 LIBMOUNT_MTAB /etc/mtab
74 LIBMOUNT_UTAB /run/mount/utab or /dev/.mount/utab