libdwarf
Reading gdbindex data

Example accessing gdbindex section data.

*/
int examplew(Dwarf_Debug dbg,Dwarf_Error *error)
{
Dwarf_Gdbindex gindexptr = 0;
Dwarf_Unsigned version = 0;
Dwarf_Unsigned cu_list_offset = 0;
Dwarf_Unsigned types_cu_list_offset = 0;
Dwarf_Unsigned address_area_offset = 0;
Dwarf_Unsigned symbol_table_offset = 0;
Dwarf_Unsigned constant_pool_offset = 0;
Dwarf_Unsigned section_size = 0;
const char * section_name = 0;
int res = 0;
res = dwarf_gdbindex_header(dbg,&gindexptr,
&version,&cu_list_offset, &types_cu_list_offset,
&address_area_offset,&symbol_table_offset,
&constant_pool_offset, &section_size,
&section_name,error);
if (res != DW_DLV_OK) {
return res;
}
{
/* do something with the data */
Dwarf_Unsigned length = 0;
Dwarf_Unsigned typeslength = 0;
res = dwarf_gdbindex_culist_array(gindexptr,
&length,error);
/* Example actions. */
if (res != DW_DLV_OK) {
return res;
}
for (i = 0; i < length; ++i) {
Dwarf_Unsigned cuoffset = 0;
Dwarf_Unsigned culength = 0;
res = dwarf_gdbindex_culist_entry(gindexptr,
i,&cuoffset,&culength,error);
if (res != DW_DLV_OK) {
return res;
}
/* Do something with cuoffset, culength */
}
&typeslength,error);
if (res != DW_DLV_OK) {
return res;
}
for (i = 0; i < typeslength; ++i) {
Dwarf_Unsigned cuoffset = 0;
Dwarf_Unsigned tuoffset = 0;
Dwarf_Unsigned type_signature = 0;
i,&cuoffset,&tuoffset,&type_signature,error);
if (res != DW_DLV_OK) {
return res;
}
/* Do something with cuoffset etc. */
}
}
return DW_DLV_OK;
}
struct Dwarf_Debug_s * Dwarf_Debug
Definition: libdwarf.h:603
struct Dwarf_Gdbindex_s * Dwarf_Gdbindex
Definition: libdwarf.h:687
struct Dwarf_Error_s * Dwarf_Error
Definition: libdwarf.h:597
unsigned long long Dwarf_Unsigned
Definition: libdwarf.h:196
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.
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.
void dwarf_dealloc_gdbindex(Dwarf_Gdbindex dw_gdbindexptr)
Free (dealloc) all allocated Dwarf_Gdbindex memory It should named dwarf_dealloc_gdbindex.
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.
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.
int dwarf_gdbindex_culist_array(Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned *dw_list_length, Dwarf_Error *dw_error)
Return the culist array length.