int dwarf_loclist_from_expr_a(Dwarf_Debug dbg, Dwarf_Ptr bytes_in, Dwarf_Unsigned bytes_len, Dwarf_Half addr_size, Dwarf_Locdesc **llbuf, Dwarf_Signed *listlen, Dwarf_Error *error) { Dwarf_Half offset_size; Dwarf_Small version; /* * Obtain offset size and DWARF version from the current * Compilation Unit or Type Unit. These values are needed * for correctly parsing DW_OP_GNU_implicit_pointer operator. * * Note that dwarf_loclist_from_expr_b() should be used instead * if the application knows correct values for offset size * and DWARF version. */ if (dbg->dbg_cu_current) { offset_size = dbg->dbg_cu_current->cu_length_size == 4 ? 4 : 8; version = dbg->dbg_cu_current->cu_version; } else if (dbg->dbg_tu_current) { offset_size = dbg->dbg_tu_current->cu_length_size == 4 ? 4 : 8; version = dbg->dbg_tu_current->cu_version; } else { /* Default values if no CU/TU context. */ offset_size = 4; version = 2; /* DWARF2 */ } return (dwarf_loclist_from_expr_b(dbg, bytes_in, bytes_len, addr_size, offset_size, version, llbuf, listlen, error)); }
/* New April 27 2009. Adding addr_size argument for the rare cases where an object has CUs with a different address_size. As of 2012 we have yet another version, dwarf_loclist_from_expr_b() with the version_stamp and offset size (length size) passed in. */ int dwarf_loclist_from_expr_a(Dwarf_Debug dbg, Dwarf_Ptr expression_in, Dwarf_Unsigned expression_length, Dwarf_Half addr_size, Dwarf_Locdesc ** llbuf, Dwarf_Signed * listlen, Dwarf_Error * error) { int res; Dwarf_Debug_InfoTypes info_reading = &dbg->de_info_reading; Dwarf_CU_Context current_cu_context = info_reading->de_cu_context; Dwarf_Small version_stamp = DW_CU_VERSION2; Dwarf_Half offset_size = dbg->de_length_size; if (current_cu_context) { /* This is ugly. It is not necessarily right. Due to oddity in DW_OP_GNU_implicit_pointer, see its implementation above. For correctness, use dwarf_loclist_from_expr_b() instead of dwarf_loclist_from_expr_a(). */ version_stamp = current_cu_context->cc_version_stamp; offset_size = current_cu_context->cc_length_size; if (version_stamp < 2) { /* This is probably totally silly. */ version_stamp = DW_CU_VERSION2; } } res = dwarf_loclist_from_expr_b(dbg, expression_in, expression_length, addr_size, offset_size, version_stamp, /* CU context DWARF version */ llbuf, listlen, error); return res; }