libdwarf
Functions
Fast Access to Gdb Index

Functions

int dwarf_gdbindex_header (Dwarf_Debug dw_dbg, Dwarf_Gdbindex *dw_gdbindexptr, Dwarf_Unsigned *dw_version, Dwarf_Unsigned *dw_cu_list_offset, Dwarf_Unsigned *dw_types_cu_list_offset, Dwarf_Unsigned *dw_address_area_offset, Dwarf_Unsigned *dw_symbol_table_offset, Dwarf_Unsigned *dw_constant_pool_offset, Dwarf_Unsigned *dw_section_size, const char **dw_section_name, Dwarf_Error *dw_error)
 Open access to the .gdb_index section. More...
 
void dwarf_dealloc_gdbindex (Dwarf_Gdbindex dw_gdbindexptr)
 Free (dealloc) all allocated Dwarf_Gdbindex memory It should named dwarf_dealloc_gdbindex. More...
 
int dwarf_gdbindex_culist_array (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned *dw_list_length, Dwarf_Error *dw_error)
 Return the culist array length. More...
 
int dwarf_gdbindex_culist_entry (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned dw_entryindex, Dwarf_Unsigned *dw_cu_offset, Dwarf_Unsigned *dw_cu_length, Dwarf_Error *dw_error)
 For a CU entry in the list return the offset and length. More...
 
int dwarf_gdbindex_types_culist_array (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned *dw_types_list_length, Dwarf_Error *dw_error)
 Return the types culist array length. More...
 
int dwarf_gdbindex_types_culist_entry (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned dw_types_entryindex, Dwarf_Unsigned *dw_cu_offset, Dwarf_Unsigned *dw_tu_offset, Dwarf_Unsigned *dw_type_signature, Dwarf_Error *dw_error)
 For a types CU entry in the list returns the offset and length. More...
 
int dwarf_gdbindex_addressarea (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned *dw_addressarea_list_length, Dwarf_Error *dw_error)
 Get access to gdbindex address area. More...
 
int dwarf_gdbindex_addressarea_entry (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned dw_entryindex, Dwarf_Unsigned *dw_low_address, Dwarf_Unsigned *dw_high_address, Dwarf_Unsigned *dw_cu_index, Dwarf_Error *dw_error)
 Get an address area value. More...
 
int dwarf_gdbindex_symboltable_array (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned *dw_symtab_list_length, Dwarf_Error *dw_error)
 Get access to the symboltable array. More...
 
int dwarf_gdbindex_symboltable_entry (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned dw_entryindex, Dwarf_Unsigned *dw_string_offset, Dwarf_Unsigned *dw_cu_vector_offset, Dwarf_Error *dw_error)
 Access individual symtab entry. More...
 
int dwarf_gdbindex_cuvector_length (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned dw_cuvector_offset, Dwarf_Unsigned *dw_innercount, Dwarf_Error *dw_error)
 Get access to a cuvector. More...
 
int dwarf_gdbindex_cuvector_inner_attributes (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned dw_cuvector_offset_in, Dwarf_Unsigned dw_innerindex, Dwarf_Unsigned *dw_field_value, Dwarf_Error *dw_error)
 Get access to a cuvector. More...
 
int dwarf_gdbindex_cuvector_instance_expand_value (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned dw_field_value, Dwarf_Unsigned *dw_cu_index, Dwarf_Unsigned *dw_symbol_kind, Dwarf_Unsigned *dw_is_static, Dwarf_Error *dw_error)
 Expand the bit fields in a cuvector entry. More...
 
int dwarf_gdbindex_string_by_offset (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned dw_stringoffset, const char **dw_string_ptr, Dwarf_Error *dw_error)
 Retrieve a symbol name from the index data. More...
 

Detailed Description

Section .gdb_index

This is a section created for and used by the GNU gdb debugger to access DWARF information.

Not part of standard DWARF.

See also
https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html#Index-Section-Format

Version 8 built by gdb, so type entries are ok as is. Version 7 built by the 'gold' linker and type index entries for a CU must be derived otherwise, the type index is not correct... Earlier versions cannot be read correctly by the functions here.

The functions here make it possible to print the section content in detail, there is no search function here.

Function Documentation

◆ dwarf_gdbindex_header()

int dwarf_gdbindex_header ( Dwarf_Debug  dw_dbg,
Dwarf_Gdbindex dw_gdbindexptr,
Dwarf_Unsigned dw_version,
Dwarf_Unsigned dw_cu_list_offset,
Dwarf_Unsigned dw_types_cu_list_offset,
Dwarf_Unsigned dw_address_area_offset,
Dwarf_Unsigned dw_symbol_table_offset,
Dwarf_Unsigned dw_constant_pool_offset,
Dwarf_Unsigned dw_section_size,
const char **  dw_section_name,
Dwarf_Error dw_error 
)

The section is a single table one thinks.

See also
Reading gdbindex data
Parameters
dw_dbgThe Dwarf_Debug of interest.
dw_gdbindexptrOn success returns a pointer to make access to table details possible.
dw_versionOn success returns the table version.
dw_cu_list_offsetOn success returns the offset of the cu_list in the section.
dw_types_cu_list_offsetOn success returns the offset of the types cu_list in the section.
dw_address_area_offsetOn success returns the area pool offset.
dw_symbol_table_offsetOn success returns the symbol table offset.
dw_constant_pool_offsetOn success returns the constant pool offset.
dw_section_sizeOn success returns section size.
dw_section_nameOn success returns section name.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc. Returns DW_DLV_NO_ENTRY if the section is absent.

