How To Install dwarves on CentOS 8

dwarves is Debugging Information Manipulation Tools (pahole & friends)

Introduction

In this tutorial we learn how to install dwarves on CentOS 8.

What is dwarves

dwarves is a set of tools that use the debugging information inserted in ELF binaries by compilers such as GCC, used by well known debuggers such as GDB, and more recent ones such as systemtap. Utilities in the dwarves suite include pahole, that can be used to find alignment holes in structs and classes in languages such as C, C++, but not limited to these. It also extracts other information such as CPU cacheline alignment, helping pack those structures to achieve more cache hits. These tools can also be used to encode and read the BTF type information format used with the Linux kernel bpf syscall, using ‘pahole -J’ and ‘pahole -F btf’. A diff like tool, codiff can be used to compare the effects changes in source code generate on the resulting binaries. Another tool is pfunct, that can be used to find all sorts of information about functions, inlines, decisions made by the compiler about inlining, etc. One example of pfunct usage is in the fullcircle tool, a shell that drivers pfunct to generate compileable code out of a .o file and then build it using gcc, with the same compiler flags, and then use codiff to make sure the original .o file and the new one generated from debug info produces the same debug info. Pahole also can be used to use all this type information to pretty print raw data according to command line directions. Headers can have its data format described from debugging info and offsets from it can be used to further format a number of records. The btfdiff utility compares the output of pahole from BTF and DWARF to make sure they produce the same results.

We can use yum or dnf to install dwarves on CentOS 8. In this tutorial we discuss both methods but you only need to choose one of method to install dwarves.

Install dwarves on CentOS 8 Using dnf

Update yum database with dnf using the following command.

sudo dnf makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install dwarves using dnf by running the following command:

sudo dnf -y install dwarves

Install dwarves on CentOS 8 Using yum

Update yum database with yum using the following command.

sudo yum makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install dwarves using yum by running the following command:

sudo yum -y install dwarves

How To Uninstall dwarves on CentOS 8

To uninstall only the dwarves package we can use the following command:

sudo dnf remove dwarves

dwarves Package Contents on CentOS 8

/usr/bin/btfdiff
/usr/bin/codiff
/usr/bin/ctracer
/usr/bin/dtagnames
/usr/bin/fullcircle
/usr/bin/ostra-cg
/usr/bin/pahole
/usr/bin/pdwtags
/usr/bin/pfunct
/usr/bin/pglobal
/usr/bin/prefcnt
/usr/bin/scncopy
/usr/bin/syscse
/usr/lib/.build-id
/usr/lib/.build-id/0a
/usr/lib/.build-id/0a/6212b79e9c31543f18b8a843f22e791512753f
/usr/lib/.build-id/18
/usr/lib/.build-id/18/835932b8047c43d74a72acd2852ac10cb0d3a4
/usr/lib/.build-id/47
/usr/lib/.build-id/47/373c8ece8fbff0666bf369251a740ac3569be5
/usr/lib/.build-id/51
/usr/lib/.build-id/51/69507b54e96ca8f175e9c2f2452e616fd13638
/usr/lib/.build-id/61
/usr/lib/.build-id/61/817865dc58feb70ee1feb8a9fe53c4daee9053
/usr/lib/.build-id/64
/usr/lib/.build-id/64/2285286612a7814e3fc8f041e9d5148d4a6ee3
/usr/lib/.build-id/96
/usr/lib/.build-id/96/bd46771d30b16401100e14d789accb3ffde286
/usr/lib/.build-id/cf
/usr/lib/.build-id/cf/286f9a4681dcedcd7bfee197f4e3e8ae356fc4
/usr/lib/.build-id/d6
/usr/lib/.build-id/d6/e0d422177531b551820dea24571814cde30777
/usr/lib/.build-id/f5
/usr/lib/.build-id/f5/783a575f4bfac13e3dae1e4b37c404d0cd26b5
/usr/share/doc/dwarves
/usr/share/doc/dwarves/NEWS
/usr/share/doc/dwarves/README.btf
/usr/share/doc/dwarves/README.ctracer
/usr/share/doc/dwarves/changes-v1.19
/usr/share/dwarves
/usr/share/dwarves/runtime
/usr/share/dwarves/runtime/Makefile
/usr/share/dwarves/runtime/ctracer_relay.c
/usr/share/dwarves/runtime/ctracer_relay.h
/usr/share/dwarves/runtime/linux.blacklist.cu
/usr/share/dwarves/runtime/python
/usr/share/dwarves/runtime/python/ostra.py
/usr/share/man/man1/pahole.1.gz

References

Summary

In this tutorial we learn how to install dwarves on CentOS 8 using yum and dnf.