DWARF Debugging Format DWARF Debugging Standard Wiki

What is libdwarf

Libdwarf is a C library intended to simplify reading (and writing) applications using DWARF2, DWARF3, DWARF4 and DWARF5. It was written at SGI (Silicon Graphics, Inc.) beginning in about 1991 to simplify the task of SGI’s compiler writers and debugger-writers and was made open source in the mid 1990’s. It is mostly copyrighted as LGPL version 2.1. It is used by a variety of projects to read DWARF2/¾/5 information from ELF, MacOS, and PE object files. It is also capable of writing DWARF information generated by a compiler (a capability used by at least 2 system manufacturers) though few of the new features of DWARF3 or later are available in the producer(writer) interfaces..

It cannot read the original AT&T DWARF1 (as it is now called) format at all: that (now nearly obsolete) format is implemented completely differently from DWARF2 and later.

What is dwarfdump

Dwarfdump is an application using libdwarf to print dwarf information in a human readable format. It is also open sourced and is copyrighted GPL. It provides an example of using libdwarf to read DWARF2/¾/5 information as well as providing readable text output. There are other examples in the dwarfexample directory.

Building libdwarf and dwarfdump

A build assumes standard POSIX utilities. It has worked on a wide variety of computers and operating systems.

Download the tar file.
tar xzf libdwarf-<version date extension>.tar.gz
cd dwarf-<version date extension>
./configure
make
cd ../dwarfdump
./configure
make

If you use ‘git clone’ to get the source read the README before attempting a build. The script scripts/FIX-CONFIGURE-TIMES is necessary as git does not keep file timestamps in a usable order.

See README.cmake if you prefer to use cmake as your build environment.

A ‘sudo make install’ step in each directory is optional. The tools assumed (shell [sh ksh or bash], cc, make, ar) are used in simple ways (any ‘cc’ or ‘gcc’, any ‘make’ or ‘ar’ should work fine) and so any toolset that understands basic POSIX options should work ok. The ‘untaring’ step may be done as separate gunzip and tar, avoiding a direct dependence on the ‘xzf’ option combination.

Other information in libdwarf

There are documents and examples in the libdwarf release that may be of interest even for those not using libdwarf directly.

SGI extensions

One document in the libdwarf release is called mips_extensions.pdf (named thus for historical reasons: it describes SGI extensions to DWARF as defined in the early-mid 1990’s) and you can ignore it.

dwarf.h

The dwarf.h in the libdwarf release contains all extensions in use that are known to the maintainer. (With the exception of a long list of Ada extensions used by at least one Ada compiler supplier: the current DWARF attributes appear to suffice for Ada so those extensions are not shown. In addition, the actual extension names that the Ada compiler-provider used did not quite follow the recommended naming guidelines, so actually listing them in dwarf.h would be quite confusing to little purpose.)

Since most of the ‘extension’ numbering allows plenty of extensions many compiler-providers prefer to avoid using the same extension numbers as other compiler providers. This is not necessary (as no one provider would use conflicting numbers) but does give a ‘universal dumper’ such as dwarfdump an easier time dumping DWARF information. It makes dwarf.h easier to read too.

Caveats

Neither the software nor the interfaces are part of the DWARF specification. Neither the software nor the interfaces are defined or supported by the DWARF Committee.

SGI no longer maintains this software.

How do I get it?

The software is available from the maintainer at 1 and there you will find git clone commands to get the source as well as all specific releases (.tar.gz).

That web site also gives additional detail on the history and approach used in libdwarf.

Do I need to use it?

No, you don’t have to. Many projects generate (gcc for example) and consume (gdb for example) DWARF2/¾/5 information without any reference-to or use-of libdwarf.

dwarfstd.org is supported by Sourceware. Contributions are welcome.

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2007-2022 by DWARF Standards Committee.