DWARF4
DWARF4
Version 4
Trademarks:
Intel386 is a trademark of Intel Corporation.
Java is a trademark of Sun Microsystems, Inc.
All other trademarks found herein are property of their respective owners.
INTRODUCTION
Table of Contents
DWARF DEBUGGING INFORMATION FORMAT VERSION 4 ...................................................................... I
1 INTRODUCTION..............................................................................................................................................1
1.1 PURPOSE AND SCOPE ...........................................................................................................................................1
1.2 OVERVIEW ...........................................................................................................................................................1
1.3 VENDOR EXTENSIBILITY......................................................................................................................................2
1.4 CHANGES FROM VERSION 3 TO VERSION 4..........................................................................................................3
1.5 CHANGES FROM VERSION 2 TO VERSION 3..........................................................................................................4
1.6 CHANGES FROM VERSION 1 TO VERSION 2..........................................................................................................5
2 GENERAL DESCRIPTION .............................................................................................................................7
2.1 THE DEBUGGING INFORMATION ENTRY (DIE) ....................................................................................................7
2.2 ATTRIBUTE TYPES ...............................................................................................................................................7
2.3 RELATIONSHIP OF DEBUGGING INFORMATION ENTRIES ....................................................................................16
2.4 TARGET ADDRESSES ..........................................................................................................................................16
2.5 DWARF EXPRESSIONS .....................................................................................................................................17
2.5.1 General Operations...................................................................................................................................17
2.5.2 Example Stack Operations ........................................................................................................................25
2.6 LOCATION DESCRIPTIONS ..................................................................................................................................25
2.6.1 Single Location Descriptions ....................................................................................................................26
2.6.2 Location Lists............................................................................................................................................30
2.7 TYPES OF PROGRAM ENTITIES ...........................................................................................................................32
2.8 ACCESSIBILITY OF DECLARATIONS ....................................................................................................................32
2.9 VISIBILITY OF DECLARATIONS...........................................................................................................................33
2.10 VIRTUALITY OF DECLARATIONS ......................................................................................................................33
2.11 ARTIFICIAL ENTRIES ........................................................................................................................................34
2.12 SEGMENTED ADDRESSES .................................................................................................................................34
2.13 NON-DEFINING DECLARATIONS AND COMPLETIONS .......................................................................................35
2.13.1 Non-Defining Declarations .....................................................................................................................35
2.13.2 Declarations Completing Non-Defining Declarations............................................................................36
2.14 DECLARATION COORDINATES .........................................................................................................................36
2.15 IDENTIFIER NAMES ..........................................................................................................................................36
2.16 DATA LOCATIONS AND DWARF PROCEDURES ...............................................................................................37
2.17 CODE ADDRESSES AND RANGES ......................................................................................................................37
2.17.1 Single Address.........................................................................................................................................38
2.17.2 Contiguous Address Range .....................................................................................................................38
2.17.3 Non-Contiguous Address Ranges............................................................................................................38
2.18 ENTRY ADDRESS .............................................................................................................................................40
2.19 STATIC AND DYNAMIC VALUES OF ATTRIBUTES .............................................................................................40
2.20 ENTITY DESCRIPTIONS.....................................................................................................................................41
2.21 BYTE AND BIT SIZES........................................................................................................................................41
2.22 LINKAGE NAMES .............................................................................................................................................41
3 PROGRAM SCOPE ENTRIES......................................................................................................................43
3.1 UNIT ENTRIES ....................................................................................................................................................43
The DWARF Debugging Information Format Committee was originally organized in 1988 as the
Programming Languages Special Interest Group (PLSIG) of Unix International, Inc., a trade
group organized to promote Unix System V Release 4 (SVR4).
PLSIG drafted a standard for DWARF Version 1, compatible with the DWARF debugging
format used at the time by SVR4 compilers and debuggers from AT&T. This was published as
Revision 1.1.0 on October 6, 1992. PLSIG also designed the DWARF Version 2
format, which followed the same general philosophy as Version 1, but with significant new
functionality and a more compact, though incompatible, encoding. An industry review draft of
DWARF Version 2 was published as Revision 2.0.0 on July 27, 1993.
Unix International dissolved shortly after the draft of Version 2 was released; no industry
comments were received or addressed, and no final standard was released. The committee
mailing list was hosted by OpenGroup (formerly XOpen).
The Committee reorganized in October, 1999, and met for the next several years to address
issues that had been noted with DWARF Version 2 as well as to add a number of new features.
In mid-2003, the Committee became a workgroup under the Free Standards Group (FSG), a
industry consortium chartered to promote open standards. DWARF Version 3 was published on
December 20, 2005, following industry review and comment.
The DWARF Committee withdrew from the Free Standards Group in February, 2007, when FSG
merged with the Open Source Development Labs to form The Linux Foundation, more narrowly
focused on promoting Linux. The DWARF Committee has been independent since that time.
It is the intention of the DWARF Committee that migrating from DWARF Version 2 or Version
3 to later versions should be straightforward and easily accomplished. Almost all DWARF
Version 2 and Version 3 constructs have been retained unchanged in DWARF Version 4.
The DWARF Debugging Information Format Committee is open to compiler and debugger
developers who have experience with source language debugging and debugging formats, and
have an interest in promoting or extending the DWARF debugging format.
1.2 Overview
There are two major pieces to the description of the DWARF format in this document. The first
piece is the informational content of the debugging entries. The second piece is the way the
debugging information is encoded and represented in an object file.
The informational content is described in Sections 2 through 6. Section 2 describes the overall
structure of the information and attributes that is common to many or all of the different
debugging information entries. Sections 3, 4 and 5 describe the specific debugging information
entries and how they communicate the necessary information about the source program to a
debugger. Section 6 describes debugging information contained outside of the debugging
information entries. The encoding of the DWARF information is presented in Section 7.
This organization closely follows that used in the DWARF Version 3 document. Except where
needed to incorporate new material or to correct errors, the DWARF Version 3 text is generally
reused in this document with little or no modification.
In the following sections, text in normal font describes required aspects of the DWARF format.
Text in italics is explanatory or supplementary material, and not part of the format definition
itself. The several appendices consist only of explanatory or supplementary material, and are not
part of the formal definition.
• Add support for bundled instructions on machine architectures where instructions do not
occupy a whole number of bytes.
• Add a new attribute form for section offsets, DW_FORM_sec_offset, to replace the use
of DW_FORM_data4 and DW_FORM_data8 for section offsets.
• Define default array lower bound values for each supported language.
• Add a new technique using separate type units, type signatures and COMDAT sections to
improve compression and duplicate elimination of DWARF information.
• Add support for new C++ language constructs, including rvalue references, generalized
constant expressions, Unicode character types and template aliases.
• Add new line number table support to facilitate profile based compiler optimization.
• Add support for strongly typed enumerations in languages (such as C++) that have two
kinds of enumeration declarations.
DWARF Version 4 is compatible with DWARF Version 3 except as follows:
• DWARF attributes that use any of the new forms of attribute value representation (for
section offsets, flag compression, type signature references, and so on) cannot be read by
DWARF Version 3 consumers because the consumer will not know how to skip over the
unexpected form of data.
• DWARF frame and line table sections include a additional fields that affect the location
and interpretation of other data in the section.
• Make provision for DWARF information files that are larger than 4 GBytes.
• Add support for Fortran 90 modules as well as allocatable array and pointer types.
• Add an optional section for global type names (similar to the global section for objects
and functions).
• Add improved support for optimized code (discontiguous scopes, end of prologue
determination, multiple section code generation).
• Certain very large values of the initial length fields that begin DWARF sections as well
as certain structures are reserved to act as escape codes for future extension; one such
extension is defined to increase the possible size of DWARF descriptions (see Section
7.4).
• References that use the attribute form DW_FORM_ref_addr are specified to be four bytes
in the DWARF 32-bit format and eight bytes in the DWARF 64-bit format, while
DWARF Version 2 specifies that such references have the same size as an address on the
target system (see Sections 7.4 and 7.5.4).
The debugging information entries are contained in the .debug_info and .debug_types
sections of an object file.
The permissible values for an attribute belong to one or more classes of attribute value forms.
Each form class may be represented in one or more ways. For example, some attribute values
consist of a single piece of constant data. “Constant data” is the class of attribute value that those
attributes may have. There are several representations of constant data, however (one, two, four,
or eight bytes, and variable length data). The particular representation for any given instance of
an attribute is encoded along with the attribute name as part of the information that guides the
interpretation of a debugging information entry.
Attribute value forms belong to one of the classes shown in Figure 3.
DW_TAG_access_declaration DW_TAG_namespace
DW_TAG_array_type DW_TAG_packed_type
DW_TAG_base_type DW_TAG_partial_unit
DW_TAG_catch_block DW_TAG_pointer_type
DW_TAG_class_type DW_TAG_ptr_to_member_type
DW_TAG_common_block DW_TAG_reference_type
DW_TAG_common_inclusion DW_TAG_restrict_type
DW_TAG_compile_unit DW_TAG_rvalue_reference_type
DW_TAG_condition DW_TAG_set_type
DW_TAG_const_type DW_TAG_shared_type
DW_TAG_constant DW_TAG_string_type
DW_TAG_dwarf_procedure DW_TAG_structure_type
DW_TAG_entry_point DW_TAG_subprogram
DW_TAG_enumeration_type DW_TAG_subrange_type
DW_TAG_enumerator DW_TAG_subroutine_type
DW_TAG_file_type DW_TAG_template_alias
DW_TAG_formal_parameter DW_TAG_template_type_parameter
DW_TAG_friend DW_TAG_template_value_parameter
DW_TAG_imported_declaration DW_TAG_thrown_type
DW_TAG_imported_module DW_TAG_try_block
DW_TAG_imported_unit DW_TAG_typedef
DW_TAG_inheritance DW_TAG_type_unit
DW_TAG_inlined_subroutine DW_TAG_union_type
DW_TAG_interface_type DW_TAG_unspecified_parameters
DW_TAG_label DW_TAG_unspecified_type
DW_TAG_lexical_block DW_TAG_variable
DW_TAG_member DW_TAG_variant
DW_TAG_module DW_TAG_variant_part
DW_TAG_namelist DW_TAG_volatile_type
DW_TAG_namelist_item DW_TAG_with_stmt
Figure 1. Tag names
Constant object
DW_AT_const_value Enumeration literal value
Template value parameter
External subroutine
DW_AT_external
External variable
Imported declaration
Imported unit
DW_AT_import Namespace alias
Namespace using declaration
Namespace using directive
Abstract instance
DW_AT_inline
Inlined subroutine
Name of declaration
DW_AT_name
Path name of compilation source
Object declaration
DW_AT_start_scope
Type declaration
Type of declaration
DW_AT_type
Type of subroutine return
Virtuality indication
DW_AT_virtuality Virtuality of base class
Virtuality of function
Attribute
General Use and Encoding
Class
address Refers to some location in the address space of the described program.
One, two, four or eight bytes of uninterpreted data, or data encoded in the variable
length format known as LEB128 (see Section 7.6.).
constant
Most constant values are integers of one kind or another (codes, offsets, counts,
and so on); these are sometimes called “integer constants” for emphasis.
lineptr Refers to a location in the DWARF section that holds line number information.
Refers to a location in the DWARF section that holds location lists, which
loclistptr
describe objects whose location can change during their lifetime.
Refers to one of the debugging information entries that describe the program.
There are three types of reference. The first is an offset relative to the beginning
of the compilation unit in which the reference occurs and must refer to an entry
reference within that same compilation unit. The second type of reference is the offset of a
debugging information entry in any compilation unit, including one different from
the unit containing the reference. The third type of reference is an indirect
reference to a type definition using a 64-bit signature for that type.
For example, if a particular target architecture supports both 32-bit and 64-bit addresses, the
compiler will generate an object file which specifies that it contains executable code generated
for one or the other of these address sizes. In that case, the DWARF debugging information
contained in this object file will use the same address size.
Architectures which have multiple instruction sets are supported by the isa entry in the line
number information (see Section 6.2.2).
The following operations all push a value onto the DWARF stack. If the value of a constant in
one of these operations is larger than can be stored in a single stack element, the value is
truncated to the element size and the low-order bits are pushed on the stack.
1. DW_OP_lit0, DW_OP_lit1, ..., DW_OP_lit31
The DW_OP_litn operations encode the unsigned literal values from 0 through 31, inclusive.
2. DW_OP_addr
The DW_OP_addr operation has a single operand that encodes a machine address and whose
size is the size of an address on the target machine.
3. DW_OP_const1u, DW_OP_const2u, DW_OP_const4u, DW_OP_const8u
The single operand of a DW_OP_constnu operation provides a 1, 2, 4, or 8-byte unsigned
integer constant, respectively.
The following operations push a value onto the stack that is the result of adding the contents of a
register to a given signed offset.
1. DW_OP_fbreg
The DW_OP_fbreg operation provides a signed LEB128 offset from the address specified by
the location description in the DW_AT_frame_base attribute of the current function. (This is
typically a “stack pointer” register plus or minus some offset. On more sophisticated systems
it might be a location list that adjusts the offset according to changes in the stack pointer as
the PC changes.)
2. DW_OP_breg0, DW_OP_breg1, ..., DW_OP_breg31
The single operand of the DW_OP_bregn operations provides a signed LEB128 offset from
the specified register.
3. DW_OP_bregx
The DW_OP_bregx operation has two operands: a register which is specified by an unsigned
LEB128 number, followed by a signed LEB128 offset.
2.5.1.3 Stack Operations
The following operations manipulate the DWARF stack. Operations that index the stack assume
that the top of the stack (most recently added entry) has index 0.
1. DW_OP_dup
The DW_OP_dup operation duplicates the value at the top of the stack.
2. DW_OP_drop
The DW_OP_drop operation pops the value at the top of the stack.
3. DW_OP_pick
The single operand of the DW_OP_pick operation provides a 1-byte index. A copy of the
stack entry with the specified index (0 through 255, inclusive) is pushed onto the stack.
4. DW_OP_over
The DW_OP_over operation duplicates the entry currently second in the stack at the top of
the stack. This is equivalent to a DW_OP_pick operation, with index 1.
5. DW_OP_swap
The DW_OP_swap operation swaps the top two stack entries. The entry at the top of the
stack becomes the second stack entry, and the second entry becomes the top of the stack.
6. DW_OP_rot
The DW_OP_rot operation rotates the first three stack entries. The entry at the top of the
stack becomes the third stack entry, the second entry becomes the top of the stack, and the
third entry becomes the second entry.
7. DW_OP_deref
The DW_OP_deref operation pops the top stack entry and treats it as an address. The value
retrieved from that address is pushed. The size of the data retrieved from the dereferenced
address is the size of an address on the target machine.
8. DW_OP_deref_size
The DW_OP_deref_size operation behaves like the DW_OP_deref operation: it pops the top
stack entry and treats it as an address. The value retrieved from that address is pushed. In the
DW_OP_deref_size operation, however, the size in bytes of the data retrieved from the
dereferenced address is specified by the single operand. This operand is a 1-byte unsigned
integral constant whose value may not be larger than the size of an address on the target
machine. The data retrieved is zero extended to the size of an address on the target machine
before being pushed onto the expression stack.
9. DW_OP_xderef
The DW_OP_xderef operation provides an extended dereference mechanism. The entry at
the top of the stack is treated as an address. The second stack entry is treated as an “address
space identifier” for those architectures that support multiple address spaces. The top two
stack elements are popped, and a data item is retrieved through an implementation-defined
address calculation and pushed as the new stack top. The size of the data retrieved from the
dereferenced address is the size of an address on the target machine.
10. DW_OP_xderef_size
The DW_OP_xderef_size operation behaves like the DW_OP_xderef operation.The entry at
the top of the stack is treated as an address. The second stack entry is treated as an “address
space identifier” for those architectures that support multiple address spaces. The top two
stack elements are popped, and a data item is retrieved through an implementation-defined
address calculation and pushed as the new stack top. In the DW_OP_xderef_size operation,
however, the size in bytes of the data retrieved from the dereferenced address is specified by
the single operand. This operand is a 1-byte unsigned integral constant whose value may not
be larger than the size of an address on the target machine. The data retrieved is zero
extended to the size of an address on the target machine before being pushed onto the
expression stack.
11. DW_OP_push_object_address
The DW_OP_push_object_address operation pushes the address of the object currently being
evaluated as part of evaluation of a user presented expression. This object may correspond to
an independent variable described by its own debugging information entry or it may be a
component of an array, structure, or class whose address has been dynamically determined
by an earlier step during user expression evaluation.
This operator provides explicit functionality (especially for arrays involving descriptors) that
is analogous to the implicit push of the base address of a structure prior to evaluation of a
DW_AT_data_member_location to access a data member of a structure. For an example, see
Appendix D.2.
12. DW_OP_form_tls_address
The DW_OP_form_tls_address operation pops a value from the stack, translates it into an
address in the current thread's thread-local storage block, and pushes the address. If the
DWARF expression containing the DW_OP_form_tls_address operation belongs to the main
executable's DWARF info, the operation uses the main executable's thread-local storage
block; if the expression belongs to a shared library's DWARF info, then it uses that shared
library's thread-local storage block.
Some implementations of C and C++ support a __thread storage class. Variables with this
storage class have distinct values and addresses in distinct threads, much as automatic
variables have distinct values and addresses in each function invocation. Typically, there is a
single block of storage containing all __thread variables declared in the main executable,
and a separate block for the variables declared in each shared library. Computing the
address of the appropriate block can be complex (in some cases, the compiler emits a
function call to do it), and difficult to describe using ordinary DWARF location descriptions.
DW_OP_form_tls_address leaves the computation to the consumer.
13. DW_OP_call_frame_cfa
The DW_OP_call_frame_cfa operation pushes the value of the CFA, obtained from the Call
Frame Information (see Section 6.4).
Although the value of DW_AT_frame_base can be computed using other DWARF expression
operators, in some cases this would require an extensive location list because the values of
the registers used in computing the CFA change during a subroutine. If the Call Frame
Information is present, then it already encodes such changes, and it is space efficient to
reference that.
2.5.1.4 Arithmetic and Logical Operations
The following provide arithmetic and logical operations. Except as otherwise specified, the
arithmetic operations perfom addressing arithmetic, that is, unsigned arithmetic that is performed
modulo one plus the largest representable address (for example, 0x100000000 when the size of
an address is 32 bits). Such operations do not cause an exception on overflow.
1. DW_OP_abs
The DW_OP_abs operation pops the top stack entry, interprets it as a signed value and
pushes its absolute value. If the absolute value cannot be represented, the result is undefined.
2. DW_OP_and
The DW_OP_and operation pops the top two stack values, performs a bitwise and operation
on the two, and pushes the result.
3. DW_OP_div
The DW_OP_div operation pops the top two stack values, divides the former second entry by
the former top of the stack using signed division, and pushes the result.
4. DW_OP_minus
The DW_OP_minus operation pops the top two stack values, subtracts the former top of the
stack from the former second entry, and pushes the result.
5. DW_OP_mod
The DW_OP_mod operation pops the top two stack values and pushes the result of the
calculation: former second stack entry modulo the former top of the stack.
6. DW_OP_mul
The DW_OP_mul operation pops the top two stack entries, multiplies them together, and
pushes the result.
7. DW_OP_neg
The DW_OP_neg operation pops the top stack entry, interprets it as a signed value and
pushes its negation. If the negation cannot be represented, the result is undefined.
8. DW_OP_not
The DW_OP_not operation pops the top stack entry, and pushes its bitwise complement.
9. DW_OP_or
The DW_OP_or operation pops the top two stack entries, performs a bitwise or operation on
the two, and pushes the result.
10. DW_OP_plus
The DW_OP_plus operation pops the top two stack entries, adds them together, and pushes
the result.
11. DW_OP_plus_uconst
The DW_OP_plus_uconst operation pops the top stack entry, adds it to the unsigned LEB128
constant operand and pushes the result.
This operation is supplied specifically to be able to encode more field offsets in two bytes
than can be done with “DW_OP_litn DW_OP_plus”.
12. DW_OP_shl
The DW_OP_shl operation pops the top two stack entries, shifts the former second entry left
(filling with zero bits) by the number of bits specified by the former top of the stack, and
pushes the result.
13. DW_OP_shr
The DW_OP_shr operation pops the top two stack entries, shifts the former second entry
right logically (filling with zero bits) by the number of bits specified by the former top of the
stack, and pushes the result.
14. DW_OP_shra
The DW_OP_shra operation pops the top two stack entries, shifts the former second entry
right arithmetically (divide the magnitude by 2, keep the same sign for the result) by the
number of bits specified by the former top of the stack, and pushes the result.
15. DW_OP_xor
The DW_OP_xor operation pops the top two stack entries, performs a bitwise exclusive-or
operation on the two, and pushes the result.
The following operations provide simple control of the flow of a DWARF expression.
1. DW_OP_le, DW_OP_ge, DW_OP_eq, DW_OP_lt, DW_OP_gt, DW_OP_ne
The six relational operators each:
• push the constant value 1 onto the stack if the result of the operation is true or the
constant value 0 if the result of the operation is false.
Comparisons are performed as signed operations. The six operators are DW_OP_le (less than
or equal to), DW_OP_ge (greater than or equal to), DW_OP_eq (equal to), DW_OP_lt (less
than), DW_OP_gt (greater than) and DW_OP_ne (not equal to).
2. DW_OP_skip
DW_OP_skip is an unconditional branch. Its single operand is a 2-byte signed integer
constant. The 2-byte constant is the number of bytes of the DWARF expression to skip
forward or backward from the current operation, beginning after the 2-byte constant.
3. DW_OP_bra
DW_OP_bra is a conditional branch. Its single operand is a 2-byte signed integer constant.
This operation pops the top of stack. If the value popped is not the constant 0, the 2-byte
constant operand is the number of bytes of the DWARF expression to skip forward or
backward from the current operation, beginning after the 2-byte constant.
0 17 DW_OP_dup 0 17
1 29 1 17
2 1000 2 29
3 1000
0 17 DW_OP_drop 0 29
1 29 1 1000
2 1000
0 17 DW_OP_pick 2 0 1000
1 29 1 17
2 1000 2 29
3 1000
0 17 DW_OP_over 0 29
1 29 1 17
2 1000 2 29
3 1000
0 17 DW_OP_swap 0 29
1 29 1 17
2 1000 2 1000
0 17 DW_OP_rot 0 29
1 29 1 1000
2 1000 2 17
Information about the location of program objects is provided by location descriptions. Location
descriptions can be either of two forms:
1. Single location descriptions, which are a language independent representation of
addressing rules of arbitrary complexity built from DWARF expressions and/or other
DWARF operations specific to describing locations. They are sufficient for describing
the location of any object as long as its lifetime is either static or the same as the lexical
block that owns it, and it does not move during its lifetime.
The following DWARF operations may be used to specify a value that has no location in the
program but is a known constant or is computed from other locations and values in the program.
1. DW_OP_implicit_value
The DW_OP_implicit_value operation specifies an immediate value using two operands: an
unsigned LEB128 length, followed by a block representing the value in the memory
representation of the target machine. The length operand gives the length in bytes of the
block.
2. DW_OP_stack_value
The DW_OP_stack_value operation specifies that the object does not exist in memory but its
value is nonetheless known and is at the top of the DWARF expression stack. In this form of
location description, the DWARF expression represents the actual value of the object, rather
than its location. The DW_OP_stack_value operation terminates the expression.
2. DW_OP_bit_piece
The DW_OP_bit_piece operation takes two operands. The first is an unsigned LEB128
number that gives the size in bits of the piece. The second is an unsigned LEB128 number
that gives the offset in bits from the location defined by the preceding DWARF location
description.
Interpretation of the offset depends on the kind of location description. If the location
description is empty, the offset doesn’t matter and the DW_OP_bit_piece operation describes
a piece consisting of the given number of bits whose values are undefined. If the location is a
register, the offset is from the least significant bit end of the register. If the location is a
memory address, the DW_OP_bit_piece operation describes a sequence of bits relative to the
location whose address is on the top of the DWARF stack using the bit numbering and
direction conventions that are appropriate to the current language on the target system. If the
location is any implicit value or stack value, the DW_OP_bit_piece operation describes a
sequence of bits using the least significant bits of that value.
DW_OP_bit_piece is used instead of DW_OP_piece when the piece to be assembled into a value
or assigned to is not byte-sized or is not at the start of a register or addressable unit of memory.
DW_OP_regx 54
The value is in register 54.
DW_OP_addr 0x80d0045c
The value of a static variable is at machine address 0x80d0045c.
DW_OP_breg11 44
Add 44 to the value in register 11 to get the address of an automatic
variable instance.
DW_OP_fbreg -50
Given a DW_AT_frame_base value of “DW_OP_breg31 64,” this example
computes the address of a local variable that is -50 bytes from a
logical frame pointer that is computed by adding 64 to the current
stack pointer (register 31).
DW_OP_bregx 54 32 DW_OP_deref
A call-by-reference parameter whose address is in the word 32 bytes
from where register 54 points.
DW_OP_plus_uconst 4
A structure member is four bytes from the start of the structure
instance. The base address is assumed to be already on the stack.
A location list entry (but not a base address selection or end of list entry) whose beginning
and ending addresses are equal has no effect because the size of the range covered by such
an entry is zero.
3. A single location description describing the location of the object over the range specified by
the beginning and end addresses.
The applicable base address of a location list entry is determined by the closest preceding base
address selection entry (see below) in the same location list. If there is no such selection entry,
then the applicable base address defaults to the base address of the compilation unit (see
Section 3.1.1).
In the case of a compilation unit where all of the machine code is contained in a single
contiguous section, no base address selection entry is needed.
Address ranges may overlap. When they do, they describe a situation in which an object exists
simultaneously in more than one place. If all of the address ranges in a given location list do not
collectively cover the entire range over which the object in question is defined, it is assumed that
the object is not available for the portion of the range that is not covered.
A base address selection entry consists of:
1. The value of the largest representable address offset (for example, 0xffffffff when the size of
an address is 32 bits).
2. An address, which defines the appropriate base address for use in interpreting the beginning
and ending address offsets of subsequent entries of the location list.
A base address selection entry affects only the list in which it is contained.
The end of any given location list is marked by an end of list entry, which consists of a 0 for the
beginning address offset and a 0 for the ending address offset. A location list containing only an
end of list entry describes an object that exists in the source code but not in the executable
program.
Neither a base address selection entry nor an end of list entry includes a location description.
A base address selection entry and an end of list entry for a location list are identical to a base
address selection entry and end of list entry, respectively, for a range list (see Section 2.17.3) in
interpretation and representation.
DW_ACCESS_public
DW_ACCESS_private
DW_ACCESS_protected
DW_VIS_local
DW_VIS_exported
DW_VIS_qualified
DW_VIRTUALITY_none
DW_VIRTUALITY_virtual
DW_VIRTUALITY_pure_virtual
For example, the Intel386 ™ processor might use the following values:
Because the names of program objects described by DWARF are the names as they appear in the
source program, implementations of language translators that use some form of mangled name
(as do many implementations of C++) should use the unmangled form of the name in the
DWARF DW_AT_name attribute, including the keyword operator (in names such as
“operator +”), if present. See also Section 2.22 regarding the use of DW_AT_linkage_name
for mangled names. Sequences of multiple whitespace characters may be compressed.
Range lists are contained in a separate object file section called .debug_ranges. A range list is
indicated by a DW_AT_ranges attribute whose value is represented as an offset from the
beginning of the .debug_ranges section to the beginning of the range list.
Each entry in a range list is either a range list entry, a base address selection entry, or an end of
list entry.
• For a constant, the value of the constant is the value of the attribute.
• For a reference, the value is a reference to another entity which specifies the value of the
attribute.
• For an exprloc, the value is interpreted as a DWARF expression; evaluation of the expression
yields the value of the attribute.
Whether an attribute value can be dynamic depends on the rules of the applicable programming
language.
The applicable attributes include: DW_AT_allocated, DW_AT_associated, DW_AT_bit_offset,
DW_AT_bit_size, DW_AT_byte_size, DW_AT_count, DW_AT_lower_bound,
DW_AT_byte_stride, DW_AT_bit_stride, DW_AT_upper_bound (and possibly others).
DW_LANG_D † D
DW_LANG_Java Java
DW_LANG_ObjC Objective C
DW_LANG_Python † Python
4. A DW_AT_stmt_list attribute whose value is a section offset to the line number information
for this compilation unit.
This information is placed in a separate object file section from the debugging information
entries themselves. The value of the statement list attribute is the offset in the .debug_line
section of the first byte of the line number information for this compilation unit (see
Section 6.2).
5. A DW_AT_macro_info attribute whose value is a section offset to the macro information for
this compilation unit.
This information is placed in a separate object file section from the debugging information
entries themselves. The value of the macro information attribute is the offset in the
.debug_macinfo section of the first byte of the macro information for this compilation unit
(see Section 6.3).
DW_ID_case_sensitive
DW_ID_up_case
DW_ID_down_case
DW_ID_case_insensitive
DW_ID_case_sensitive is the default for all compilation units that do not have this attribute.
It indicates that names given as the values of DW_AT_name attributes in debugging
information entries for the compilation unit reflect the names as they appear in the source
program. The debugger should be sensitive to the case of identifier names when doing
identifier lookups.
DW_ID_up_case means that the producer of the debugging information for this compilation
unit converted all source names to upper case. The values of the name attributes may not
reflect the names as they appear in the source program. The debugger should convert all
names to upper case when doing lookups.
DW_ID_down_case means that the producer of the debugging information for this
compilation unit converted all source names to lower case. The values of the name attributes
may not reflect the names as they appear in the source program. The debugger should convert
all names to lower case when doing lookups.
DW_ID_case_insensitive means that the values of the name attributes reflect the names as
they appear in the source program but that a case insensitive lookup should be used to access
those names.
The base address of a compilation unit is defined as the value of the DW_AT_low_pc attribute,
if present; otherwise, it is undefined. If the base address is undefined, then any DWARF entry or
structure defined in terms of the base address of that compilation unit is not valid.
3.1.2 Imported Unit Entries
The place where a normal or partial unit is imported is represented by a debugging information
entry with the tag DW_TAG_imported_unit. An imported unit entry contains a DW_AT_import
attribute whose value is a reference to the normal or partial compilation unit whose declarations
logically belong at the place of the imported unit entry.
An imported unit entry does not necessarily correspond to any entity or construct in the source
program. It is merely “glue” used to relate a partial unit, or a compilation unit used as a partial
unit, to a place in some other compilation unit.
For C++, such owned program entities may be declarations, including certain declarations that
are also object or function definitions.
If a type, variable, or function declared in a namespace is defined outside of the body of the
namespace declaration, that type, variable, or function definition entry has a
DW_AT_specification attribute whose value is a reference to the debugging information entry
representing the declaration of the type, variable or function. Type, variable, or function entries
with a DW_AT_specification attribute do not need to duplicate information provided by the
declaration entry referenced by the specification attribute.
The C++ global namespace (the namespace referred to by “::f”, for example) is not explicitly
represented in DWARF with a namespace entry (thus mirroring the situation in C++ source).
Global items may be simply declared with no reference to a namespace.
The C++ compilation unit specific “unnamed namespace” may be represented by a namespace
entry with no name attribute in the original namespace declaration entry (and therefore no name
attribute in any namespace extension entry of this namespace).
A compiler emitting namespace information may choose to explicitly represent namespace
extensions, or to represent the final namespace declaration of a compilation unit; this is a
quality-of-implementation issue and no specific requirements are given here. If only the final
namespace is represented, it is impossible for a debugger to interpret using declaration
references in exactly the manner defined by the C++ language.
Emitting all namespace declaration information in all compilation units can result in a
significant increase in the size of the debug information and significant duplication of
information across compilation units. The C++ namespace std, for example, is large and will
probably be referenced in every C++ compilation unit.
For a C++ namespace example, see Appendix D.3.
3.2.3 Imported (or Renamed) Declaration Entries
Some languages support the concept of importing into or making accessible in a given unit
declarations made in a different module or scope. An imported declaration may sometimes be
given another name.
An imported declaration is represented by one or more debugging information entries with the
tag DW_TAG_imported_declaration. When an overloaded entity is imported, there is one
imported declaration entry for each overloading. Each imported declaration entry has a
DW_AT_import attribute, whose value is a reference to the debugging information entry
representing the declaration that is being imported.
An imported declaration may also have a DW_AT_name attribute whose value is a null-
terminated string containing the name, as it appears in the source program, by which the
imported entity is to be known in the context of the imported declaration entry (which may be
different than the name of the entity being imported). If no name is present, then the name by
which the entity is to be known is the same as the name of the entity being imported.
An imported declaration entry with a name attribute may be used as a general means to rename
or provide an alias for an entity, regardless of the context in which the importing declaration or
the imported entity occurs.
A C++ namespace alias may be represented by an imported declaration entry with a name
attribute whose value is a null-terminated string containing the alias name as it appears in the
source program and an import attribute whose value is a reference to the applicable original
namespace or namespace extension entry.
A C++ using declaration may be represented by one or more imported declaration entries.
When the using declaration refers to an overloaded function, there is one imported declaration
entry corresponding to each overloading. Each imported declaration entry has no name attribute
but it does have an import attribute that refers to the entry for the entity being imported. (C++
provides no means to “rename” an imported entity, other than a namespace).
A Fortran use statement with an “only list” may be represented by a series of imported
declaration entries, one (or more) for each entity that is imported. An entity that is renamed in
the importing context may be represented by an imported declaration entry with a name attribute
that specifies the new local name.
3.2.4 Imported Module Entries
Some languages support the concept of importing into or making accessible in a given unit all of
the declarations contained within a separate module or namespace.
An imported module declaration is represented by a debugging information entry with the tag
DW_TAG_imported_module. An imported module entry contains a DW_AT_import attribute
whose value is a reference to the module or namespace entry containing the definition and/or
declaration entries for the entities that are to be imported into the context of the imported module
entry.
An imported module declaration may own a set of imported declaration entries, each of which
refers to an entry in the module whose corresponding entity is to be known in the context of the
imported module declaration by a name other than its name in that module. Any entity in the
module that is not renamed in this way is known in the context of the imported module entry by
the same name as it is declared in the module.
A C++ using directive may be represented by an imported module entry, with an import
attribute referring to the namespace entry of the appropriate extension of the namespace (which
might be the original namespace entry) and no owned entries.
A Fortran use statement with a “rename list” may be represented by an imported module entry
with an import attribute referring to the module and owned entries corresponding to those
entities that are renamed as part of being imported.
A Fortran use statement with neither a “rename list” nor an “only list” may be represented by
an imported module entry with an import attribute referring to the module and no owned child
entries.
A use statement with an “only list” is represented by a series of individual imported declaration
entries as described in Section 3.2.3.
A Fortran use statement for an entity in a module that is itself imported by a use statement
without an explicit mention may be represented by an imported declaration entry that refers to
the original debugging information entry. For example, given
module A
integer X, Y, Z
end module
module B
use A
end module
module C
use B, only Q => X
end module
the imported declaration entry for Q within module C refers directly to the variable declaration
entry for A in module A because there is no explicit representation for X in module B.
A similar situation arises for a C++ using declaration that imports an entity in terms of a
namespace alias. See Appendix D.3 for an example.
DW_CC_normal
DW_CC_program
DW_CC_nocall
The Fortran language allows the keywords elemental, pure and recursive to be included as
part of the declaration of a subroutine; these attributes reflect that usage. These attributes are
not relevant for languages that do not support similar keywords or syntax. In particular, the
DW_AT_recursive attribute is neither needed nor appropriate in languages such as C where
functions support recursion by default.
A subprogram entry may have a DW_AT_elemental attribute, which is a flag. The attribute
indicates whether the subroutine or entry point was declared with the “elemental” keyword or
property.
A subprogram entry may have a DW_AT_pure attribute, which is a flag. The attribute indicates
whether the subroutine was declared with the “pure” keyword or property.
A subprogram entry may have a DW_AT_recursive attribute, which is a flag. The attribute
indicates whether the subroutine or entry point was declared with the “recursive” keyword or
property.
3.3.2 Subroutine and Entry Point Return Types
If the subroutine or entry point is a function that returns a value, then its debugging information
entry has a DW_AT_type attribute to denote the type returned by that function.
Debugging information entries for C void functions should not have an attribute for the return
type.
3.3.3 Subroutine and Entry Point Locations
A subroutine entry may have either a DW_AT_low_pc and DW_AT_high_pc pair of attributes
or a DW_AT_ranges attribute whose values encode the contiguous or non-contiguous address
ranges, respectively, of the machine instructions generated for the subroutine (see Section 2.17).
A subroutine entry may also have a DW_AT_entry_pc attribute whose value is the address of the
first executable instruction of the subroutine (see Section 2.18).
An entry point has a DW_AT_low_pc attribute whose value is the relocated address of the first
machine instruction generated for the entry point.
While the DW_AT_entry_pc attribute might also seem appropriate for this purpose, historically
the DW_AT_low_pc attribute was used before the DW_AT_entry_pc was introduced (in DWARF
Version 3). There is insufficient reason to change this.
Subroutines and entry points may also have DW_AT_segment and DW_AT_address_class
attributes, as appropriate, to specify which segments the code for the subroutine resides in and
the addressing mode to be used in calling that subroutine.
A subroutine entry representing a subroutine declaration that is not also a definition does not
have code address or range attributes.
3.3.4 Declarations Owned by Subroutines and Entry Points
The declarations enclosed by a subroutine or entry point are represented by debugging
information entries that are owned by the subroutine or entry point entry. Entries representing the
formal parameters of the subroutine or entry point appear in the same order as the corresponding
declarations in the source program.
There is no ordering requirement for entries for declarations that are children of subroutine or
entry point entries but that do not represent formal parameters. The formal parameter entries
may be interspersed with other entries used by formal parameter entries, such as type entries.
The unspecified parameters of a variable parameter list are represented by a debugging
information entry with the tag DW_TAG_unspecified_parameters.
The entry for a subroutine that includes a Fortran common block has a child entry with the tag
DW_TAG_common_inclusion. The common inclusion entry has a DW_AT_common_reference
attribute whose value is a reference to the debugging information entry for the common block
being included (see Section 4.2).
3.3.5 Low-Level Information
A subroutine or entry point entry may have a DW_AT_return_addr attribute, whose value is a
location description. The location calculated is the place where the return address for the
subroutine or entry point is stored.
A subroutine or entry point entry may also have a DW_AT_frame_base attribute, whose value is
a location description that computes the “frame base” for the subroutine or entry point. If the
location description is a simple register location description, the given register contains the frame
base address. If the location description is a DWARF expression, the result of evaluating that
expression is the frame base address. Finally, for a location list, this interpretation applies to each
location description contained in the list of location list entries.
The use of one of the DW_OP_reg<n> operations in this context is equivalent to using
DW_OP_breg<n>(0) but more compact. However, these are not equivalent in general.
The frame base for a procedure is typically an address fixed relative to the first unit of storage
allocated for the procedure’s stack frame. The DW_AT_frame_base attribute can be used in
several ways:
1. In procedures that need location lists to locate local variables, the DW_AT_frame_base can
hold the needed location list, while all variables’ location descriptions can be simpler ones
involving the frame base.
2. It can be used in resolving “up-level” addressing within nested routines. (See also
DW_AT_static_link, below)
Some languages support nested subroutines. In such languages, it is possible to reference the
local variables of an outer subroutine from within an inner subroutine. The DW_AT_static_link
and DW_AT_frame_base attributes allow debuggers to support this same kind of referencing.
If a subroutine or entry point is nested, it may have a DW_AT_static_link attribute, whose value
is a location description that computes the frame base of the relevant instance of the subroutine
that immediately encloses the subroutine or entry point.
In the context of supporting nested subroutines, the DW_AT_frame_base attribute value should
obey the following constraints:
1. It should compute a value that does not change during the life of the procedure, and
2. The computed value should be unique among instances of the same subroutine. (For typical
DW_AT_frame_base use, this means that a recursive subroutine’s stack frame must have
non-zero size.)
If a debugger is attempting to resolve an up-level reference to a variable, it uses the nesting
structure of DWARF to determine which subroutine is the lexical parent and the
DW_AT_static_link value to identify the appropriate active frame of the parent. It can then
attempt to find the reference within the context of the parent.
3.3.6 Types Thrown by Exceptions
In C++ a subroutine may declare a set of types which it may validly throw.
If a subroutine explicitly declares that it may throw an exception for one or more types, each
such type is represented by a debugging information entry with the tag DW_TAG_thrown_type.
Each such entry is a child of the entry representing the subroutine that may throw this type. Each
thrown type entry contains a DW_AT_type attribute, whose value is a reference to an entry
describing the type of the exception that may be thrown.
3.3.7 Function Template Instantiations
In C++, a function template is a generic definition of a function that is instantiated differently
when called with values of different types. DWARF does not represent the generic template
definition, but does represent each instantiation.
Name Meaning
In C++, a function or a constructor declared with constexpr is implicitly declared inline. The
abstract inline instance (see below) is represented by a debugging information entry with the tag
DW_TAG_subprogram. Such an entry has a DW_AT_inline attribute whose value is
DW_INL_inlined.
Any debugging information entry that is owned (either directly or indirectly) by a debugging
information entry that contains the DW_AT_inline attribute is referred to as an “abstract instance
entry.” Any subroutine entry that contains a DW_AT_inline attribute whose value is other than
DW_INL_not_inlined is known as an “abstract instance root.” Any set of abstract instance
entries that are all children (either directly or indirectly) of some abstract instance root, together
with the root itself, is known as an “abstract instance tree.” However, in the case where an
abstract instance tree is nested within another abstract instance tree, the entries in the nested
abstract instance tree are not considered to be entries in the outer abstract instance tree.
Each abstract instance root is either part of a larger tree (which gives a context for the root) or
uses DW_AT_specification to refer to the declaration in context.
For example, in C++ the context might be a namespace declaration or a class declaration.
Abstract instance trees are defined so that no entry is part of more than one abstract instance
tree. This simplifies the following descriptions.
A debugging information entry that is a member of an abstract instance tree should not contain
any attributes which describe aspects of the subroutine which vary between distinct inlined
expansions or distinct out-of-line expansions. For example, the DW_AT_low_pc,
Each inline expansion of a subroutine is represented by a debugging information entry with the
tag DW_TAG_inlined_subroutine. Each such entry should be a direct child of the entry that
represents the scope within which the inlining occurs.
Each inlined subroutine entry may have either a DW_AT_low_pc and DW_AT_high_pc pair of
attributes or a DW_AT_ranges attribute whose values encode the contiguous or non-contiguous
address ranges, respectively, of the machine instructions generated for the inlined subroutine (see
Section 2.17). An inlined subroutine entry may also contain a DW_AT_entry_pc attribute,
representing the first executable instruction of the inline expansion (see Section 2.18).
An inlined subroutine entry may also have DW_AT_call_file, DW_AT_call_line and
DW_AT_call_column attributes, each of whose value is an integer constant. These attributes
represent the source file, source line number, and source column number, respectively, of the
first character of the statement or expression that caused the inline expansion. The call file, call
line, and call column attributes are interpreted in the same way as the declaration file, declaration
line, and declaration column attributes, respectively (see Section 2.14).
The call file, call line and call column coordinates do not describe the coordinates of the
subroutine declaration that was inlined, rather they describe the coordinates of the call.
An inlined subroutine entry may have a DW_AT_const_expr attribute, which is a flag whose
presence indicates that the subroutine has been evaluated as a compile-time constant. Such an
entry may also have a DW_AT_const_value attribute, whose value may be of any form that is
appropriate for the representation of the subroutine's return value. The value of this attribute is
the actual return value of the subroutine, represented as it would be on the target architecture.
Any debugging information entry that is owned (either directly or indirectly) by a debugging
information entry with the tag DW_TAG_inlined_subroutine is referred to as a “concrete inlined
instance entry.” Any entry that has the tag DW_TAG_inlined_subroutine is known as a
“concrete inlined instance root.” Any set of concrete inlined instance entries that are all children
(either directly or indirectly) of some concrete inlined instance root, together with the root itself,
is known as a “concrete inlined instance tree.” However, in the case where a concrete inlined
instance tree is nested within another concrete instance tree, the entries in the nested concrete
instance tree are not considered to be entries in the outer concrete instance tree.
Concrete inlined instance trees are defined so that no entry is part of more than one concrete
inlined instance tree. This simplifies later descriptions.
Each concrete inlined instance tree is uniquely associated with one (and only one) abstract
instance tree.
Note, however, that the reverse is not true. Any given abstract instance tree may be associated
with several different concrete inlined instance trees, or may even be associated with zero
concrete inlined instance trees.
Concrete inlined instance entries may omit attributes that are not specific to the concrete instance
(but present in the abstract instance) and need include only attributes that are specific to the
concrete instance (but omitted in the abstract instance). In place of these omitted attributes, each
concrete inlined instance entry has a DW_AT_abstract_origin attribute that may be used to
obtain the missing information (indirectly) from the associated abstract instance entry. The value
of the abstract origin attribute is a reference to the associated abstract instance entry.
If an entry within a concrete inlined instance tree contains attributes describing the declaration
coordinates of that entry, then those attributes should refer to the file, line and column of the
original declaration of the subroutine, not to the point at which it was inlined. As a consequence,
they may usually be omitted from any entry that has an abstract origin attribute.
For each pair of entries that are associated via a DW_AT_abstract_origin attribute, both
members of the pair have the same tag. So, for example, an entry with the tag
DW_TAG_variable can only be associated with another entry that also has the tag
DW_TAG_variable. The only exception to this rule is that the root of a concrete instance tree
(which must always have the tag DW_TAG_inlined_subroutine) can only be associated with the
root of its associated abstract instance tree (which must have the tag DW_TAG_subprogram).
In general, the structure and content of any given concrete inlined instance tree will be closely
analogous to the structure and content of its associated abstract instance tree. There are a few
exceptions:
1. An entry in the concrete instance tree may be omitted if it contains only a
DW_AT_abstract_origin attribute and either has no children, or its children are omitted. Such
entries would provide no useful information. In C-like languages, such entries frequently
include types, including structure, union, class, and interface types; and members of types. If
any entry within a concrete inlined instance tree needs to refer to an entity declared within
the scope of the relevant inlined subroutine and for which no concrete instance entry exists,
the reference should refer to the abstract instance entry.
2. Entries in the concrete instance tree which are associated with entries in the abstract instance
tree such that neither has a DW_AT_name attribute, and neither is referenced by any other
debugging information entry, may be omitted. This may happen for debugging information
entries in the abstract instance trees that became unnecessary in the concrete instance tree
because of additional information available there. For example, an anonymous variable might
have been created and described in the abstract instance tree, but because of the actual
parameters for a particular inlined expansion, it could be described as a constant value
without the need for that separate debugging information entry.
3. A concrete instance tree may contain entries which do not correspond to entries in the
abstract instance tree to describe new entities that are specific to a particular inlined
expansion. In that case, they will not have associated entries in the abstract instance tree,
should not contain DW_AT_abstract_origin attributes, and must contain all their own
attributes directly. This allows an abstract instance tree to omit debugging information entries
for anonymous entities that are unlikely to be needed in most inlined expansions. In any
expansion which deviates from that expectation, the entries can be described in its concrete
inlined instance tree.
3.3.8.3 Out-of-Line Instances of Inlined Subroutines
Under some conditions, compilers may need to generate concrete executable instances of inlined
subroutines other than at points where those subroutines are actually called. Such concrete
instances of inlined subroutines are referred to as “concrete out-of-line instances.”
In C++, for example, taking the address of a function declared to be inline can necessitate the
generation of a concrete out-of-line instance of the given function.
Some languages and compilers may permit the logical nesting of a subroutine within another
subroutine, and may permit either the outer or the nested subroutine, or both, to be inlined.
For a non-inlined subroutine nested within an inlined subroutine, the nested subroutine is
described normally in both the abstract and concrete inlined instance trees for the outer
subroutine. All rules pertaining to the abstract and concrete instance trees for the outer
subroutine apply also to the abstract and concrete instance entries for the nested subroutine.
For an inlined subroutine nested within another inlined subroutine, the following rules apply to
their abstract and concrete instance trees:
1. The abstract instance tree for the nested subroutine is described within the abstract
instance tree for the outer subroutine according to the rules in Section 3.3.8.1, and
without regard to the fact that it is within an outer abstract instance tree.
2. Any abstract instance tree for a nested subroutine is always omitted within the concrete
instance tree for an outer subroutine.
3. A concrete instance tree for a nested subroutine is always omitted within the abstract
instance tree for an outer subroutine.
4. The concrete instance tree for any inlined or out-of-line expansion of the nested
subroutine is described within a concrete instance tree for the outer subroutine according
to the rules in Sections 3.3.8.2 or 3.3.8.3, respectively, and without regard to the fact that
it is within an outer concrete instance tree.
See Appendix D.7 for discussion and examples.
3.3.9 Trampolines
A trampoline is a compiler-generated subroutine that serves as an intermediary in making a call
to another subroutine. It may adjust parameters and/or the result (if any) as appropriate to the
combined calling and called execution contexts.
A trampoline is represented by a debugging information entry with the tag
DW_TAG_subprogram or DW_TAG_inlined_subroutine that has a DW_AT_trampoline
attribute. The value of that attribute indicates the target subroutine of the trampoline, that is, the
subroutine to which the trampoline passes control. (A trampoline entry may but need not also
have a DW_AT_artificial attribute.)
The value of the trampoline attribute may be represented using any of the following forms,
which are listed in order of preference:
• If the value is of class reference, then the value specifies the debugging information entry of
the target subprogram.
• If the value is of class address, then the value is the relocated address of the target
subprogram.
• If the value is of class string, then the value is the (possibly mangled) name of the target
subprogram.
• If the value is of class flag, then the value true indicates that the containing subroutine is a
trampoline but that the target subroutine is not known.
The target subprogram may itself be a trampoline. (A sequence of trampolines necessarily ends
with a non-trampoline subprogram.)
In C++, trampolines may be used to implement derived virtual member functions; such
trampolines typically adjust the implicit this pointer parameter in the course of passing control.
Other languages and environments may use trampolines in a manner sometimes known as
transfer functions or transfer vectors.
Trampolines may sometimes pass control to the target subprogram using a branch or jump
instruction instead of a call instruction, thereby leaving no trace of their existence in the
subsequent execution context.
This attribute helps make it feasible for a debugger to arrange that stepping into a trampoline or
setting a breakpoint in a trampoline will result in stepping into or setting the breakpoint in the
target subroutine instead. This helps to hide the compiler generated subprogram from the user.
If the target subroutine is not known, a debugger may choose to repeatedly step until control
arrives in a new subroutine which can be assumed to be the target subroutine.
The label entry has a DW_AT_low_pc attribute whose value is the relocated address of the first
machine instruction generated for the statement identified by the label in the source program.
The label entry also has a DW_AT_name attribute whose value is a null-terminated string
containing the name of the label as it appears in the source program.
Catch block entries have at least one child entry, an entry representing the type of exception
accepted by that catch block. This child entry has one of the tags DW_TAG_formal_parameter
or DW_TAG_unspecified_parameters, and will have the same form as other parameter entries.
The siblings immediately following a try block entry are its corresponding catch block entries.
If a variable entry describes an anonymous union, the name attribute is omitted or consists of
a single zero byte.
2. A DW_AT_external attribute, which is a flag, if the name of a variable is visible outside of
its enclosing compilation unit.
The definitions of C++ static data members of structures or classes are represented by
variable entries flagged as external. Both file static and local variables in C and C++ are
represented by non-external variable entries.
3. A DW_AT_declaration attribute, which is a flag that indicates whether this entry represents a
non-defining declaration of an object.
4. A DW_AT_location attribute, whose value describes the location of a variable or parameter
at run-time.
In a variable entry representing the definition of a variable (that is, with no
DW_AT_declaration attribute) if no location attribute is present, or if the location attribute is
present but has an empty location description (as described in Section 2.6), the variable is
assumed to exist in the source code but not in the executable program (but see number 10,
below).
For a constant form there is no way to express the absence of a default value.
b) Otherwise, the scope of the object is specified using a value of class rangelistptr. This
value indicates the beginning of a range list (see Section 2.17.3).
The scope of a variable may begin somewhere in the middle of a lexical block in a language
that allows executable code in a block before a variable declaration, or where one
declaration containing initialization code may change the scope of a subsequent declaration.
For example, in the following C code:
float x = 99.99;
int myfunc()
{
float f = x;
float x = 88.99;
return 0;
}
C scoping rules require that the value of the variable x assigned to the variable f in the
initialization sequence is the value of the global variable x, rather than the local x, because
the scope of the local variable x only starts after the full declarator for the local x.
Due to optimization, the scope of an object may be non-contiguous and require use of a
range list even when the containing scope is contiguous. Conversely, the scope of an object
may not require its own range list even when the containing scope is non-contiguous.
12. A DW_AT_endianity attribute, whose value is a constant that specifies the endianity of the
object. The value of this attribute specifies an ABI-defined byte ordering for the value of the
object. If omitted, the default endianity of data for the given type is assumed.
The set of values and their meaning for this attribute is given in Figure 12.
Name Meaning
These represent the default encoding formats as defined by the target architecture’s ABI or
processor definition. The exact definition of these formats may differ in subtle ways for
different architectures.
13. A DW_AT_const_expr attribute, which is a flag, if a variable entry represents a C++ object
declared with the constexpr specifier. This attributes indicates that the variable can be
evaluated as a compile-time constant.
In C++, a variable declared with constexpr is implicitly const. Such a variable has a
DW_AT_type attribute whose value is a reference to a debugging information entry
describing a const qualified type.
14. A DW_AT_linkage_name attribute for a variable or constant entry as described in Section
2.22.
For example, the C type int on a machine that uses 32-bit integers is represented by a base type
entry with a name attribute whose value is “int”, an encoding attribute whose value is
DW_ATE_signed and a byte size attribute whose value is 4.
If the value of an object of the given type does not fully occupy the storage described by a byte
size attribute, the base type entry may also have a DW_AT_bit_size and a
DW_AT_data_bit_offset attribute, both of whose values are integer constant values (see Section
2.19). The bit size attribute describes the actual size in bits used to represent values of the given
type. The data bit offset attribute is the offset in bits from the beginning of the containing storage
to the beginning of the value. Bits that are part of the offset are padding. The data bit offset uses
the bit numbering and direction conventions that are appropriate to the current language on the
target system to locate the beginning of the storage and value. If this attribute is omitted a default
data bit offset of zero is assumed.
Attribute DW_AT_data_bit_offset is new in DWARF Version 4 and is also used for bit field
members (see Section 5.5.6). It replaces the attribute DW_AT_bit_offset when used for base
types as defined in DWARF V3 and earlier. The earlier attribute is defined in a manner suitable
for bit field members on big-endian architectures but which is wasteful for use on little-endian
architectures.
The attribute DW_AT_bit_offset is deprecated in DWARF Version 4 for use in base types, but
implementations may continue to support its use for compatibility.
The DWARF Version 3 definition of these attributes is as follows.
A base type entry has a DW_AT_byte_size attribute, whose value (see Section 2.19) is the
size in bytes of the storage unit used to represent an object of the given type.
If the value of an object of the given type does not fully occupy the storage unit described
by the byte size attribute, the base type entry may have a DW_AT_bit_size attribute and a
DW_AT_bit_offset attribute, both of whose values (see Section 2.19) are integers. The bit
size attribute describes the actual size in bits used to represent a value of the given type.
The bit offset attribute describes the offset in bits of the high order bit of a value of the
given type from the high order bit of the storage unit used to contain that value.
In comparing DWARF Versions 3 and 4, note that DWARF V4 defines the following
combinations of attributes:
• DW_AT_byte_size
• DW_AT_bit_size
• DW_AT_byte_size, DW_AT_bit_size and optionally DW_AT_data_bit_offset
DWARF V3 defines the following combinations:
• DW_AT_byte_size
• DW_AT_byte_size, DW_AT_bit_size and DW_AT_bit_offset
Name Meaning
The DW_ATE_UTF encoding is intended for Unicode string encodings (see the Universal
Character Set standard, ISO/IEC 10646-1:1993). For example, the C++ type char16_t is
represented by a base type entry with a name attribute whose value is “char16_t”, an encoding
attribute whose value is DW_ATE_UTF and a byte size attribute whose value is 2.
The fixed binary type entries have a DW_AT_digit_count attribute with the same interpretation
as described for the DW_ATE_packed_decimal and DW_ATE_numeric_string base types.
For a data type with a decimal scale factor, the fixed binary type entry has a
DW_AT_decimal_scale attribute with the same interpretation as described for the
DW_ATE_packed_decimal and DW_ATE_numeric_string base types.
For a data type with a binary scale factor, the fixed binary type entry has a
DW_AT_binary_scale attribute. The DW_AT_binary_scale attribute is an integer constant value
that represents the exponent of the base two scale factor to be applied to an instance of the type.
Zero scale puts the binary point immediately to the right of the least significant bit. Positive scale
moves the binary point to the right and implies that additional zero bits on the right are not stored
in an instance of the type. Negative scale moves the binary point to the left; if the absolute value
of the scale is larger than the number of bits, this implies additional zero bits on the left are not
stored in an instance of the type.
For a data type with a non-decimal and non-binary scale factor, the fixed binary type entry has a
DW_AT_small attribute which references a DW_TAG_constant entry. The scale factor value is
interpreted in accordance with the value defined by the DW_TAG_constant entry. The value
represented is the product of the integer value in memory and the associated constant entry for
the type.
The DW_AT_small attribute is defined with the Ada small attribute in mind.
Name Meaning
DW_DS_unsigned Unsigned
DW_DS_leading_separate Sign is a ‘+’ or ‘-’ character to the left of the most significant
digit
DW_DS_trailing_separate Decimal type: Sign is a ‘+’ or ‘-’ character to the right of the least
significant digit
Packed decimal type: Least significant nibble contains a target-
dependent value indicating positive or negative
A base or user-defined type may be modified in different ways in different languages. A type
modifier is represented in DWARF by a debugging information entry with one of the tags given
in Figure 15.
If a name has been given to the modified type in the source program, then the corresponding
modified type entry has a DW_AT_name attribute whose value is a null-terminated string
containing the modified type name as it appears in the source program.
Each of the type modifier entries has a DW_AT_type attribute, whose value is a reference to a
debugging information entry describing a base type, a user-defined type or another type
modifier.
A modified type entry describing a pointer or reference type (using DW_TAG_pointer_type,
DW_TAG_reference_type or DW_TAG_rvalue_reference_type) may have a
DW_AT_address_class attribute to describe how objects having the given pointer or reference
type ought to be dereferenced.
A modified type entry describing a shared qualified type (using DW_TAG_shared_type) may
have a DW_AT_count attribute whose value is a constant expressing the blocksize of the type. If
no count attribute is present, then the “infinite” blocksize is assumed.
When multiple type modifiers are chained together to modify a base or user-defined type, the
tree ordering reflects the semantics of the applicable lanuage rather than the textual order in the
source presentation.
Tag Meaning
As examples of how type modifiers are ordered, take the following C declarations:
const unsigned char * volatile p;
which represents a volatile pointer to a constant
character. This is encoded in DWARF as:
DW_TAG_variable(p) →
DW_TAG_volatile_type →
DW_TAG_pointer_type →
DW_TAG_const_type →
DW_TAG_base_type(unsigned char)
DW_ORD_col_major
DW_ORD_row_major
If the size of the array can be determined statically at compile time, this value can usually be
computed by multiplying the number of array elements by the size of each element.
Each array dimension is described by a debugging information entry with either the tag
DW_TAG_subrange_type or the tag DW_TAG_enumeration_type. These entries are children of
the array type entry and are ordered to reflect the appearance of the dimensions in the source
program (i.e., leftmost dimension first, next to leftmost second, and so on).
In languages, such as C, in which there is no concept of a “multidimensional array”, an array of
arrays may be represented by a debugging information entry for a multidimensional array.
Other attributes especially applicable to arrays are DW_AT_allocated, DW_AT_associated and
DW_AT_data_location, which are described in Section 5.14. For relevant examples, see also
Appendix D.2.1.
The members of a structure, union, or class are represented by debugging information entries that
are owned by the corresponding structure type, union type, or class type entry and appear in the
same order as the corresponding declarations in the source program.
A structure type, union type or class type entry may have either a DW_AT_byte_size or a
DW_AT_bit_size attribute (see Section 2.21), whose value is the amount of storage needed to
hold an instance of the structure, union or class type, including any padding.
An incomplete structure, union or class type is represented by a structure, union or class entry
that does not have a byte size attribute and that has a DW_AT_declaration attribute.
If the complete declaration of a type has been placed in a separate type unit (see Section 3.1.3),
an incomplete declaration of that type in the compilation unit may provide the unique 64-bit
signature of the type using a DW_AT_signature attribute.
If a structure, union or class entry represents the definition of a structure, class or union member
corresponding to a prior incomplete structure, class or union, the entry may have a
DW_AT_specification attribute whose value is a reference to the debugging information entry
representing that incomplete declaration.
Structure, union and class entries containing the DW_AT_specification attribute do not need to
duplicate information provided by the declaration entry referenced by the specification attribute.
In particular, such entries do not need to contain an attribute for the name of the structure, class
or union they represent if such information is already provided in the declaration.
For C and C++, data member declarations occurring within the declaration of a structure,
union or class type are considered to be “definitions” of those members, with the exception of
“static” data members, whose definitions appear outside of the declaration of the enclosing
structure, union or class type. Function member declarations appearing within a structure,
union or class type declaration are definitions only if the body of the function also appears
within the type declaration.
If the definition for a given member of the structure, union or class does not appear within the
body of the declaration, that member also has a debugging information entry describing its
definition. That latter entry has a DW_AT_specification attribute referencing the debugging
information entry owned by the body of the structure, union or class entry and representing a
non-defining declaration of the data, function or type member. The referenced entry will not
have information about the location of that member (low and high pc attributes for function
members, location descriptions for data members) and will have a DW_AT_declaration attribute.
Consider a nested class whose definition occurs outside of the containing class definition, as in:
struct A {
struct B;
};
struct A::B { … };
The two different structs can be described in different compilation units to facilitate DWARF
space compression (see Appendix E.1).
5.5.2 Interface Type Entries
The Java language defines "interface" types. An interface in Java is similar to a C++ or Java
class with only abstract methods and constant data members.
Interface types are represented by debugging information entries with the tag
DW_TAG_interface_type.
An interface type entry has a DW_AT_name attribute, whose value is a null-terminated string
containing the type name as it appears in the source program.
The members of an interface are represented by debugging information entries that are owned by
the interface type entry and that appear in the same order as the corresponding declarations in the
source program.
5.5.3 Derived or Extended Structs, Classes and Interfaces
In C++, a class (or struct) may be "derived from" or be a "subclass of" another class. In Java,
an interface may "extend" one or more other interfaces, and a class may "extend" another class
and/or "implement" one or more interfaces. All of these relationships may be described using the
following. Note that in Java, the distinction between extends and implements is implied by the
entities at the two ends of the relationship.
A class type or interface type entry that describes a derived, extended or implementing class or
interface owns debugging information entries describing each of the classes or interfaces it is
derived from, extending or implementing, respectively, ordered as they were in the source
program. Each such entry has the tag DW_TAG_inheritance.
An inheritance entry has a DW_AT_type attribute whose value is a reference to the debugging
information entry describing the class or interface from which the parent class or structure of the
inheritance entry is derived, extended or implementing.
An inheritance entry for a class that derives from or extends another class or struct also has a
DW_AT_data_member_location attribute, whose value describes the location of the beginning
of the inherited type relative to the beginning address of the derived class. If that value is a
constant, it is the offset in bytes from the beginning of the class to the beginning of the inherited
type. Otherwise, the value must be a location description. In this latter case, the beginning
address of the derived class is pushed on the expression stack before the location description is
evaluated and the result of the evaluation is the location of the inherited type.
The interpretation of the value of this attribute for inherited types is the same as the
interpretation for data members (see Section 5.5.6).
An inheritance entry may have a DW_AT_accessibility attribute. If no accessibility attribute is
present, private access is assumed for an entry of a class and public access is assumed for an
entry of an interface, struct or union.
If the class referenced by the inheritance entry serves as a C++ virtual base class, the inheritance
entry has a DW_AT_virtuality attribute.
For a C++ virtual base, the data member location attribute will usually consist of a non-trivial
location description.
5.5.4 Access Declarations
In C++, a derived class may contain access declarations that change the accessibility of
individual class members from the overall accessibility specified by the inheritance declaration.
A single access declaration may refer to a set of overloaded names.
If a derived class or structure contains access declarations, each such declaration may be
represented by a debugging information entry with the tag DW_TAG_access_declaration. Each
such entry is a child of the class or structure type entry.
An access declaration entry has a DW_AT_name attribute, whose value is a null-terminated
string representing the name used in the declaration in the source program, including any class or
structure qualifiers.
An access declaration entry also has a DW_AT_accessibility attribute describing the declared
accessibility of the named entities.
5.5.5 Friends
Each “friend” declared by a structure, union or class type may be represented by a debugging
information entry that is a child of the structure, union or class type entry; the friend entry has
the tag DW_TAG_friend.
A friend entry has a DW_AT_friend attribute, whose value is a reference to the debugging
information entry describing the declaration of the friend.
The following diagrams show the structure layout and data bit offsets for example big- and little-
endian architectures, respectively. Both diagrams show a structure that begins at address A and
whose size is four bytes. Also, high order bits are to the left and low order bits are to the right.
Note that data member bit offsets in this example are the same for both big- and little-endian
architectures even though the fields are allocated in different directions (high-order to low-order
versus low-order to high-order); the bit naming conventions for memory and/or registers of the
target architecture may or may not make this seem natural.
For a more extensive example showing nested and packed records and arrays, see Appendix
D.2.3.
Attribute DW_AT_data_bit_offset is new in DWARF Version 4 and is also used for base types
(see Section 5.1). It replaces the attributes DW_AT_bit_offset and DW_AT_byte_size when used
to identify the beginning of bit field data members as defined in DWARF V3 and earlier. The
earlier attributes are defined in a manner suitable for bit field members on big-endian
architectures but which is either awkward or incomplete for use on little-endian architectures.
(DW_AT_byte_size also has other uses that are not affected by this change.)
4. If the compiler has generated a special compilation unit to hold the template instantiation and
that special compilation unit has a different name from the compilation unit containing the
template definition, the name attribute for the debugging information entry representing the
special compilation unit should be empty or omitted.
5. If the class type entry representing the template instantiation or any of its child entries
contains declaration coordinate attributes, those attributes should refer to the source for the
template definition, not to any source generated artificially by the compiler.
5.5.9 Variant Entries
A variant part of a structure is represented by a debugging information entry with the tag
DW_TAG_variant_part and is owned by the corresponding structure type entry.
If the variant part has a discriminant, the discriminant is represented by a separate debugging
information entry which is a child of the variant part entry. This entry has the form of a structure
data member entry. The variant part entry will have a DW_AT_discr attribute whose value is a
reference to the member entry for the discriminant.
If the variant part does not have a discriminant (tag field), the variant part entry has a
DW_AT_type attribute to represent the tag type.
Each variant of a particular variant part is represented by a debugging information entry with the
tag DW_TAG_variant and is a child of the variant part entry. The value that selects a given
variant may be represented in one of three ways. The variant entry may have a
DW_AT_discr_value attribute whose value represents a single case label. The value of this
attribute is encoded as an LEB128 number. The number is signed if the tag type for the variant
part containing this variant is a signed type. The number is unsigned if the tag type is an
unsigned type.
Alternatively, the variant entry may contain a DW_AT_discr_list attribute, whose value
represents a list of discriminant values. This list is represented by any of the block forms and
may contain a mixture of case labels and label ranges. Each item on the list is prefixed with a
discriminant value descriptor that determines whether the list item represents a single label or a
label range. A single case label is represented as an LEB128 number as defined above for the
DW_AT_discr_value attribute. A label range is represented by two LEB128 numbers, the low
value of the range followed by the high value. Both values follow the rules for signedness just
described. The discriminant value descriptor is an integer constant that may have one of the
values given in Figure 17.
DW_DSC_label
DW_DSC_range
If the enumeration type occurs as the description of a dimension of an array type, and the stride
for that dimension is different than what would otherwise be determined, then the enumeration
type entry has either a DW_AT_byte_stride or DW_AT_bit_stride attribute which specifies the
separation between successive elements along the dimension as described in Section 2.19. The
value of the DW_AT_bit_stride attribute is interpreted as bits and the value of the
DW_AT_byte_stride attribute is interpreted as bytes.
The subrange entry may have the attributes DW_AT_lower_bound and DW_AT_upper_bound
to specify, respectively, the lower and upper bound values of the subrange. The
DW_AT_upper_bound attribute may be replaced by a DW_AT_count attribute, whose value
describes the number of elements in the subrange rather than the value of the last element. The
value of each of these attributes is determined as described in Section 2.19.
If the lower bound value is missing, the value is assumed to be a language-dependent default
constant. The default lower bound is 0 for C, C++, D, Java, Objective C, Objective C++, Python,
and UPC. The default lower bound is 1 for Ada, COBOL, Fortran, Modula-2, Pascal and PL/I.
No other default lower bound values are currently defined.
If the upper bound and count are missing, then the upper bound value is unknown.
If the subrange entry has no type attribute describing the basis type, the basis type is assumed to
be the same as the object described by the lower bound attribute (if it references an object). If
there is no lower bound attribute, or that attribute does not reference an object, the basis type is
the type of the upper bound or count attribute (if either of them references an object). If there is
no upper bound or count attribute, or neither references an object, the type is assumed to be the
same type, in the source language of the compilation unit containing the subrange entry, as a
signed integer with the same size as an address on the target machine.
If the subrange type occurs as the description of a dimension of an array type, and the stride for
that dimension is different than what would otherwise be determined, then the subrange type
entry has either a DW_AT_byte_stride or DW_AT_bit_stride attribute which specifies the
separation between successive elements along the dimension as described in Section 2.21..
Note that the stride can be negative.
The DW_AT_use_location description is used in conjunction with the location descriptions for a
particular object of the given pointer to member type and for a particular structure or class
instance. The DW_AT_use_location attribute expects two values to be pushed onto the DWARF
expression stack before the DW_AT_use_location description is evaluated. The first value
pushed is the value of the pointer to member object itself. The second value pushed is the base
address of the entire structure or union instance containing the member whose address is being
calculated.
For an expression such as
object.*mbr_ptr
2. Push the base address of object onto the DWARF expression stack.
the ALLOCATABLE property. If both attributes are present, then the type should be assumed to
have the POINTER property (and not ALLOCATABLE); the DW_AT_allocated attribute may
then be used to indicate that the association status of the object resulted from execution of an
ALLOCATE statement rather than pointer assignment.
For examples using DW_AT_allocated for Ada and Fortran 90 arrays, see Appendix D.2.
• Initial length, section offset and section length, which are defined in Sections 7.2.2 and 7.4.
• Sbyte, ubyte, uhalf, and uword, which are defined in Section 7.26.
2. version (uhalf)
A version number (see Section 7.19). This number is specific to the name lookup table and is
independent of the DWARF version number.
The offset from the beginning of the .debug_info section of the compilation unit header
referenced by the set.
The size in bytes of the contents of the .debug_info section generated to represent that
compilation unit.
This header is followed by a variable number of offset/name pairs. Each pair consists of the
section offset from the beginning of the compilation unit corresponding to the current set to the
debugging information entry for the given object, followed by a null-terminated character string
representing the name of the object as given by the DW_AT_name attribute of the referenced
debugging information entry. Each set of names is terminated by an offset field containing zero
(and no following string).
In the case of the name of a function member or static data member of a C++ structure, class or
union, the name presented in the .debug_pubnames section is not the simple name given by the
DW_AT_name attribute of the referenced debugging information entry, but rather the fully
qualified name of the data or function member.
6.1.2 Lookup by Address
For lookup by address, a table is maintained in a separate object file section called
.debug_aranges. The table consists of sets of variable length entries, each set describing the
portion of the program’s address space that is covered by a single compilation unit.
Each set begins with a header containing five values:
2. version (uhalf)
A version number (see Appendix F). This number is specific to the address lookup table and
is independent of the DWARF version number.
The offset from the beginning of the .debug_info or .debug_types section of the
compilation unit header referenced by the set.
4. address_size (ubyte)
The size of an address in bytes on the target architecture. For segmented addressing, this is
the size of the offset portion of the address.
5. segment_size (ubyte)
The size of a segment selector in bytes on the target architecture. If the target system uses a
flat address space, this value is 0.
This header is followed by a variable number of address range descriptors. Each descriptor is a
triple consisting of a segment selector, the beginning address within that segment of a range of
text or data covered by some entry owned by the corresponding compilation unit, followed by
the non-zero length of that range. A particular set is terminated by an entry consisting of three
zeroes. When the segment_size value is zero in the header, the segment selector is omitted so
that each descriptor is just a pair, including the terminating entry. By scanning the table, a
debugger can quickly decide which compilation unit to look in to find the debugging information
for an object that has a given address.
If the range of addresses covered by the text and/or data of a compilation unit is not contiguous,
then there may be multiple address range descriptors for that compilation unit.
Line number information generated for a compilation unit is represented in the .debug_line
section of an object file and is referenced by a corresponding compilation unit debugging
information entry (see Section 3.1.1) in the .debug_info section.
Some computer architectures employ more than one instruction set (for example, the ARM and
MIPS architectures support a 32-bit as well as a 16-bit instruction set). Because the instruction
set is a function of the program counter, it is convenient to encode the applicable instruction set
in the .debug_line section as well.
If space were not a consideration, the information provided in the .debug_line section could be
represented as a large matrix, with one row for each instruction in the emitted object code. The
matrix would have columns for:
• and so on
Such a matrix, however, would be impractically large. We shrink it with two techniques. First,
we delete from the matrix each row whose file, line, source column and discriminator
information is identical with that of its predecessors. Any deleted row would never be the
beginning of a source statement. Second, we design a byte-coded language for a state machine
and store a stream of bytes in the object file instead of the matrix. This language can be much
more compact than the matrix. When a consumer of the line number information executes, it
must “run” the state machine to generate the matrix for each compilation unit it is interested in.
The concept of an encoded matrix also leaves room for expansion. In the future, columns can be
added to the matrix to encode other things that are related to individual instruction addresses.
When the set of addresses of a compilation unit cannot be described as a single contiguous
range, there will be a separate matrix for each contiguous subrange.
6.2.1 Definitions
The following terms are used in the description of the line number information format:
state machine The hypothetical machine used by a consumer of the line number
information to expand the byte-coded instruction stream into a matrix of
line number information.
line number program A series of byte-coded line number information instructions representing
one compilation unit.
basic block A sequence of instructions where only the first instruction may be a
branch target and only the last instruction may transfer control. A
procedure invocation is defined to be an exit from a basic block.
A basic block does not necessarily correspond to a specific source code
construct.
sequence A series of contiguous target machine instructions. One compilation unit
may emit multiple sequences (that is, not all instructions within a
compilation unit are assumed to be contiguous).
6.2.2 State Machine Registers
The line number information state machine has the following registers:
line An unsigned integer indicating a source line number. Lines are numbered
beginning at 1. The compiler may emit the value 0 in cases where an
instruction cannot be attributed to any source line.
basic_block A boolean indicating that the current instruction is the beginning of a basic
block.
end_sequence A boolean indicating that the current address is that of the first byte after
the end of a sequence of target machine instructions. end_sequence
terminates a sequence of lines; therefore other information in the same
row is not meaningful.
prologue_end A boolean indicating that the current address is one (of possibly many)
where execution should be suspended for an entry breakpoint of a
function.
epilogue_begin A boolean indicating that the current address is one (of possibly many)
where execution should be suspended for an exit breakpoint of a function.
isa An unsigned integer whose value encodes the applicable instruction set
architecture for the current instruction.
The encoding of instruction sets should be shared by all users of a given
architecture. It is recommended that this encoding be defined by the ABI
authoring committee for each architecture.
discriminator An unsigned integer identifying the block to which the current instruction
belongs. Discriminator values are assigned arbitrarily by the DWARF
producer and serve to distinguish among multiple blocks that may all be
associated with the same source file, line, and column. Where only one
block exists for a given source position, the discriminator value should be
zero.
At the beginning of each sequence within a line number program, the state of the registers is:
address 0
op_index 0
file 1
line 1
column 0
is_stmt determined by default_is_stmt in the line number program header
basic_block “false”
end_sequence “false”
prologue_end “false”
epilogue_begin “false”
isa 0
discriminator 0
The isa value 0 specifies that the instruction set is the architecturally determined default
instruction set. This may be fixed by the ABI, or it may be specified by other means, for example,
by the object file description.
6.2.3 Line Number Program Instructions
The state machine instructions in a line number program belong to one of three categories:
special opcodes These have a ubyte opcode field and no operands.
extended opcodes These have a multiple byte format. The first byte is zero; the next bytes
are an unsigned LEB128 integer giving the number of bytes in the
instruction itself (does not include the first zero byte or the size). The
remaining bytes are the instruction itself (which begins with a ubyte
extended opcode).
6.2.4 The Line Number Program Header
The optimal encoding of line number information depends to a certain degree upon the
architecture of the target machine. The line number program header provides information used
by consumers in decoding the line number program instructions for a particular compilation unit
and also provides information used throughout the rest of the line number program.
The line number program for each compilation unit begins with a header containing the
following fields in order:
2. version (uhalf)
A version number (see Appendix F). This number is specific to the line number information
and is independent of the DWARF version number.
3. header_length
The number of bytes following the header_length field to the beginning of the first byte of
the line number program itself. In the 32-bit DWARF format, this is a 4-byte unsigned
length; in the 64-bit DWARF format, this field is an 8-byte unsigned length (see Section 7.4).
4. minimum_instruction_length (ubyte)
The size in bytes of the smallest target machine instruction. Line number program opcodes
that alter the address and op_index registers use this and
maximum_operations_per_instruction in their calculations.
5. maximum_operations_per_instruction (ubyte)
The maximum number of individual operations that may be encoded in an instruction. Line
number program opcodes that alter the address and op_index registers use this and
minimum_instruction_length in their calculations.
For non-VLIW architectures, this field is 1, the op_index register is always 0, and the
operation pointer is simply the address register.
6. default_is_stmt (ubyte)
7. line_base (sbyte)
This parameter affects the meaning of the special opcodes. See below.
8. line_range (ubyte)
This parameter affects the meaning of the special opcodes. See below.
9. opcode_base (ubyte)
The number assigned to the first special opcode.
Opcode base is typically one greater than the highest-numbered standard opcode defined for
the specified version of the line number information (12 in DWARF Version 3 and Version 4,
9 in Version 2). If opcode_base is less than the typical value, then standard opcode numbers
greater than or equal to the opcode base are not used in the line number table of this unit
(and the codes are treated as special opcodes). If opcode_base is greater than the typical
value, then the numbers between that of the highest standard opcode and the first special
opcode (not inclusive) are used for vendor specific extensions.
By increasing opcode_base, and adding elements to this array, new standard opcodes can
be added, while allowing consumers who do not know about these new opcodes to be able to
skip them.
Codes for vendor specific extensions, if any, are described just like standard opcodes.
• A null-terminated string containing the full or relative path name of a source file. If the
entry contains a file name or relative path name, the file is located relative to either the
compilation directory (as specified by the DW_AT_comp_dir attribute given in the
compilation unit) or one of the directories listed in the include_directories section.
• An unsigned LEB128 number representing the length in bytes of the file, or 0 if not
available.
The last entry is followed by a single null byte.
The directory index represents an entry in the include_directories section. The index is 0
if the file was found in the current directory of the compilation, 1 if it was found in the first
directory in the include_directories section, and so on. The directory index is ignored for
file names that represent full path names.
The primary source file is described by an entry whose path name exactly matches that given
in the DW_AT_name attribute in the compilation unit, and whose directory is understood to
be given by the implicit entry with index 0.
The line number program assigns numbers to each of the file entries in order, beginning with
1, and uses those numbers instead of file names in the file register.
A compiler may generate a single null byte for the file names field and define file names
using the extended opcode DW_LNE_define_file.
6.2.5 The Line Number Program
As stated before, the goal of a line number program is to build a matrix representing one
compilation unit, which may have produced multiple sequences of target machine instructions.
Within a sequence, addresses (operation pointers) may only increase. (Line numbers may
decrease in cases of pipeline scheduling or other optimization.)
Each ubyte special opcode has the following effect on the state machine:
2. Modify the operation pointer by incrementing the address and op_index registers as
described below.
3. Append a row to the matrix using the current values of the state machine registers.
A special opcode value is chosen based on the amount that needs to be added to the line,
address and op_index registers. The maximum line increment for a special opcode is the value
of the line_base field in the header, plus the value of the line_range field, minus 1 (line
base + line range - 1). If the desired line increment is greater than the maximum line
increment, a standard opcode must be used instead of a special opcode. The operation advance
represents the number of operations to skip when advancing the operation pointer.
The special opcode is then calculated using the following formula:
opcode = (desired line increment - line_base) +
(line_range * operation advance) + opcode_base
If the resulting opcode is greater than 255, a standard opcode must be used instead.
To decode a special opcode, subtract the opcode_base from the opcode itself to give the
adjusted opcode. The operation advance is the result of the adjusted opcode divided by the
line_range. The new address and op_index values are given by
adjusted opcode = opcode – opcode_base
operation advance = adjusted opcode / line_range
new address =
address +
minimum_instruction_length *
((op_index + operation advance)/maximum_operations_per_instruction)
new op_index =
The amount to increment the line register is the line_base plus the result of the adjusted
opcode modulo the line_range. That is,
As an example, suppose that the opcode_base is 13, line_base is -3, line_range is 12,
minimum_instruction_length is 1 and maximum_operations_per_instruction is 1. This means
that we can use a special opcode whenever two successive rows in the matrix have source line
numbers differing by any value within the range [-3, 8] and (because of the limited number of
opcodes available) when the difference between addresses is within the range [0, 20], but not all
line advances are available for the maximum operation advance (see below).
The opcode mapping would be:
\ Line advance
Operation \
Advance \ -3 -2 -1 0 1 2 3 4 5 6 7 8
--------- -----------------------------------------------
0 13 14 15 16 17 18 19 20 21 22 23 24
1 25 26 27 28 29 30 31 32 33 34 35 36
2 37 38 39 40 41 42 43 44 45 46 47 48
3 49 50 51 52 53 54 55 56 57 58 59 60
4 61 62 63 64 65 66 67 68 69 70 71 72
5 73 74 75 76 77 78 79 80 81 82 83 84
6 85 86 87 88 89 90 91 92 93 94 95 96
7 97 98 99 100 101 102 103 104 105 106 107 108
8 109 110 111 112 113 114 115 116 117 118 119 120
9 121 122 123 124 125 126 127 128 129 130 131 132
10 133 134 135 136 137 138 139 140 141 142 143 144
11 145 146 147 148 149 150 151 152 153 154 155 156
12 157 158 159 160 161 162 163 164 165 166 167 168
13 169 170 171 172 173 174 175 176 177 178 179 180
14 181 182 183 184 185 186 187 188 189 190 191 192
15 193 194 195 196 197 198 199 200 201 202 203 204
16 205 206 207 208 209 210 211 212 213 214 215 216
17 217 218 219 220 221 222 223 224 225 226 227 228
18 229 230 231 232 233 234 235 236 237 238 239 240
19 241 242 243 244 245 246 247 248 249 250 251 252
20 253 254 255
The standard opcodes, their applicable operands and the actions performed by these opcodes are
as follows:
1. DW_LNS_copy
The DW_LNS_copy opcode takes no operands. It appends a row to the matrix using the
current values of the state machine registers. Then it sets the discriminator register to 0,
and sets the basic_block, prologue_end and epilogue_begin registers to “false.”
2. DW_LNS_advance_pc
The DW_LNS_advance_pc opcode takes a single unsigned LEB128 operand as the operation
advance and modifies the address and op_index registers as specified in Section 6.2.5.1.
3. DW_LNS_advance_line
The DW_LNS_advance_line opcode takes a single signed LEB128 operand and adds that
value to the line register of the state machine.
4. DW_LNS_set_file
The DW_LNS_set_file opcode takes a single unsigned LEB128 operand and stores it in the
file register of the state machine.
5. DW_LNS_set_column
The DW_LNS_set_column opcode takes a single unsigned LEB128 operand and stores it in
the column register of the state machine.
6. DW_LNS_negate_stmt
The DW_LNS_negate_stmt opcode takes no operands. It sets the is_stmt register of the
state machine to the logical negation of its current value.
7. DW_LNS_set_basic_block
8. DW_LNS_const_add_pc
When the line number program needs to advance the address by a small amount, it can use a
single special opcode, which occupies a single byte. When it needs to advance the address by
up to twice the range of the last special opcode, it can use DW_LNS_const_add_pc followed
by a special opcode, for a total of two bytes. Only if it needs to advance the address by more
than twice that range will it need to use both DW_LNS_advance_pc and a special opcode,
requiring three or more bytes.
9. DW_LNS_fixed_advance_pc
The DW_LNS_fixed_advance_pc opcode takes a single uhalf (unencoded) operand and adds
it to the address register of the state machine and sets the op_index register to 0. This is the
only standard opcode whose operand is not a variable length number. It also does not
multiply the operand by the minimum_instruction_length field of the header.
Existing assemblers cannot emit DW_LNS_advance_pc or special opcodes because they
cannot encode LEB128 numbers or judge when the computation of a special opcode
overflows and requires the use of DW_LNS_advance_pc. Such assemblers, however, can use
DW_LNS_fixed_advance_pc instead, sacrificing compression.
10. DW_LNS_set_prologue_end
11. DW_LNS_set_epilogue_begin
3. DW_LNE_define_file
The DW_LNE_define_file opcode takes four operands:
1. A null-terminated string containing the full or relative path name of a source file. If the
entry contains a file name or a relative path name, the file is located relative to either the
compilation directory (as specified by the DW_AT_comp_dir attribute given in the
compilation unit) or one of the directories in the include_directories section.
2. An unsigned LEB128 number representing the directory index of the directory in which
the file was found.
3. An unsigned LEB128 number representing the time of last modification of the file, or 0 if
not available.
4. An unsigned LEB128 number representing the length in bytes of the file, or 0 if not
available.
The directory index represents an entry in the include_directories section of the line
number program header. The index is 0 if the file was found in the current directory of the
compilation, 1 if it was found in the first directory in the include_directories section, and
so on. The directory index is ignored for file names that represent full path names.
The primary source file is described by an entry whose path name exactly matches that given
in the DW_AT_name attribute in the compilation unit, and whose directory index is 0. The
files are numbered, starting at 1, in the order in which they appear; the names in the header
come before names defined by the DW_LNE_define_file instruction. These numbers are
used in the file register of the state machine.
4. DW_LNE_set_discriminator
The DW_LNE_set_discriminator opcode takes a single parameter, an unsigned LEB128
integer. It sets the discriminator register to the new value.
All DW_MACINFO_define and DW_MACINFO_undef entries have two operands. The first
operand encodes the line number of the source line on which the relevant defining or undefining
macro directives appeared.
The second operand consists of a null-terminated character string. In the case of a
DW_MACINFO_undef entry, the value of this string will be simply the name of the pre-
processor symbol that was undefined at the indicated source line.
In the case of a DW_MACINFO_define entry, the value of this string will be the name of the
macro symbol that was defined at the indicated source line, followed immediately by the macro
formal parameter list including the surrounding parentheses (in the case of a function-like macro)
followed by the definition string for the macro. If there is no formal parameter list, then the name
of the defined macro is followed directly by its definition string.
In the case of a function-like macro definition, no whitespace characters should appear between
the name of the defined macro and the following left parenthesis. Also, no whitespace characters
should appear between successive formal parameters in the formal parameter list. (Successive
formal parameters are, however, separated by commas.) Also, exactly one space character should
separate the right parenthesis that terminates the formal parameter list and the following
definition string.
In the case of a “normal” (i.e. non-function-like) macro definition, exactly one space character
should separate the name of the defined macro from the following definition text.
6.3.1.2 Start File Entries
Each DW_MACINFO_start_file entry also has two operands. The first operand encodes the line
number of the source line on which the inclusion macro directive occurred.
The second operand encodes a source file name index. This index corresponds to a file number
in the line number information table for the relevant compilation unit. This index indicates
(indirectly) the name of the file that is being included by the inclusion directive on the indicated
source line.
6.3.1.3 End File Entries
A DW_MACINFO_end_file entry has no operands. The presence of the entry marks the end of
the current source file inclusion.
6.3.1.4 Vendor Extension Entries
A DW_MACINFO_vendor_ext entry has two operands. The first is a constant. The second is a
null-terminated character string. The meaning and/or significance of these operands is
intentionally left undefined by this specification.
A consumer must be able to totally ignore all DW_MACINFO_vendor_ext entries that it does not
understand (see Section 7.1).
All macinfo entries within a .debug_macinfo section for a given compilation unit appear in the
same order in which the directives were processed by the compiler.
All macinfo entries representing command line options appear in the same order as the relevant
command line options were given to the compiler. In the case where the compiler itself implicitly
supplies one or more macro definitions or un-definitions in addition to those which may be
specified on the command line, macinfo entries are also produced for these implicit definitions
and un-definitions, and these entries also appear in the proper order relative to each other and to
any definitions or undefinitions given explicitly by the user on the command line.
• A code location that is within the subroutine. This location is either the place where the
program stopped when the debugger got control (e.g. a breakpoint), or is a place where a
subroutine made a call or was interrupted by an asynchronous event (e.g. a signal).
• An area of memory that is allocated on a stack called a “call frame.” The call frame is
identified by an address on the stack. We refer to this address as the Canonical Frame
Address or CFA. Typically, the CFA is defined to be the value of the stack pointer at the
call site in the previous frame (which may be different from its value on entry to the
current frame).
• A set of registers that are in use by the subroutine at the code location.
Typically, a set of registers are designated to be preserved across a call. If a callee wishes to use
such a register, it saves the value that the register had at entry time in its call frame and restores
it on exit. The code that allocates space on the call frame stack and performs the save operation
is called the subroutine’s prologue, and the code that performs the restore operation and
deallocates the frame is called its epilogue. Typically, the prologue code is physically at the
beginning of a subroutine and the epilogue code is at the end.
To be able to view or modify an activation that is not on the top of the call frame stack, the
debugger must “virtually unwind” the stack of activations until it finds the activation of interest.
A debugger unwinds a stack in steps. Starting with the current activation it virtually restores any
registers that were preserved by the current activation and computes the predecessor’s CFA and
code location. This has the logical effect of returning from the current subroutine to its
predecessor. We say that the debugger virtually unwinds the stack because the actual state of the
target process is unchanged.
The unwinding operation needs to know where registers are saved and how to compute the
predecessor’s CFA and code location. When considering an architecture-independent way of
encoding this information one has to consider a number of special things.
• Prologue and epilogue code is not always in distinct blocks at the beginning and end of a
subroutine. It is common to duplicate the epilogue code at the site of each return from the
code. Sometimes a compiler breaks up the register save/unsave operations and moves them
into the body of the subroutine to just where they are needed.
• Compilers use different ways to manage the call frame. Sometimes they use a frame pointer
register, sometimes not.
• The algorithm to compute CFA changes as you progress through the prologue and epilogue
code. (By definition, the CFA value does not change.)
• Sometimes a register is saved in another register that by convention does not need to be
saved.
• Some architectures have special instructions that perform some or all of the register
management in one instruction, leaving special information on the stack that indicates how
registers are saved.
• Some architectures treat return address values specially. For example, in one architecture,
the call instruction guarantees that the low order two bits will be zero and the return
instruction ignores those bits. This leaves two bits of storage that are available to other uses
that must be treated specially.
6.4.1 Structure of Call Frame Information
DWARF supports virtual unwinding by defining an architecture independent basis for recording
how procedures save and restore registers during their lifetimes. This basis must be augmented
on some machines with specific information that is defined by an architecture specific ABI
authoring committee, a hardware vendor, or a compiler producer. The body defining a specific
augmentation is referred to below as the “augmenter.”
Abstractly, this mechanism describes a very large table that has the following structure:
LOC CFA R0 R1 ... RN
L0
L1
...
LN
The first column indicates an address for every location that contains code in a program. (In
shared objects, this is an object-relative offset.) The remaining columns contain virtual
unwinding rules that are associated with the indicated location.
The CFA column defines the rule which computes the Canonical Frame Address value; it may be
either a register and a signed offset that are added together, or a DWARF expression that is
evaluated.
The remaining columns are labeled by register number. This includes some registers that have
special designation on some architectures such as the PC and the stack pointer register. (The
actual mapping of registers for a particular architecture is defined by the augmenter.) The
register columns contain rules that describe whether a given register has been saved and the rule
to find the value for the register in the previous frame.
The register rules are:
undefined A register that has this rule has no recoverable value in the previous frame.
(By convention, it is not preserved by a callee.)
same value This register has not been modified from the previous frame. (By convention,
it is preserved by the callee, but the callee has not modified it.)
offset(N) The previous value of this register is saved at the address CFA+N where CFA
is the current CFA value and N is a signed offset.
val_offset(N) The previous value of this register is the value CFA+N where CFA is the
current CFA value and N is a signed offset.
register(R) The previous value of this register is stored in another register numbered R.
expression(E) The previous value of this register is located at the address produced by
executing the DWARF expression E.
val_expression(E) The previous value of this register is the value produced by executing the
DWARF expression E.
architectural The rule is defined externally to this specification by the augmenter.
This table would be extremely large if actually constructed as described. Most of the entries at
any point in the table are identical to the ones above them. The whole table can be represented
quite compactly by recording just the differences starting at the beginning address of each
subroutine in the program.
A Common Information Entry holds information that is shared among many Frame Description
Entries. There is at least one CIE in every non-empty .debug_frame section. A CIE contains the
following fields, in order:
A constant that gives the number of bytes of the CIE structure, not including the length field
itself (see Section 7.2.2). The size of the length field plus the value of length must be an
integral multiple of the address size.
3. version (ubyte)
A version number (see Section 7.23). This number is specific to the call frame information
and is independent of the DWARF version number.
The size of a target address in this CIE and any FDEs that use it, in bytes. If a compilation
unit exists for this frame, its address size must match the address size here.
6. segment_size (ubyte)
The size of a segment selector in this CIE and any FDEs that use it, in bytes.
The default rule for all columns before interpretation of the initial instructions is the
undefined rule. However, an ABI authoring body or a compilation system authoring body
may specify an alternate default value for any or all columns.
Enough DW_CFA_nop instructions to make the size of this entry match the length value
above.
An FDE contains the following fields, in order:
A constant offset into the .debug_frame section that denotes the CIE that is associated with
this FDE.
Enough DW_CFA_nop instructions to make the size of this entry match the length value
above.
6.4.2 Call Frame Instructions
Each call frame instruction is defined to take 0 or more operands. Some of the operands may be
encoded as part of the opcode (see Section 7.23). The instructions are defined in the following
sections.
Some call frame instructions have operands that are encoded as DWARF expressions (see
Section 2.5.1). The following DWARF operators cannot be used in such operands:
1. DW_CFA_set_loc
The DW_CFA_set_loc instruction takes a single operand that represents a target address. The
required action is to create a new table row using the specified address as the location. All
other values in the new row are initially identical to the current row. The new location value
is always greater than the current one. If the segment_size field of this FDE's CIE is non-
zero, the initial location is preceded by a segment selector of the given length.
2. DW_CFA_advance_loc
The DW_CFA_advance instruction takes a single operand (encoded with the opcode) that
represents a constant delta. The required action is to create a new table row with a location
value that is computed by taking the current entry’s location value and adding the value of
delta * code_alignment_factor. All other values in the new row are initially identical
to the current row.
3. DW_CFA_advance_loc1
The DW_CFA_advance_loc1 instruction takes a single ubyte operand that represents a
constant delta. This instruction is identical to DW_CFA_advance_loc except for the encoding
and size of the delta operand.
4. DW_CFA_advance_loc2
The DW_CFA_advance_loc2 instruction takes a single uhalf operand that represents a
constant delta. This instruction is identical to DW_CFA_advance_loc except for the encoding
and size of the delta operand.
5. DW_CFA_advance_loc4
The DW_CFA_advance_loc4 instruction takes a single uword operand that represents a
constant delta. This instruction is identical to DW_CFA_advance_loc except for the encoding
and size of the delta operand.
6.4.2.2 CFA Definition Instructions
1. DW_CFA_def_cfa
The DW_CFA_def_cfa instruction takes two unsigned LEB128 operands representing a
register number and a (non-factored) offset. The required action is to define the current CFA
rule to use the provided register and offset.
2. DW_CFA_def_cfa_sf
The DW_CFA_def_cfa_sf instruction takes two operands: an unsigned LEB128 value
representing a register number and a signed LEB128 factored offset. This instruction is
identical to DW_CFA_def_cfa except that the second operand is signed and factored. The
resulting offset is factored_offset * data_alignment_factor.
3. DW_CFA_def_cfa_register
The DW_CFA_def_cfa_register instruction takes a single unsigned LEB128 operand
representing a register number. The required action is to define the current CFA rule to use
the provided register (but to keep the old offset). This operation is valid only if the current
CFA rule is defined to use a register and offset.
4. DW_CFA_def_cfa_offset
The DW_CFA_def_cfa_offset instruction takes a single unsigned LEB128 operand
representing a (non-factored) offset. The required action is to define the current CFA rule to
use the provided offset (but to keep the old register). This operation is valid only if the
current CFA rule is defined to use a register and offset.
5. DW_CFA_def_cfa_offset_sf
The DW_CFA_def_cfa_offset_sf instruction takes a signed LEB128 operand representing a
factored offset. This instruction is identical to DW_CFA_def_cfa_offset except that the
operand is signed and factored. The resulting offset is factored_offset *
data_alignment_factor. This operation is valid only if the current CFA rule is defined to
use a register and offset.
6. DW_CFA_def_cfa_expression
The DW_CFA_def_cfa_expression instruction takes a single operand encoded as a
DW_FORM_exprloc value representing a DWARF expression. The required action is to
establish that expression as the means by which the current CFA is computed.
See Section 6.4.2 regarding restrictions on the DWARF expression operators that can be
used.
1. DW_CFA_undefined
The DW_CFA_undefined instruction takes a single unsigned LEB128 operand that
represents a register number. The required action is to set the rule for the specified register to
“undefined.”
2. DW_CFA_same_value
The DW_CFA_same_value instruction takes a single unsigned LEB128 operand that
represents a register number. The required action is to set the rule for the specified register to
“same value.”
3. DW_CFA_offset
The DW_CFA_offset instruction takes two operands: a register number (encoded with the
opcode) and an unsigned LEB128 constant representing a factored offset. The required action
is to change the rule for the register indicated by the register number to be an offset(N) rule
where the value of N is factored offset * data_alignment_factor.
4. DW_CFA_offset_extended
The DW_CFA_offset_extended instruction takes two unsigned LEB128 operands
representing a register number and a factored offset. This instruction is identical to
DW_CFA_offset except for the encoding and size of the register operand.
5. DW_CFA_offset_extended_sf
The DW_CFA_offset_extended_sf instruction takes two operands: an unsigned LEB128
value representing a register number and a signed LEB128 factored offset. This instruction is
identical to DW_CFA_offset_extended except that the second operand is signed and
factored. The resulting offset is factored_offset * data_alignment_factor.
6. DW_CFA_val_offset
The DW_CFA_val_offset instruction takes two unsigned LEB128 operands representing a
register number and a factored offset. The required action is to change the rule for the
register indicated by the register number to be a val_offset(N) rule where the value of N is
factored_offset * data_alignment_factor.
7. DW_CFA_val_offset_sf
The DW_CFA_val_offset_sf instruction takes two operands: an unsigned LEB128 value
representing a register number and a signed LEB128 factored offset. This instruction is
identical to DW_CFA_val_offset except that the second operand is signed and factored. The
resulting offset is factored_offset * data_alignment_factor.
8. DW_CFA_register
The DW_CFA_register instruction takes two unsigned LEB128 operands representing
register numbers. The required action is to set the rule for the first register to be register(R)
where R is the second register.
9. DW_CFA_expression
The DW_CFA_expression instruction takes two operands: an unsigned LEB128 value
representing a register number, and a DW_FORM_block value representing a DWARF
expression. The required action is to change the rule for the register indicated by the register
number to be an expression(E) rule where E is the DWARF expression. That is, the DWARF
expression computes the address. The value of the CFA is pushed on the DWARF evaluation
stack prior to execution of the DWARF expression.
See Section 6.4.2 regarding restrictions on the DWARF expression operators that can be
used.
10. DW_CFA_val_expression
The DW_CFA_val_expression instruction takes two operands: an unsigned LEB128 value
representing a register number, and a DW_FORM_block value representing a DWARF
expression. The required action is to change the rule for the register indicated by the register
number to be a val_expression(E) rule where E is the DWARF expression. That is, the
DWARF expression computes the value of the given register. The value of the CFA is
pushed on the DWARF evaluation stack prior to execution of the DWARF expression.
See Section 6.4.2 regarding restrictions on the DWARF expression operators that can be
used.
11. DW_CFA_restore
The DW_CFA_restore instruction takes a single operand (encoded with the opcode) that
represents a register number. The required action is to change the rule for the indicated
register to the rule assigned it by the initial_instructions in the CIE.
12. DW_CFA_restore_extended
The DW_CFA_restore_extended instruction takes a single unsigned LEB128 operand that
represents a register number. This instruction is identical to DW_CFA_restore except for the
encoding and size of the register operand.
6.4.2.4 Row State Instructions
The next two instructions provide the ability to stack and retrieve complete register states. They
may be useful, for example, for a compiler that moves epilogue code into the body of a function.
1. DW_CFA_remember_state
The DW_CFA_remember_state instruction takes no operands. The required action is to push
the set of rules for every register onto an implicit stack.
2. DW_CFA_restore_state
The DW_CFA_restore_state instruction takes no operands. The required action is to pop the
set of rules off the implicit stack and place them in the current row.
6.4.2.5 Padding Instruction
1. DW_CFA_nop
The DW_CFA_nop instruction has no operands and no required actions. It is used as padding
to make a CIE or FDE an appropriate size.
6.4.3 Call Frame Instruction Usage
To determine the virtual unwind rule set for a given location (L1), one searches through the FDE
headers looking at the initial_location and address_range values to see if L1 is contained
in the FDE. If so, then:
1. Initialize a register set by reading the initial_instructions field of the associated CIE.
2. Read and process the FDE’s instruction sequence until a DW_CFA_advance_loc,
DW_CFA_set_loc, or the end of the instruction stream is encountered.
If a Return Address register is defined in the virtual unwind table, and its rule is undefined (for
example, by DW_CFA_undefined), then there is no return address and no call address, and the
virtual unwind of stack activations is complete.
In most cases the return address is in the same context as the calling address, but that need not
be the case, especially if the producer knows in some way the call never will return. The context
of the 'return address' might be on a different line, in a different lexical block, or past the end of
the calling subroutine. If a consumer were to assume that it was in the same context as the
calling address, the unwind might fail.
For architectures with constant-length instructions where the return address immediately follows
the call instruction, a simple solution is to subtract the length of an instruction from the return
address to obtain the calling instruction. For architectures with variable-length instructions (e.g.
x86), this is not possible. However, subtracting 1 from the return address, although not
guaranteed to provide the exact calling address, generally will produce an address within the
same context as the calling address, and that usually is sufficient.
In an initial length field, the values 0xfffffff0 through 0xffffffff are reserved by DWARF
to indicate some form of extension relative to DWARF Version 2; such values must not be
interpreted as a length field. The use of one such value, 0xffffffff, is defined below (see
Section 7.4); the use of the other values is reserved for possible future extensions.
The differences between the 32- and 64-bit DWARF formats are detailed in the following:
1. In the 32-bit DWARF format, an initial length field (see Section 7.2.2) is an unsigned 32-bit
integer (which must be less than 0xfffffff0); in the 64-bit DWARF format, an initial
length field is 96 bits in size, and has two parts:
• The following 64-bits contain the actual length represented as an unsigned 64-bit integer.
This representation allows a DWARF consumer to dynamically detect that a DWARF section
contribution is using the 64-bit format and to adapt its processing accordingly.
2. Section offset and section length fields that occur in the headers of DWARF sections (other
than initial length fields) are listed following. In the 32-bit DWARF format these are 32-bit
unsigned integer values; in the 64-bit DWARF format, they are 64-bit unsigned integer
values.
Section Name Role
.debug_aranges debug_info_offset offset in .debug_info
.debug_frame/CIE CIE_id CIE distinguished value
.debug_frame/FDE CIE_pointer offset in .debug_frame
.debug_info debug_abbrev_offset offset in .debug_abbrev
.debug_line header_length length of header itself
.debug_pubnames debug_info_offset offset in .debug_info
debug_info_length length of .debug_info
contribution
.debug_pubtypes debug_info_offset offset in .debug_info
debug_info_length length of .debug_info
contribution
.debug_types debug_abbrev_offset offset in .debug_abbrev
type_offset offset in .debug_types
The CIE_id field in a CIE structure must be 64 bits because it overlays the CIE_pointer
in a FDE structure; this implicit union must be accessed to distinguish whether a CIE or
FDE is present, consequently, these two fields must exactly overlay each other (both
offset and size).
3. Within the body of the .debug_info or .debug_types section, certain forms of attribute
value depend on the choice of DWARF format as follows. For the 32-bit DWARF format,
the value is a 32-bit unsigned integer; for the 64-bit DWARF format, the value is a 64-bit
unsigned integer.
Form Role
4. Within the body of the .debug_pubnames and .debug_pubtypes sections, the representation
of the first field of each tuple (which represents an offset in the .debug_info section)
depends on the DWARF format as follows: in the 32-bit DWARF format, this field is a 32-
bit unsigned integer; in the 64-bit DWARF format, it is a 64-bit unsigned integer.
The 32-bit and 64-bit DWARF format conventions must not be intermixed within a single
compilation unit.
Attribute values and section header fields that represent addresses in the target program are not
affected by these rules.
A DWARF consumer that supports the 64-bit DWARF format must support executables in
which some compilation units use the 32-bit format and others use the 64-bit format provided
that the combination links correctly (that is, provided that there are no link-time errors due to
truncation or overflow). (An implementation is not required to guarantee detection and reporting
of all such errors.)
It is expected that DWARF producing compilers will not use the 64-bit format by default. In most
cases, the division of even very large applications into a number of executable and shared
objects will suffice to assure that the DWARF sections within each individual linked object are
less than 4 GBytes in size. However, for those cases where needed, the 64-bit format allows the
unusual case to be handled as well. Even in this case, it is expected that only application
supplied objects will need to be compiled using the 64-bit format; separate 32-bit format
versions of system supplied shared executable libraries can still be used.
For each type defined in a compilation unit, a contribution may be made to the .debug_types
section of the object file. Each such contribution consists of a type unit header (see Section
7.5.1.2) followed by a DW_TAG_type_unit entry, together with its children.
Each debugging information entry begins with a code that represents an entry in a separate
abbreviations table. This code is followed directly by a series of attribute values.
The appropriate entry in the abbreviations table guides the interpretation of the information
contained directly in the .debug_info or .debug_types section.
Multiple debugging information entries may share the same abbreviation table entry. Each
compilation unit is associated with a particular abbreviation table, but multiple compilation units
may share the same table.
2. version (uhalf)
A 2-byte unsigned integer representing the version of the DWARF information for the
compilation unit (see Appendix F). The value in this field is 4.
A 4-byte or 8-byte unsigned offset into the .debug_abbrev section. This offset associates the
compilation unit with a particular set of debugging information entry abbreviations. In the
32-bit DWARF format, this is a 4-byte unsigned length; in the 64-bit DWARF format, this is
an 8-byte unsigned length (see Section 7.4).
4. address_size (ubyte)
A 1-byte unsigned integer representing the size in bytes of an address on the target
architecture. If the system uses segmented addressing, this value represents the size of the
offset portion of an address.
2. version (uhalf)
A 2-byte unsigned integer representing the version of the DWARF information for the
compilation unit (see Appendix F). The value in this field is 4.
A 4-byte or 8-byte unsigned offset into the .debug_abbrev section. This offset associates the
compilation unit with a particular set of debugging information entry abbreviations. In the
32-bit DWARF format, this is a 4-byte unsigned length; in the 64-bit DWARF format, this is
an 8-byte unsigned length (see Section 7.4).
4. address_size (ubyte)
A 1-byte unsigned integer representing the size in bytes of an address on the target
architecture. If the system uses segmented addressing, this value represents the size of the
offset portion of an address.
Following the tag encoding is a 1-byte value that determines whether a debugging information
entry using this abbreviation has child entries or not. If the value is DW_CHILDREN_yes, the
next physically succeeding entry of any debugging information entry using this abbreviation is
the first child of that entry. If the 1-byte value following the abbreviation’s tag encoding is
DW_CHILDREN_no, the next physically succeeding entry of any debugging information entry
using this abbreviation is a sibling of that entry. (Either the first child or sibling entries may be
null entries). The encodings for the child determination byte are given in Figure 19 (page 154).
(As mentioned in Section 2.3, each chain of sibling entries is terminated by a null entry.)
Finally, the child encoding is followed by a series of attribute specifications. Each attribute
specification consists of two parts. The first part is an unsigned LEB128 number representing the
attribute’s name. The second part is an unsigned LEB128 number representing the attribute’s
form. The series of attribute specifications ends with an entry containing 0 for the name and 0 for
the form.
The attribute form DW_FORM_indirect is a special case. For attributes with this form, the
attribute value itself in the .debug_info or .debug_types section begins with an unsigned
LEB128 number that represents its form. This allows producers to choose forms for particular
attributes dynamically, without having to add a new entry to the abbreviations table.
The abbreviations for a given compilation unit end with an entry consisting of a 0 byte for the
abbreviation code.
See Appendix D.1 for a depiction of the organization of the debugging information.
7.5.4 Attribute Encodings
The encodings for the attribute names are given in Figure 20 (page 159).
The attribute form governs how the value of the attribute is encoded. There are nine classes of
form, listed below. Each class is a set of forms which have related representations and which are
given a common interpretation according to the attribute in which the form is used.
Form DW_FORM_sec_offset is a member of more than one class, namely lineptr, loclistptr,
macptr or rangelistptr; the list of classes allowed by the applicable attribute in Figure 20
determines the class of the form.
In DWARF V3 the forms DW_FORM_data4 and DW_FORM_data8 were members of either
class constant or one of the classes lineptr, loclistptr, macptr or rangelistptr, depending on
context. In DWARF V4 DW_FORM_data4 and DW_FORM_data8 are members of class
constant in all cases. The new DW_FORM_sec_offset replaces their usage for the other classes.
macptr
format, this offset is a 4-byte unsigned value; in the 64-bit DWARF format, it is an 8-byte
unsigned value (see Section 7.4).
A debugging information entry that may be referenced by another compilation unit using
DW_FORM_ref_addr must have a global symbolic name.
For a reference from one executable or shared object to another, the reference is resolved by
the debugger to identify the shared object or executable and the offset into that object’s
.debug_info section in the same fashion as the run time loader, either when the debug
information is first read, or when the reference is used.
The third type of reference can identify any debugging information type entry that has been
placed in its own type unit. This type of reference (DW_FORM_ref_sig8) is the 64-bit type
signature (see Section 7.27) that was computed for the type.
The use of compilation unit relative references will reduce the number of link-time
relocations and so speed up linking. The use of the second and third type of reference allows
for the sharing of information, such as types, across compilation units.
A reference to any kind of compilation unit identifies the debugging information entry for
that unit, not the preceding header.
string
A string is a sequence of contiguous non-null bytes followed by one null byte. A string may
be represented immediately in the debugging information entry itself (DW_FORM_string),
or may be represented as an offset into a string table contained in the .debug_str section of
the object file (DW_FORM_strp). In the 32-bit DWARF format, the representation of a
DW_FORM_strp value is a 4-byte unsigned offset; in the 64-bit DWARF format, it is an
8-byte unsigned offset (see Section 7.4).
If the DW_AT_use_UTF8 attribute is specified for the compilation unit entry, string values
are encoded using the UTF-8 (Unicode Transformation Format-8) from the Universal
Character Set standard (ISO/IEC 10646-1:1993). Otherwise, the string representation is
unspecified.
The Unicode Standard Version 3 is fully compatible with ISO/IEC 10646-1:1993. It contains
all the same characters and encoding points as ISO/IEC 10646, as well as additional
information about the characters and their use.
Earlier versions of DWARF did not specify the representation of strings; for compatibility,
this version also does not. However, the UTF-8 representation is strongly recommended.
In no case does an attribute use one of the classes lineptr, loclistptr, macptr or rangelistptr to
point into either the .debug_info or .debug_str section.
The form encodings are listed in Figure 21 (page 161).
DW_TAG_array_type 0x01
DW_TAG_class_type 0x02
DW_TAG_entry_point 0x03
DW_TAG_enumeration_type 0x04
DW_TAG_formal_parameter 0x05
DW_TAG_imported_declaration 0x08
DW_TAG_label 0x0a
DW_TAG_lexical_block 0x0b
DW_TAG_member 0x0d
DW_TAG_pointer_type 0x0f
DW_TAG_reference_type 0x10
DW_TAG_compile_unit 0x11
DW_TAG_string_type 0x12
DW_TAG_structure_type 0x13
DW_TAG_subroutine_type 0x15
DW_TAG_typedef 0x16
DW_TAG_union_type 0x17
DW_TAG_unspecified_parameters 0x18
DW_TAG_variant 0x19
DW_TAG_common_block 0x1a
DW_TAG_common_inclusion 0x1b
DW_TAG_inheritance 0x1c
DW_TAG_inlined_subroutine 0x1d
DW_TAG_module 0x1e
DW_TAG_ptr_to_member_type 0x1f
DW_TAG_set_type 0x20
DW_TAG_subrange_type 0x21
DW_TAG_with_stmt 0x22
DW_TAG_access_declaration 0x23
DW_TAG_base_type 0x24
DW_TAG_catch_block 0x25
DW_TAG_const_type 0x26
DW_TAG_constant 0x27
DW_TAG_enumerator 0x28
DW_TAG_file_type 0x29
DW_TAG_friend 0x2a
DW_TAG_namelist 0x2b
DW_TAG_namelist_item 0x2c
DW_TAG_packed_type 0x2d
DW_TAG_subprogram 0x2e
DW_TAG_template_type_parameter 0x2f
DW_TAG_template_value_parameter 0x30
DW_TAG_thrown_type 0x31
DW_TAG_try_block 0x32
DW_TAG_variant_part 0x33
DW_TAG_variable 0x34
DW_TAG_volatile_type 0x35
DW_TAG_dwarf_procedure 0x36
DW_TAG_restrict_type 0x37
DW_TAG_interface_type 0x38
DW_TAG_namespace 0x39
DW_TAG_imported_module 0x3a
DW_TAG_unspecified_type 0x3b
DW_TAG_partial_unit 0x3c
DW_TAG_imported_unit 0x3d
DW_TAG_condition 0x3f
DW_TAG_shared_type 0x40
DW_TAG_type_unit ‡ 0x41
DW_TAG_rvalue_reference_type ‡ 0x42
DW_TAG_template_alias ‡ 0x43
DW_TAG_lo_user 0x4080
DW_TAG_hi_user 0xffff
DW_CHILDREN_no 0x00
DW_CHILDREN_yes 0x01
The encoding for signed, two’s complement LEB128 (SLEB128) numbers is similar, except that
the criterion for discarding high order bytes is not whether they are zero, but whether they
consist entirely of sign extension bits. Consider the 32-bit integer -2. The three high level bytes
of the number are sign extension, thus LEB128 would represent it as a single byte containing the
low order 7 bits, with the high order bit cleared to indicate the end of the byte stream. Note that
there is nothing within the LEB128 representation that indicates whether an encoded number is
signed or unsigned. The decoder must know what type of number to expect. Figure 22 gives
some examples of unsigned LEB128 numbers and Figure 23 gives some examples of signed
LEB128 numbers.
Appendix C gives algorithms for encoding and decoding these forms.
2 2 ---
128 0+0x80 1
129 1+0x80 1
130 2+0x80 1
2 2 ---
-2 0x7e ---
127 127+0x80 0
128 0+0x80 1
129 1+0x80 1
No. of
Operation Code Notes
Operands
constant address
DW_OP_addr 0x03 1
(size target specific)
DW_OP_deref 0x06 0
No. of
Operation Code Notes
Operands
DW_OP_dup 0x12 0
DW_OP_drop 0x13 0
DW_OP_over 0x14 0
DW_OP_swap 0x16 0
DW_OP_rot 0x17 0
DW_OP_xderef 0x18 0
DW_OP_abs 0x19 0
DW_OP_and 0x1a 0
DW_OP_div 0x1b 0
No. of
Operation Code Notes
Operands
DW_OP_minus 0x1c 0
DW_OP_mod 0x1d 0
DW_OP_mul 0x1e 0
DW_OP_neg 0x1f 0
DW_OP_not 0x20 0
DW_OP_or 0x21 0
DW_OP_plus 0x22 0
DW_OP_shl 0x24 0
DW_OP_shr 0x25 0
DW_OP_shra 0x26 0
DW_OP_xor 0x27 0
DW_OP_eq 0x29 0
DW_OP_ge 0x2a 0
DW_OP_gt 0x2b 0
DW_OP_le 0x2c 0
DW_OP_lt 0x2d 0
DW_OP_ne 0x2e 0
No. of
Operation Code Notes
Operands
DW_OP_lit0 0x30 0
DW_OP_lit31 0x4f 0
DW_OP_reg0 0x50 0
DW_OP_reg31 0x6f 0
DW_OP_breg0 0x70 1
SLEB128 offset
DW_OP_breg1 0x71 1
base register 0..31 =
... (DW_OP_breg0 + regnum)
DW_OP_breg31 0x8f 1
DW_OP_nop 0x96 0
No. of
Operation Code Notes
Operands
DW_OP_push_object_address 0x97 0
DW_OP_form_tls_address 0x9b 0
DW_OP_call_frame_cfa 0x9c 0
DW_OP_stack_value ‡ 0x9f 0
DW_OP_lo_user 0xe0
DW_OP_hi_user 0xff
number of bytes in that block. The two offsets are the same size as an address on the target
machine.
A base address selection entry and an end of list entry each consist of two (constant or relocated)
address offsets. The two offsets are the same size as an address on the target machine.
For a location list to be specified, the base address of the corresponding compilation unit must be
defined (see Section 3.1.1).
DW_ATE_address 0x01
DW_ATE_boolean 0x02
DW_ATE_complex_float 0x03
DW_ATE_float 0x04
DW_ATE_signed 0x05
DW_ATE_signed_char 0x06
DW_ATE_unsigned 0x07
DW_ATE_unsigned_char 0x08
DW_ATE_imaginary_float 0x09
DW_ATE_packed_decimal 0x0a
DW_ATE_numeric_string 0x0b
DW_ATE_edited 0x0c
DW_ATE_signed_fixed 0x0d
DW_ATE_unsigned_fixed 0x0e
DW_ATE_decimal_float 0x0f
DW_ATE_UTF ‡ 0x10
DW_ATE_lo_user 0x80
DW_ATE_hi_user 0xff
‡ New in DWARF Version 4
Figure 25. Base type encoding values
The encodings of the constants used in the DW_AT_decimal_sign attribute are given in Figure
26.
DW_DS_unsigned 0x01
DW_DS_leading_overpunch 0x02
DW_DS_trailing_overpunch 0x03
DW_DS_leading_separate 0x04
DW_DS_trailing_separate 0x05
The encodings of the constants used in the DW_AT_endianity attribute are given in Figure 27.
DW_END_default 0x00
DW_END_big 0x01
DW_END_little 0x02
DW_END_lo_user 0x40
DW_END_hi_user 0xff
DW_ACCESS_public 0x01
DW_ACCESS_protected 0x02
DW_ACCESS_private 0x03
DW_VIS_local 0x01
DW_VIS_exported 0x02
DW_VIS_qualified 0x03
DW_VIRTUALITY_none 0x00
DW_VIRTUALITY_virtual 0x01
DW_VIRTUALITY_pure_virtual 0x02
DW_LANG_C89 0x0001 0
DW_LANG_C 0x0002 0
DW_LANG_Ada83 † 0x0003 1
DW_LANG_C_plus_plus 0x0004 0
DW_LANG_Cobol74 † 0x0005 1
DW_LANG_Cobol85 † 0x0006 1
DW_LANG_Fortran77 0x0007 1
DW_LANG_Fortran90 0x0008 1
DW_LANG_Pascal83 0x0009 1
DW_LANG_Modula2 0x000a 1
DW_LANG_Java 0x000b 0
DW_LANG_C99 0x000c 0
DW_LANG_Ada95 † 0x000d 1
DW_LANG_Fortran95 0x000e 1
DW_LANG_PLI † 0x000f 1
DW_LANG_ObjC 0x0010 0
DW_LANG_ObjC_plus_plus 0x0011 0
DW_LANG_UPC 0x0012 0
DW_LANG_D 0x0013 0
DW_LANG_Python † 0x0014 0
DW_LANG_lo_user 0x8000
DW_LANG_hi_user 0xffff
† See text
Figure 31. Language encodings
DW_ID_case_sensitive 0x00
DW_ID_up_case 0x01
DW_ID_down_case 0x02
DW_ID_case_insensitive 0x03
DW_CC_normal 0x01
DW_CC_program 0x02
DW_CC_nocall 0x03
DW_CC_lo_user 0x40
DW_CC_hi_user 0xff
DW_INL_not_inlined 0x00
DW_INL_inlined 0x01
DW_INL_declared_not_inlined 0x02
DW_INL_declared_inlined 0x03
DW_ORD_row_major 0x00
DW_ORD_col_major 0x01
DW_DSC_label 0x00
DW_DSC_range 0x01
2. version (uhalf)
A 2-byte version identifier containing the value 2 (see Appendix F).
A 4-byte or 8-byte offset into the .debug_info section of the compilation unit header. In the
32-bit DWARF format, this is a 4-byte unsigned offset; in the 64-bit DWARF format, this
field is an 8-byte unsigned offset (see Section 7.4).
A 4-byte or 8-byte length containing the size in bytes of the contents of the .debug_info
section generated to represent this compilation unit. In the 32-bit DWARF format, this is a 4-
byte unsigned length; in the 64-bit DWARF format, this is an 8-byte unsigned length (see
Section 7.4).
This header is followed by a series of tuples. Each tuple consists of a 4-byte or 8-byte offset
followed by a string of non-null bytes terminated by one null byte. In the 32-bit DWARF format,
this is a 4-byte offset; in the 64-bit DWARF format, it is an 8-byte offset. Each set is terminated
by an offset containing the value 0.
2. version (uhalf)
A 2-byte version identifier containing the value 2 (see Appendix F).
A 4-byte or 8-byte offset into the .debug_info section of the compilation unit header. In the
32-bit DWARF format, this is a 4-byte unsigned offset; in the 64-bit DWARF format, this is
an 8-byte unsigned offset (see Section 7.4).
4. address_size (ubyte)
A 1-byte unsigned integer containing the size in bytes of an address (or the offset portion of
an address for segmented addressing) on the target system.
5. segment_size (ubyte)
A 1-byte unsigned integer containing the size in bytes of a segment selector on the target
system.
This header is followed by a series of tuples. Each tuple consists of a segment, an address and a
length. The segment size is given by the segment_size field of the header; the address and
length size are each given by the address_size field of the header. The first tuple following the
header in each set begins at an offset that is a multiple of the size of a single tuple (that is, the
size of a segment selector plus twice the size of an address). The header is padded, if necessary,
to that boundary. Each set of tuples is terminated by a 0 for the segment, a 0 for the address and
0 for the length. If the segment_size field in the header is zero, the segment selectors are
omitted from all tuples, including the terminating tuple.
DW_LNS_copy 0x01
DW_LNS_advance_pc 0x02
DW_LNS_advance_line 0x03
DW_LNS_set_file 0x04
DW_LNS_set_column 0x05
DW_LNS_negate_stmt 0x06
DW_LNS_set_basic_block 0x07
DW_LNS_const_add_pc 0x08
DW_LNS_fixed_advance_pc 0x09
DW_LNS_set_prologue_end 0x0a
DW_LNS_set_epilogue_begin 0x0b
DW_LNS_set_isa 0x0c
The encodings for the extended opcodes are given in Figure 38.
DW_LNE_end_sequence 0x01
DW_LNE_set_address 0x02
DW_LNE_define_file 0x03
DW_LNE_set_discriminator ‡ 0x04
DW_LNE_lo_user 0x80
DW_LNE_hi_user 0xff
‡ New in DWARF Version 4
Figure 38. Line Number Extended Opcode Encodings
DW_MACINFO_define 0x01
DW_MACINFO_undef 0x02
DW_MACINFO_start_file 0x03
DW_MACINFO_end_file 0x04
DW_MACINFO_vendor_ext 0xff
High 2 Low 6
Instruction Operand 1 Operand 2
Bits Bits
DW_CFA_nop 0 0
DW_CFA_remember_state 0 0x0a
DW_CFA_restore_state 0 0x0b
High 2 Low 6
Instruction Operand 1 Operand 2
Bits Bits
DW_CFA_lo_user 0 0x1c
DW_CFA_hi_user 0 0x3f
• For the 32-bit DWARF format and a target architecture with 32-bit addresses, an assembler
or compiler must provide a way to produce 2-byte and 4-byte quantities without alignment
restrictions, and the linker must be able to relocate a 4-byte address or section offset that
occurs at an arbitrary alignment.
• For the 32-bit DWARF format and a target architecture with 64-bit addresses, an assembler
or compiler must provide a way to produce 2-byte, 4-byte and 8-byte quantities without
alignment restrictions, and the linker must be able to relocate an 8-byte address or 4-byte
section offset that occurs at an arbitrary alignment.
• For the 64-bit DWARF format and a target architecture with 32-bit addresses, an assembler
or compiler must provide a way to produce 2-byte, 4-byte and 8-byte quantities without
alignment restrictions, and the linker must be able to relocate a 4-byte address or 8-byte
section offset that occurs at an arbitrary alignment.
It is expected that this will be required only for very large 32-bit programs or by those
architectures which support a mix of 32-bit and 64-bit code and data within the same
executable object.
• For the 64-bit DWARF format and a target architecture with 64-bit addresses, an assembler
or compiler must provide a way to produce 2-byte, 4-byte and 8-byte quantities without
alignment restrictions, and the linker must be able to relocate an 8-byte address or section
offset that occurs at an arbitrary alignment.
Representation
Representation
name
4. For each of the following attributes that are present in the debugging information entry,
in the order listed below, append to S a marker letter (see below), the DWARF attribute
code, and the attribute value.
DW_AT_name
DW_AT_accessibility
DW_AT_address_class
DW_AT_allocated
DW_AT_artificial
DW_AT_associated
DW_AT_binary_scale
DW_AT_bit_offset
DW_AT_bit_size
DW_AT_bit_stride
DW_AT_byte_size
DW_AT_byte_stride
DW_AT_const_expr
DW_AT_const_value
DW_AT_containing_type
DW_AT_count
DW_AT_data_bit_offset
DW_AT_data_location
DW_AT_data_member_location
DW_AT_decimal_scale
DW_AT_decimal_sign
DW_AT_default_value
DW_AT_digit_count
DW_AT_discr
DW_AT_discr_list
DW_AT_discr_value
DW_AT_encoding
DW_AT_enum_class
DW_AT_endianity
DW_AT_explicit
DW_AT_is_optional
DW_AT_location
DW_AT_lower_bound
DW_AT_mutable
DW_AT_ordering
DW_AT_picture_string
DW_AT_prototyped
DW_AT_small
DW_AT_segment
DW_AT_string_length
DW_AT_threads_scaled
DW_AT_upper_bound
DW_AT_use_location
DW_AT_use_UTF8
DW_AT_variable_parameter
DW_AT_virtuality
DW_AT_visibility
DW_AT_vtable_elem_location
Note that except for the initial DW_AT_name attribute, attributes are appended in order
according to the alphabetical spelling of their identifier.
If an implementation defines any vendor-specific attributes, any such attributes that are
essential to the definition of the type should also be included at the end of the above list,
in their own alphabetical suborder.
An attribute that refers to another type entry T is processed as follows: (a) If T is in the
list V at some V[x], use the letter 'R' as the marker and use the unsigned LEB128
encoding of x as the attribute value; otherwise, (b) use the letter 'T' as the marker, process
the type T recursively by performing Steps 2 through 7, and use the result as the attribute
value.
Other attribute values use the letter 'A' as the marker, and the value consists of the form
code (encoded as an unsigned LEB128 value) followed by the encoding of the value
according to the form code. To ensure reproducibility of the signature, the set of forms
used in the signature computation is limited to the following: DW_FORM_sdata,
DW_FORM_flag, DW_FORM_string, and DW_FORM_block.
5. If the tag in Step 3 is one of DW_TAG_pointer_type, DW_TAG_reference_type,
DW_TAG_rvalue_reference_type, DW_TAG_ptr_to_member_type, or
DW_TAG_friend, and the referenced type (via the DW_AT_type or DW_AT_friend
attribute) has a DW_AT_name attribute, append to S the letter 'N', the DWARF attribute
code (DW_AT_type or DW_AT_friend), the context of the type (according to the method
in Step 2), the letter 'E', and the name of the type. For DW_TAG_friend, if the referenced
entry is a DW_TAG_subprogram, the context is omitted and the name to be used is the
ABI-specific name of the subprogram (e.g., the mangled linker name).
6. If the tag in Step 3 is not one of DW_TAG_pointer_type, DW_TAG_reference_type,
DW_TAG_rvalue_reference_type, DW_TAG_ptr_to_member_type, or
DW_TAG_friend, but has a DW_AT_type attribute, or if the referenced type (via the
DW_AT_type or DW_AT_friend attribute) does not have a DW_AT_name attribute, the
attribute is processed according to the method in Step 4 for an attribute that refers to
another type entry.
7. Visit each child C of the debugging information entry as follows: If C is a nested type
entry or a member function entry, and has a DW_AT_name attribute, append to S the
letter 'S', the tag of C, and its name; otherwise, process C recursively by performing Steps
3 through 7, appending the result to S. Following the last child (or if there are no
children), append a zero byte.
For the purposes of this algorithm, if a debugging information entry S has a
DW_AT_specification attribute that refers to another entry D (which has a DW_AT_declaration
attribute), then S inherits the attributes and children of D, and S is processed as if those attributes
and children were present in the entry S. Exception: if a particular attribute is found in both S
and D, the attribute in S is used and the corresponding one in D is ignored.
DWARF tag and attribute codes are appended to the sequence as unsigned LEB128 values, using
the values defined earlier in this chapter.
A grammar describing this computation may be found in Appendix E.2.2.
An attribute that refers to another type entry should be recursively processed or replaced with
the name of the referent (in Step 4, 5 or 6). If neither treatment applies to an attribute that
references another type entry, the entry that contains that attribute should not be considered for
a separate type unit.
If a debugging information entry contains an attribute from the list above that would require an
unsupported form, that entry should not be considered for a separate type unit.
A type should be considered for a separate type unit only if all of the type entries that it contains
or refers to in Steps 6 and 7 can themselves each be considered for a separate type unit.
Where the DWARF producer may reasonably choose two or more different forms for a given
attribute, it should choose the simplest possible form in computing the signature. (For example, a
constant value should be preferred to a location expression when possible.)
Once the string S has been formed from the DWARF encoding, an MD5 hash is computed for
the string and the lower 64 bits are taken as the type signature.
The string S is intended to be a flattened representation of the type that uniquely identifies that
type (i.e., a different type is highly unlikely to produce the same string).
A debugging information entry should not be placed in a separate type unit if any of the
following apply:
• The entry has an attribute whose value is a location expression, and the location
expression contains a reference to another debugging information entry (e.g., a
DW_OP_call_ref operator), as it is unlikely that the entry will remain identical across
compilation units.
• The entry has an attribute whose value refers to a code location or a location list.
• The entry has an attribute whose value refers to another debugging information entry
that does not represent a type.
Certain attributes are not included in the type signature:
• The DW_AT_declaration attribute is not included because it indicates that the
debugging information entry represents an incomplete declaration, and incomplete
declarations should not be placed in separate type units.
• The DW_AT_description attribute is not included because it does not provide any
information unique to the defining declaration of the type.
• The DW_AT_decl_file, DW_AT_decl_line, and DW_AT_decl_column attributes are not
included because they may vary from one source file to the next, and would prevent two
otherwise identical type declarations from producing the same hash.
DW_TAG_access_declaration DECL
DW_AT_accessibility
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_TAG_array_type DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_bit_size
DW_AT_bit_stride
DW_AT_byte_size
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_ordering
DW_AT_sibling
DW_AT_specification
DW_AT_start_scope
DW_AT_type
DW_AT_visibility
DW_TAG_base_type DECL
DW_AT_allocated
DW_AT_associated
DW_AT_binary_scale
DW_AT_bit_offset
DW_AT_bit_size
DW_AT_byte_size
DW_AT_data_bit_offset
DW_AT_data_location
DW_AT_decimal_scale
DW_AT_decimal_sign
DW_AT_description
DW_AT_digit_count
DW_AT_encoding
DW_AT_endianity
DW_AT_name
DW_AT_picture_string
DW_AT_sibling
DW_AT_small
DW_TAG_catch_block DECL
DW_AT_abstract_origin
DW_AT_high_pc
DW_AT_low_pc
DW_AT_ranges
DW_AT_segment
DW_AT_sibling
DW_TAG_class_type DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_bit_size
DW_AT_byte_size
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_signature
DW_AT_specification
DW_AT_start_scope
DW_AT_visibility
DW_TAG_common_block DECL
DW_AT_declaration
DW_AT_description
DW_AT_linkage_name
DW_AT_location
DW_AT_name
DW_AT_segment
DW_AT_sibling
DW_AT_visibility
DW_TAG_common_inclusion DECL
DW_AT_common_reference
DW_AT_declaration
DW_AT_sibling
DW_AT_visibility
DW_TAG_compile_unit DW_AT_base_types
DW_AT_comp_dir
DW_AT_identifier_case
DW_AT_high_pc
DW_AT_language
DW_AT_low_pc
DW_AT_macro_info
DW_AT_main_subprogram
DW_AT_name
DW_AT_producer
DW_AT_ranges
DW_AT_segment
DW_AT_stmt_list
DW_AT_use_UTF8
DW_TAG_condition DECL
DW_AT_name
DW_AT_sibling
DW_TAG_const_type DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_constant DECL
DW_AT_accessibility
DW_AT_const_value
DW_AT_declaration
DW_AT_description
DW_AT_endianity
DW_AT_external
DW_AT_linkage_name
DW_AT_name
DW_AT_sibling
DW_AT_start_scope
DW_AT_type
DW_AT_visibility
DW_TAG_dwarf_procedure DW_AT_location
DW_TAG_entry_point DECL
DW_AT_address_class
DW_AT_description
DW_AT_frame_base
DW_AT_linkage_name
DW_AT_low_pc
DW_AT_name
DW_AT_return_addr
DW_AT_segment
DW_AT_sibling
DW_AT_static_link
DW_AT_type
DW_TAG_enumeration_type DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_bit_size
DW_AT_bit_stride
DW_AT_byte_size
DW_AT_byte_stride
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_enum_class
DW_AT_name
DW_AT_sibling
DW_AT_signature
DW_AT_specification
DW_AT_start_scope
DW_AT_type
DW_AT_visibility
DW_TAG_enumerator DECL
DW_AT_const_value
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_TAG_file_type DECL
DW_AT_abstract_origin
DW_AT_allocated
DW_AT_associated
DW_AT_bit_size
DW_AT_byte_size
DW_AT_data_location
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_start_scope
DW_AT_type
DW_AT_visibility
DW_TAG_formal_parameter DECL
DW_AT_abstract_origin
DW_AT_artificial
DW_AT_const_value
DW_AT_default_value
DW_AT_description
DW_AT_endianity
DW_AT_is_optional
DW_AT_location
DW_AT_name
DW_AT_segment
DW_AT_sibling
DW_AT_type
DW_AT_variable_parameter
DW_TAG_friend DECL
DW_AT_abstract_origin
DW_AT_friend
DW_AT_sibling
DW_TAG_imported_declaration DECL
DW_AT_accessibility
DW_AT_description
DW_AT_import
DW_AT_name
DW_AT_sibling
DW_AT_start_scope
DW_TAG_imported_module DECL
DW_AT_import
DW_AT_sibling
DW_AT_start_scope
DW_TAG_imported_unit DW_AT_import
DW_TAG_inheritance DECL
DW_AT_accessibility
DW_AT_data_member_location
DW_AT_sibling
DW_AT_type
DW_AT_virtuality
DW_TAG_inlined_subroutine DW_AT_abstract_origin
DW_AT_call_column
DW_AT_call_file
DW_AT_call_line
DW_AT_const_expr
DW_AT_entry_pc
DW_AT_high_pc
DW_AT_low_pc
DW_AT_ranges
DW_AT_return_addr
DW_AT_segment
DW_AT_sibling
DW_AT_start_scope
DW_AT_trampoline
DW_TAG_interface_type DECL
DW_AT_accessibility
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_start_scope
DW_TAG_label DECL
DW_AT_abstract_origin
DW_AT_description
DW_AT_low_pc
DW_AT_name
DW_AT_segment
DW_AT_start_scope
DW_AT_sibling
DW_TAG_lexical_block DECL
DW_AT_abstract_origin
DW_AT_description
DW_AT_high_pc
DW_AT_low_pc
DW_AT_name
DW_AT_ranges
DW_AT_segment
DW_AT_sibling
DW_TAG_member DECL
DW_AT_accessibility
DW_AT_bit_offset
DW_AT_bit_size
DW_AT_byte_size
DW_AT_data_bit_offset
DW_AT_data_member_location
DW_AT_declaration
DW_AT_description
DW_AT_mutable
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_AT_visibility
DW_TAG_module DECL
DW_AT_accessibility
DW_AT_declaration
DW_AT_description
DW_AT_entry_pc
DW_AT_high_pc
DW_AT_low_pc
DW_AT_name
DW_AT_priority
DW_AT_ranges
DW_AT_segment
DW_AT_sibling
DW_AT_specification
DW_AT_visibility
DW_TAG_namelist DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_declaration
DW_AT_name
DW_AT_sibling
DW_AT_visibility
DW_TAG_namelist_item DECL
DW_AT_namelist_item
DW_AT_sibling
DW_TAG_namespace DECL
DW_AT_description
DW_AT_extension
DW_AT_name
DW_AT_sibling
DW_AT_start_scope
DW_TAG_packed_type DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_partial_unit DW_AT_base_types
DW_AT_comp_dir
DW_AT_description
DW_AT_identifier_case
DW_AT_high_pc
DW_AT_language
DW_AT_low_pc
DW_AT_macro_info
DW_AT_main_subprogram
DW_AT_name
DW_AT_producer
DW_AT_ranges
DW_AT_segment
DW_AT_stmt_list
DW_AT_use_UTF8
DW_TAG_pointer_type DW_AT_address_class
DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_ptr_to_member_type DECL
DW_AT_abstract_origin
DW_AT_address_class
DW_AT_allocated
DW_AT_associated
DW_AT_containing_type
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_AT_use_location
DW_AT_visibility
DW_TAG_reference_type DW_AT_address_class
DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_restrict_type DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_rvalue_reference_type DECL
DW_AT_address_class
DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_set_type DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_bit_size
DW_AT_byte_size
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_start_scope
DW_AT_sibling
DW_AT_type
DW_AT_visibility
DW_TAG_shared_type DW_AT_allocated
DW_AT_associated
DW_AT_count
DW_AT_data_location
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_string_type DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_bit_size
DW_AT_byte_size
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_start_scope
DW_AT_string_length
DW_AT_visibility
DW_TAG_structure_type DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_bit_size
DW_AT_byte_size
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_signature
DW_AT_specification
DW_AT_start_scope
DW_AT_visibility
DW_TAG_subprogram DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_address_class
DW_AT_artificial
DW_AT_calling_convention
DW_AT_declaration
DW_AT_description
DW_AT_elemental
DW_AT_entry_pc
DW_AT_explicit
DW_AT_external
DW_AT_frame_base
DW_AT_high_pc
DW_AT_inline
DW_AT_linkage_name
DW_AT_low_pc
DW_AT_main_subprogram
DW_AT_name
DW_AT_object_pointer
DW_AT_prototyped
DW_AT_pure
DW_AT_ranges
DW_AT_recursive
DW_AT_return_addr
DW_AT_segment
DW_AT_sibling
DW_AT_specification
DW_AT_start_scope
DW_AT_static_link
DW_AT_trampoline
DW_AT_type
DW_AT_visibility
DW_AT_virtuality
DW_AT_vtable_elem_location
DW_TAG_subrange_type DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_bit_size
DW_AT_bit_stride
DW_AT_byte_size
DW_AT_byte_stride
DW_AT_count
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_lower_bound
DW_AT_name
DW_AT_sibling
DW_AT_threads_scaled
DW_AT_type
DW_AT_upper_bound
DW_AT_visibility
DW_TAG_subroutine_type DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_address_class
DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_prototyped
DW_AT_sibling
DW_AT_start_scope
DW_AT_type
DW_AT_visibility
DW_TAG_template_alias DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_signature
DW_AT_start_scope
DW_AT_type
DW_AT_visibility
DW_TAG_template_type_parameter DECL
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_template_value_parameter DECL
DW_AT_const_value
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_thrown_type DECL
DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_sibling
DW_AT_type
DW_TAG_try_block DECL
DW_AT_abstract_origin
DW_AT_high_pc
DW_AT_low_pc
DW_AT_ranges
DW_AT_segment
DW_AT_sibling
DW_TAG_typedef DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_start_scope
DW_AT_type
DW_AT_visibility
DW_TAG_type_unit DW_AT_language
DW_TAG_union_type DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_allocated
DW_AT_associated
DW_AT_bit_size
DW_AT_byte_size
DW_AT_data_location
DW_AT_declaration
DW_AT_description
DW_AT_name
DW_AT_sibling
DW_AT_signature
DW_AT_specification
DW_AT_start_scope
DW_AT_visibility
DW_TAG_unspecified_parameters DECL
DW_AT_abstract_origin
DW_AT_artificial
DW_AT_sibling
DW_TAG_unspecified_type DECL
DW_AT_description
DW_AT_name
DW_TAG_variable DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_const_expr
DW_AT_const_value
DW_AT_declaration
DW_AT_description
DW_AT_endianity
DW_AT_external
DW_AT_linkage_name
DW_AT_location
DW_AT_name
DW_AT_segment
DW_AT_sibling
DW_AT_specification
DW_AT_start_scope
DW_AT_type
DW_AT_visibility
DW_TAG_variant DECL
DW_AT_accessibility
DW_AT_abstract_origin
DW_AT_declaration
DW_AT_discr_list
DW_AT_discr_value
DW_AT_sibling
DW_TAG_variant_part DECL
DW_AT_abstract_origin
DW_AT_accessibility
DW_AT_declaration
DW_AT_discr
DW_AT_sibling
DW_AT_type
DW_TAG_volatile_type DW_AT_allocated
DW_AT_associated
DW_AT_data_location
DW_AT_name
DW_AT_sibling
DW_AT_type
DW_TAG_with_stmt DW_AT_accessibility
DW_AT_address_class
DW_AT_declaration
DW_AT_high_pc
DW_AT_location
DW_AT_low_pc
DW_AT_ranges
DW_AT_segment
DW_AT_sibling
DW_AT_type
DW_AT_visibility
.debug_aranges
.debug_frame .debug_abbrev
DW_FORM_strp (d)
DW_OP_call_ref (e)
.debug_info .debug_loc
DW_AT_ranges (g)
and others
.debug_ranges
To compilation unit (b) DW_AT_macinfo (h)
DW_AT_stmt_list (i)
.debug_pubnames .debug_macinfo
.debug_line
.debug_pubtypes
Notes
(a) .debug_aranges The debug_info_offset value in the header is the offset in the
.debug_info section of the corresponding compilation unit header (not
the compilation unit entry).
(e) .debug_loc The operand of the DW_OP_call_ref DWARF expression operator is the
offset of a debugging information entry in the .debug_info section.
do
{
byte = low order 7 bits of value;
value >>= 7;
if (value != 0) /* more bytes to come */
set high order bit of byte;
emit byte;
} while (value != 0);
more = 1;
negative = (value < 0);
size = no. of bits in signed integer;
while(more)
{
byte = low order 7 bits of value;
value >>= 7;
/* the following is unnecessary if the
* implementation of >>= uses an arithmetic rather
* than logical shift for a signed left operand
*/
if (negative)
/* sign extend */
value |= - (1 <<(size - 7));
/* sign bit of byte is second high order bit (0x40) */
if ((value == 0 && sign bit of byte is clear) ||
(value == -1 && sign bit of byte is set))
more = 0;
else
set high order bit of byte;
emit byte;
}
Figure 45. Algorithm to encode a signed integer
result = 0;
shift = 0;
while(true)
{
byte = next byte in input;
result |= (low order 7 bits of byte << shift);
if (high order bit of byte == 0)
break;
shift += 7;
}
result = 0;
shift = 0;
size = number of bits in signed integer;
while(true)
{
byte = next byte in input;
result |= (low order 7 bits of byte << shift);
shift += 7;
/* sign bit of byte is second high order bit (0x40) */
if (high order bit of byte == 0)
break;
}
if ((shift <size) && (sign bit of byte is set))
/* sign extend */
result |= - (1 << shift);
-----
length a1: 1
4 DW_TAG_compile_unit
a1 (abbreviations table offset) DW_CHILDREN_yes
4 DW_AT_name DW_FORM_string
DW_AT_producer DW_FORM_string
1 DW_AT_comp_dir DW_FORM_string
“myfile.c” DW_AT_language DW_FORM_data1
“Best Compiler Corp: Version 1.3” DW_AT_low_pc DW_FORM_addr
“/home/mydir/src” DW_AT_high_pc DW_FORM_data1
DW_LANG_C89 DW_AT_stmt_list DW_FORM_indirect
0x0 0 0
0x55
DW_FORM_sec_offset 2
0x0 DW_TAG_base_type
DW_CHILDREN_no
e1: 2 DW_AT_name DW_FORM_string
“char” DW_AT_encoding DW_FORM_data1
DW_ATE_unsigned_char DW_AT_byte_size DW_FORM_data1
1 0 0
e2: 3 3
e1 DW_TAG_pointer_type
DW_CHILDREN_no
4 DW_AT_type DW_FORM_ref4
“POINTER” 0 0
e2
4
0 DW_TAG_typedef
DW_CHILDREN_no
Compilation Unit 2: .debug_info DW_AT_name DW_FORM_string
DW_AT_type DW_FORM_ref_addr
length 0 0
4
a1 (abbreviations table offset) 0
4
...
4
“strp”
e2
...
type array_ptr
real :: myvar
real, dimension (:), pointer :: ap
end type array_ptr
allocate(arrays(20))
do i = 1, 20
allocate(arrays(i)%ap(i+10))
end do
Figure 49. Fortran 90 example: source fragment
For allocatable and pointer arrays, it is essentially required by the Fortran 90 semantics that each
array consist of two parts, which we here call 1) the descriptor and 2) the raw data. (A descriptor
has often been called a dope vector in other contexts, although it is often a structure of some kind
rather than a simple vector.) Because there are two parts, and because the lifetime of the
descriptor is necessarily longer than and includes that of the raw data, there must be an address
somewhere in the descriptor that points to the raw data when, in fact, there is some (that is, when
the “variable”" is allocated or associated).
For concreteness, suppose that a descriptor looks something like the C structure in Figure 50.
Note, however, that it is a property of the design that 1) a debugger needs no builtin knowledge
of this structure and 2) there does not need to be an explicit representation of this structure in the
DWARF input to the debugger.
struct desc {
long el_len; // Element length
void * base; // Address of raw data
int ptr_assoc : 1; // Pointer is associated flag
int ptr_alloc : 1; // Pointer is allocated flag
int num_dims : 6; // Number of dimensions
struct dims_str { // For each dimension...
long low_bound;
long upper_bound;
long stride;
} dims[63];
};
Figure 50. Fortran 90 example: descriptor representation
In practice, of course, a “real” descriptor will have dimension substructures only for as many
dimensions as are specified in the num_dims component. Let us use the notation desc<n> to
indicate a specialization of the desc struct in which n is the bound for the dims component as
well as the contents of the num_dims component.
Because the arrays considered here come in two parts, it is necessary to distinguish the parts
carefully. In particular, the “address of the variable” or equivalently, the “base address of the
object” always refers to the descriptor. For arrays that do not come in two parts, an
implementation can provide a descriptor anyway, thereby giving it two parts. (This may be
convenient for general runtime support unrelated to debugging.) In this case the above
vocabulary applies as stated. Alternatively, an implementation can do without a descriptor, in
which case the “address of the variable”, or equivalently the “base address of the object”, refers
to the “raw data” (the real data, the only thing around that can be the object).
If an object has a descriptor, then the DWARF type for that object will have a
DW_AT_data_location attribute. If an object does not have a descriptor, then usually the
DWARF type for the object will not have a DW_AT_data_location. (See the following Ada
example for a case where the type for an object without a descriptor does have a
DW_AT_data_location attribute. In that case the object doubles as its own descriptor.)
The Fortran 90 derived type array_ptr can now be redescribed in C-like terms that expose
some of the representation as in
struct array_ptr {
float myvar;
desc<1> ap;
};
2. offset(type, comp): offset in bytes of the comp component within an entity of the given
type
The DWARF description is shown in Figure 51.
! Description for type of 'ap'
1$: DW_TAG_array_type
! No name, default (Fortran) ordering, default stride
DW_AT_type(reference to REAL)
DW_AT_associated(expression= ! Test 'ptr_assoc' flag
DW_OP_push_object_address
DW_OP_lit<n> ! where n == offset(ptr_assoc)
DW_OP_plus
DW_OP_deref
DW_OP_lit1 ! mask for 'ptr_assoc' flag
DW_OP_and)
DW_AT_data_location(expression= ! Get raw data address
DW_OP_push_object_address
DW_OP_lit<n> ! where n == offset(base)
DW_OP_plus
DW_OP_deref) ! Type of index of array 'ap'
2$: DW_TAG_subrange_type
! No name, default stride
DW_AT_type(reference to INTEGER)
DW_AT_lower_bound(expression=
DW_OP_push_object_address
DW_OP_lit<n> ! where n ==
! offset(desc, dims) +
! offset(dims_str, lower_bound)
DW_OP_plus
DW_OP_deref)
DW_AT_upper_bound(expression=
DW_OP_push_object_address
DW_OP_lit<n> ! where n ==
! offset(desc, dims) +
! offset(dims_str, upper_bound)
DW_OP_plus
DW_OP_deref)
3$: DW_TAG_structure_type
DW_AT_name("array_ptr")
DW_AT_byte_size(constant sizeof(REAL) + sizeof(desc<1>))
4$: DW_TAG_member
DW_AT_name("myvar")
DW_AT_type(reference to REAL)
DW_AT_data_member_location(constant 0)
5$: DW_TAG_member
DW_AT_name("ap");
DW_AT_type(reference to 1$)
DW_AT_data_member_location(constant sizeof(REAL))
6$: DW_TAG_array_type
! No name, default (Fortran) ordering, default stride
DW_AT_type(reference to 3$)
DW_AT_allocated(expression= ! Test 'ptr_alloc' flag
DW_OP_push_object_address
DW_OP_lit<n> ! where n == offset(ptr_alloc)
DW_OP_plus
DW_OP_deref
DW_OP_lit2 ! mask for 'ptr_alloc' flag
DW_OP_and)
DW_AT_data_location(expression= ! Get raw data address
DW_OP_push_object_address
DW_OP_lit<n> ! where n = offset(base)
DW_OP_plus
DW_OP_deref)
7$: DW_TAG_subrange_type
! No name, default stride
DW_AT_type(reference to INTEGER)
DW_AT_lower_bound(expression=
DW_OP_push_object_address
DW_OP_lit<n> ! where n == ...
DW_OP_plus
DW_OP_deref)
DW_AT_upper_bound(expression=
DW_OP_push_object_address
DW_OP_lit<n> ! where n == ...
DW_OP_plus
DW_OP_deref)
8$: DW_TAG_variable
DW_AT_name("arrays")
DW_AT_type(reference to 6$)
DW_AT_location(expression=
...as appropriate...) ! Assume static allocation
Suppose the program is stopped immediately following completion of the do loop. Suppose
further that the user enters the following debug command:
debug> print arrays(5)%ap(2)
1) Lookup name arrays. We find that it is a variable, whose type is given by the unnamed type
at 6$. Notice that the type is an array type.
2) Find the 5th element of that array object. To do array indexing requires several pieces of
information:
a) the address of the array data
b) the lower bounds of the array
[To check that 5 is within bounds would require the upper bound too, but we’ll skip that
for this example.]
c) the stride
For a), check for a DW_AT_data_location attribute. Since there is one, go execute the
expression, whose result is the address needed. The object address used in this case is the
object we are working on, namely the variable named arrays, whose address was found in
step 1. (Had there been no DW_AT_data_location attribute, the desired address would be the
same as the address from step 1.)
For b), for each dimension of the array (only one in this case), go interpret the usual lower
bound attribute. Again this is an expression, which again begins with
DW_OP_push_object_address. This object is still arrays, from step 1, because we haven’t
begun to actually perform any indexing yet.
For c), the default stride applies. Since there is no DW_AT_byte_stride attribute, use the size
of the array element type, which is the size of type array_ptr (at 3$).
Having acquired all the necessary data, perform the indexing operation in the usual manner—
which has nothing to do with any of the attributes involved up to now. Those just provide the
actual values used in the indexing step.
The result is an object within the memory that was dynamically allocated for arrays.
3) Find the ap component of the object just identified, whose type is array_ptr.
This is a conventional record component lookup and interpretation. It happens that the ap
component in this case begins at offset 4 from the beginning of the containing object.
Component ap has the unnamed array type defined at 1$ in the symbol table.
4) Find the second element of the array object found in step 3. To do array indexing requires
several pieces of information:
a) the address of the array storage
b) the lower bounds of the array
[To check that 2 is within bounds we would require the upper bound too, but we’ll skip
that for this example]
c) the stride
This is just like step 2), so the details are omitted. Recall that because the DWARF type 1$ has a
DW_AT_data_location, the address that results from step 4) is that of a descriptor, and that
address is the address pushed by the DW_OP_push_object_address operations in 1$ and 2$.
Note: we happen to be accessing a pointer array here instead of an allocatable array; but because
there is a common underlying representation, the mechanics are the same. There could be
completely different descriptor arrangements and the mechanics would still be the same—only
the stack machines would be different.
Figure 52 illustrates two kinds of Ada parameterized array, one embedded in a record.
M : INTEGER := <exp>;
VEC1 : array (1..M) of INTEGER;
OBJ2B : REC2;
VEC1 illustrates an (unnamed) array type where the upper bound of the first and only dimension
is determined at runtime. Ada semantics require that the value of an array bound is fixed at the
time the array type is elaborated (where elaboration refers to the runtime executable aspects of
type processing). For the purposes of this example, we assume that there are no other
assignments to M so that it safe for the REC1 type description to refer directly to that variable
(rather than a compiler generated copy).
REC2 illustrates another array type (the unnamed type of component VEC2) where the upper
bound of the first and only bound is also determined at runtime. In this case, the upper bound is
contained in a discriminant of the containing record type. (A discriminant is a component of a
record whose value cannot be changed independently of the rest of the record because that value
is potentially used in the specification of other components of the record.)
The DWARF description is shown in Figure 53.
2) One of the bounds of VEC2 is nonetheless dynamic and part of the same containing
record. It is described as a reference to a member, and the location of the upper bound is
determined as for any member. That is, the location is determined using an address
calculation relative to the base of the containing object.
A consumer must notice that the referenced bound is a member of the same containing
object and implicitly push the base address of the containing object just as for accessing a
data member generally.
3) The lack of a subtype concept in DWARF means that DWARF types serve the role of
subtypes and must replicate information from what should be the parent type. For this
reason, DWARF for the unconstrained array ARR is not needed for the purposes of this
example and therefore not shown.
11$: DW_TAG_variable
DW_AT_name("M")
DW_AT_type(reference to INTEGER)
12$: DW_TAG_array_type
! No name, default (Ada) order, default stride
DW_AT_type(reference to INTEGER)
13$: DW_TAG_subrange_type
DW_AT_type(reference to INTEGER)
DW_AT_lower_bound(constant 1)
DW_AT_upper_bound(reference to variable M at 11$)
14$: DW_TAG_variable
DW_AT_name("VEC1")
DW_AT_type(reference to array type at 12$)
. . .
21$: DW_TAG_subrange_type
DW_AT_name("TEENY")
DW_AT_type(reference to INTEGER)
DW_AT_lower_bound(constant 1)
DW_AT_upper_bound(constant 100)
. . .
26$: DW_TAG_structure_type
DW_AT_name("REC2")
27$: DW_TAG_member
DW_AT_name("N")
DW_AT_type(reference to subtype TEENY at 21$)
DW_AT_data_member_location(constant 0)
28$: DW_TAG_array_type
! No name, default (Ada) order, default stride
! Default data location
DW_AT_TYPE(reference to INTEGER)
29$: DW_TAG_subrange_type
DW_AT_type(reference to subrange TEENY at 21$)
DW_AT_lower_bound(constant 1)
DW_AT_upper_bound(reference to member N at 27$)
30$: DW_TAG_member
DW_AT_name("VEC2")
DW_AT_type(reference to array “subtype” at 28$)
DW_AT_data_member_location(machine=
DW_OP_lit<n> ! where n == offset(REC2, VEC2)
DW_OP_plus)
. . .
41$: DW_TAG_variable
DW_AT_name("OBJ2B")
DW_AT_type(reference to REC2 at 26$)
DW_AT_location(...as appropriate...)
10$: DW_TAG_base_type
DW_AT_name("BOOLEAN")
...
11$: DW_TAG_base_type
DW_AT_name("INTEGER")
...
20$: DW_TAG_structure_type
DW_AT_name("T")
DW_AT_bit_size(2)
DW_TAG_member
DW_AT_name("F5")
DW_AT_type(reference to 10$)
DW_AT_data_bit_offset(0) ! may be omitted
DW_AT_bit_size(1)
DW_TAG_member
DW_AT_name("F6")
DW_AT_type(reference to 10$)
DW_AT_data_bit_offset(1)
DW_AT_bit_size(1)
DW_TAG_variable
DW_AT_name("V")
DW_AT_type(reference to 23$)
DW_AT_location(...)
...
namespace {
int i;
}
namespace A {
namespace B {
int j;
int myfunc (int a);
float myfunc (float f) { return f – 2.0; }
int myfunc2(int a) { return a + 2; }
}
}
namespace Y {
using A::B::j; // (1) using declaration
int foo;
}
namespace A {
namespace B {
using namespace Y; // (6) using directive
int k;
}
}
int Foo::myfunc(int a)
{
i = 3;
j = 4;
return myfunc2(3) + j + i + a + 2;
}
Figure 56. Namespace example: source fragment
1$: DW_TAG_base_type
DW_AT_name("int")
...
2$: DW_TAG_base_type
DW_AT_name("float")
...
6$: DW_TAG_namespace
! no DW_AT_name attribute
7$: DW_TAG_variable
DW_AT_name("i")
DW_AT_type(reference to 1$)
DW_AT_location ...
...
10$: DW_TAG_namespace
DW_AT_name("A")
20$: DW_TAG_namespace
DW_AT_name("B")
30$: DW_TAG_variable
DW_AT_name("j")
DW_AT_type(reference to 1$)
DW_AT_location ...
...
34$: DW_TAG_subprogram
DW_AT_name("myfunc")
DW_AT_type(reference to 1$)
...
36$: DW_TAG_subprogram
DW_AT_name("myfunc")
DW_AT_type(reference to 2$)
...
38$: DW_TAG_subprogram
DW_AT_name("myfunc2")
DW_AT_low_pc ...
DW_AT_high_pc ...
DW_AT_type(reference to 1$)
...
40$: DW_TAG_namespace
DW_AT_name("Y")
DW_TAG_imported_declaration ! (1) using-declaration
DW_AT_import(reference to 30$)
DW_TAG_variable
DW_AT_name("foo")
DW_AT_type(reference to 1$)
DW_AT_location ...
...
DW_TAG_namespace
DW_AT_extension(reference to 10$)
DW_TAG_namespace
DW_AT_extension(reference to 20$)
DW_TAG_imported_module ! (6) using directive
DW_AT_import(reference to 40$)
DW_TAG_variable
DW_AT_name("k")
DW_AT_type(reference to 1$)
DW_AT_location ...
...
60$: DW_TAG_subprogram
DW_AT_specification(reference to 34$)
DW_AT_low_pc ...
DW_AT_high_pc ...
...
Figure 57. Namespace example: DWARF description
1$: DW_TAG_unspecified_type
DW_AT_name("void")
...
2$ DW_TAG_base_type
DW_AT_name("int")
...
3$: DW_TAG_class_type
DW_AT_name("A")
...
4$: DW_TAG_pointer_type
DW_AT_type(reference to 3$)
...
5$: DW_TAG_const_type
DW_AT_type(reference to 3$)
...
6$: DW_TAG_pointer_type
DW_AT_type(reference to 5$)
...
7$: DW_TAG_subprogram
DW_AT_declaration
DW_AT_name("func1")
DW_AT_type(reference to 1$)
DW_AT_object_pointer(reference to 8$)
! References a formal parameter in this member function
...
8$: DW_TAG_formal_parameter
DW_AT_artificial(true)
DW_AT_name("this")
DW_AT_type(reference to 4$)
! Makes type of 'this' as 'A*' =>
! func1 has not been marked const or volatile
DW_AT_location ...
...
9$: DW_TAG_formal_parameter
DW_AT_name(x1)
DW_AT_type(reference to 2$)
...
10$: DW_TAG_subprogram
DW_AT_declaration
DW_AT_name("func2")
DW_AT_type(reference to 1$)
DW_AT_object_pointer(reference to 11$)
! References a formal parameter in this member function
...
11$: DW_TAG_formal_parameter
DW_AT_artificial(true)
DW_AT_name("this")
DW_AT_type(reference to 6$)
! Makes type of 'this' as 'A const*' =>
! func2 marked as const
DW_AT_location ...
...
12$: DW_TAG_subprogram
DW_AT_declaration
DW_AT_name("func3")
DW_AT_type(reference to 1$)
...
! No object pointer reference formal parameter
! implies func3 is static
13$: DW_TAG_formal_parameter
DW_AT_name(x3)
DW_AT_type(reference to 2$)
...
1: int
2: main()
0x239: push pb
0x23a: mov bp,sp
3: {
4: printf("Omit needless words\n");
0x23c: mov ax,0xaa
0x23f: push ax
0x240: call _printf
0x243: pop cx
5: exit(0);
0x244: xor ax,ax
0x246: push ax
0x247: call _exit
0x24a: pop cx
6: }
0x24b: pop bp
0x24c: ret
7: 0x24d:
Figure 60. Line number program example: machine code
Suppose the line number program header includes the following (header fields not needed below
are not shown):
version 4
minimum_instruction_length 1
opcode_base 10 ! Opcodes 10-12 not needed
line_base 1
line_range 15
Figure 61 shows one encoding of the line number program, which occupies 12 bytes (the opcode
SPECIAL(m,n) indicates the special opcode generated for a line increment of m and an address
increment of n).
Figure 62 shows an alternate encoding of the same program using standard opcodes to advance
the program counter; this encoding occupies 22 bytes.
• The address for the load and store instructions is computed by adding the contents of the
source register with the constant.
• The architectural ABI committee specifies that the stack pointer (R7) is the same as the CFA
The following are two code fragments from a subroutine called foo that uses a frame pointer (in
addition to the stack pointer). The first column values are byte addresses. <fs> denotes the stack
frame size in bytes, namely 12.
;; start prologue
foo sub R7, R7, <fs> ; Allocate frame
foo+4 store R1, R7, (<fs>-4) ; Save the return address
foo+8 store R6, R7, (<fs>-8) ; Save R6
foo+12 add R6, R7, 0 ; R6 is now the Frame ptr
foo+16 store R4, R6, (<fs>-12) ; Save a preserved reg
;; This subroutine does not change R5
...
;; Start epilogue (R7 is returned to entry value)
foo+64 load R4, R6, (<fs>-12) ; Restore R4
foo+68 load R6, R7, (<fs>-8) ; Restore R6
foo+72 load R1, R7, (<fs>-4) ; Restore return address
foo+76 add R7, R7, <fs> ; Deallocate frame
foo+80 jump R1 ; Return
foo+84
Figure 63. Call frame information example: machine code fragments
An abstract table (see Section 6.4.1) for the foo subroutine is shown in Figure 64. Corresponding
fragments from the .debug_frame section are shown in Figure 65.
The following notations apply in Figure 64:
1. R8 is the return address
2. s = same_value rule
3. u = undefined rule
4. rN = register(N) rule
5. cN = offset(N) rule
6. a = architectural rule
Location CFA R0 R1 R2 R3 R4 R5 R6 R7 R8
foo [R7]+0 s u u u s s s a r1
foo+4 [R7]+fs s u u u s s s a r1
foo+8 [R7]+fs s u u u s s s a c-4
foo+12 [R7]+fs s u u u s s c-8 a c-4
foo+16 [R6]+fs s u u u s s c-8 a c-4
foo+20 [R6]+fs s u u u c-12 s c-8 a c-4
...
foo+64 [R6]+fs s u u u c-12 s c-8 a c-4
foo+68 [R6]+fs s u u u s s c-8 a c-4
foo+72 [R7]+fs s u u u s s s a c-4
foo+76 [R7]+fs s u u u s s s a r1
foo+80 [R7]+0 s u u u s s s a r1
Figure 65. Call frame information example: common information entry encoding
Figure 66. Call frame information example: frame description entry encoding
OUTER_LOCAL : integer;
INNER_LOCAL : integer;
print(INNER_FORMAL + OUTER_LOCAL);
end;
INNER(OUTER_LOCAL);
...
INNER(31);
end;
! Call OUTER
!
OUTER(7);
Figure 67. Inlining examples: pseudo-source fragment
There are several approaches that a compiler might take to inlining for this sort of example. This
presentation considers three such approaches, all of which involve inline expansion of
subprogram OUTER. (If OUTER is not inlined, the inlining reduces to a simpler single level
subset of the two level approaches considered here.)
where <io> is either INNER or OUTER to indicate to which subprogram the debugging
information entry applies, <ac> is either AI or CI to indicate “abstract instance” or “concrete
instance” respectively, <n> is the number of the alternative being considered, and <s> is a
sequence number that distinguishes the individual entries. There is no implication that symbolic
labels, nor any particular naming convention, are required in actual use.
For conciseness, declaration coordinates and call coordinates are omitted.
D.7.1 Alternative #1: inline both OUTER and INNER
A suitable abstract instance for an alternative where both OUTER and INNER are always inlined
is shown in Figure 68.
Notice in Figure 68 that the debugging information entry for INNER (labelled INNER.AI.1.1) is
nested in (is a child of) that for OUTER (labelled OUTER.AI.1.1). Nonetheless, the abstract
instance tree for INNER is considered to be separate and distinct from that for OUTER.
The call of OUTER shown in Figure 67 might be described as shown in Figure 69.
...
0
...
0
In the second alternative we assume that subprogram INNER is not inlinable for some reason,
but subprogram OUTER is inlinable. Each concrete inlined instance of OUTER has its own
normal instance of INNER. The abstract instance for OUTER, which includes INNER, is shown
in Figure 70.
Note that the debugging information in this Figure differs from that in Figure 68 in that INNER
lacks a DW_AT_inline attribute and therefore is not a distinct abstract instance. INNER is
merely an out-of-line routine that is part of OUTER’s abstract instance. This is reflected in the
Figure 70 by the fact that the labels for INNER use the substring OUTER instead of INNER.
A resulting concrete inlined instance of OUTER is shown in Figure 71.
Notice in Figure 71 that OUTER is expanded as a concrete inlined instance, and that INNER is
nested within it as a concrete out-of-line subprogram. Because INNER is cloned for each inline
expansion of OUTER, only the invariant attributes of INNER (for example, DW_AT_name) are
specified in the abstract instance of OUTER, and the low-level, instance-specific attributes of
INNER (for example, DW_AT_low_pc) are specified in each concrete instance of OUTER.
The several calls of INNER within OUTER are compiled as normal calls to the instance of
INNER that is specific to the same instance of OUTER that contains the calls.
In the third approach, one normal subprogram for INNER is compiled which is called from all
concrete inlined instances of OUTER. The abstract instance for OUTER is shown in Figure 72.
The most distinctive aspect of that Figure is that subprogram INNER exists only within the
abstract instance of OUTER, and not in OUTER’s concrete instance. In the abstract instance of
OUTER, the description of INNER has the full complement of attributes that would be expected
for a normal subprogram. While attributes such as DW_AT_low_pc, DW_AT_high_pc,
DW_AT_location, and so on, typically are omitted from an abstract instance because they are not
invariant across instances of the containing abstract instance, in this case those same attributes
are included precisely because they are invariant--there is only one subprogram INNER to be
described and every description is the same.
A concrete inlined instance of OUTER is illustrated in Figure 73.
Notice in Figure 73 that there is no DWARF representation for INNER at all; the representation
of INNER does not vary across instances of OUTER and the abstract instance of OUTER
includes the complete description of INNER, so that the description of INNER may be (and for
reasons of space efficiency, should be) omitted from each concrete instance of OUTER.
There is one aspect of this approach that is problematical from the DWARF perspective. The
single compiled instance of INNER is assumed to access up-level variables of OUTER; however,
those variables may well occur at varying positions within the frames that contain the concrete
inlined instances. A compiler might implement this in several ways, including the use of
additional compiler generated parameters that provide reference parameters for the up-level
variables, or a compiler generated static link like parameter that points to the group of up-level
entities, among other possibilities. In either of these cases, the DWARF description for the
location attribute of each uplevel variable needs to be different if accessed from within INNER
compared to when accessed from within the instances of OUTER. An implementation is likely to
require vendor-specific DWARF attributes and/or debugging information entries to describe such
cases.
Note that in C++, a member function of a class defined within a function definition does not
require any vendor-specific extensions because the C++ language disallows access to entities
that would give rise to this problem. (Neither extern variables nor static members require any
form of static link for accessing purposes.)
...
0
// C++ source
//
char16_t chr_a = u'h';
char32_t chr_b = U'h';
! DWARF description
!
1$: DW_TAG_base_type
DW_AT_name("char16_t")
DW_AT_encoding(DW_ATE_UTF)
DW_AT_byte_size(2)
2$: DW_TAG_base_type
DW_AT_name("char32_t")
DW_AT_encoding(DW_ATE_UTF)
DW_AT_byte_size(4)
3$: DW_TAG_variable
DW_AT_name("chr_a")
DW_AT_type(reference to 1$)
4$: DW_TAG_variable
DW_AT_name("chr_b")
DW_AT_type(reference to 2$)
// C++ source
//
enum class E { E1, E2=100 };
E e1;
! DWARF description
!
11$: DW_TAG_enumeration_type
DW_AT_name("E")
DW_AT_type(reference to "int")
DW_AT_enum_class(present)
12$: DW_TAG_enumerator
DW_AT_name("E1")
DW_AT_const_value(0)
13$: DW_TAG_enumerator
DW_AT_name("E2")
DW_AT_const_value(100)
14$: DW_TAG_variable
DW_AT_name("e1")
DW_AT_type(reference to 11$)
// C++ source
//
template<class T>
struct wrapper {
T comp;
};
wrapper<int> obj;
! DWARF description
!
11$: DW_TAG_structure_type
DW_AT_name("wrapper")
12$: DW_TAG_template_type_parameter
DW_AT_name("T")
DW_AT_type(reference to "int")
13$ DW_TAG_member
DW_AT_name("comp")
DW_AT_type(reference to 12$)
14$: DW_TAG_variable
DW_AT_name("obj")
DW_AT_type(reference to 11$)
Figure 78. C++ template example #1
The actual type of the component comp is int, but in the DWARF the type references the
DW_TAG_template_type_parameter for T, which in turn references int. This implies that in the
original template comp was of type T and that was replaced with int in the instance.
There exist situations where it is not possible for the DWARF to imply anything about the nature
of the original template. Consider the C++ source in Figure 79.
// C++ source
//
template<class T>
struct wrapper {
T comp;
};
template<class U>
void consume(wrapper<U> formal)
{
...
}
wrapper<int> obj;
consume(obj);
! DWARF description
!
11$: DW_TAG_structure_type
DW_AT_name("wrapper")
12$: DW_TAG_template_type_parameter
DW_AT_name("T")
DW_AT_type(reference to "int")
13$ DW_TAG_member
DW_AT_name("comp")
DW_AT_type(reference to 12$)
14$: DW_TAG_variable
DW_AT_name("obj")
DW_AT_type(reference to 11$)
21$: DW_TAG_subprogram
DW_AT_name("consume")
22$: DW_TAG_template_type_parameter
DW_AT_name("U")
DW_AT_type(reference to "int")
23$: DW_TAG_formal_parameter
DW_AT_name("formal")
DW_AT_type(reference to 11$)
In the DW_TAG_subprogram entry for the instance of consume, U is described as int. The type
of formal is wrapper<U> in the source. DWARF only represents instantiations of templates;
there is no entry which represents wrapper<U>, which is neither a template parameter nor a
template instantiation. The type of formal is described as wrapper<int>, the instantiation of
wrapper<U>, in the DW_AT_type attribute at 23$. There is no description of the relationship
between template type parameter T at 12$ and U at 22$ which was used to instantiate
wrapper<U>.
A consequence of this is that the DWARF information would not distinguish between the
existing example and one where the formal of consume were declared in the source to be
wrapper<int>.
// C++ source
//
template<typename T, typename U>
struct Alpha {
T tango;
U uniform;
};
Beta<long> b;
// C++ source
//
template<class TX> struct X { };
template<class TY> struct Y { };
template<class T> using Z = Y<T>;
X<Y<int>> y;
X<Z<int>> z;
! Note that 32$ and 42$ are actually the same type
!
50$: DW_TAG_variable
DW_AT_name("y")
DW_AT_type(reference to $32)
51$: DW_TAG_variable
DW_AT_name("z")
DW_AT_type(reference to $42)
E.1.1 Overview
The general approach is to break up the debug information of a compilation into separate normal
and partial compilation units, each consisting of one or more sections. By arranging that a
sufficiently similar partitioning occurs in other compilations, a suitable system linker can delete
redundant groups of sections when combining object files.
The following uses some traditional section naming here but aside from the DWARF sections,
the names are just meant to suggest traditional contents as a way of explaining the approach, not
to be limiting.
A traditional relocatable object output from a single compilation might contain sections named:
.data
.text
.debug_info
.debug_abbrev
.debug_line
.debug_aranges
A relocatable object from a compilation system attempting duplicate DWARF elimination might
contain sections as in:
.data
.text
.debug_info
.debug_abbrev
.debug_line
.debug_aranges
followed (or preceded, the order is not significant) by a series of section groups:
==== Section group 1
.debug_info
.debug_abbrev
.debug_line
==== ...
For example, if a linker determines that section group 1 from A.o and section group 3 from B.o
are identical, it could discard one group and arrange that all references in A.o and B.o apply to
the remaining one of the two identical section groups. This saves space.
An important part of making it possible to “redirect” references to the surviving section group is
the use of consistently chosen linker global symbols for referring to locations within each section
group. It follows that references are simply to external names and the linker already knows how
to match up references and definitions.
What is minimally needed from the object file format and system linker (outside of DWARF
itself, and normal object/linker facilities such as simple relocations) are:
Section groups must have a section group name. For the subsequent C++ example, a name like
<producer-prefix>.<file-designator>.<gid-number>
• <gid-number> is a string generated to identify the specific wa.h header file in such a way
that
• a 'matching' output from another compile generates the same <gid-number>, and
So, for example, the section group corresponding to file wa.h above is given the name
my.compiler.company.cpp.wa.h.123456.
such as
my.compiler.company.wa.h.123456.987
where
• <prefix> distinguishes this as a DWARF debug info name, and should identify the producer
and, when appropriate, the language.
In general, every point in the section group .debug_info that could be referenced from outside
by any compilation unit must normally have an external name generated for it in the linker
symbol table, whether the current compilation references all those points or not.
The completeness of the set of names generated is a quality-of-implementation issue.
It is up to the producer to ensure that if <die-numbers> in separate compilations would not match
properly then a distinct <gid-number> is generated.
Note that only section groups that are designated as duplicate-removal-applies actually require
the
<prefix>.<file-designator>.<gid-number>.<die-number>
external labels for debugging information entries as all other section group sections can use
'local' labels (section-relative relocations).
(This is a consequence of separate compilation, not a rule imposed by this document.)
Local labels use references with form DW_FORM_ref4 or DW_FORM_ref8. (These are affected
by relocations so DW_FORM_ref_udata, DW_FORM_ref1 and DW_FORM_ref2 are normally
not usable and DW_FORM_ref_addr is not necessary for a local label.)
This also applies to Fortran INCLUDE lines when declarations are included into a procedure or
module context.
Consequently a compiler must use DW_TAG_partial_unit (instead of DW_TAG_compile_unit)
in a section group whenever the section group contents are not necessarily globally visible. This
directs consumers to ignore that compilation unit when scanning top level declarations and
definitions.
The DW_TAG_partial_unit compilation unit will be referenced from elsewhere and the
referencing locations give the appropriate context for interpreting the partial compilation unit.
A DW_TAG_partial_unit entry may have, as appropriate, any of the attributes assigned to a
DW_TAG_compile_unit.
Use of DW_TAG_imported_unit
A DW_TAG_imported_unit debugging information entry has an DW_AT_import attribute
referencing a DW_TAG_compile_unit or DW_TAG_partial_unit debugging information entry.
Use of DW_FORM_ref_addr
Use DW_FORM_ref_addr to reference from one compilation unit's debugging information
entries to those of another compilation unit.
When referencing into a removable section group .debug_info from another .debug_info
(from anywhere), the
<prefix>.<file-designator>.<gid-number>.<die-number>
name should be used for an external symbol and a relocation generated based on that name.
When referencing into a non-section group .debug_info, from another .debug_info (from
anywhere) DW_FORM_ref_addr is still the form to be used, but a section-relative relocation
generated by use of a non-exported name (often called an “internal name”) may be used for
references within the same object file.
E.1.3 Examples
This section provides several examples in order to have a concrete basis for discussion.
In these examples, the focus is on the arrangement of DWARF information into sections
(specifically the .debug_info section) and the naming conventions used to achieve references
into section groups. In practice, all of the examples that follow involve DWARF sections other
than just .debug_info (for example, .debug_line, .debug_aranges, or others); however, only
the .debug_info section is shown to keep the figures compact and easier to read.
The grouping of sections into a named set is shown, but the means for achieving this in terms of
the underlying object language is not (and varies from system to system).
C++ Example
The C++ source in Figure 82 is used to illustrate the DWARF representation intended to allow
duplicate elimination.
Figure 83 shows the section group corresponding to the included file wa.h.
== section .debug_info
Figure 84 shows the “normal” DWARF sections, which are not part of any section group, and
how they make use of the information in the section group shown above.
== section .text
[generated code for function f]
== section .debug_info
DW_TAG_compile_unit
.L1: ! local (non-linker) symbol
DW_TAG_reference_type
DW_AT_type(reference to DW.cpp.wa.h.123456.3)
DW_TAG_subprogram
DW_AT_name("f")
DW_AT_type(reference to DW.cpp.wa.h.123456.2)
DW_TAG_variable
DW_AT_name("a")
DW_AT_type(reference to .L1)
...
Figure 84. Duplicate elimination example #1: primary compilation unit
This example uses DW_TAG_compile_unit for the section group, implying that the contents of
the compilation unit are globally visible (in accordance with C++ language rules).
DW_TAG_partial_unit is not needed for the same reason.
Fortran Example
IMPLICIT INTEGER(A-Z)
COMMON /Common1/ C(100)
PARAMETER(SEVEN = 7)
Figure 86 shows the section group corresponding to the included file CommonStuff.fh.
my.f90.company.f90.CommonStuff.fh.654321
== section .debug_info
== section .text
[code for function Foo]
== section .debug_info
DW_TAG_compile_unit
DW_TAG_subprogram
DW_AT_name("Foo")
DW_AT_type(reference to DW.f90.F90$main.f.2)
! base type INTEGER
DW_TAG_imported_unit
DW_AT_import(reference to
DW.myf90.CommonStuff.fh.654321.1)
DW_TAG_common_inclusion ! For Common1
DW_AT_common_reference(reference to
DW.myf90.CommonStuff.fh.654321.3)
INCLUDE 'CommonStuff.fh'
C(50) = 8
PRINT *, 'Result = ', FOO(50 - SEVEN)
END
That main program results in an object file that contained a duplicate of the section group named
my.f90.company.f90.CommonStuff.fh.654321 corresponding to the included file as well as
the remainder of the main subprogram as shown in Figure 89.
== section .debug_info
DW_TAG_compile_unit
DW_AT_name(F90$main)
DW_TAG_base_type
DW_AT_name("INTEGER")
DW_AT_encoding(DW_ATE_signed)
DW_AT_byte_size(...)
DW_TAG_base_type
...
... ! other base types
DW_TAG_subprogram
DW_AT_name("F90$main")
DW_TAG_imported_unit
DW_AT_import(reference to
DW.myf90.CommonStuff.fh.654321.1)
DW_TAG_common_inclusion ! for Common1
DW_AT_common_reference(reference to
DW.myf90.CommonStuff.fh.654321.3)
...
This example uses DW_TAG_partial_unit for the section group because the included
declarations are not independently visible as global entities.
C Example
The C++ example in this Section might appear to be equally valid as a C example. However, it is
prudent to include a DW_TAG_imported_unit in the primary unit (see Figure 84) with an
DW_AT_import attribute that refers to the proper unit in the section group.
The C rules for consistency of global (file scope) symbols across compilations are less strict
than for C++; inclusion of the import unit attribute assures that the declarations of the proper
section group are considered before declarations from other compilations.
As discussed in the previous section (Section E.1), many linkers today support the concept of a
COMDAT group or linkonce section. The general idea is that a “key” can be attached to a
section or a group of sections, and the linker will include only one copy of a section group (or
individual section) for any given key. For .debug_types sections, the key is the type signature
formed from the algorithm given in Section 7.27.
1 namespace N {
2
3 struct B;
4
5 struct C {
6 int x;
7 int y;
8 };
9
10 class A {
11 public:
12 A(int v);
13 int v();
14 private:
15 int v_;
16 struct A *next;
17 struct B *bp;
18 struct C c;
19 };
20
21 }
Figure 90. Type signature examples: C++ source
Next, consider one possible representation of the DWARF information that describes the type
“struct C” as shown in Figure 91:
DW_TAG_type_unit
DW_AT_language: DW_LANG_C_plus_plus (4)
DW_TAG_namespace
DW_AT_name: "N"
L1:
DW_TAG_structure_type
DW_AT_name: "C"
DW_AT_byte_size: 8
DW_AT_decl_file: 1
DW_AT_decl_line: 5
DW_TAG_member
DW_AT_name: "x"
DW_AT_decl_file: 1
DW_AT_decl_line: 6
DW_AT_type: reference to L2
DW_AT_data_member_location: 0
DW_TAG_member
DW_AT_name: "y"
DW_AT_decl_file: 1
DW_AT_decl_line: 7
DW_AT_type: reference to L2
DW_AT_data_member_location: 4
L2:
DW_TAG_base_type
DW_AT_byte_size: 4
DW_AT_encoding: DW_ATE_signed
DW_AT_name: "int"
Figure 91. Type signature computation #1: DWARF representation
In computing a signature for the type N::C, flatten the type description into a byte stream
according to the procedure outlined in Section 7.27. The result is shown in Figure 92.
Running an MD5 hash over this byte stream, and taking the low-order 64 bits, yields the final
signature: 0xd28081e8 dcf5070a.
Next, consider a representation of the DWARF information that describes the type “class A” as
shown in Figure 93.
DW_TAG_type_unit
DW_AT_language: DW_LANG_C_plus_plus (4)
DW_TAG_namespace
DW_AT_name: "N"
L1:
DW_TAG_class_type
DW_AT_name: "A"
DW_AT_byte_size: 20
DW_AT_decl_file: 1
DW_AT_decl_line: 10
DW_TAG_member
DW_AT_name: "v_"
DW_AT_decl_file: 1
DW_AT_decl_line: 15
DW_AT_type: reference to L2
DW_AT_data_member_location: 0
DW_AT_accessibility: DW_ACCESS_private
DW_TAG_member
DW_AT_name: "next"
DW_AT_decl_file: 1
DW_AT_decl_line: 16
DW_AT_type: reference to L3
DW_AT_data_member_location: 4
DW_AT_accessibility: DW_ACCESS_private
DW_TAG_member
DW_AT_name: "bp"
DW_AT_decl_file: 1
DW_AT_decl_line: 17
DW_AT_type: reference to L4
DW_AT_data_member_location: 8
DW_AT_accessibility: DW_ACCESS_private
DW_TAG_member
DW_AT_name: "c"
DW_AT_decl_file: 1
DW_AT_decl_line: 18
DW_AT_type: 0xd28081e8 dcf5070a (signature for struct C)
DW_AT_data_member_location: 12
DW_AT_accessibility: DW_ACCESS_private
DW_TAG_subprogram
DW_AT_external: 1
DW_AT_name: "A"
DW_AT_decl_file: 1
DW_AT_decl_line: 12
DW_AT_declaration: 1
DW_TAG_formal_parameter
DW_AT_type: reference to L3
DW_AT_artificial: 1
DW_TAG_formal_parameter
DW_AT_type: reference to L2
DW_TAG_subprogram
DW_AT_external: 1
DW_AT_name: "v"
DW_AT_decl_file: 1
DW_AT_decl_line: 13
DW_AT_type: reference to L2
DW_AT_declaration: 1
DW_TAG_formal_parameter
DW_AT_type: reference to L3
DW_AT_artificial: 1
L2:
DW_TAG_base_type
DW_AT_byte_size: 4
DW_AT_encoding: DW_ATE_signed
DW_AT_name: "int"
L3:
DW_TAG_pointer_type
DW_AT_type: reference to L1
L4:
DW_TAG_pointer_type
DW_AT_type: reference to L5
DW_TAG_namespace
DW_AT_name: "N"
L5:
DW_TAG_structure_type
DW_AT_name: "B"
DW_AT_declaration: 1
Figure 93. Type signature computation #2: DWARF representation
In this example, the structure types N::A and N::C have each been placed in separate type units.
For N::A, the actual definition of the type begins at label L1. The definition involves references
to the int base type and to two pointer types. The information for each of these referenced types
is also included in this type unit, since base types and pointer types are trivial types that are not
worth the overhead of a separate type unit. The last pointer type contains a reference to an
incomplete type N::B, which is also included here as a declaration, since the complete type is
unknown and its signature is therefore unavailable. There is also a reference to N::C, using
DW_FORM_sig8 to refer to the type signature for that type.
In computing a signature for the type N::A, flatten the type description into a byte stream
according to the procedure outlined in Section 7.27. The result is shown in Figure 1.
Figure 94, Type signature example #2: flattened byte stream, begins here.
// Step 2: 'C' DW_TAG_namespace "N"
0x43 0x39 0x4e 0x00
// Step 3: 'D' DW_TAG_class_type
0x44 0x02
// Step 4: 'A' DW_AT_name DW_FORM_string "A"
0x41 0x03 0x08 0x41 0x00
// Step 4: 'A' DW_AT_byte_size DW_FORM_sdata 20
0x41 0x0b 0x0d 0x14
// Step 7: First child ("v_")
// Step 3: 'D' DW_TAG_member
0x44 0x0d
// Step 4: 'A' DW_AT_name DW_FORM_string "v_"
0x41 0x03 0x08 0x76 0x5f 0x00
// Step 4: 'A' DW_AT_accessibility DW_FORM_sdata DW_ACCESS_private
0x41 0x32 0x0d 0x03
// Step 4: 'A' DW_AT_data_member_location DW_FORM_sdata 0
0x41 0x38 0x0d 0x00
// Step 6: 'T' DW_AT_type (type #2)
0x54 0x49
// Step 3: 'D' DW_TAG_base_type
0x44 0x24
// Step 4: 'A' DW_AT_name DW_FORM_string "int"
0x41 0x03 0x08 0x69 0x6e 0x74 0x00
// Step 4: 'A' DW_AT_byte_size DW_FORM_sdata 4
0x41 0x0b 0x0d 0x04
// Step 4: 'A' DW_AT_encoding DW_FORM_sdata DW_ATE_signed
0x41 0x3e 0x0d 0x05
// Step 7: End of DW_TAG_base_type "int"
0x00
// Step 7: End of DW_TAG_member "v_"
0x00
// Step 7: Second child ("next")
// Step 3: 'D' DW_TAG_member
0x44 0x0d
// Step 4: 'A' DW_AT_name DW_FORM_string "next"
0x41 0x03 0x08 0x6e 0x65 0x78 0x74 0x00
// Step 4: 'A' DW_AT_accessibility DW_FORM_sdata DW_ACCESS_private
0x41 0x32 0x0d 0x03
// Step 4: 'A' DW_AT_data_member_location DW_FORM_sdata 4
0x41 0x38 0x0d 0x04
// Step 6: 'T' DW_AT_type (type #3)
0x54 0x49
// Step 3: 'D' DW_TAG_pointer_type
0x44 0x0f
// Step 5: 'N' DW_AT_type
0x4e 0x49
// Step 5: 'C' DW_AT_namespace "N" 'E'
0x43 0x39 0x4e 0x00 0x45
// Step 5: "A"
0x41 0x00
// Step 7: End of DW_TAG_pointer_type
0x00
// Step 7: End of DW_TAG_member "next"
0x00
// Step 7: Third child ("bp")
// Step 3: 'D' DW_TAG_member
0x44 0x0d
// Step 4: 'A' DW_AT_name DW_FORM_string "bp"
0x41 0x03 0x08 0x62 0x70 0x00
// Step 4: 'A' DW_AT_accessibility DW_FORM_sdata DW_ACCESS_private
0x41 0x32 0x0d 0x03
// Step 4: 'A' DW_AT_data_member_location DW_FORM_sdata 8
0x41 0x38 0x0d 0x08
// Step 6: 'T' DW_AT_type (type #4)
0x54 0x49
// Step 3: 'D' DW_TAG_pointer_type
0x44 0x0f
// Step 5: 'N' DW_AT_type
0x4e 0x49
// Step 5: 'C' DW_AT_namespace "N" 'E'
0x43 0x39 0x4e 0x00 0x45
// Step 5: "B"
0x42 0x00
// Step 7: End of DW_TAG_pointer_type
0x00
// Step 7: End of DW_TAG_member "next"
0x00
// Step 7: Fourth child ("c")
// Step 3: 'D' DW_TAG_member
0x44 0x0d
// Step 4: 'A' DW_AT_name DW_FORM_string "c"
0x41 0x03 0x08 0x63 0x00
// Step 4: 'A' DW_AT_accessibility DW_FORM_sdata DW_ACCESS_private
0x41 0x32 0x0d 0x03
// Step 4: 'A' DW_AT_data_member_location DW_FORM_sdata 12
0x41 0x38 0x0d 0x0c
// Step 6: 'T' DW_AT_type (type #5)
0x54 0x49
// Step 2: 'C' DW_TAG_namespace "N"
0x43 0x39 0x4e 0x00
Running an MD5 hash over this byte stream, and taking the low-order 64 bits, yields the final
signature: 0xd6d160f5 5589f6e9.
A source file that includes this header file may declare a variable of type N::A, and its DWARF
information may look that shown in Figure 95.
DW_TAG_compile_unit
...
DW_TAG_subprogram
...
DW_TAG_variable
DW_AT_name: "a"
DW_AT_type: (signature) 0xd6d160f5 5589f6e9
DW_AT_location: ...
...
Figure 95. Type signature example usage
signature
: opt-context debug-entry attributes children
opt-context // Step 2
: 'C' tag-code string opt-context
: empty
debug-entry // Step 3
: 'D' tag-code
attributes // Steps 4, 5, 6
: attribute attributes
: empty
attribute
: 'A' at-code form-encoded-value // Normal attributes
: 'N' at-code opt-context 'E' string // Reference to type
// by name
: 'R' at-code back-ref // Back-reference
// to visited type
: 'T' at-code signature // Recursive type
children // Step 7
: child children
: '\0'
child
: 'S' tag-code string
: signature
tag-code
: <ULEB128>
at-code
: <ULEB128>
form-encoded-value
: DW_FORM_sdata value
: DW_FORM_flag value
: DW_FORM_string string
: DW_FORM_block block
DW_FORM_string
: '\x08'
DW_FORM_block
: '\x09'
DW_FORM_flag
: '\x0c'
DW_FORM_sdata
: '\x0d'
value
: <SLEB128>
block
: <ULEB128> <fixed-length-block>
// The ULEB128 gives the length of the block
back-ref
: <ULEB128>
string
: <null-terminated-string>
empty
:
Figure 96. Type signature computation grammar
C++ has a much greater problem than C with the number and size of the headers included and
the amount of data in each, but even with C there is substantial header file information
duplication.
A reasonable approach is to put each header file in its own section group, using the naming rules
mentioned above. The section groups are marked to ensure duplicate removal.
All data instances and code instances (even if they came from the header files above) are put into
non-section group sections such as the base object file .debug_info section.
E.3.2 Eliminating function duplication
Function templates (C++) result in code for the same template instantiation being compiled into
multiple archives or relocatable objects. The linker wants to keep only one of a given entity. The
DWARF description, and everything else for this function, should be reduced to just a single
copy.
For each such code group (function template in this example) the compiler assigns a name for the
group which will match all other instantiations of this function but match nothing else. The
section groups are marked to ensure duplicate removal, so that the second and subsequent
definitions seen by the static linker are simply discarded.
References to other .debug_info sections follow the approach suggested above, but the naming
rule might be slightly different in that the <file-designator> should be interpreted as a <function-
designator>.
E.3.3 Single-function-per-DWARF-compilation-unit
Section groups can help make it easy for a linker to completely remove unused functions.
Such section groups are not marked for duplicate removal, since the functions are not duplicates
of anything.
Each function is given a compilation unit and a section group. Each such compilation unit is
complete, with its own text, data, and DWARF sections.
There will also be a compilation unit that has the file-level declarations and definitions. Other
per-function compilation unit DWARF information (.debug_info) points to this common file-
level compilation unit using DW_TAG_imported_unit.
Section groups can use DW_FORM_ref_addr and internal labels (section-relative relocations) to
refer to the main object file sections, as the section groups here are either deleted as unused or
kept. There is no possibility (aside from error) of a group from some other compilation being
used in place of one of these groups.
E.3.4 Inlining and out-of-line-instances
Abstract instances and concrete-out-of-line instances may be put in distinct compilation units
using section groups. This makes possible some useful duplicate DWARF elimination.
No special provision for eliminating class duplication resulting from template instantiation is
made here, though nothing prevents eliminating such duplicates using section groups.
Section Name Section version number Section version number Section version number
in DWARF Version 2 in DWARF Version 3 in DWARF Version 4
(July 1993) (December 2005) (this document)
.debug_abbrev - - -
.debug_aranges 2 2 2
.debug_frame 1 3 4
.debug_info 2 3 4
.debug_line 2 3 4
.debug_loc - - -
.debug_macinfo - - -
.debug_pubnames 2 2 2
.debug_pubtypes x 2 2
.debug_ranges x - -
.debug_str - - -
.debug_types x x 4
Figure 97. Section version numbers
Notes:
• "-" means that a version number is not applicable (the section's header does not include a
version).
• "x" means that the section was not defined in that version of the DWARF standard.
• The version numbers for the .debug_info and .debug_types sections must be the same.
For .debug_frame, section version 2 is unused.
Higher numbers are reserved for future use.
Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
http://fsf.org/
0. PREAMBLE
Secondarily, this License preserves for the author and publisher a way to get
credit for their work, while not being considered responsible for
modifications made by others.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free program
should come with manuals providing the same freedoms that the software does.
But this License is not limited to software manuals; it can be used for any
textual work, regardless of subject matter or whether it is published as a
printed book. We recommend this License principally for works whose purpose
is instruction or reference.
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be distributed
under the terms of this License. Such a notice grants a world-wide, royalty-
free license, unlimited in duration, to use that work under the conditions
stated herein. The "Document", below, refers to any such manual or work.
A "Modified Version" of the Document means any work containing the Document
or a portion of it, either copied verbatim, or with modifications and/or
translated into another language.
The "Invariant Sections" are certain Secondary Sections whose titles are
designated, as being those of Invariant Sections, in the notice that says
that the Document is released under this License. If a section does not fit
the above definition of Secondary then it is not allowed to be designated as
Invariant. The Document may contain zero Invariant Sections. If the
Document does not identify any Invariant Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed, as
Front-Cover Texts or Back-Cover Texts, in the notice that says that the
Document is released under this License. A Front-Cover Text may be at most 5
words, and a Back-Cover Text may be at most 25 words.
which the DTD and/or processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word processors
for output purposes only.
The "Title Page" means, for a printed book, the title page itself, plus such
following pages as are needed to hold, legibly, the material this License
requires to appear in the title page. For works in formats which do not have
any title page as such, "Title Page" means the text near the most prominent
appearance of the work's title, preceding the beginning of the body of the
text.
The "publisher" means any person or entity that distributes copies of
the Document to the public.
A section "Entitled XYZ" means a named subunit of the Document whose title
either is precisely XYZ or contains XYZ in parentheses following text that
translates XYZ in another language. (Here XYZ stands for a specific section
name mentioned below, such as "Acknowledgements", "Dedications",
"Endorsements", or "History".) To "Preserve the Title" of such a section
when you modify the Document means that it remains a section "Entitled XYZ"
according to this definition.
The Document may include Warranty Disclaimers next to the notice which states
that this License applies to the Document. These Warranty Disclaimers are
considered to be included by reference in this License, but only as regards
disclaiming warranties: any other implication that these Warranty Disclaimers
may have is void and has no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially
or noncommercially, provided that this License, the copyright notices, and
the license notice saying this License applies to the Document are reproduced
in all copies, and that you add no other conditions whatsoever to those of
this License. You may not use technical measures to obstruct or control the
reading or further copying of the copies you make or distribute. However,
you may accept compensation in exchange for copies. If you distribute a
large enough number of copies you must also follow the conditions in
section 3.
You may also lend copies, under the same conditions stated above, and you may
publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed
covers) of the Document, numbering more than 100, and the Document's license
notice requires Cover Texts, you must enclose the copies in covers that
carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the
front cover, and Back-Cover Texts on the back cover. Both covers must also
clearly and legibly identify you as the publisher of these copies. The front
cover must present the full title with all words of the title equally
prominent and visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve the
title of the Document and satisfy these conditions, can be treated as
verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you
should put the first ones listed (as many as fit reasonably) on the actual
cover, and continue the rest onto adjacent pages.
If you use the latter option, you must take reasonably prudent steps, when
you begin distribution of Opaque copies in quantity, to ensure that this
Transparent copy will remain thus accessible at the stated location until at
least one year after the last time you distribute an Opaque copy (directly or
through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give them
a chance to provide you with an updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the
conditions of sections 2 and 3 above, provided that you release the Modified
Version under precisely this License, with the Modified Version filling the
role of the Document, thus licensing distribution and modification of the
Modified Version to whoever possesses a copy of it. In addition, you must do
these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct from
that of the Document, and from those of previous versions (which should,
if there were any, be listed in the History section of the Document). You
may use the same title as a previous version if the original publisher of
that version gives permission.
C. State on the Title page the name of the publisher of the Modified Version,
as the publisher.
G. Preserve in that license notice the full lists of Invariant Sections and
required Cover Texts given in the Document's license notice.
I. Preserve the section Entitled "History", Preserve its Title, and add to it
an item stating at least the title, year, new authors, and publisher of
the Modified Version as given on the Title Page. If there is no section
Entitled "History" in the Document, create one stating the title, year,
authors, and publisher of the Document as given on its Title Page, then
add an item describing the Modified Version as stated in the previous
sentence.
J. Preserve the network location, if any, given in the Document for public
access to a Transparent copy of the Document, and likewise the network
locations given in the Document for previous versions it was based on.
These may be placed in the "History" section.
You may omit a network location for a work that was published at least
four years before the Document itself, or if the original publisher of the
version it refers to gives permission.
The author(s) and publisher(s) of the Document do not by this License give
permission to use their names for publicity for or to assert or imply
endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified versions,
provided that you include in the combination all of the Invariant Sections of
all of the original documents, unmodified, and list them all as Invariant
Sections of your combined work in its license notice, and that you preserve
all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple
identical Invariant Sections may be replaced with a single copy. If there
are multiple Invariant Sections with the same name but different contents,
make the title of each such section unique by adding at the end of it, in
parentheses, the name of the original author or publisher of that section if
known, or else a unique number.
Make the same adjustment to the section titles in the list of Invariant
Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled "History" in the
various original documents, forming one section Entitled "History"; likewise
combine any sections Entitled "Acknowledgements", and any sections Entitled
"Dedications". You must delete all sections Entitled "Endorsements".
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in the
collection, provided that you follow the rules of this License for verbatim
copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it
individually under this License, provided you insert a copy of this License
into the extracted document, and follow this License in all other respects
regarding verbatim copying of that document.
When the Document is included in an aggregate, this License does not apply to
the other works in the aggregate which are not themselves derivative works of
the Document.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
8. TRANSLATION
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as
expressly provided under this License. Any attempt otherwise to copy,
modify, sublicense, or distribute it is void, and will automatically
terminate your rights under this License.
However, if you cease all violation of this License, then your license from a
particular copyright holder is reinstated (a) provisionally, unless and until
the copyright holder explicitly and finally terminates your license, and (b)
permanently, if the copyright holder fails to notify you of the violation by
some reasonable means prior to 60 days after the cessation.
Termination of your rights under this section does not terminate the licenses
of parties who have received copies or rights from you under this License. If
your rights have been terminated and not permanently reinstated, receipt of a
copy of some or all of the same material does not give you any rights to use
it.
The Free Software Foundation may publish new, revised versions of the GNU
Free Documentation License from time to time. Such new versions will be
similar in spirit to the present version, but may differ in detail to address
new problems or concerns. See http://www.gnu.org/copyleft/.
11. RELICENSING
"Massive Multiauthor Collaboration Site" (or "MMC Site") means any World Wide
Web server that publishes copyrightable works and also provides prominent
facilities for anybody to edit those works. A public wiki that anybody can
edit is an example of such a server. A "Massive Multiauthor Collaboration"
(or "MMC") contained in the site means any set of copyrightable works thus
published on the MMC site. "CC-BY-SA" means the Creative Commons
Attribution-Share Alike 3.0 license published by Creative Commons
Corporation, a not-for-profit corporation with a principal place of business
in San Francisco, California, as well as future copyleft versions of that
license published by that same organization.
The operator of an MMC Site may republish an MMC contained in the site under
CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC
is eligible for relicensing.
To use this License in a document you have written, include a copy of the
License in the document and put the following copyright and license notices
just after the title page:
with the Invariant Sections being LIST THEIR TITLES, with the Front-
Cover Texts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other combination
of the three, merge those two alternatives to suit the situation.
... parameters.....................See unspecified parameters entry implicit push for member pointer.............................. 101
.data ................................................................................264 implicit push of base ................................................... 20
.debug_abbrev......... 141, 144, 145, 183, 215, 264, 276, 289 size of an .......................................See size of an address
example ..................................................................219 address class............................................................. 15, 147
.debug_aranges ....... 107, 140, 141, 177, 183, 215, 264, 289 address class attribute........................................... 34, 55, 81
.debug_frame .......................... 128, 130, 140, 141, 183, 289 encoding.................................................................... 173
example ..................................................................240 address range
.debug_info ...7, 24, 105, 106, 107, 108, 140, 141, 142, 143, in location list.............................................................. 31
145, 146, 149, 151, 176, 177, 183, 215, 264, 265, 267, in range list.................................................................. 39
268, 269, 271, 273, 274, 275, 276, 287, 289 address register
example ..................................................................219 in call frame information........................................... 127
.debug_line 45, 108, 140, 141, 148, 183, 215, 264, 276, 289 in line number machine............................................. 109
.debug_loc......................................... 30, 148, 183, 215, 289 address selection..........................See base address selection
.debug_macinfo ................ 45, 123, 125, 149, 183, 215, 289 address size ........................................See size of an address
.debug_pubnames ... 106, 140, 141, 142, 176, 183, 215, 289 address space
.debug_pubtypes ..... 106, 140, 141, 142, 176, 183, 215, 289 flat34
.debug_ranges ................................... 38, 149, 183, 215, 289 multiple ................................................................. 19, 20
.debug_str ............................... 142, 150, 151, 183, 215, 289 segmented ............................................34, 107, 144, 177
.debug_types .7, 24, 105, 107, 140, 141, 142, 143, 144, 145, address, uplevel ................................ See static link attribute
146, 183, 276, 289 address_size ....................................107, 129, 144, 177, 178
.text .................................................................264, 271, 274 alias declaration....................See imported declaration entry
<caf>............................................See code alignment factor allocated attribute ........................................................... 102
<daf> ............................................See data alignment factor anonymous union ....................................................... 69, 88
32-bit DWARF format....................................................140 ARM instruction set architecture.................................... 108
64-bit DWARF format....................................................140 array
abbreviations table ..................................................143, 145 declaration of type....................................................... 83
dynamic forms in.......................................................146 descriptor for............................................................. 221
example .....................................................................219 element ordering ......................................................... 83
abstract instance..............................................................288 element type................................................................ 83
example ..................................................... 245, 248, 251 array type entry ................................................................ 83
nested...........................................................................63 examples ................................................................... 221
abstract instance entry.......................................................59 artificial attribute.............................................................. 34
abstract instance root ........................................................59 associated attribute ......................................................... 102
abstract instance tree...................................................59, 61 attribute duplication............................................................ 7
abstract origin attribute ...............................................61, 63 attribute ordering ................................................................ 7
accelerated access ...........................................................105 attribute value classes......................................................... 7
by address..................................................................107 attributes............................................................................. 7
by name .....................................................................106 list of ............................................................................. 9
access declaration entry ....................................................87 base address selection entry
accessibility attribute ......................................32, 87, 88, 92 in location list................................................ 30, 31, 168
encoding ....................................................................170 in range list.................................................... 38, 39, 182
activation, call frame.......................................................126 base type entry.................................................................. 75
Ada ......1, 9, 32, 41, 44, 79, 80, 81, 103, 222, 227, 228, 229 base types attribute ........................................................... 47
address basic_block..............................................110, 111, 116, 119
dereference operator ..............................................19, 20 beginning of a data member ............................................. 88
digit count attribute....................................................78, 79, DW_AT_call_line ...................................... 10, 60, 158, 198
discontiguous address ranges....See non-contiguous address DW_AT_calling_convention ..............10, 54, 156, 174, 205
ranges DW_AT_common_reference ......10, 56, 155, 193, 274, 275
discriminant (entry) ..........................................................94 DW_AT_comp_dir ..... 10, 46, 115, 122, 155, 194, 201, 220
discriminant attribute ........................................................94 DW_AT_const_expr10, 60, 61, 72, 159, 185, 198, 210, 254
discriminant list attribute ..................................................94 DW_AT_const_value. 10, 60, 61, 71, 93, 96, 103, 155, 185,
encoding ....................................................................176 195, 196, 207, 210, 247, 254, 256, 273
discriminant value attribute...............................................94 DW_AT_containing_type .................10, 100, 156, 185, 202
discriminator........................................... 111, 116, 119, 122 DW_AT_count................10, 40, 81, 99, 156, 185, 203, 206
duplicate elimination..... See DWARF duplicate elimination DW_AT_data_bit_offset ......10, 75, 76, 88, 89, 90, 91, 159,
DW_ACCESS_private..............................................32, 170 185, 192, 200, 230, 231
DW_ACCESS_protected..........................................32, 170 DW_AT_data_location ......10, 84, 102, 158, 185, 191, 192,
DW_ACCESS_public...............................................32, 170 193, 194, 196, 197, 201, 202, 203, 204, 206, 207, 208,
DW_ADDR_far16.............................................................35 209, 211, 222, 223, 224, 225, 226, 228
DW_ADDR_far32.............................................................35 DW_AT_data_member_location10, 20, 86, 88, 89, 91, 156,
DW_ADDR_huge16..........................................................35 185, 198, 200, 224, 229, 277, 278, 279, 280, 282, 283,
DW_ADDR_near16 ..........................................................35 284
DW_ADDR_near32 ..........................................................35 DW_AT_data_member_location (V3) ............................. 91
DW_ADDR_none...............................................34, 35, 173 DW_AT_decimal_scale ................10, 78, 79, 158, 185, 192
DW_AT_abstract_origin . 9, 61, 62, 63, 156, 191, 192, 193, DW_AT_decimal_sign................10, 78, 158, 169, 185, 192
196, 197, 198, 199, 200, 202, 203, 204, 205, 206, 207, DW_AT_decl_column .........10, 36, 156, 188, 191, See also
208, 209, 210, 247, 250, 253, 254 declaration coordinates
DW_AT_accessibility 9, 32, 87, 88, 92, 156, 170, 185, 191, DW_AT_decl_file...... 10, 36, 157, 188, 191, 277, 278, 280,
193, 195, 196, 198, 199, 200, 203, 204, 205, 206, 207, 281, See also declaration coordinates
208, 209, 210, 211, 280, 282, 283 DW_AT_decl_line ..... 10, 36, 157, 188, 191, 277, 278, 280,
DW_AT_address_class.... 9, 34, 55, 81, 156, 185, 195, 202, 281, See also declaration coordinates
203, 205, 206, 211 DW_AT_declaration .. 10, 35, 36, 49, 69, 85, 157, 187, 188,
DW_AT_allocated. 9, 40, 84, 102, 103, 158, 185, 191, 192, 191, 193, 195, 196, 200, 202, 203, 204, 205, 206, 207,
193, 194, 196, 197, 201, 202, 203, 204, 206, 207, 208, 208, 209, 210, 211, 236, 281
209, 211, 224 DW_AT_default_value .......................10, 70, 156, 185, 197
DW_AT_artificial 7, 9, 34, 64, 92, 156, 185, 197, 205, 209, DW_AT_description ......7, 10, 41, 158, 188, 191, 192, 193,
236, 281 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
DW_AT_associated9, 40, 84, 102, 158, 185, 191, 192, 193, 206, 207, 208, 209, 210
194, 196, 197, 201, 202, 203, 204, 206, 207, 208, 209, DW_AT_digit_count.....................11, 78, 79, 158, 185, 192
211, 223 DW_AT_discr ...............................11, 94, 95, 155, 185, 210
DW_AT_base_types............................. 9, 47, 156, 194, 201 DW_AT_discr_list ................11, 94, 95, 157, 176, 185, 210
DW_AT_binary_scale .......................... 9, 79, 158, 185, 192 DW_AT_discr_value ....................11, 94, 95, 155, 185, 210
DW_AT_bit_offset ........... 9, 40, 90, 91, 155, 185, 192, 200 DW_AT_elemental .................................... 11, 54, 159, 205
DW_AT_bit_offset (V3).............................................76, 91 DW_AT_encoding ..... 11, 75, 157, 168, 186, 192, 220, 255,
DW_AT_bit_size. 9, 40, 41, 75, 83, 85, 89, 91, 98, 99, 101, 275
155, 185, 191, 192, 193, 196, 197, 200, 203, 204, 206, DW_AT_endianity11, 72, 75, 159, 170, 186, 192, 195, 197,
209, 230, 231 210
DW_AT_bit_size (V3) ...............................................76, 91 DW_AT_entry_pc 11, 34, 38, 40, 49, 55, 60, 158, 198, 200,
DW_AT_bit_stride .... 9, 40, 41, 83, 97, 100, 156, 185, 191, 205
196, 206, 231 DW_AT_enum_class ..................11, 96, 159, 186, 196, 256
DW_AT_byte_size 9, 40, 41, 75, 76, 83, 85, 89, 90, 91, 96, DW_AT_explicit.................................11, 92, 159, 186, 205
98, 99, 101, 155, 185, 191, 192, 193, 196, 197, 200, DW_AT_extension .............................11, 49, 158, 201, 234
203, 204, 206, 209, 220, 224, 254, 255, 275, 277, 278, DW_AT_external.... 11, 53, 69, 70, 157, 195, 205, 210, 281
279, 280, 281, 282, 284 DW_AT_frame_base11, 18, 29, 56, 57, 157, 195, 205, 250,
DW_AT_byte_size (V3).............................................76, 91 252, 253
DW_AT_byte_stride.. 9, 40, 41, 83, 97, 100, 158, 185, 196, DW_AT_friend ...................................11, 87, 157, 187, 197
206, 226 DW_AT_hi_user ............................................................ 159
DW_AT_call_column................................... 9, 60, 158, 198
DW_AT_call_file ......................................... 9, 60, 158, 198
DW_AT_high_pc11, 34, 37, 38, 44, 49, 55, 60, 65, 66, 155, DW_AT_specification ...13, 36, 50, 59, 70, 85, 92, 93, 157,
192, 194, 198, 199, 200, 201, 205, 208, 211, 220, 233, 187, 191, 193, 196, 200, 204, 205, 209, 210, 234
234, 247, 250, 252, 253 DW_AT_start_scope.. 13, 37, 38, 60, 71, 75, 156, 191, 193,
DW_AT_identifier_case ..... 11, 46, 157, 174, 194, 201, 273 195, 196, 197, 198, 199, 201, 203, 204, 205, 206, 207,
DW_AT_import..... 11, 47, 50, 51, 155, 198, 234, 268, 274, 208, 209, 210
275 DW_AT_static_link .....13, 56, 57, 157, 195, 205, 247, 250,
DW_AT_inline .... 12, 58, 59, 156, 175, 205, 246, 248, 249, 252
252, 254 DW_AT_stmt_list .......................13, 45, 155, 194, 201, 220
DW_AT_is_optional........................... 12, 70, 156, 186, 197 DW_AT_string_length........................13, 98, 155, 186, 204
DW_AT_language. 12, 44, 48, 83, 155, 171, 194, 201, 208, DW_AT_threads_scaled .....................13, 99, 159, 186, 206
220, 270, 273, 277, 280 DW_AT_trampoline............................13, 64, 158, 198, 205
DW_AT_linkage_name ..... 12, 37, 41, 53, 72, 73, 159, 193, DW_AT_type. 13, 32, 55, 57, 58, 66, 70, 72, 81, 82, 83, 86,
195, 205, 210 88, 93, 94, 95, 96, 97, 98, 99, 100, 101, 103, 157, 187,
DW_AT_lo_user.............................................................159 191, 194, 195, 196, 197, 198, 200, 201, 202, 203, 205,
DW_AT_location 12, 24, 37, 60, 66, 69, 73, 155, 186, 193, 206, 207, 208, 210, 211, 220, 223, 224, 225, 228, 229,
195, 197, 210, 211, 225, 229, 231, 233, 234, 236, 247, 230, 231, 233, 234, 235, 236, 246, 249, 252, 254, 255,
250, 252, 253, 273, 285 256, 257, 258, 260, 270, 271, 273, 274, 277, 278, 279,
DW_AT_low_pc.. 12, 34, 37, 38, 40, 44, 49, 55, 59, 60, 65, 280, 281, 282, 283, 284, 285
66, 155, 192, 194, 195, 198, 199, 200, 201, 205, 208, DW_AT_upper_bound.13, 40, 99, 156, 186, 206, 223, 224,
211, 220, 233, 234, 247, 250, 252, 253 228, 229, 231, 254, 273
DW_AT_lower_bound 12, 40, 99, 156, 171, 186, 206, 223, DW_AT_use_location...............13, 100, 101, 157, 186, 202
224, 228, 229, 231, 273 DW_AT_use_UTF8 ............13, 47, 150, 158, 186, 194, 201
DW_AT_macro_info .......................... 12, 45, 157, 194, 201 DW_AT_variable_parameter ..............13, 70, 157, 186, 197
DW_AT_main_subprogram .... 3, 12, 47, 53, 159, 194, 201, DW_AT_virtuality .. 13, 33, 87, 92, 157, 171, 186, 198, 205
205 DW_AT_visibility...... 14, 33, 155, 171, 186, 191, 193, 195,
DW_AT_mutable ............................... 12, 88, 158, 186, 200 196, 197, 200, 202, 203, 204, 205, 206, 207, 208, 209,
DW_AT_name12, 36, 37, 41, 44, 46, 49, 51, 53, 58, 62, 65, 210, 211
66, 69, 73, 75, 80, 81, 82, 83, 84, 86, 87, 88, 93, 95, 96, DW_AT_vtable_elem_location...........14, 92, 157, 186, 205
97, 98, 99, 100, 101, 103, 106, 107, 115, 122, 155, 184, DW_ATE_address ................................................... 77, 168
185, 187, 191, 192, 193, 194, 195, 196, 197, 198, 199, DW_ATE_boolean................................................... 77, 168
200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, DW_ATE_complex_float ........................................ 77, 168
211, 220, 224, 225, 228, 229, 230, 231, 233, 234, 235, DW_ATE_decimal_float.......................................... 77, 169
236, 246, 248, 249, 252, 254, 255, 256, 257, 258, 260, DW_ATE_edited................................................ 77, 78, 168
270, 271, 273, 274, 275, 277, 278, 279, 280, 281, 282, DW_ATE_float ........................................................ 77, 168
283, 284, 285 DW_ATE_hi_user.......................................................... 169
DW_AT_namelist_item.............................. 12, 73, 157, 201 DW_ATE_imaginary_float ...................................... 77, 168
DW_AT_object_pointer ............. 12, 92, 159, 189, 205, 236 DW_ATE_lo_user.......................................................... 169
DW_AT_ordering....................... 12, 83, 155, 175, 186, 191 DW_ATE_numeric_string ........................... 77, 78, 79, 168
DW_AT_picture_string ...................... 12, 78, 158, 186, 192 DW_ATE_packed_decimal.......................... 77, 78, 79, 168
DW_AT_priority ........................................ 12, 49, 157, 200 DW_ATE_signed....................................... 75, 77, 168, 275
DW_AT_producer ...................... 12, 46, 156, 194, 201, 220 DW_ATE_signed_char ............................................ 77, 168
DW_AT_prototyped ............. 12, 54, 97, 156, 186, 205, 206 DW_ATE_signed_fixed..................................... 77, 78, 169
DW_AT_pure ............................................. 12, 55, 159, 205 DW_ATE_unsigned ......................................... 77, 168, 220
DW_AT_ranges..12, 34, 37, 38, 44, 49, 55, 60, 65, 66, 158, DW_ATE_unsigned_char ................................ 77, 168, 220
192, 194, 198, 199, 200, 201, 205, 208, 211 DW_ATE_unsigned_fixed................................. 77, 78, 169
DW_AT_recursive................................ 13, 54, 55, 159, 205 DW_ATE_UTF.......................................... 77, 78, 169, 255
DW_AT_return_addr............ 13, 56, 60, 156, 195, 198, 205 DW_CC_hi_user ............................................................ 174
DW_AT_segment .... 13, 34, 55, 60, 70, 157, 186, 192, 193, DW_CC_lo_user ............................................................ 174
194, 195, 197, 198, 199, 200, 201, 205, 208, 210, 211 DW_CC_nocall ........................................................ 54, 174
DW_AT_sibling .. 13, 16, 36, 155, 191, 192, 193, 194, 195, DW_CC_normal ...................................................... 54, 174
196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, DW_CC_program .................................................... 54, 174
207, 208, 209, 210, 211 DW_CFA_advance_loc ..................132, 136, 137, 181, 243
DW_AT_signature...... 13, 85, 159, 193, 196, 204, 207, 209 DW_CFA_advance_loc1........................................ 132, 181
DW_AT_small.................................... 13, 79, 158, 186, 192 DW_CFA_advance_loc2........................................ 132, 181
DW_TAG_enumerator ......................... 8, 96, 152, 196, 256 DW_TAG_unspecified_parameters ..8, 56, 67, 97, 152, 209
DW_TAG_file_type ................................... 8, 101, 152, 197 DW_TAG_unspecified_type.................8, 80, 153, 209, 235
DW_TAG_formal_parameter .... 8, 67, 69, 95, 97, 151, 197, DW_TAG_variable ...... 8, 41, 61, 69, 82, 95, 153, 210, 225,
236, 246, 247, 249, 250, 252, 253, 254, 258, 281 228, 229, 231, 233, 234, 246, 247, 249, 250, 252, 253,
DW_TAG_friend.................................. 8, 87, 152, 187, 197 254, 255, 256, 257, 258, 260, 261, 271, 273, 274, 285
DW_TAG_hi_user..................................................139, 154 DW_TAG_variant.................................8, 94, 152, 153, 210
DW_TAG_imported_declaration.......... 8, 50, 151, 198, 234 DW_TAG_variant_part................................ 8, 94, 153, 210
DW_TAG_imported_module ............... 8, 51, 153, 198, 234 DW_TAG_volatile_type .........................8, 81, 82, 153, 211
DW_TAG_imported_unit .... 8, 47, 153, 198, 268, 274, 275, DW_TAG_with_stmt ................................... 8, 66, 152, 211
287 DW_VIRTUALITY_none ....................................... 33, 171
DW_TAG_inheritance.................................. 8, 86, 152, 198 DW_VIRTUALITY_pure_virtual............................ 33, 171
DW_TAG_inlined_subroutine..... 8, 53, 60, 61, 63, 64, 152, DW_VIRTUALITY_virtual..................................... 33, 171
198, 246, 247, 250, 253, 254 DW_VIS_exported................................................... 33, 171
DW_TAG_interface_type............................. 8, 86, 153, 199 DW_VIS_local......................................................... 33, 171
DW_TAG_label............................................ 8, 65, 151, 199 DW_VIS_qualified................................................... 33, 171
DW_TAG_lexical_block .............................. 8, 65, 151, 199 DWARF compression .................................................... 263
DW_TAG_lo_user..................................................139, 154 DWARF duplicate elimination....................................... 263
DW_TAG_member . 8, 70, 88, 95, 151, 200, 224, 228, 229, C example ................................................................. 275
230, 231, 257, 258, 260, 270, 277, 278, 279, 280, 282, C++ example............................................................. 269
283, 284 examples ................................................................... 269
DW_TAG_module ....................................... 8, 49, 152, 200 Fortran example ........................................................ 272
DW_TAG_namelist ...................................... 8, 73, 153, 200 DWARF expression .......... 17, See also location description
DW_TAG_namelist_item ............................. 8, 73, 153, 201 arithmetic operations................................................... 21
DW_TAG_namespace . 8, 49, 153, 201, 233, 234, 277, 279, control flow operations ............................................... 23
280, 281, 282, 283 examples ..................................................................... 25
DW_TAG_packed_type ............................... 8, 81, 153, 201 literal encodings .......................................................... 17
DW_TAG_partial_unit 8, 43, 143, 153, 201, 268, 271, 273, logical operations ........................................................ 21
275 operator encodings ................................................... 163
DW_TAG_pointer_type 8, 81, 82, 151, 187, 202, 220, 235, special operations........................................................ 24
281, 283 stack operations........................................................... 17
DW_TAG_ptr_to_member_type ........ 8, 100, 152, 187, 202 DWARF procedure .......................................................... 37
DW_TAG_reference_type............ 8, 81, 151, 187, 202, 271 DWARF procedure entry ................................................. 37
DW_TAG_restrict_type.......................... 8, 81, 82, 153, 202 DWARF section names, list of....................................... 183
DW_TAG_rvalue_reference_type ........ 8, 81, 154, 187, 203 DWARF Version 2..................................4, 5, 114, 140, 289
DW_TAG_set_type ...................................... 8, 98, 152, 203 DWARF Version 3.. 1, 2, 3, 4, 38, 55, 76, 91, 114, 117, 289
DW_TAG_shared_type ................................ 8, 81, 154, 203 elemental attribute ............................................................ 54
DW_TAG_string_type.................................. 8, 98, 151, 204 empty location description ............................................... 28
DW_TAG_structure_type...... 8, 84, 93, 151, 204, 224, 229, encoding attribute............................................................. 75
230, 231, 257, 258, 260, 261, 270, 277, 279, 281, 284 encoding.................................................................... 168
DW_TAG_subprogram ..... 8, 41, 53, 58, 59, 61, 63, 64, 92, end of list entry
153, 187, 205, 233, 234, 236, 246, 247, 249, 250, 252, in location list...................................................... 31, 168
253, 254, 258, 271, 274, 275, 281, 284, 285 in range list.......................................................... 38, 182
DW_TAG_subrange_type 8, 84, 95, 99, 152, 171, 206, 223, end_sequence ................................................. 110, 111, 121
224, 228, 229, 231, 254, 273 endianity attribute....................................................... 72, 75
DW_TAG_subroutine_type.......................... 8, 97, 151, 206 entity .................................................................................. 7
DW_TAG_template_alias........... 8, 103, 154, 207, 260, 261 entry PC attribute ............................................................. 34
DW_TAG_template_type_parameter .... 8, 58, 93, 103, 153, and abstract instance ................................................... 60
207, 257, 258, 260, 261 for inlined subprogram................................................ 60
DW_TAG_template_value_parameter . 8, 93, 103, 153, 207 for module initialization.............................................. 49
DW_TAG_thrown_type ............................... 8, 57, 153, 207 for subroutine.............................................................. 55
DW_TAG_try_block .................................... 8, 66, 153, 208 entry point entry ............................................................... 53
DW_TAG_type_unit .................... 8, 48, 154, 208, 277, 280 enum class .................................. See type-safe enumeration
DW_TAG_typedef ............................... 8, 82, 151, 208, 220 enumeration literal ..............................See enumerator entry
DW_TAG_union_type............................ 8, 84, 93, 152, 209 enumeration type entry..................................................... 96