libdwarf: Using dwarf_init_path()

libdwarf

Loading...
Searching...
No Matches
Using dwarf_init_path()

Example of a libdwarf initialization call.

Example of a libdwarf initialization call.

An example calling dwarf_init_path() and dwarf_finish()

Parameters

  path | Path to an object we wish to open.
  groupnumber | Desired groupnumber. Use DW_DW_GROUPNUMBER_ANY unless you have reason to do otherwise.

Returns
  Returns the applicable result. DW_DLV_OK etc.

*/
int exampleinit(const char *path, unsigned groupnumber)
{
static char true_pathbuf[FILENAME_MAX];
unsigned tpathlen = FILENAME_MAX;
Dwarf_Handler errhand = 0;
Dwarf_Ptr errarg = 0;
Dwarf_Error error = 0;
Dwarf_Debug dbg = 0;
int res = 0;
res = dwarf_init_path(path,true_pathbuf,
tpathlen,groupnumber,errhand,
errarg,&dbg, &error);
if (res == DW_DLV_ERROR) {
/* Necessary call even though dbg is null!
This avoids a memory leak.
Dwarf_Handler
void(* Dwarf_Handler)(Dwarf_Error dw_error, Dwarf_Ptr dw_errarg)
Definition libdwarf.h:737
Dwarf_Error
struct Dwarf_Error_s * Dwarf_Error
Definition libdwarf.h:611
Dwarf_Debug
struct Dwarf_Debug_s * Dwarf_Debug
Definition libdwarf.h:617
Dwarf_Ptr
void * Dwarf_Ptr
Definition libdwarf.h:208
dwarf_init_path
DW_API int dwarf_init_path(const char *dw_path, char *dw_true_path_out_buffer, unsigned int dw_true_path_bufferlen, unsigned int dw_groupnumber, Dwarf_Handler dw_errhand, Dwarf_Ptr dw_errarg, Dwarf_Debug *dw_dbg, Dwarf_Error *dw_error)
Initialization based on path, the most common initialization.