1 Debugging util-linux programs
2 =============================
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.
12 Let's take for example the mount command:
14 $> cd /path/to/util-linux
16 mount/mount: Bourne-Again shell script text executable
18 The binary itself is located in the mount/.libs/ directory:
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) [...]
24 When this command is run, there's a library dependency error:
27 mount/.libs/mount: /lib/libblkid.so.1: version `BLKID_2.20' not found \
28 (required by mount/.libs/mount)
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:
33 $> export LD_LIBRARY_PATH=$PWD/libblkid/src/.libs/:$LD_LIBRARY_PATH
35 Now external debugging tools can be run on the binary.
38 Davidlohr Bueso, August 2011
41 The libmount & libblkid
42 -----------------------
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
51 to see what the different bits mean. At the time of writing this the following
54 export LIBBLKID_DEBUG=all
55 export LIBMOUNT_DEBUG=all
56 export LIBFDISK_DEBUG=all
57 export LIBSMARTCOLS_DEBUG=all
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.
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.
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
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