]> git.ipfire.org Git - thirdparty/util-linux.git/blame - Documentation/howto-debug.txt
Merge branch 'dmverity_options' of https://github.com/bluca/util-linux
[thirdparty/util-linux.git] / Documentation / howto-debug.txt
CommitLineData
2e88e3c6
DB
1Debugging util-linux programs
2=============================
3
4How to deal libtool
5-------------------
6
7There are considerations to be made when profiling or debugging some programs
8found in the util-linux package. Because wrapper scripts are used for the
9binaries to make sure all library dependencies are met, you cannot use tools
10such as gdb or valgrind directly with them.
11
12Let'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
18The 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
24When 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
30To overcome this we need set the LD_LIBRARY_PATH variable to read the path of
31the shared lib found in the sources, and not system-wide:
32
33 $> export LD_LIBRARY_PATH=$PWD/libblkid/src/.libs/:$LD_LIBRARY_PATH
34
35Now external debugging tools can be run on the binary.
36
37Happy hacking!
38Davidlohr Bueso, August 2011
7ec51ba9
SK
39
40
41The libmount & libblkid
42-----------------------
43
44Both of the libraries can be debugged by setting an environment variable
89c6bb4d
PU
45consisting of a number. The number will be used as a bit mask, so the more 1 the
46higher the debugging level. Search for `DEBUG' from files
7ec51ba9
SK
47
48 libblkid/src/blkidP.h
49 libmount/src/mountP.h
50
89c6bb4d 51to see what the different bits mean. At the time of writing this the following
7ec51ba9
SK
52enabled full debug.
53
68e422ec
KZ
54 export LIBBLKID_DEBUG=all
55 export LIBMOUNT_DEBUG=all
56 export LIBFDISK_DEBUG=all
57 export LIBSMARTCOLS_DEBUG=all
7ec51ba9 58
89c6bb4d 59The libblkid reads by default /etc/blkid.conf which can be overridden by the
7ec51ba9
SK
60environment variable BLKID_CONF. See manual libblkid/libblkid.3 for details
61about the configuration file.
62
b82590ad
KZ
63Block device information is normally kept in a cache file (see blkid man page
64for more information about the cache file location) that can be overridden by
65the environment variable BLKID_FILE.
7ec51ba9 66
89c6bb4d 67To libmount uses three paths, which can be overridden by using environment
7ec51ba9 68variables. Notice that these environment variables are ignored for non-root
89c6bb4d 69users.
7ec51ba9
SK
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