IBM Support

Adding DWARF 5 Support to CDA

Release Notes


Abstract

Starting with the release of the July 2025 Run-Time Library Extensions (CDA), CDA will now support the DWARF 5 debugging data format.

Content

The July 2025 Run-Time Library Extensions (CDA) PTF adds support for the DWARF 5 debugging format.  The PTF ID for this release is:  UO03572, and is also documented on the Fix list for z/OS XL C/C++ under the 2.4 tab.  The release is versioned at V2R4, however is only supported on V2R5 and V3R1.

Documentation Updates

The following contains documentation updates to the "Consumer APIs for standard DWARF sections" section of the DWARF/ELF Extensions Library Reference to add DWARF 5 updates.



Consumer APIs for standard DWARF sections
=======================================================================
Update to "Type definition":
 
typedef enum Dwarf_section_type_s {
  DW_SECTION_DEBUG_INFO        =  0,
  DW_SECTION_DEBUG_LINE        =  1,
  DW_SECTION_DEBUG_ABBREV      =  2,
  DW_SECTION_DEBUG_FRAME       =  3,
  DW_SECTION_EH_FRAME          =  4,
  DW_SECTION_DEBUG_ARANGES     =  5,
  DW_SECTION_DEBUG_RANGES      =  6,
  DW_SECTION_DEBUG_PUBNAMES    =  7,
  DW_SECTION_DEBUG_PUBTYPES    =  8,
  DW_SECTION_DEBUG_STR         =  9,
  DW_SECTION_DEBUG_FUNCNAMES   =  10,
  DW_SECTION_DEBUG_VARNAMES    =  11,
  DW_SECTION_DEBUG_WEAKNAMES   =  12,
  DW_SECTION_DEBUG_MACINFO     =  13,
  DW_SECTION_DEBUG_LOC         =  14,
  DW_SECTION_DEBUG_PPA         =  15,
  DW_SECTION_DEBUG_SRCFILES    =  16,
  DW_SECTION_DEBUG_SRCTEXT     =  17,
  DW_SECTION_DEBUG_SRCATTR     =  18,
  DW_SECTION_DEBUG_XREF        =  19,
  DW_SECTION_DEBUG_TYPE        =  20,
  DW_SECTION_DEBUG_STROFFS     =  21,
  DW_SECTION_DEBUG_ADDR        =  22,
  DW_SECTION_DEBUG_LINE_STR    =  23,
  DW_SECTION_DEBUG_RNGLISTS    =  24,
  DW_SECTION_DEBUG_LOCLISTS    =  25,
  DW_SECTION_NUM_SECTIONS
} Dwarf_section_type;
Addition to "Members":
DW_SECTION_DEBUG_TYPE        .debug_types       D_TYPES
DW_SECTION_DEBUG_STROFFS     .debug_str_offsets D_STROFFS
DW_SECTION_DEBUG_ADDR        .debug_addr        D_ADDR
DW_SECTION_DEBUG_LINE_STR    .debug_line_str    D_LINESTR
DW_SECTION_DEBUG_RNGLISTS    .debug_rnglists    D_RNGLISTS
DW_SECTION_DEBUG_LOCLISTS    .debug_loclists    D_LOCLISTS
=======================================================================
Error object consumer operations -> Error handling macros
Addition to the list of error values:

DW_DLE_DEBUG_TYPE_DUPLICATE
    Value = 261. More than one .debug_types section was found.
DW_DLE_DEBUG_TYPE_NULL
    Value = 262. The .debug_types section is present but an error has occurred while retrieving the content.
DW_DLE_STRING_NOT_TERMINATED
    Value = 263. The string is not null terminated.
DW_DLE_READ_ERROR
    Value = 264. Error reading from memory.
DW_DLE_HEADERLEN_BIGGER_THAN_SECSIZE
    Value = 265. The header length is larger than the section size.
DW_DLE_DEBUG_STR_OFFSETS_DUPLICATE
    Value = 266. More than one .debug_str_offsets section was found.
DW_DLE_DEBUG_STR_OFFSETS_NULL
    Value = 267. The .debug_str_offsets section is present but an error has occurred while retrieving the content.
DW_DLE_DEBUG_ADDR_DUPLICATE
    Value = 268. More than one .debug_addr section was found.
DW_DLE_DEBUG_ADDR_NULL
    Value = 269. The .debug_addr section is present but an error has occurred while retrieving the content.
DW_DLE_DEBUG_LINE_STR_DUPLICATE
    Value = 270. More than one .debug_line_str section was found.
DW_DLE_DEBUG_LINE_STR_NULL
    Value = 271. The .debug_line_str section is present but an error has occurred while retrieving the content.
DW_DLE_DEBUG_LINE_STR_ERROR
    Value = 272. An error occurred processing .debug_line_str.
DW_DLE_DEBUG_RNGLISTS_DUPLICATE
    Value = 273. More than one .debug_rnglists section was found.
DW_DLE_DEBUG_RNGLISTS_NULL
    Value = 274. The .debug_rnglists section is present but an error has occurred while retrieving the content.
