Browse Prior Art Database

Formatting DWARF debug information with DWARF format specifiers Disclosure Number: IPCOM000012871D
Original Publication Date: 2003-Jun-05
Included in the Prior Art Database: 2003-Jun-05
Document File: 3 page(s) / 53K

Publishing Venue



DWARF defines a format to hold information about symbolic and source level debugging. (The DWARF3 debugging information format specification can be found in Consumers of DWARF debug information (DWARF, from now on) often require a mechanism to format information within DWARF into a syntax that is similar to a programming language. For example, given a Debug Information Entry(DIE) for a integer variable 'a' defined within a C program, a debugger may choose to format it as "int a = 5;" or simply "int a;". Current debuggers solve this problem by implementing different logics to extract this information from different classes of DIE. All debuggers that need this functionality must create new code to handle the formatting of these language constructs. Furthermore, every debugger will need to implement these logics, and having so many different logics to handle the same task can be error prone. In order to unify the method in which the language constructs are formatted, it is necessary to design a common user interface to describe the DIEs.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 49% of the total text.

Page 1 of 3

Formatting DWARF debug information with DWARF format specifiers

   The user interface must be flexible enough to display all the information that are available within a DIE. The C standard function "printf" introduced a set of format specifiers that can format a value to whichever format the user wishes to represent. (i.e. '%d' to format a value as integer, '%f' to format a value as a floating point).

We've taken this design one step further, and introduce a new set of format specifiers (call DWARF format specifiers, or DFS for short) to describe the information within a DIE.

All DFS have the form of %<>, (i.e. %<NT> would describe the type of the DIE). We use the angle brackets to avoid namespace collision with the existing and future implementation of printf format specifiers. Once all the DFS are properly defined, the user can access the information within the DIEs through this unique user interface, and it would work across multiple languages, and platform.

i.e. to print the type of a DIE, one would code DFS_formatter ("%<NT>", DIE);

And this single line of code would work on any DIE with a valid type, and it does so in a platform and language neutral way.

Several predefined DFS are introduced to describe a single DIE:

   %<NV> name of the DIE (DW_AT_name attribute) %<NT> type of the DIE (name of DIE referenced by DW_AT_type attribute) %<V> values of the DIE (value is formatted differently based on the type of the DIE, the value can be calculated during runtime using the location expression stored in the DW_AT_location attribute. All language specific rules about the object model is embedded within the location expression, therefore, once the location expression is evaluated, the appropriate value for the DIE can be obtained) The design is flexible enough, so that user can also define their own specifiers to retrieve information within the DIE.

Each DFS is replaced with a string representing a particular piece of information about a DIE. In the following examples, 'vardie' is the DIE with the name 'var'.

   To display "int var;" DFS_formatter ("%<NT> %<NV>;", vardie); To display "int var = 10;" DFS_formatter ("%<NT> %<NV> = %<V>;", vardie); To display "var = 0xA;" DFS_formatter ("%<NV> = %X;", vardie); Whenever a DFS is encountered, the DFS is replaced with a value that is extracted from the given DIE. Any non-DFS is also replaced with the appropriate values that is extracted from the location expression of the given DIE. This process continues until all the format specifiers are processed.

Here is a sample walkthrough for displaying "int var = 10":

DFS_formatter ("%<NT> %<NV> = %<V>", vardie);

Scan the format string for the first occurence of format specifier. Replace %<NT> with "int", because the type of vardie is "int". Form new format string: "int %<NV> = %<V>" Replace format string with new format string and repeat the process again. DFS_formatter ("int %<NV> = %<V>", vardie);

Scan the format string for the first occurence of form...