3#ifndef SYMS_UNWIND_ELF_X64_C
4#define SYMS_UNWIND_ELF_X64_C
40 SYMS_Log(
"Does not have needed sections\n");
83 SYMS_Log(
"No matching CFI record\n");
109 SYMS_Log(
"Could not decode initial row\n");
128 SYMS_Log(
"Could not decode main row\n");
161 switch (
row->cfa_cell.rule){
164 SYMS_Log(
"CFA rule: REGOFF(%llu,0x%llx)\n",
row->cfa_cell.reg_idx,
row->cfa_cell.offset);
182 cfa = stack_pointer +
row->cfa_cell.offset;
185 cfa = regs->
r[reg_idx] +
row->cfa_cell.offset;
196 missed_read_addr =
location.non_piece_loc.fail_data;
204 SYMS_Log(
"CFA value: 0x%llx\n", cfa);
237 missed_read_addr = addr;
263 missed_read_addr =
location.non_piece_loc.fail_data;
270 missed_read_addr = addr;
283 missed_read_addr =
location.non_piece_loc.fail_data;
295 SYMS_Log(
"REG[%llu] VAL: 0x%llx\n", i,
v);
306 if (missed_read_addr != 0){
307 SYMS_Log(
"Memory read miss: 0x%llx\n", missed_read_addr);
463 if (version == 1 || version == 3){
506 if (augmentation.
size > 0 && augmentation.
str[0] ==
'z'){
520 if (has_augmentation_size > 0){
522 for (
SYMS_U8 *ptr = augmentation.
str + 1, *opl = augmentation.
str + augmentation.
size;
570 cie_out->lsda_encoding = lsda_encoding;
571 cie_out->addr_encoding = addr_encoding;
572 cie_out->has_augmentation_size = has_augmentation_size;
573 cie_out->augmentation_size = augmentation_size;
574 cie_out->augmentation = augmentation;
575 cie_out->code_align_factor = code_align_factor;
576 cie_out->data_align_factor = data_align_factor;
577 cie_out->ret_addr_reg = ret_addr_reg;
578 cie_out->handler_ip = handler_ip;
912 if (initial_row != 0){
921#if SYMS_ENABLE_DEV_LOG
922 if (initial_row == 0){
1023#if SYMS_ENABLE_DEV_LOG
1202 if (initial_row == 0){
1212 if (initial_row == 0){
1272#if SYMS_ENABLE_DEV_LOG
1274 switch (
row->cfa_cell.rule){
1277 SYMS_Log(
"CFA:(%llu, %lld); ",
row->cfa_cell.reg_idx,
row->cfa_cell.offset);
1285 for (
SYMS_U64 i = 0; i < cells_per_row; i += 1,
cell += 1){
1287 switch (
cell->rule){
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
char * dst
Definition lz4.h:735
float v
Definition radaudio_mdct.cpp:62
Definition syms_base.h:402
Definition syms_unwind_elf_x64.h:118
SYMS_DwCFIRegisterRule rule
Definition syms_unwind_elf_x64.h:119
Definition syms_unwind_elf_x64.h:132
SYMS_U64 fde_ip
Definition syms_unwind_elf_x64.h:137
SYMS_DwCFIRow * initial_row
Definition syms_unwind_elf_x64.h:136
SYMS_U64 cells_per_row
Definition syms_unwind_elf_x64.h:133
SYMS_DwEhPtrCtx * ptr_ctx
Definition syms_unwind_elf_x64.h:135
SYMS_DwCIEUnpacked * cie
Definition syms_unwind_elf_x64.h:134
Definition syms_unwind_elf_x64.h:86
SYMS_DwFDEUnpacked fde
Definition syms_unwind_elf_x64.h:89
SYMS_DwCIEUnpacked cie
Definition syms_unwind_elf_x64.h:88
SYMS_B32 valid
Definition syms_unwind_elf_x64.h:87
Definition syms_unwind_elf_x64.h:126
SYMS_DwCFICFACell cfa_cell
Definition syms_unwind_elf_x64.h:129
SYMS_DwCFICell * cells
Definition syms_unwind_elf_x64.h:128
Definition syms_unwind_elf_x64.h:71
SYMS_U64 offset
Definition syms_unwind_elf_x64.h:74
SYMS_DwCIEUnpacked cie
Definition syms_unwind_elf_x64.h:73
struct SYMS_DwCIEUnpackedNode * next
Definition syms_unwind_elf_x64.h:72
Definition syms_unwind_elf_x64.h:53
SYMS_S64 data_align_factor
Definition syms_unwind_elf_x64.h:63
SYMS_B8 has_augmentation_size
Definition syms_unwind_elf_x64.h:58
SYMS_DwEhPtrEnc lsda_encoding
Definition syms_unwind_elf_x64.h:55
SYMS_U8 version
Definition syms_unwind_elf_x64.h:54
SYMS_U64 code_align_factor
Definition syms_unwind_elf_x64.h:62
SYMS_DwEhPtrEnc addr_encoding
Definition syms_unwind_elf_x64.h:56
Definition syms_unwind_elf_x64.h:45
SYMS_U64 raw_base_vaddr
Definition syms_unwind_elf_x64.h:46
SYMS_U64 text_vaddr
Definition syms_unwind_elf_x64.h:47
SYMS_U64 data_vaddr
Definition syms_unwind_elf_x64.h:48
SYMS_U64 func_vaddr
Definition syms_unwind_elf_x64.h:49
Definition syms_dwarf_expr.h:83
SYMS_U64 max_step_count
Definition syms_dwarf_expr.h:85
Definition syms_unwind_elf_x64.h:78
SYMS_U64Range ip_voff_range
Definition syms_unwind_elf_x64.h:79
Definition syms_dwarf_expr.h:186
Definition syms_dwarf_expr.h:15
SYMS_U64 rip
Definition syms_dwarf_expr.h:34
SYMS_U64 r[17]
Definition syms_dwarf_expr.h:36
Definition syms_elf_parser.h:68
Definition syms_elf_parser.h:25
Definition syms_base.h:410
Definition syms_base.h:296
SYMS_U8 * str
Definition syms_base.h:297
SYMS_U64 size
Definition syms_base.h:298
Definition syms_base.h:264
SYMS_U64 max
Definition syms_base.h:266
SYMS_U64 min
Definition syms_base.h:265
Definition syms_base.h:420
SYMS_U64 stack_pointer
Definition syms_base.h:424
SYMS_B32 dead
Definition syms_base.h:421
SYMS_API SYMS_U64 syms_u64_range_size(SYMS_U64Range range)
Definition syms_base.c:31
SYMS_API SYMS_U64 syms_based_range_read(void *base, SYMS_U64Range range, SYMS_U64 offset, SYMS_U64 out_size, void *out)
Definition syms_base.c:753
SYMS_API void syms_unwind_result_missed_read(SYMS_UnwindResult *unwind_result, SYMS_U64 addr)
Definition syms_base.c:861
SYMS_API SYMS_ArenaTemp syms_get_scratch(SYMS_Arena **conflicts, SYMS_U64 conflict_count)
Definition syms_base.c:694
SYMS_API SYMS_U64Range syms_make_u64_range(SYMS_U64 min, SYMS_U64 max)
Definition syms_base.c:18
SYMS_API SYMS_U64 syms_based_range_read_sleb128(void *base, SYMS_U64Range range, SYMS_U64 offset, SYMS_S64 *out_value)
Definition syms_base.c:792
SYMS_API SYMS_String8 syms_based_range_read_string(void *base, SYMS_U64Range range, SYMS_U64 offset)
Definition syms_base.c:823
SYMS_API SYMS_U64 syms_based_range_read_uleb128(void *base, SYMS_U64Range range, SYMS_U64 offset, SYMS_U64 *out_value)
Definition syms_base.c:765
#define syms_true
Definition syms_base.h:105
#define SYMS_StackPush(f, n)
Definition syms_base.h:227
#define syms_based_range_read_struct(b, r, o, p)
Definition syms_base.h:593
#define SYMS_U32_MAX
Definition syms_base.h:175
#define syms_push_array(a, T, c)
Definition syms_base.h:561
#define syms_memory_view_read_struct(s, a, p)
Definition syms_base.h:602
#define syms_memzero_struct(s)
Definition syms_base.h:161
#define SYMS_LOCAL
Definition syms_base.h:43
#define syms_expand_string(s)
Definition syms_base.h:484
#define syms_false
Definition syms_base.h:104
#define SYMS_API
Definition syms_base.h:29
SYMS_S32 SYMS_B32
Definition syms_base.h:99
#define SYMS_StackPop(f)
Definition syms_base.h:228
#define syms_string_from_enum_value(enum_type, value)
Definition syms_base.h:461
SYMS_S8 SYMS_B8
Definition syms_base.h:97
#define SYMS_U64_MAX
Definition syms_base.h:176
#define syms_str8_lit(s)
Definition syms_base.h:483
#define SYMS_QueuePush(f, l, n)
Definition syms_base.h:220
#define syms_release_scratch
Definition syms_base.h:567
uint32_t SYMS_U32
Definition syms_crt_overrides.h:38
uint64_t SYMS_U64
Definition syms_crt_overrides.h:39
#define syms_memmove
Definition syms_crt_overrides.h:65
int64_t SYMS_S64
Definition syms_crt_overrides.h:35
#define SYMS_S64
Definition syms_crt_overrides.h:50
#define syms_memset
Definition syms_crt_overrides.h:66
uint8_t SYMS_U8
Definition syms_crt_overrides.h:36
#define SYMS_Arena
Definition syms_default_arena.h:61
#define SYMS_LogClose(block)
Definition syms_dev.h:142
#define SYMS_LogOpen(ftr, uid, block)
Definition syms_dev.h:141
@ SYMS_LogFeature_DwarfCFIApply
Definition syms_dev.h:26
@ SYMS_LogFeature_DwarfUnwind
Definition syms_dev.h:23
@ SYMS_LogFeature_DwarfCFILookup
Definition syms_dev.h:24
@ SYMS_LogFeature_DwarfCFIDecode
Definition syms_dev.h:25
#define SYMS_Log(fmt,...)
Definition syms_dev.h:143
SYMS_API SYMS_DwLocation syms_dw_expr__eval(SYMS_Arena *arena_optional, void *expr_base, SYMS_U64Range expr_range, SYMS_DwExprMachineConfig *config)
Definition syms_dwarf_expr.c:578
@ SYMS_DwSimpleLocKind_Address
Definition syms_dwarf_expr.h:128
@ SYMS_DwSimpleLocKind_Fail
Definition syms_dwarf_expr.h:133
@ SYMS_DwLocFailKind_MissingMemory
Definition syms_dwarf_expr.h:149
SYMS_API SYMS_U64 syms_dw_based_range_read_length(void *base, SYMS_U64Range range, SYMS_U64 offset, SYMS_U64 *out_value)
Definition syms_dwarf_parser.c:427
SYMS_API SYMS_U64 syms_elf_default_vbase_from_bin(SYMS_ElfBinAccel *bin)
Definition syms_elf_parser.c:479
SYMS_API SYMS_ElfSection * syms_elf_sec_from_bin_name__unstable(SYMS_ElfBinAccel *bin, SYMS_String8 name)
Definition syms_elf_parser.c:500
SYMS_API void syms_unwind_elf_x64__row_copy(SYMS_DwCFIRow *dst, SYMS_DwCFIRow *src, SYMS_U64 cells_per_row)
Definition syms_unwind_elf_x64.c:887
SYMS_API SYMS_U64 syms_unwind_elf_x64__parse_pointer(void *frame_base, SYMS_U64Range frame_range, SYMS_DwEhPtrCtx *ptr_ctx, SYMS_DwEhPtrEnc encoding, SYMS_U64 off, SYMS_U64 *ptr_out)
Definition syms_unwind_elf_x64.c:359
SYMS_API void syms_unwind_elf_x64__init(void)
Definition syms_unwind_elf_x64.c:321
SYMS_API SYMS_DwCFIRecords syms_unwind_elf_x64__eh_frame_cfi_from_ip__sloppy(void *base, SYMS_U64Range range, SYMS_DwEhPtrCtx *ptr_ctx, SYMS_U64 ip_voff)
Definition syms_unwind_elf_x64.c:641
SYMS_API SYMS_DwCFIRecords syms_unwind_elf_x64__eh_frame_hdr_from_ip(void *base, SYMS_U64Range eh_frame_hdr_range, SYMS_U64Range eh_frame_range, SYMS_DwEhPtrCtx *ptr_ctx, SYMS_U64 ip_voff)
Definition syms_unwind_elf_x64.c:794
SYMS_API SYMS_UnwindResult syms_unwind_elf_x64(SYMS_String8 bin_data, SYMS_ElfBinAccel *bin, SYMS_U64 bin_base, SYMS_MemoryView *memview, SYMS_U64 stack_pointer, SYMS_DwRegsX64 *regs)
Definition syms_unwind_elf_x64.c:15
SYMS_API void syms_unwind_elf_x64__eh_frame_parse_fde(void *base, SYMS_U64Range range, SYMS_DwEhPtrCtx *ptr_ctx, SYMS_DwCIEUnpacked *cie, SYMS_U64 off, SYMS_DwFDEUnpacked *fde_out)
Definition syms_unwind_elf_x64.c:585
SYMS_API void syms_unwind_elf_x64__machine_equip_fde_ip(SYMS_DwCFIMachine *machine, SYMS_U64 fde_ip)
Definition syms_unwind_elf_x64.c:869
SYMS_API SYMS_U64 syms_search_eh_frame_hdr__linear(void *base, SYMS_U64Range range, SYMS_DwEhPtrCtx *ptr_ctx, SYMS_U64 location)
Definition syms_unwind_elf_x64.c:740
SYMS_API void syms_unwind_elf_x64__machine_equip_initial_row(SYMS_DwCFIMachine *machine, SYMS_DwCFIRow *initial_row)
Definition syms_unwind_elf_x64.c:864
SYMS_API SYMS_DwCFIMachine syms_unwind_elf_x64__machine_make(SYMS_U64 cells_per_row, SYMS_DwCIEUnpacked *cie, SYMS_DwEhPtrCtx *ptr_ctx)
Definition syms_unwind_elf_x64.c:855
SYMS_API void syms_unwind_elf_x64__row_zero(SYMS_DwCFIRow *row, SYMS_U64 cells_per_row)
Definition syms_unwind_elf_x64.c:881
SYMS_API void syms_unwind_elf_x64__eh_frame_parse_cie(void *base, SYMS_U64Range range, SYMS_DwEhPtrCtx *ptr_ctx, SYMS_U64 off, SYMS_DwCIEUnpacked *cie_out)
Definition syms_unwind_elf_x64.c:453
SYMS_API SYMS_DwCFIRow * syms_unwind_elf_x64__row_alloc(SYMS_Arena *arena, SYMS_U64 cells_per_row)
Definition syms_unwind_elf_x64.c:874
SYMS_API SYMS_B32 syms_unwind_elf_x64__machine_run_to_ip(void *base, SYMS_U64Range range, SYMS_DwCFIMachine *machine, SYMS_U64 target_ip, SYMS_DwCFIRow *row)
Definition syms_unwind_elf_x64.c:894
SYMS_API SYMS_UnwindResult syms_unwind_elf_x64__apply_rules(SYMS_String8 bin_data, SYMS_DwCFIRow *row, SYMS_U64 text_base_vaddr, SYMS_MemoryView *memview, SYMS_U64 stack_pointer, SYMS_DwRegsX64 *regs)
Definition syms_unwind_elf_x64.c:145
#define SYMS_UNWIND_ELF_X64__REG_SLOT_COUNT
Definition syms_unwind_elf_x64.h:163
SYMS_U16 SYMS_DwCFAControlBits
Definition syms_unwind_elf_x64.h:149
SYMS_U8 SYMS_DwEhPtrEnc
Definition syms_unwind_elf_x64.h:17
@ SYMS_DwEhPtrEnc_PCREL
Definition syms_unwind_elf_x64.h:33
@ SYMS_DwEhPtrEnc_MODIF_MASK
Definition syms_unwind_elf_x64.h:32
@ SYMS_DwEhPtrEnc_ALIGNED
Definition syms_unwind_elf_x64.h:37
@ SYMS_DwEhPtrEnc_DATAREL
Definition syms_unwind_elf_x64.h:35
@ SYMS_DwEhPtrEnc_FUNCREL
Definition syms_unwind_elf_x64.h:36
@ SYMS_DwEhPtrEnc_TEXTREL
Definition syms_unwind_elf_x64.h:34
@ SYMS_DwEhPtrEnc_SLEB128
Definition syms_unwind_elf_x64.h:26
@ SYMS_DwEhPtrEnc_SDATA8
Definition syms_unwind_elf_x64.h:29
@ SYMS_DwEhPtrEnc_UDATA2
Definition syms_unwind_elf_x64.h:22
@ SYMS_DwEhPtrEnc_SDATA4
Definition syms_unwind_elf_x64.h:28
@ SYMS_DwEhPtrEnc_UDATA8
Definition syms_unwind_elf_x64.h:24
@ SYMS_DwEhPtrEnc_TYPE_MASK
Definition syms_unwind_elf_x64.h:19
@ SYMS_DwEhPtrEnc_SDATA2
Definition syms_unwind_elf_x64.h:27
@ SYMS_DwEhPtrEnc_ULEB128
Definition syms_unwind_elf_x64.h:21
@ SYMS_DwEhPtrEnc_SIGNED
Definition syms_unwind_elf_x64.h:25
@ SYMS_DwEhPtrEnc_UDATA4
Definition syms_unwind_elf_x64.h:23
@ SYMS_DwEhPtrEnc_PTR
Definition syms_unwind_elf_x64.h:20
SYMS_GLOBAL SYMS_DwCFAControlBits syms_unwind_elf__cfa_control_bits_kind2[SYMS_DwCFADetail_OPL_KIND2+1]
Definition syms_unwind_elf_x64.h:160
@ SYMS_DwCFICFARule_REGOFF
Definition syms_unwind_elf_x64.h:93
@ SYMS_DwCFICFARule_EXPR
Definition syms_unwind_elf_x64.h:94
@ SYMS_DwEhPtrEnc_OMIT
Definition syms_unwind_elf_x64.h:42
SYMS_U8 SYMS_DwCFADecode
Definition syms_unwind_elf_x64.h:140
@ SYMS_DwCFADecode_ADDRESS
Definition syms_unwind_elf_x64.h:144
@ SYMS_DwCFADecode_SLEB128
Definition syms_unwind_elf_x64.h:146
@ SYMS_DwCFADecode_ULEB128
Definition syms_unwind_elf_x64.h:145
SYMS_DwCFIRegisterRule
Definition syms_unwind_elf_x64.h:108
@ SYMS_DwCFIRegisterRule_UNDEFINED
Definition syms_unwind_elf_x64.h:110
@ SYMS_DwCFIRegisterRule_EXPRESSION
Definition syms_unwind_elf_x64.h:114
@ SYMS_DwCFIRegisterRule_REGISTER
Definition syms_unwind_elf_x64.h:113
@ SYMS_DwCFIRegisterRule_SAME_VALUE
Definition syms_unwind_elf_x64.h:109
@ SYMS_DwCFIRegisterRule_VAL_OFFSET
Definition syms_unwind_elf_x64.h:112
@ SYMS_DwCFIRegisterRule_VAL_EXPRESSION
Definition syms_unwind_elf_x64.h:115
@ SYMS_DwCFIRegisterRule_OFFSET
Definition syms_unwind_elf_x64.h:111
@ SYMS_DwCFAControlBits_NEW_ROW
Definition syms_unwind_elf_x64.h:156
@ SYMS_DwCFAControlBits_IS_REG_0
Definition syms_unwind_elf_x64.h:153
@ SYMS_DwCFAControlBits_IS_REG_1
Definition syms_unwind_elf_x64.h:154
@ SYMS_DwCFAControlBits_IS_REG_2
Definition syms_unwind_elf_x64.h:155
SYMS_GLOBAL SYMS_DwCFAControlBits syms_unwind_elf__cfa_control_bits_kind1[SYMS_DwCFADetail_OPL_KIND1+1]
Definition syms_unwind_elf_x64.h:159