Changeset 75238 in vbox
- Timestamp:
- Nov 3, 2018 2:53:46 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.kmk
r75105 r75238 1800 1800 $(SED) -f include/VBox/err.sed --output include/iprt/err.mac include/iprt/err.h 1801 1801 $(SED) -f include/VBox/various.sed --output include/iprt/x86.mac include/iprt/x86.h 1802 $(SED) -f include/VBox/various.sed --output include/iprt/formats/dwarf.mac include/iprt/formats/dwarf.h 1802 1803 $(APPEND) include/iprt/x86.mac '%include "iprt/x86extra.mac"' 1803 1804 $(SED) -f include/VBox/various.sed --output include/VBox/apic.mac include/VBox/apic.h -
trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp
r75236 r75238 47 47 #include <iprt/strcache.h> 48 48 #include <iprt/x86.h> 49 #include <iprt/formats/dwarf.h> 49 50 #include "internal/dbgmod.h" 50 51 51 52 /*********************************************************************************************************************************53 * Defined Constants And Macros *54 *********************************************************************************************************************************/55 /** @name Standard DWARF Line Number Opcodes56 * @{ */57 #define DW_LNS_extended UINT8_C(0x00)58 #define DW_LNS_copy UINT8_C(0x01)59 #define DW_LNS_advance_pc UINT8_C(0x02)60 #define DW_LNS_advance_line UINT8_C(0x03)61 #define DW_LNS_set_file UINT8_C(0x04)62 #define DW_LNS_set_column UINT8_C(0x05)63 #define DW_LNS_negate_stmt UINT8_C(0x06)64 #define DW_LNS_set_basic_block UINT8_C(0x07)65 #define DW_LNS_const_add_pc UINT8_C(0x08)66 #define DW_LNS_fixed_advance_pc UINT8_C(0x09)67 #define DW_LNS_set_prologue_end UINT8_C(0x0a)68 #define DW_LNS_set_epilogue_begin UINT8_C(0x0b)69 #define DW_LNS_set_isa UINT8_C(0x0c)70 #define DW_LNS_what_question_mark UINT8_C(0x0d)71 /** @} */72 73 74 /** @name Extended DWARF Line Number Opcodes75 * @{ */76 #define DW_LNE_end_sequence UINT8_C(1)77 #define DW_LNE_set_address UINT8_C(2)78 #define DW_LNE_define_file UINT8_C(3)79 #define DW_LNE_set_descriminator UINT8_C(4)80 /** @} */81 82 /** @name DIE Tags.83 * @{ */84 #define DW_TAG_array_type UINT16_C(0x0001)85 #define DW_TAG_class_type UINT16_C(0x0002)86 #define DW_TAG_entry_point UINT16_C(0x0003)87 #define DW_TAG_enumeration_type UINT16_C(0x0004)88 #define DW_TAG_formal_parameter UINT16_C(0x0005)89 #define DW_TAG_imported_declaration UINT16_C(0x0008)90 #define DW_TAG_label UINT16_C(0x000a)91 #define DW_TAG_lexical_block UINT16_C(0x000b)92 #define DW_TAG_member UINT16_C(0x000d)93 #define DW_TAG_pointer_type UINT16_C(0x000f)94 #define DW_TAG_reference_type UINT16_C(0x0010)95 #define DW_TAG_compile_unit UINT16_C(0x0011)96 #define DW_TAG_string_type UINT16_C(0x0012)97 #define DW_TAG_structure_type UINT16_C(0x0013)98 #define DW_TAG_subroutine_type UINT16_C(0x0015)99 #define DW_TAG_typedef UINT16_C(0x0016)100 #define DW_TAG_union_type UINT16_C(0x0017)101 #define DW_TAG_unspecified_parameters UINT16_C(0x0018)102 #define DW_TAG_variant UINT16_C(0x0019)103 #define DW_TAG_common_block UINT16_C(0x001a)104 #define DW_TAG_common_inclusion UINT16_C(0x001b)105 #define DW_TAG_inheritance UINT16_C(0x001c)106 #define DW_TAG_inlined_subroutine UINT16_C(0x001d)107 #define DW_TAG_module UINT16_C(0x001e)108 #define DW_TAG_ptr_to_member_type UINT16_C(0x001f)109 #define DW_TAG_set_type UINT16_C(0x0020)110 #define DW_TAG_subrange_type UINT16_C(0x0021)111 #define DW_TAG_with_stmt UINT16_C(0x0022)112 #define DW_TAG_access_declaration UINT16_C(0x0023)113 #define DW_TAG_base_type UINT16_C(0x0024)114 #define DW_TAG_catch_block UINT16_C(0x0025)115 #define DW_TAG_const_type UINT16_C(0x0026)116 #define DW_TAG_constant UINT16_C(0x0027)117 #define DW_TAG_enumerator UINT16_C(0x0028)118 #define DW_TAG_file_type UINT16_C(0x0029)119 #define DW_TAG_friend UINT16_C(0x002a)120 #define DW_TAG_namelist UINT16_C(0x002b)121 #define DW_TAG_namelist_item UINT16_C(0x002c)122 #define DW_TAG_packed_type UINT16_C(0x002d)123 #define DW_TAG_subprogram UINT16_C(0x002e)124 #define DW_TAG_template_type_parameter UINT16_C(0x002f)125 #define DW_TAG_template_value_parameter UINT16_C(0x0030)126 #define DW_TAG_thrown_type UINT16_C(0x0031)127 #define DW_TAG_try_block UINT16_C(0x0032)128 #define DW_TAG_variant_part UINT16_C(0x0033)129 #define DW_TAG_variable UINT16_C(0x0034)130 #define DW_TAG_volatile_type UINT16_C(0x0035)131 #define DW_TAG_dwarf_procedure UINT16_C(0x0036)132 #define DW_TAG_restrict_type UINT16_C(0x0037)133 #define DW_TAG_interface_type UINT16_C(0x0038)134 #define DW_TAG_namespace UINT16_C(0x0039)135 #define DW_TAG_imported_module UINT16_C(0x003a)136 #define DW_TAG_unspecified_type UINT16_C(0x003b)137 #define DW_TAG_partial_unit UINT16_C(0x003c)138 #define DW_TAG_imported_unit UINT16_C(0x003d)139 #define DW_TAG_condition UINT16_C(0x003f)140 #define DW_TAG_shared_type UINT16_C(0x0040)141 #define DW_TAG_type_unit UINT16_C(0x0041)142 #define DW_TAG_rvalue_reference_type UINT16_C(0x0042)143 #define DW_TAG_template_alias UINT16_C(0x0043)144 #define DW_TAG_lo_user UINT16_C(0x4080)145 #define DW_TAG_GNU_call_site UINT16_C(0x4109)146 #define DW_TAG_GNU_call_site_parameter UINT16_C(0x410a)147 #define DW_TAG_WATCOM_address_class_type UINT16_C(0x4100) /**< Watcom extension. */148 #define DW_TAG_WATCOM_namespace UINT16_C(0x4101) /**< Watcom extension. */149 #define DW_TAG_hi_user UINT16_C(0xffff)150 /** @} */151 152 153 /** @name DIE Attributes.154 * @{ */155 #define DW_AT_sibling UINT16_C(0x0001)156 #define DW_AT_location UINT16_C(0x0002)157 #define DW_AT_name UINT16_C(0x0003)158 #define DW_AT_ordering UINT16_C(0x0009)159 #define DW_AT_byte_size UINT16_C(0x000b)160 #define DW_AT_bit_offset UINT16_C(0x000c)161 #define DW_AT_bit_size UINT16_C(0x000d)162 #define DW_AT_stmt_list UINT16_C(0x0010)163 #define DW_AT_low_pc UINT16_C(0x0011)164 #define DW_AT_high_pc UINT16_C(0x0012)165 #define DW_AT_language UINT16_C(0x0013)166 #define DW_AT_discr UINT16_C(0x0015)167 #define DW_AT_discr_value UINT16_C(0x0016)168 #define DW_AT_visibility UINT16_C(0x0017)169 #define DW_AT_import UINT16_C(0x0018)170 #define DW_AT_string_length UINT16_C(0x0019)171 #define DW_AT_common_reference UINT16_C(0x001a)172 #define DW_AT_comp_dir UINT16_C(0x001b)173 #define DW_AT_const_value UINT16_C(0x001c)174 #define DW_AT_containing_type UINT16_C(0x001d)175 #define DW_AT_default_value UINT16_C(0x001e)176 #define DW_AT_inline UINT16_C(0x0020)177 #define DW_AT_is_optional UINT16_C(0x0021)178 #define DW_AT_lower_bound UINT16_C(0x0022)179 #define DW_AT_producer UINT16_C(0x0025)180 #define DW_AT_prototyped UINT16_C(0x0027)181 #define DW_AT_return_addr UINT16_C(0x002a)182 #define DW_AT_start_scope UINT16_C(0x002c)183 #define DW_AT_bit_stride UINT16_C(0x002e)184 #define DW_AT_upper_bound UINT16_C(0x002f)185 #define DW_AT_abstract_origin UINT16_C(0x0031)186 #define DW_AT_accessibility UINT16_C(0x0032)187 #define DW_AT_address_class UINT16_C(0x0033)188 #define DW_AT_artificial UINT16_C(0x0034)189 #define DW_AT_base_types UINT16_C(0x0035)190 #define DW_AT_calling_convention UINT16_C(0x0036)191 #define DW_AT_count UINT16_C(0x0037)192 #define DW_AT_data_member_location UINT16_C(0x0038)193 #define DW_AT_decl_column UINT16_C(0x0039)194 #define DW_AT_decl_file UINT16_C(0x003a)195 #define DW_AT_decl_line UINT16_C(0x003b)196 #define DW_AT_declaration UINT16_C(0x003c)197 #define DW_AT_discr_list UINT16_C(0x003d)198 #define DW_AT_encoding UINT16_C(0x003e)199 #define DW_AT_external UINT16_C(0x003f)200 #define DW_AT_frame_base UINT16_C(0x0040)201 #define DW_AT_friend UINT16_C(0x0041)202 #define DW_AT_identifier_case UINT16_C(0x0042)203 #define DW_AT_macro_info UINT16_C(0x0043)204 #define DW_AT_namelist_item UINT16_C(0x0044)205 #define DW_AT_priority UINT16_C(0x0045)206 #define DW_AT_segment UINT16_C(0x0046)207 #define DW_AT_specification UINT16_C(0x0047)208 #define DW_AT_static_link UINT16_C(0x0048)209 #define DW_AT_type UINT16_C(0x0049)210 #define DW_AT_use_location UINT16_C(0x004a)211 #define DW_AT_variable_parameter UINT16_C(0x004b)212 #define DW_AT_virtuality UINT16_C(0x004c)213 #define DW_AT_vtable_elem_location UINT16_C(0x004d)214 #define DW_AT_allocated UINT16_C(0x004e)215 #define DW_AT_associated UINT16_C(0x004f)216 #define DW_AT_data_location UINT16_C(0x0050)217 #define DW_AT_byte_stride UINT16_C(0x0051)218 #define DW_AT_entry_pc UINT16_C(0x0052)219 #define DW_AT_use_UTF8 UINT16_C(0x0053)220 #define DW_AT_extension UINT16_C(0x0054)221 #define DW_AT_ranges UINT16_C(0x0055)222 #define DW_AT_trampoline UINT16_C(0x0056)223 #define DW_AT_call_column UINT16_C(0x0057)224 #define DW_AT_call_file UINT16_C(0x0058)225 #define DW_AT_call_line UINT16_C(0x0059)226 #define DW_AT_description UINT16_C(0x005a)227 #define DW_AT_binary_scale UINT16_C(0x005b)228 #define DW_AT_decimal_scale UINT16_C(0x005c)229 #define DW_AT_small UINT16_C(0x005d)230 #define DW_AT_decimal_sign UINT16_C(0x005e)231 #define DW_AT_digit_count UINT16_C(0x005f)232 #define DW_AT_picture_string UINT16_C(0x0060)233 #define DW_AT_mutable UINT16_C(0x0061)234 #define DW_AT_threads_scaled UINT16_C(0x0062)235 #define DW_AT_explicit UINT16_C(0x0063)236 #define DW_AT_object_pointer UINT16_C(0x0064)237 #define DW_AT_endianity UINT16_C(0x0065)238 #define DW_AT_elemental UINT16_C(0x0066)239 #define DW_AT_pure UINT16_C(0x0067)240 #define DW_AT_recursive UINT16_C(0x0068)241 #define DW_AT_signature UINT16_C(0x0069)242 #define DW_AT_main_subprogram UINT16_C(0x006a)243 #define DW_AT_data_bit_offset UINT16_C(0x006b)244 #define DW_AT_const_expr UINT16_C(0x006c)245 #define DW_AT_enum_class UINT16_C(0x006d)246 #define DW_AT_linkage_name UINT16_C(0x006e)247 #define DW_AT_lo_user UINT16_C(0x2000)248 /** Used by GCC and others, same as DW_AT_linkage_name. See http://wiki.dwarfstd.org/index.php?title=DW_AT_linkage_name*/249 #define DW_AT_MIPS_linkage_name UINT16_C(0x2007)250 #define DW_AT_WATCOM_memory_model UINT16_C(0x2082) /**< Watcom extension. */251 #define DW_AT_WATCOM_references_start UINT16_C(0x2083) /**< Watcom extension. */252 #define DW_AT_WATCOM_parm_entry UINT16_C(0x2084) /**< Watcom extension. */253 #define DW_AT_hi_user UINT16_C(0x3fff)254 /** @} */255 256 /** @name DIE Forms.257 * @{ */258 #define DW_FORM_addr UINT16_C(0x01)259 /* 0x02 was FORM_REF in DWARF v1, obsolete now. */260 #define DW_FORM_block2 UINT16_C(0x03)261 #define DW_FORM_block4 UINT16_C(0x04)262 #define DW_FORM_data2 UINT16_C(0x05)263 #define DW_FORM_data4 UINT16_C(0x06)264 #define DW_FORM_data8 UINT16_C(0x07)265 #define DW_FORM_string UINT16_C(0x08)266 #define DW_FORM_block UINT16_C(0x09)267 #define DW_FORM_block1 UINT16_C(0x0a)268 #define DW_FORM_data1 UINT16_C(0x0b)269 #define DW_FORM_flag UINT16_C(0x0c)270 #define DW_FORM_sdata UINT16_C(0x0d)271 #define DW_FORM_strp UINT16_C(0x0e)272 #define DW_FORM_udata UINT16_C(0x0f)273 #define DW_FORM_ref_addr UINT16_C(0x10)274 #define DW_FORM_ref1 UINT16_C(0x11)275 #define DW_FORM_ref2 UINT16_C(0x12)276 #define DW_FORM_ref4 UINT16_C(0x13)277 #define DW_FORM_ref8 UINT16_C(0x14)278 #define DW_FORM_ref_udata UINT16_C(0x15)279 #define DW_FORM_indirect UINT16_C(0x16)280 #define DW_FORM_sec_offset UINT16_C(0x17)281 #define DW_FORM_exprloc UINT16_C(0x18)282 #define DW_FORM_flag_present UINT16_C(0x19)283 #define DW_FORM_ref_sig8 UINT16_C(0x20)284 /** @} */285 286 /** @name Address classes.287 * @{ */288 #define DW_ADDR_none UINT8_C(0)289 #define DW_ADDR_i386_near16 UINT8_C(1)290 #define DW_ADDR_i386_far16 UINT8_C(2)291 #define DW_ADDR_i386_huge16 UINT8_C(3)292 #define DW_ADDR_i386_near32 UINT8_C(4)293 #define DW_ADDR_i386_far32 UINT8_C(5)294 /** @} */295 296 297 /** @name Location Expression Opcodes298 * @{ */299 #define DW_OP_addr UINT8_C(0x03) /**< 1 operand, a constant address (size target specific). */300 #define DW_OP_deref UINT8_C(0x06) /**< 0 operands. */301 #define DW_OP_const1u UINT8_C(0x08) /**< 1 operand, a 1-byte constant. */302 #define DW_OP_const1s UINT8_C(0x09) /**< 1 operand, a 1-byte constant. */303 #define DW_OP_const2u UINT8_C(0x0a) /**< 1 operand, a 2-byte constant. */304 #define DW_OP_const2s UINT8_C(0x0b) /**< 1 operand, a 2-byte constant. */305 #define DW_OP_const4u UINT8_C(0x0c) /**< 1 operand, a 4-byte constant. */306 #define DW_OP_const4s UINT8_C(0x0d) /**< 1 operand, a 4-byte constant. */307 #define DW_OP_const8u UINT8_C(0x0e) /**< 1 operand, a 8-byte constant. */308 #define DW_OP_const8s UINT8_C(0x0f) /**< 1 operand, a 8-byte constant. */309 #define DW_OP_constu UINT8_C(0x10) /**< 1 operand, a ULEB128 constant. */310 #define DW_OP_consts UINT8_C(0x11) /**< 1 operand, a SLEB128 constant. */311 #define DW_OP_dup UINT8_C(0x12) /**< 0 operands. */312 #define DW_OP_drop UINT8_C(0x13) /**< 0 operands. */313 #define DW_OP_over UINT8_C(0x14) /**< 0 operands. */314 #define DW_OP_pick UINT8_C(0x15) /**< 1 operands, a 1-byte stack index. */315 #define DW_OP_swap UINT8_C(0x16) /**< 0 operands. */316 #define DW_OP_rot UINT8_C(0x17) /**< 0 operands. */317 #define DW_OP_xderef UINT8_C(0x18) /**< 0 operands. */318 #define DW_OP_abs UINT8_C(0x19) /**< 0 operands. */319 #define DW_OP_and UINT8_C(0x1a) /**< 0 operands. */320 #define DW_OP_div UINT8_C(0x1b) /**< 0 operands. */321 #define DW_OP_minus UINT8_C(0x1c) /**< 0 operands. */322 #define DW_OP_mod UINT8_C(0x1d) /**< 0 operands. */323 #define DW_OP_mul UINT8_C(0x1e) /**< 0 operands. */324 #define DW_OP_neg UINT8_C(0x1f) /**< 0 operands. */325 #define DW_OP_not UINT8_C(0x20) /**< 0 operands. */326 #define DW_OP_or UINT8_C(0x21) /**< 0 operands. */327 #define DW_OP_plus UINT8_C(0x22) /**< 0 operands. */328 #define DW_OP_plus_uconst UINT8_C(0x23) /**< 1 operands, a ULEB128 addend. */329 #define DW_OP_shl UINT8_C(0x24) /**< 0 operands. */330 #define DW_OP_shr UINT8_C(0x25) /**< 0 operands. */331 #define DW_OP_shra UINT8_C(0x26) /**< 0 operands. */332 #define DW_OP_xor UINT8_C(0x27) /**< 0 operands. */333 #define DW_OP_skip UINT8_C(0x2f) /**< 1 signed 2-byte constant. */334 #define DW_OP_bra UINT8_C(0x28) /**< 1 signed 2-byte constant. */335 #define DW_OP_eq UINT8_C(0x29) /**< 0 operands. */336 #define DW_OP_ge UINT8_C(0x2a) /**< 0 operands. */337 #define DW_OP_gt UINT8_C(0x2b) /**< 0 operands. */338 #define DW_OP_le UINT8_C(0x2c) /**< 0 operands. */339 #define DW_OP_lt UINT8_C(0x2d) /**< 0 operands. */340 #define DW_OP_ne UINT8_C(0x2e) /**< 0 operands. */341 #define DW_OP_lit0 UINT8_C(0x30) /**< 0 operands - literals 0..31 */342 #define DW_OP_lit31 UINT8_C(0x4f) /**< last litteral. */343 #define DW_OP_reg0 UINT8_C(0x50) /**< 0 operands - reg 0..31. */344 #define DW_OP_reg31 UINT8_C(0x6f) /**< last register. */345 #define DW_OP_breg0 UINT8_C(0x70) /**< 1 operand, a SLEB128 offset. */346 #define DW_OP_breg31 UINT8_C(0x8f) /**< last branch register. */347 #define DW_OP_regx UINT8_C(0x90) /**< 1 operand, a ULEB128 register. */348 #define DW_OP_fbreg UINT8_C(0x91) /**< 1 operand, a SLEB128 offset. */349 #define DW_OP_bregx UINT8_C(0x92) /**< 2 operands, a ULEB128 register followed by a SLEB128 offset. */350 #define DW_OP_piece UINT8_C(0x93) /**< 1 operand, a ULEB128 size of piece addressed. */351 #define DW_OP_deref_size UINT8_C(0x94) /**< 1 operand, a 1-byte size of data retrieved. */352 #define DW_OP_xderef_size UINT8_C(0x95) /**< 1 operand, a 1-byte size of data retrieved. */353 #define DW_OP_nop UINT8_C(0x96) /**< 0 operands. */354 #define DW_OP_lo_user UINT8_C(0xe0) /**< First user opcode */355 #define DW_OP_hi_user UINT8_C(0xff) /**< Last user opcode. */356 /** @} */357 358 /** @name Exception Handler Pointer Encodings (GCC/LSB).359 * @{ */360 #define DW_EH_PE_FORMAT_MASK UINT8_C(0x0f) /**< Format mask. */361 #define DW_EH_PE_APPL_MASK UINT8_C(0x70) /**< Application mask. */362 #define DW_EH_PE_indirect UINT8_C(0x80) /**< Flag: Indirect pointer. */363 #define DW_EH_PE_omit UINT8_C(0xff) /**< Special value: Omitted. */364 #define DW_EH_PE_ptr UINT8_C(0x00) /**< Format: pointer sized, unsigned. */365 #define DW_EH_PE_uleb128 UINT8_C(0x01) /**< Format: unsigned LEB128. */366 #define DW_EH_PE_udata2 UINT8_C(0x02) /**< Format: unsigned 16-bit. */367 #define DW_EH_PE_udata4 UINT8_C(0x03) /**< Format: unsigned 32-bit. */368 #define DW_EH_PE_udata8 UINT8_C(0x04) /**< Format: unsigned 64-bit. */369 #define DW_EH_PE_sleb128 UINT8_C(0x09) /**< Format: signed LEB128. */370 #define DW_EH_PE_sdata2 UINT8_C(0x0a) /**< Format: signed 16-bit. */371 #define DW_EH_PE_sdata4 UINT8_C(0x0b) /**< Format: signed 32-bit. */372 #define DW_EH_PE_sdata8 UINT8_C(0x0c) /**< Format: signed 64-bit. */373 #define DW_EH_PE_absptr UINT8_C(0x00) /**< Application: Absolute */374 #define DW_EH_PE_pcrel UINT8_C(0x10) /**< Application: PC relative, i.e. relative pointer address. */375 #define DW_EH_PE_textrel UINT8_C(0x20) /**< Application: text section relative. */376 #define DW_EH_PE_datarel UINT8_C(0x30) /**< Application: data section relative. */377 #define DW_EH_PE_funcrel UINT8_C(0x40) /**< Application: relative to start of function. */378 #define DW_EH_PE_aligned UINT8_C(0x50) /**< Application: aligned pointer. */379 /** @} */380 381 /** @name Call frame instructions.382 * @{ */383 /** Mask to use to identify DW_CFA_advance_loc, DW_CFA_offset and DW_CFA_restore. */384 #define DW_CFA_high_bit_mask UINT8_C(0xc0)385 386 #define DW_CFA_nop UINT8_C(0x00) /**< No operands. */387 388 #define DW_CFA_advance_loc UINT8_C(0x40) /**< low 6 bits: delta to advance. */389 #define DW_CFA_set_loc UINT8_C(0x01) /**< op1: address. */390 #define DW_CFA_advance_loc1 UINT8_C(0x02) /**< op1: 1-byte delta. */391 #define DW_CFA_advance_loc2 UINT8_C(0x03) /**< op1: 2-byte delta. */392 #define DW_CFA_advance_loc4 UINT8_C(0x04) /**< op1: 4-byte delta. */393 394 #define DW_CFA_offset UINT8_C(0x80) /**< low 6 bits: register; op1: ULEB128 offset. */395 #define DW_CFA_offset_extended UINT8_C(0x05) /**< op1: ULEB128 register; op2: ULEB128 offset. */396 #define DW_CFA_offset_extended_sf UINT8_C(0x11) /**< op1: ULEB128 register; op2: SLEB128 offset. */397 #define DW_CFA_restore UINT8_C(0xc0) /**< low 6 bits: register. */398 #define DW_CFA_restore_extended UINT8_C(0x06) /**< op1: ULEB128 register. */399 #define DW_CFA_undefined UINT8_C(0x07) /**< op1: ULEB128 register. */400 #define DW_CFA_same_value UINT8_C(0x08) /**< op1: ULEB128 register. */401 #define DW_CFA_register UINT8_C(0x09) /**< op1: ULEB128 destination register; op2: ULEB128 source register. */402 #define DW_CFA_expression UINT8_C(0x10) /**< op1: ULEB128 register; op2: BLOCK. */403 404 #define DW_CFA_val_offset UINT8_C(0x14) /**< op1: ULEB128 register; op2: ULEB128. */405 #define DW_CFA_val_offset_sf UINT8_C(0x15) /**< op1: ULEB128 register; op2: SLEB128. */406 #define DW_CFA_val_expression UINT8_C(0x16) /**< op1: ULEB128 register; op2: BLOCK. */407 408 #define DW_CFA_remember_state UINT8_C(0x0a) /**< No operands. */409 #define DW_CFA_restore_state UINT8_C(0x0b) /**< No operands. */410 411 #define DW_CFA_def_cfa UINT8_C(0x0c) /**< op1: ULEB128 register; op2: ULEB128 offset. */412 #define DW_CFA_def_cfa_register UINT8_C(0x0d) /**< op1: ULEB128 register. */413 #define DW_CFA_def_cfa_offset UINT8_C(0x0e) /**< op1: ULEB128 offset. */414 #define DW_CFA_def_cfa_expression UINT8_C(0x0f) /**< op1: BLOCK. */415 #define DW_CFA_def_cfa_sf UINT8_C(0x12) /**< op1: ULEB128 register; op2: SLEB128 offset. */416 #define DW_CFA_def_cfa_offset_sf UINT8_C(0x13) /**< op1: SLEB128 offset. */417 418 #define DW_CFA_lo_user UINT8_C(0x1c) /**< User defined operands. */419 #define DW_CFA_MIPS_advance_loc8 UINT8_C(0x1d) /**< op1: 8-byte delta? */420 #define DW_CFA_GNU_window_save UINT8_C(0x2d) /**< op1: ??; op2: ?? */421 #define DW_CFA_GNU_args_size UINT8_C(0x2e) /**< op1: ??; op2: ?? */422 #define DW_CFA_GNU_negative_offset_extended UINT8_C(0x2f) /**< op1: ??; op2: ?? */423 #define DW_CFA_hi_user UINT8_C(0x3f) /**< User defined operands. */424 /** @} */425 426 427 /** @name DWREG_X86_XXX - 386+ register number mappings.428 * @{ */429 #define DWREG_X86_EAX 0430 #define DWREG_X86_ECX 1431 #define DWREG_X86_EDX 2432 #define DWREG_X86_EBX 3433 #define DWREG_X86_ESP 4434 #define DWREG_X86_EBP 5435 #define DWREG_X86_ESI 6436 #define DWREG_X86_EDI 7437 #define DWREG_X86_RA 8 /* return address (=EIP) */438 #define DWREG_X86_EFLAGS 9439 #define DWREG_X86_ST1 11440 #define DWREG_X86_ST2 12441 #define DWREG_X86_ST3 13442 #define DWREG_X86_ST4 14443 #define DWREG_X86_ST5 15444 #define DWREG_X86_ST6 16445 #define DWREG_X86_ST7 17446 #define DWREG_X86_XMM0 21447 #define DWREG_X86_XMM1 22448 #define DWREG_X86_XMM2 23449 #define DWREG_X86_XMM3 24450 #define DWREG_X86_XMM4 25451 #define DWREG_X86_XMM5 26452 #define DWREG_X86_XMM6 27453 #define DWREG_X86_XMM7 28454 #define DWREG_X86_MM0 29455 #define DWREG_X86_MM1 30456 #define DWREG_X86_MM2 31457 #define DWREG_X86_MM3 32458 #define DWREG_X86_MM4 33459 #define DWREG_X86_MM5 34460 #define DWREG_X86_MM6 35461 #define DWREG_X86_MM7 36462 #define DWREG_X86_MXCSR 39463 #define DWREG_X86_ES 40464 #define DWREG_X86_CS 41465 #define DWREG_X86_SS 42466 #define DWREG_X86_DS 43467 #define DWREG_X86_FS 44468 #define DWREG_X86_GS 45469 #define DWREG_X86_TR 48470 #define DWREG_X86_LDTR 49471 /** @} */472 473 474 /** @name DWREG_AMD64_XXX - AMD64 register number mappings.475 * @note This for some braindead reason the first 8 GPR are in intel encoding476 * order, unlike the DWREG_X86_XXX variant. Utter stupidity.477 * @{ */478 #define DWREG_AMD64_RAX 0479 #define DWREG_AMD64_RDX 1480 #define DWREG_AMD64_RCX 2481 #define DWREG_AMD64_RBX 3482 #define DWREG_AMD64_RSI 4483 #define DWREG_AMD64_RDI 5484 #define DWREG_AMD64_RBP 6485 #define DWREG_AMD64_RSP 7486 #define DWREG_AMD64_R8 8487 #define DWREG_AMD64_R9 9488 #define DWREG_AMD64_R10 10489 #define DWREG_AMD64_R11 11490 #define DWREG_AMD64_R12 12491 #define DWREG_AMD64_R13 13492 #define DWREG_AMD64_R14 14493 #define DWREG_AMD64_R15 15494 #define DWREG_AMD64_RA 16 /* return address (=RIP) */495 #define DWREG_AMD64_XMM0 17496 #define DWREG_AMD64_XMM1 18497 #define DWREG_AMD64_XMM2 19498 #define DWREG_AMD64_XMM3 20499 #define DWREG_AMD64_XMM4 21500 #define DWREG_AMD64_XMM5 22501 #define DWREG_AMD64_XMM6 23502 #define DWREG_AMD64_XMM7 24503 #define DWREG_AMD64_XMM8 25504 #define DWREG_AMD64_XMM9 26505 #define DWREG_AMD64_XMM10 27506 #define DWREG_AMD64_XMM11 28507 #define DWREG_AMD64_XMM12 29508 #define DWREG_AMD64_XMM13 30509 #define DWREG_AMD64_XMM14 31510 #define DWREG_AMD64_XMM15 32511 #define DWREG_AMD64_ST0 33512 #define DWREG_AMD64_ST1 34513 #define DWREG_AMD64_ST2 35514 #define DWREG_AMD64_ST3 36515 #define DWREG_AMD64_ST4 37516 #define DWREG_AMD64_ST5 38517 #define DWREG_AMD64_ST6 39518 #define DWREG_AMD64_ST7 40519 #define DWREG_AMD64_MM0 41520 #define DWREG_AMD64_MM1 42521 #define DWREG_AMD64_MM2 43522 #define DWREG_AMD64_MM3 44523 #define DWREG_AMD64_MM4 45524 #define DWREG_AMD64_MM5 46525 #define DWREG_AMD64_MM6 47526 #define DWREG_AMD64_MM7 48527 #define DWREG_AMD64_RFLAGS 49528 #define DWREG_AMD64_ES 50529 #define DWREG_AMD64_CS 51530 #define DWREG_AMD64_SS 52531 #define DWREG_AMD64_DS 53532 #define DWREG_AMD64_FS 54533 #define DWREG_AMD64_GS 55534 #define DWREG_AMD64_FS_BASE 58535 #define DWREG_AMD64_GS_BASE 59536 #define DWREG_AMD64_TR 62537 #define DWREG_AMD64_LDTR 63538 #define DWREG_AMD64_MXCSR 64539 #define DWREG_AMD64_FCW 65540 #define DWREG_AMD64_FSW 66541 /** @} */542 52 543 53 … … 3420 2930 * @param pRow The "row" in the dwarf unwind table. 3421 2931 * @param pCie The CIE structure for the row. 3422 */ 3423 static int rtDwarfUnwind_UpdateStateFromRow(PRTDBGUNWINDSTATE pState, PRTDWARFCFROW pRow, PCRTDWARFCIEINFO pCie) 2932 * @param enmImageArch The image architecture. 2933 */ 2934 static int rtDwarfUnwind_UpdateStateFromRow(PRTDBGUNWINDSTATE pState, PRTDWARFCFROW pRow, 2935 PCRTDWARFCIEINFO pCie, RTLDRARCH enmImageArch) 3424 2936 { 3425 2937 /* … … 3433 2945 */ 3434 2946 PFNDWARFUNWINDGEREGFROMSTATE pfnGetReg; 3435 switch ( pState->enmArch)2947 switch (enmImageArch) 3436 2948 { 3437 2949 case RTLDRARCH_AMD64: … … 3466 2978 * Do the architecture specific register updating. 3467 2979 */ 3468 switch ( pState->enmArch)2980 switch (enmImageArch) 3469 2981 { 3470 2982 case RTLDRARCH_AMD64: 2983 pState->enmRetType = RTDBGRETURNTYPE_NEAR64; 3471 2984 pState->u.x86.FrameAddr.off = uCfa - 8*2; 3472 2985 pState->u.x86.Loaded.fAll = 0; … … 3500 3013 case RTLDRARCH_X86_32: 3501 3014 case RTLDRARCH_X86_16: 3015 pState->enmRetType = RTDBGRETURNTYPE_NEAR32; 3502 3016 pState->u.x86.FrameAddr.off = uCfa - 4*2; 3503 3017 pState->u.x86.Loaded.fAll = 0; … … 3519 3033 rtDwarfUnwind_UpdateX86SRegFromRow(pState, &Old, X86_SREG_FS, pRow, DWREG_X86_FS, pCie, uCfa, pfnGetReg); 3520 3034 rtDwarfUnwind_UpdateX86SRegFromRow(pState, &Old, X86_SREG_GS, pRow, DWREG_X86_GS, pCie, uCfa, pfnGetReg); 3035 if (pState->u.x86.Loaded.s.fRegs & RT_BIT_32(X86_GREG_xSP)) 3036 pState->u.x86.FrameAddr.off = pState->u.x86.auRegs[X86_GREG_xSP] - 8; 3037 else 3038 pState->u.x86.FrameAddr.off = uCfa - 8; 3039 pState->u.x86.FrameAddr.sel = pState->u.x86.auSegs[X86_SREG_SS]; 3040 if (pState->u.x86.Loaded.s.fSegs & RT_BIT_32(X86_SREG_CS)) 3041 { 3042 if ((pState->uPc >> 16) == pState->u.x86.auSegs[X86_SREG_CS]) 3043 { 3044 pState->enmRetType = RTDBGRETURNTYPE_FAR16; 3045 pState->uPc &= UINT16_MAX; 3046 Log8(("rtDwarfUnwind_UpdateStateFromRow: Detected FAR16 return to %04x:%04RX64\n", pState->u.x86.auSegs[X86_SREG_CS], pState->uPc)); 3047 } 3048 else 3049 { 3050 pState->enmRetType = RTDBGRETURNTYPE_FAR32; 3051 Log8(("rtDwarfUnwind_UpdateStateFromRow: CS loaded, assume far return.\n")); 3052 } 3053 } 3521 3054 break; 3522 3055 … … 3539 3072 * @param offInRange The offset into the range corresponding to 3540 3073 * pState->uPc. 3074 * @param enmImageArch The image architecture. 3541 3075 * @param pState The unwind state to work. 3542 3076 */ 3543 3077 static int rtDwarfUnwind_ProcessFde(PRTDWARFCURSOR pCursor, PCRTDWARFCIEINFO pCie, uint64_t uPcBegin, 3544 uint64_t cbPcRange, uint64_t offInRange, PRTDBGUNWINDSTATE pState)3078 uint64_t cbPcRange, uint64_t offInRange, RTLDRARCH enmImageArch, PRTDBGUNWINDSTATE pState) 3545 3079 { 3546 3080 /* … … 3592 3126 /* On success, extract whatever state we've got. */ 3593 3127 if (RT_SUCCESS(rc)) 3594 rc = rtDwarfUnwind_UpdateStateFromRow(pState, &Row, pCie );3128 rc = rtDwarfUnwind_UpdateStateFromRow(pState, &Row, pCie, enmImageArch); 3595 3129 3596 3130 /* … … 3627 3161 static int rtDwarfUnwind_LoadCie(PRTDWARFCURSOR pCursor, PRTDWARFCIEINFO pNewCie, uint64_t offUnit, uint8_t bDefaultPtrEnc) 3628 3162 { 3629 Log8(("%#08RX64: rtDwarfUnwind_LoadCie: %.*Rhxs\n", offUnit, pCursor->cbUnitLeft, pCursor->pb));3630 3163 /* 3631 3164 * Initialize the CIE record and get the version. … … 3785 3318 * @param fIsEhFrame Set if this is a '.eh_frame'. GCC generate these 3786 3319 * with different CIE_pointer values. 3320 * @param enmImageArch The image architecture. 3787 3321 */ 3788 3322 DECLHIDDEN(int) rtDwarfUnwind_Slow(PRTDWARFCURSOR pCursor, RTUINTPTR uRvaCursor, 3789 3323 RTDBGSEGIDX idxSeg, RTUINTPTR offSeg, RTUINTPTR uRva, 3790 PRTDBGUNWINDSTATE pState, uint8_t bDefaultPtrEnc, bool fIsEhFrame )3324 PRTDBGUNWINDSTATE pState, uint8_t bDefaultPtrEnc, bool fIsEhFrame, RTLDRARCH enmImageArch) 3791 3325 { 3792 3326 Log8(("rtDwarfUnwind_Slow: idxSeg=%#x offSeg=%RTptr uRva=%RTptr enmArch=%d PC=%#RX64\n", idxSeg, offSeg, uRva, pState->enmArch, pState->uPc)); … … 3802 3336 * Do the scanning. 3803 3337 */ 3338 uint64_t const offCieOffset = pCursor->f64bitDwarf ? UINT64_MAX : UINT32_MAX; 3804 3339 int rc = VERR_DBG_UNWIND_INFO_NOT_FOUND; 3805 3340 while (!rtDwarfCursor_IsAtEnd(pCursor)) … … 3808 3343 if (rtDwarfCursor_GetInitialLength(pCursor) == 0) 3809 3344 break; 3810 Log8(("%#08RX64: rtDwarfCursor_GetInitialLength -> %#x\n", offUnit, pCursor->cbUnitLeft)); 3811 3812 uint64_t const offRelCie = rtDwarfCursor_GetUOff(pCursor, 0); 3813 if ( offRelCie != 0 3814 && offRelCie != (pCursor->f64bitDwarf ? UINT64_MAX : UINT32_MAX)) 3345 3346 uint64_t const offRelCie = rtDwarfCursor_GetUOff(pCursor, offCieOffset); 3347 if (offRelCie != offCieOffset) 3815 3348 { 3816 3349 /* … … 3867 3400 rc = rtDwarfUnwind_ProcessFde(pCursor, pCieForFde, uPcBegin, cbPcRange, 3868 3401 idxFdeSeg == RTDBGSEGIDX_RVA ? uRva - uPcBegin : offSeg - uPcBegin, 3869 pState);3402 enmImageArch, pState); 3870 3403 break; 3871 3404 } … … 3960 3493 rtDwarfCursor_InitForMem(&Cursor, pvSection, cbSection); 3961 3494 int rc = rtDwarfUnwind_Slow(&Cursor, uRvaSection, idxSeg, offSeg, uRva, pState, 3962 rtDwarfUnwind_ArchToPtrEnc(enmArch), true /*fIsEhFrame*/ );3495 rtDwarfUnwind_ArchToPtrEnc(enmArch), true /*fIsEhFrame*/, enmArch); 3963 3496 LogFlow(("rtDwarfUnwind_EhData: rtDwarfUnwind_Slow -> %Rrc\n", rc)); 3964 3497 rc = rtDwarfCursor_Delete(&Cursor, rc); … … 5414 4947 AssertReturn(ATTR_GET_SIZE(pDesc) == 2, VERR_DWARF_IPE); 5415 4948 5416 RTDWARFLOCST LocSt; 5417 int rc = rtDwarfLoc_Init(&LocSt, pCursor, uForm); 5418 if (RT_SUCCESS(rc)) 5419 { 5420 rc = rtDwarfLoc_Evaluate(&LocSt, NULL, NULL); 4949 int rc; 4950 if ( uForm == DW_FORM_block 4951 || uForm == DW_FORM_block1 4952 || uForm == DW_FORM_block2 4953 || uForm == DW_FORM_block4) 4954 { 4955 RTDWARFLOCST LocSt; 4956 rc = rtDwarfLoc_Init(&LocSt, pCursor, uForm); 5421 4957 if (RT_SUCCESS(rc)) 5422 4958 { 5423 if (LocSt.iTop >= 0) 4959 rc = rtDwarfLoc_Evaluate(&LocSt, NULL, NULL); 4960 if (RT_SUCCESS(rc)) 5424 4961 { 5425 *(uint16_t *)pbMember = LocSt.auStack[LocSt.iTop]; 5426 Log4((" %-20s %#06llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), 5427 LocSt.auStack[LocSt.iTop], rtDwarfLog_FormName(uForm))); 5428 return VINF_SUCCESS; 4962 if (LocSt.iTop >= 0) 4963 { 4964 *(uint16_t *)pbMember = LocSt.auStack[LocSt.iTop]; 4965 Log4((" %-20s %#06llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), 4966 LocSt.auStack[LocSt.iTop], rtDwarfLog_FormName(uForm))); 4967 return VINF_SUCCESS; 4968 } 4969 rc = VERR_DWARF_STACK_UNDERFLOW; 5429 4970 } 5430 rc = VERR_DWARF_STACK_UNDERFLOW;5431 4971 } 5432 4972 } 4973 else 4974 rc = rtDwarfDecode_UnsignedInt(pDie, pbMember, pDesc, uForm, pCursor); 5433 4975 return rc; 5434 4976 } … … 5609 5151 { 5610 5152 PCRTDWARFDIELABEL pLabel = (PCRTDWARFDIELABEL)pDie; 5611 if (pLabel->fExternal)5153 //if (pLabel->fExternal) 5612 5154 { 5613 5155 Log5(("label %s %#x:%#llx\n", pLabel->pszName, pLabel->uSegment, pLabel->Address.uAddress)); … … 5630 5172 else 5631 5173 Log5(("rtDbgModDwarfLinkAddressToSegOffset failed: %Rrc\n", rc)); 5174 5175 /* Ignore errors regarding local labels. */ 5176 if (RT_FAILURE(rc) && !pLabel->fExternal) 5177 rc = -rc; 5632 5178 } 5633 5179 … … 6258 5804 /* Do the work */ 6259 5805 rc = rtDwarfUnwind_Slow(&Cursor, 0 /** @todo .debug_frame RVA*/, iSeg, off, uRva, 6260 pState, bPtrEnc, false /*fIsEhFrame*/ );5806 pState, bPtrEnc, false /*fIsEhFrame*/, pMod->pImgVt->pfnGetArch(pMod)); 6261 5807 6262 5808 rc = rtDwarfCursor_Delete(&Cursor, rc);
Note:
See TracChangeset
for help on using the changeset viewer.