DW_DLE_DEBUG_LOCLISTS_DUPLICATE
    Value = 275. More than one .debug_loclists section was found.
DW_DLE_DEBUG_LOCLISTS_NULL
    Value = 276. The .debug_loclists section is present but an error has occurred while retrieving the content.

=======================================================================
Non-contiguous address ranges consumer operations -> dwarf_get_ranges_given_offset operation

Update “.debug_ranges section” to “.debug_ranges or .debug_rnglists section”.

=======================================================================
Non-contiguous address ranges consumer operations

Update 2 new APIs:

- dwarf_get_ranges_given_index
The dwarf_get_ranges_given_index operation returns an unordered list of address ranges given an index in the .debug_rnglists section
 
- dwarf_get_ranges_given_die
The dwarf_get_ranges_given_die operation returns an unordered list of address ranges given a DIE with a DW_AT_ranges attribute

----------------------------------------------------------------

dwarf_get_ranges_given_index operation
 
The dwarf_get_ranges_given_index operation returns a unordered list of address ranges given an index in the .debug_rnglists section.

Prototype
int dwarf_get_ranges_given_index (
  Dwarf_Debug           dbg,
  Dwarf_Unsigned        index,
  Dwarf_Ranges**        ret_ranges,
  Dwarf_Unsigned*       ret_count,
  Dwarf_Off*            ret_off,
  Dwarf_Off*            ret_nextoff,
  Dwarf_Error*          error);
Parameters
dbg
    Input. This accepts a libdwarf consumer object.
index
    Input. This accepts the index to use in the .debug_rnglists section.
ret_ranges
    Output. This returns the array of ranges.
ret_count
    Output. This returns the number of entries in the array.
ret_off
    Output. This returns the offset of this entry in the .debug_rnglists section.
ret_nextoff
    Output. This returns the offset of the next entry in the .debug_rnglists section.
error
    Input/output. This accepts or returns the Dwarf_Error object.

Return values
dwarf_get_ranges_given_index returns DW_DLV_NO_ENTRY if either the .debug_info or the .debug_rnglists section is empty.

Memory allocation
You can deallocate the parameters as required.

Example: The following example is a code fragment that deallocates the ret_ranges parameter:
 
if (dwarf_get_ranges_given_index (dbg,...&ret_ranges, &ret_count,...&err)
  == DW_DLV_OK) {
  for (i=0; i<ret_count; i++)
    dwarf_dealloc (dbg, ret_ranges[i], DW_DLA_RANGES);
  dwarf_dealloc (dbg, ret_ranges, DW_DLA_LIST);
}
Note: For reasons of clarity, not all the parameters have been entered in the above code. Unlisted parameters are represented by ellipses (...).

----------------------------------------------------------------

dwarf_get_ranges_given_die operation
 
The dwarf_get_ranges_given_die operation returns a unordered list of address ranges given a DIE with a DW_AT_ranges attribute

Prototype
int dwarf_get_ranges_given_die (
  Dwarf_Debug           dbg,
  Dwarf_Die             die,
  Dwarf_Ranges**        ret_ranges,
  Dwarf_Unsigned*       ret_count,
  Dwarf_Off*            ret_off,
  Dwarf_Off*            ret_nextoff,
  Dwarf_Error*          error);
Parameters
dbg
    Input. This accepts a libdwarf consumer object.
die
    Input. This accepts the DIE with a DW_AT_ranges attribute
ret_ranges
    Output. This returns the array of ranges.
ret_count
    Output. This returns the number of entries in the array.
ret_off
    Output. This returns the offset of this entry in the .debug_rnglists section.
ret_nextoff
    Output. This returns the offset of the next entry in the .debug_rnglists section.
error
    Input/output. This accepts or returns the Dwarf_Error object.

Return values
dwarf_get_ranges_given_die returns DW_DLV_NO_ENTRY if either the .debug_info or the .debug_ranges and .debug_rnglists sections are empty, or if the given DIE does not have a DW_AT_ranges attribute

Memory allocation
You can deallocate the parameters as required.

Example: The following example is a code fragment that deallocates the ret_ranges parameter:
 
if (dwarf_get_ranges_given_die (dbg,...&ret_ranges, &ret_count,...&err)
  == DW_DLV_OK) {
  for (i=0; i<ret_count; i++)
    dwarf_dealloc (dbg, ret_ranges[i], DW_DLA_RANGES);
  dwarf_dealloc (dbg, ret_ranges, DW_DLA_LIST);
}
Note: For reasons of clarity, not all the parameters have been entered in the above code. Unlisted parameters are represented by ellipses (...).

=======================================================================
Update “.debug_ranges section” to “.debug_ranges and .debug_rnglists sections”.

Add new entry:

- String and address consumer operations
This section contains a list of APIs for querying information within the .debug_str, .debug_str_offsets, .debug_line_str, and .debug_addr sections.

----------------------------------------------------------------

String and address consumer operations
 
This section contains a list of APIs for querying information within the .debug_str, .debug_str_offsets, .debug_line_str, and .debug_addr sections.
 