◆ dwarf_dealloc_gdbindex()

void dwarf_dealloc_gdbindex ( Dwarf_Gdbindex  dw_gdbindexptr)
Parameters
dw_gdbindexptrPass in a valid dw_gdbindexptr and on return assign zero to dw_gdbindexptr as it is stale.

◆ dwarf_gdbindex_culist_array()

int dwarf_gdbindex_culist_array ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned dw_list_length,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_list_lengthOn success returns the array length of the cu list.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_culist_entry()

int dwarf_gdbindex_culist_entry ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned  dw_entryindex,
Dwarf_Unsigned dw_cu_offset,
Dwarf_Unsigned dw_cu_length,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_entryindexPass in a number from 0 through dw_list_length-1. If dw_entryindex is too large for the array the function returns DW_DLV_NO_ENTRY.
dw_cu_offsetOn success returns the CU offset for this list entry.
dw_cu_lengthOn success returns the CU length(in bytes) for this list entry.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_types_culist_array()

int dwarf_gdbindex_types_culist_array ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned dw_types_list_length,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_types_list_lengthOn success returns the array length of the types cu list.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_types_culist_entry()

int dwarf_gdbindex_types_culist_entry ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned  dw_types_entryindex,
Dwarf_Unsigned dw_cu_offset,
Dwarf_Unsigned dw_tu_offset,
Dwarf_Unsigned dw_type_signature,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_types_entryindexPass in a number from 0 through dw_list_length-1. If the value is greater than dw_list_length-1 the function returns DW_DLV_NO_ENTRY.
dw_cu_offsetOn success returns the types CU offset for this list entry.
dw_tu_offsetOn success returns the tu offset for this list entry.
dw_type_signatureOn success returns the type unit offset for this entry if the type has a signature.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_addressarea()

int dwarf_gdbindex_addressarea ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned dw_addressarea_list_length,
Dwarf_Error dw_error 
)
See also
Reading gdbindex addressarea
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_addressarea_list_lengthOn success returns the number of entries in the addressarea.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_addressarea_entry()

int dwarf_gdbindex_addressarea_entry ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned  dw_entryindex,
Dwarf_Unsigned dw_low_address,
Dwarf_Unsigned dw_high_address,
Dwarf_Unsigned dw_cu_index,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_entryindexPass in an index, 0 through dw_addressarea_list_length-1. addressarea.
dw_low_addressOn success returns the low address for the entry.
dw_high_addressOn success returns the high address for the entry.
dw_cu_indexOn success returns the index to the cu for the entry.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_symboltable_array()

int dwarf_gdbindex_symboltable_array ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned dw_symtab_list_length,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_symtab_list_lengthOn success returns the number of entries in the symbol table
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_symboltable_entry()

int dwarf_gdbindex_symboltable_entry ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned  dw_entryindex,
Dwarf_Unsigned dw_string_offset,
Dwarf_Unsigned dw_cu_vector_offset,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_entryindexPass in a valid index in the range 0 through dw_symtab_list_length-1 If the value is greater than dw_symtab_list_length-1 the function returns DW_DLV_NO_ENTRY;
dw_string_offsetOn success returns the string offset in the appropriate string section.
dw_cu_vector_offsetOn success returns the CU vector offset.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_cuvector_length()

int dwarf_gdbindex_cuvector_length ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned  dw_cuvector_offset,
Dwarf_Unsigned dw_innercount,
Dwarf_Error dw_error 
)
See also
Reading the gdbindex symbol table
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_cuvector_offsetPass in the offset, dw_cu_vector_offset.
dw_innercountOn success returns the number of CUs in the cuvector instance array.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_cuvector_inner_attributes()

int dwarf_gdbindex_cuvector_inner_attributes ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned  dw_cuvector_offset_in,
Dwarf_Unsigned  dw_innerindex,
Dwarf_Unsigned dw_field_value,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_cuvector_offset_inPass in the value of dw_cuvector_offset
dw_innerindexPass in the index of the CU vector in, from 0 through dw_innercount-1.
dw_field_valueOn success returns a field of bits. To expand the bits call dwarf_gdbindex_cuvector_instance_expand_value.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_cuvector_instance_expand_value()

int dwarf_gdbindex_cuvector_instance_expand_value ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned  dw_field_value,
Dwarf_Unsigned dw_cu_index,
Dwarf_Unsigned dw_symbol_kind,
Dwarf_Unsigned dw_is_static,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_field_valuePass in the dw_field_value returned by dwarf_gdbindex_cuvector_inner_attributes.
dw_cu_indexOn success returns the CU index from the dw_field_value
dw_symbol_kindOn success returns the symbol kind (see the sourceware page. Kinds are TYPE, VARIABLE, or FUNCTION.
dw_is_staticOn success returns non-zero if the entry is a static symbol (file-local, as in C or C++), otherwise it returns non-zero and the symbol is global.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_gdbindex_string_by_offset()

int dwarf_gdbindex_string_by_offset ( Dwarf_Gdbindex  dw_gdbindexptr,
Dwarf_Unsigned  dw_stringoffset,
const char **  dw_string_ptr,
Dwarf_Error dw_error 
)
Parameters
dw_gdbindexptrPass in the Dwarf_Gdbindex pointer of interest.
dw_stringoffsetPass in the string offset returned by dwarf_gdbindex_symboltable_entry
dw_string_ptrOn success returns a a pointer to the null-terminated string.
dw_errorThe usual pointer to return error details.
Returns
Returns DW_DLV_OK etc.