int dwarf_next_types_section(Dwarf_Debug dbg, Dwarf_Error *error) { /* Free resource allocated for current .debug_types section. */ _dwarf_type_unit_cleanup(dbg); dbg->dbg_types_loaded = 0; dbg->dbg_types_off = 0; /* Reset type unit pointer. */ dbg->dbg_tu_current = NULL; /* Search for the next .debug_types section. */ dbg->dbg_types_sec = _dwarf_find_next_types_section(dbg, dbg->dbg_types_sec); if (dbg->dbg_types_sec == NULL) { DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY); return (DW_DLV_NO_ENTRY); } return (DW_DLV_OK); }
static int _dwarf_consumer_init(Dwarf_Debug dbg, Dwarf_Error *error) { const Dwarf_Obj_Access_Methods *m; Dwarf_Obj_Access_Section sec; void *obj; Dwarf_Unsigned cnt; Dwarf_Half i; int ret; assert(dbg != NULL); assert(dbg->dbg_iface != NULL); m = dbg->dbg_iface->methods; obj = dbg->dbg_iface->object; assert(m != NULL); assert(obj != NULL); if (m->get_byte_order(obj) == DW_OBJECT_MSB) { dbg->read = _dwarf_read_msb; dbg->write = _dwarf_write_msb; dbg->decode = _dwarf_decode_msb; } else { dbg->read = _dwarf_read_lsb; dbg->write = _dwarf_write_lsb; dbg->decode = _dwarf_decode_lsb; } dbg->dbg_pointer_size = m->get_pointer_size(obj); dbg->dbg_offset_size = m->get_length_size(obj); cnt = m->get_section_count(obj); if (cnt == 0) { DWARF_SET_ERROR(dbg, error, DW_DLE_DEBUG_INFO_NULL); return (DW_DLE_DEBUG_INFO_NULL); } dbg->dbg_seccnt = cnt; if ((dbg->dbg_section = calloc(cnt + 1, sizeof(Dwarf_Section))) == NULL) { DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); return (DW_DLE_MEMORY); } for (i = 0; i < cnt; i++) { if (m->get_section_info(obj, i, &sec, &ret) != DW_DLV_OK) { DWARF_SET_ERROR(dbg, error, ret); return (ret); } dbg->dbg_section[i].ds_addr = sec.addr; dbg->dbg_section[i].ds_size = sec.size; dbg->dbg_section[i].ds_name = sec.name; if (m->load_section(obj, i, &dbg->dbg_section[i].ds_data, &ret) != DW_DLV_OK) { DWARF_SET_ERROR(dbg, error, ret); return (ret); } } dbg->dbg_section[cnt].ds_name = NULL; dbg->dbg_info_sec = _dwarf_find_section(dbg, ".debug_info"); /* Try to find the optional DWARF4 .debug_types section. */ dbg->dbg_types_sec = _dwarf_find_next_types_section(dbg, NULL); /* Initialise call frame API related parameters. */ _dwarf_frame_params_init(dbg); return (DW_DLV_OK); }