| DWARF_OBJECT_INIT(3) | Library Functions Manual | DWARF_OBJECT_INIT(3) |
dwarf_object_init —
allocate a DWARF debug descriptor with application-specific
file access methods
DWARF Access Library (libdwarf, -ldwarf)
#include
<libdwarf.h>
int
dwarf_object_init(Dwarf_Obj_Access_Interface
*iface, Dwarf_Handler errhand,
Dwarf_Ptr errarg, Dwarf_Debug
*dbg, Dwarf_Error *err);
The
dwarf_object_init()
function allocates and returns a Dwarf_Debug instance
that uses application-supplied access methods to read file content.
The argument iface should point to a populated Dwarf_Obj_Access_Interface structure. The contents of the Dwarf_Obj_Access_Interface structure are described in the section Object Access Functions below.
The argument errhand should point to a
function to be called in case of an error. If this argument is
NULL then a default error handling scheme is used.
See dwarf(3) for a description
of the error handling schemes available.
The argument errarg will be passed to the error handler function pointed to by argument errhand.
The argument dbg should point to a memory location that will be set to a reference to the returned Dwarf_Debug descriptor.
The argument err will be used to return a Dwarf_Error descriptor in case of an error.
The data structures used to specify object access methods are
defined in <libdwarf.h>.
typedef struct {
void *object;
const Dwarf_Obj_Access_Methods *methods;
} Dwarf_Obj_Access_Interface;
typedef struct {
int (*get_section_info)(void *obj, Dwarf_Half index,
Dwarf_Obj_Access_Section *ret, int *error);
Dwarf_Endianness (*get_byte_order)(void *obj);
Dwarf_Small (*get_length_size)(void *obj);
Dwarf_Small (*get_pointer_size)(void *obj);
Dwarf_Unsigned (*get_section_count)(void *obj);
int (*load_section)(void *obj, Dwarf_Half ndx,
Dwarf_Small **ret_data, int *error);
} Dwarf_Obj_Access_Methods;
DW_OBJECT_MSB
or DW_OBJECT_LSB.The argument obj passed to these functions will be set to the pointer value in the object field of the associated Dwarf_Obj_Access_Interface structure.
The argument error is used to return an error code in case of an error.
typedef struct {
Dwarf_Addr addr;
Dwarf_Unsigned size;
const char *name;
} Dwarf_Obj_Access_Section;
On success, the dwarf_object_init()
function returns DW_DLV_OK. In case of an error, the
function returns DW_DLV_ERROR and sets the argument
err.
The dwarf_object_init() function may fail
with the following errors:
DW_DLE_ARGUMENT]NULL.DW_DLE_DEBUG_INFO_NULL]DW_DLE_MEMORY]dwarf(3), dwarf_init(3), dwarf_init_elf(3), dwarf_object_finish(3)
| September 29, 2011 | NetBSD 11.0 |