libdwarf: Fast Access to Gdb Index

libdwarf

Loading...
Searching...
No Matches
Functions
Fast Access to Gdb Index

## Functions
DW_API 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.
DW_API void | dwarf_dealloc_gdbindex (Dwarf_Gdbindex dw_gdbindexptr)
| Free (dealloc) all allocated Dwarf_Gdbindex memory It should named dwarf_dealloc_gdbindex.
DW_API int | dwarf_gdbindex_culist_array (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned *dw_list_length, Dwarf_Error *dw_error)
| Return the culist array length.
DW_API 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.
DW_API 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.
DW_API 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.
DW_API int | dwarf_gdbindex_addressarea (Dwarf_Gdbindex dw_gdbindexptr, Dwarf_Unsigned *dw_addressarea_list_length, Dwarf_Error *dw_error)
| Get access to gdbindex address area.
DW_API 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.
DW_API 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.
DW_API 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.
DW_API 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.
DW_API 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.
DW_API 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.
DW_API 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.

## 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_dealloc_gdbindex()

DW_API void dwarf_dealloc_gdbindex | ( | Dwarf_Gdbindex | dw_gdbindexptr | ) |

Free (dealloc) all allocated Dwarf_Gdbindex memory It should named dwarf_dealloc_gdbindex.

Parameters

  dw_gdbindexptr | Pass in a valid dw_gdbindexptr and on return assign zero to dw_gdbindexptr as it is stale.

## ◆ dwarf_gdbindex_addressarea()

DW_API int dwarf_gdbindex_addressarea | ( | Dwarf_Gdbindex | dw_gdbindexptr,
|  | Dwarf_Unsigned * | dw_addressarea_list_length,
|  | Dwarf_Error * | dw_error )

Get access to gdbindex address area.

See also
  Reading gdbindex addressarea

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_addressarea_list_length | On success returns the number of entries in the addressarea.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_addressarea_entry()

DW_API 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.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_entryindex | Pass in an index, 0 through dw_addressarea_list_length-1. addressarea.
  dw_low_address | On success returns the low address for the entry.
  dw_high_address | On success returns the high address for the entry.
  dw_cu_index | On success returns the index to the cu for the entry.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_culist_array()

DW_API int dwarf_gdbindex_culist_array | ( | Dwarf_Gdbindex | dw_gdbindexptr,
|  | Dwarf_Unsigned * | dw_list_length,
|  | Dwarf_Error * | dw_error )

Return the culist array length.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_list_length | On success returns the array length of the cu list.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_culist_entry()

DW_API 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.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_entryindex | Pass 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_offset | On success returns the CU offset for this list entry.
  dw_cu_length | On success returns the CU length(in bytes) for this list entry.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_cuvector_inner_attributes()

DW_API 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.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_cuvector_offset_in | Pass in the value of dw_cuvector_offset
  dw_innerindex | Pass in the index of the CU vector in, from 0 through dw_innercount-1.
  dw_field_value | On success returns a field of bits. To expand the bits call dwarf_gdbindex_cuvector_instance_expand_value.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_cuvector_instance_expand_value()

DW_API 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.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_field_value | Pass in the dw_field_value returned by dwarf_gdbindex_cuvector_inner_attributes.
  dw_cu_index | On success returns the CU index from the dw_field_value
  dw_symbol_kind | On success returns the symbol kind (see the sourceware page. Kinds are TYPE, VARIABLE, or FUNCTION.
  dw_is_static | On 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_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_cuvector_length()

DW_API 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.

See also
  Reading the gdbindex symbol table

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_cuvector_offset | Pass in the offset, dw_cu_vector_offset.
  dw_innercount | On success returns the number of CUs in the cuvector instance array.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_header()

DW_API 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.

The section is a single table one thinks.

See also
  Reading gdbindex data

Parameters

  dw_dbg | The Dwarf_Debug of interest.
  dw_gdbindexptr | On success returns a pointer to make access to table details possible.
  dw_version | On success returns the table version.
  dw_cu_list_offset | On success returns the offset of the cu_list in the section.
  dw_types_cu_list_offset | On success returns the offset of the types cu_list in the section.
  dw_address_area_offset | On success returns the area pool offset.
  dw_symbol_table_offset | On success returns the symbol table offset.
  dw_constant_pool_offset | On success returns the constant pool offset.
  dw_section_size | On success returns section size.
  dw_section_name | On success returns section name.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc. Returns DW_DLV_NO_ENTRY if the section is absent.

## ◆ dwarf_gdbindex_string_by_offset()

DW_API 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.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_stringoffset | Pass in the string offset returned by dwarf_gdbindex_symboltable_entry
  dw_string_ptr | On success returns a a pointer to the null-terminated string.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_symboltable_array()

DW_API 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.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_symtab_list_length | On success returns the number of entries in the symbol table
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_symboltable_entry()

DW_API 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.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_entryindex | Pass 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_offset | On success returns the string offset in the appropriate string section.
  dw_cu_vector_offset | On success returns the CU vector offset.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_types_culist_array()

DW_API 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.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_types_list_length | On success returns the array length of the types cu list.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_gdbindex_types_culist_entry()

DW_API 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.

Parameters

  dw_gdbindexptr | Pass in the Dwarf_Gdbindex pointer of interest.
  dw_types_entryindex | Pass 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_offset | On success returns the types CU offset for this list entry.
  dw_tu_offset | On success returns the tu offset for this list entry.
  dw_type_signature | On success returns the type unit offset for this entry if the type has a signature.
  dw_error | The usual pointer to return error details.

Returns
  Returns DW_DLV_OK etc.