- dwarf_get_str
The dwarf_get_str operation returns a string given an offset in the .debug_str section.
 
- dwarf_get_line_str
The dwarf_get_line_str operation returns a string given an offset in the .debug_line_str section.
 
- dwarf_get_str_offset_given_index
The dwarf_get_str_offset_given_index operation returns a string offset given an index in the .debug_str_offsets section.
 
- dwarf_addr_get_address_given_index
The dwarf_addr_get_ address_given_index operation returns an address and segment selector given an index in the .debug_addr section.

----------------------------------------------------------------

dwarf_get_str operation
 
The dwarf_get_str operation returns a string given an offset in the .debug_str section.

Prototype
int dwarf_get_str(
  Dwarf_Debug           dbg,
  Dwarf_Off             offset,
  char**                ret_string,
  Dwarf_Signed *        ret_strlen,
  Dwarf_Error*          error);
Parameters
dbg
    Input. This accepts a libdwarf consumer object.
offset
    Input. This accepts the string offset in the .debug_str section.
ret_string
    Output. This returns the string
ret_strlen
    Output. This returns the string length
error
    Input/output. This accepts or returns the Dwarf_Error object.

Return values
dwarf_get_str returns DW_DLV_NO_ENTRY if the .debug_str section does not exist, or the offset is one byte beyond the size of .debug_str

Memory allocation
You can deallocate the parameters as required.

Example: The following example is a code fragment that deallocates the ret_string parameter:
 
if (dwarf_get_str (dbg,...&ret_string,...&err) == DW_DLV_OK)
  dwarf_dealloc (dbg, ret_string, DW_DLA_STRING);
}
Note: For reasons of clarity, not all the parameters have been entered in the above code. Unlisted parameters are represented by ellipses (...).

----------------------------------------------------------------

dwarf_get_line_str operation
 
The dwarf_get_line_str operation returns a string given an offset in the .debug_line_str section.

Prototype
int dwarf_get_line_str(
  Dwarf_Debug           dbg,
  Dwarf_Off             offset,
  char**                ret_string,
  Dwarf_Signed *        ret_strlen,
  Dwarf_Error*          error);
Parameters
dbg
    Input. This accepts a libdwarf consumer object.
offset
    Input. This accepts the string offset in the .debug_line_str section.
ret_string
    Output. This returns the string
ret_strlen
    Output. This returns the string length
error
    Input/output. This accepts or returns the Dwarf_Error object.

Return values
dwarf_get_line_str returns DW_DLV_NO_ENTRY if the .debug_line_str section does not exist, or the offset is one byte beyond the size of .debug_line_str

Memory allocation
You can deallocate the parameters as required.

Example: The following example is a code fragment that deallocates the ret_string parameter:
 
if (dwarf_get_line_str (dbg,...&ret_string,...&err) == DW_DLV_OK)
  dwarf_dealloc (dbg, ret_string, DW_DLA_STRING);
}
Note: For reasons of clarity, not all the parameters have been entered in the above code. Unlisted parameters are represented by ellipses (...).

----------------------------------------------------------------

dwarf_get_str_offset_given_index operation
 
The dwarf_get_str_offset_given_index operation returns a string offset given an index in the .debug_str_offsets section.

Prototype
int dwarf_get_str_offset_given_index(
  Dwarf_Die           root_die,
  Dwarf_Unsigned      index,
  Dwarf_Off *         ret_offset,
  Dwarf_Error*        error);
Parameters
root_die
    Input. This accepts the root DIE from the .debug_info section
index
    Input. This accepts the index in the .debug_str_offsets section
ret_offset
    Output. This returns the string offset in the .debug_str section
error
    Input/output. This accepts or returns the Dwarf_Error object.

Return values
dwarf_get_str_offset_given_index returns DW_DLV_NO_ENTRY if the .debug_str_offsets section does not exist, or the index is out of range for the .debug_str_offsets section

----------------------------------------------------------------

dwarf_addr_get_address_given_index operation
 
The dwarf_addr_get_address_given_index operation returns an address and segment selector given an index in the .debug_addr section.

Prototype
int dwarf_addr_get_address_given_index(
  Dwarf_Die           root_die,
  Dwarf_Unsigned      index,
  Dwarf_Unsigned*     ret_seg_selector,
  Dwarf_Off *         ret_addr,
  Dwarf_Error*        error);
Parameters
root_die
Input. This accepts the root DIE from the .debug_info section
index
Input. This accepts the index in the .debug_addr section
ret_seg_selector
Output. This returns the segment selector
ret_addr
Output. This returns the address
error
Input/output. This accepts or returns the Dwarf_Error object.

Return values
dwarf_addr_get_address_given_index returns DW_DLV_NO_ENTRY if the .debug_addr section does not exist, or the index is out of range for the .debug_addr section
 
=======================================================================

[{"Type":"MASTER","Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSTLTF","label":"z\/OS XL C\/C++"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":""}]

Document Information

Modified date:
28 July 2025

UID

ibm17240738