diff --git a/src/async/async.c b/src/async/async.c index ec84c372..c9af67f1 100644 --- a/src/async/async.c +++ b/src/async/async.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/async/async.h b/src/async/async.h index 6d9f2b00..f2f31d2a 100644 --- a/src/async/async.h +++ b/src/async/async.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef ASYNC_H diff --git a/src/base/base_arena.c b/src/base/base_arena.c index 68ad2544..626808dc 100644 --- a/src/base/base_arena.c +++ b/src/base/base_arena.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/base/base_arena.h b/src/base/base_arena.h index 8696f49f..25aafe7f 100644 --- a/src/base/base_arena.h +++ b/src/base/base_arena.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_ARENA_H diff --git a/src/base/base_command_line.c b/src/base/base_command_line.c index ec726752..a0f9717d 100644 --- a/src/base/base_command_line.c +++ b/src/base/base_command_line.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/base/base_command_line.h b/src/base/base_command_line.h index acd7f17b..212d1022 100644 --- a/src/base/base_command_line.h +++ b/src/base/base_command_line.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_COMMAND_LINE_H diff --git a/src/base/base_context_cracking.h b/src/base/base_context_cracking.h index edec2be4..301ee71b 100644 --- a/src/base/base_context_cracking.h +++ b/src/base/base_context_cracking.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_CONTEXT_CRACKING_H diff --git a/src/base/base_core.c b/src/base/base_core.c index e5faadde..0b8c1ec8 100644 --- a/src/base/base_core.c +++ b/src/base/base_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// @@ -523,7 +523,7 @@ date_time_from_unix_time(U64 unix_time) date.sec = (U32)unix_time % 60; date.min = (U32)(unix_time / 60) % 60; date.hour = (U32)(unix_time / 3600) % 24; - + for(;;) { for(date.month = 0; date.month < 12; ++date.month) @@ -564,7 +564,7 @@ date_time_from_unix_time(U64 unix_time) ++date.year; } exit:; - + return date; } diff --git a/src/base/base_core.h b/src/base/base_core.h index 01e3423f..f38333cc 100644 --- a/src/base/base_core.h +++ b/src/base/base_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_CORE_H diff --git a/src/base/base_entry_point.c b/src/base/base_entry_point.c index 37009653..bd121af7 100644 --- a/src/base/base_entry_point.c +++ b/src/base/base_entry_point.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) global U64 global_update_tick_idx = 0; diff --git a/src/base/base_entry_point.h b/src/base/base_entry_point.h index 318f8d9f..346df5df 100644 --- a/src/base/base_entry_point.h +++ b/src/base/base_entry_point.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_ENTRY_POINT_H diff --git a/src/base/base_inc.c b/src/base/base_inc.c index 299d9042..45e1fe84 100644 --- a/src/base/base_inc.c +++ b/src/base/base_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/base/base_inc.h b/src/base/base_inc.h index a878cacc..e6adf0d3 100644 --- a/src/base/base_inc.h +++ b/src/base/base_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_INC_H diff --git a/src/base/base_log.c b/src/base/base_log.c index 1c2a05f8..3916ce1c 100644 --- a/src/base/base_log.c +++ b/src/base/base_log.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/base/base_log.h b/src/base/base_log.h index ba181ce2..e8d3d50b 100644 --- a/src/base/base_log.h +++ b/src/base/base_log.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_LOG_H diff --git a/src/base/base_markup.c b/src/base/base_markup.c index 5ad47ef5..0efbaab8 100644 --- a/src/base/base_markup.c +++ b/src/base/base_markup.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal void diff --git a/src/base/base_markup.h b/src/base/base_markup.h index 2de3aa5d..4389d9b1 100644 --- a/src/base/base_markup.h +++ b/src/base/base_markup.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_MARKUP_H diff --git a/src/base/base_math.c b/src/base/base_math.c index 7a65b45b..1a4d4293 100644 --- a/src/base/base_math.c +++ b/src/base/base_math.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/base/base_math.h b/src/base/base_math.h index eb322865..b33b139d 100644 --- a/src/base/base_math.h +++ b/src/base/base_math.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_MATH_H diff --git a/src/base/base_meta.c b/src/base/base_meta.c index 2bf14eb6..a489a39d 100644 --- a/src/base/base_meta.c +++ b/src/base/base_meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/base/base_meta.h b/src/base/base_meta.h index 62faafeb..18a69d9e 100644 --- a/src/base/base_meta.h +++ b/src/base/base_meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_META_H diff --git a/src/base/base_profile.c b/src/base/base_profile.c index f23453ce..2216a282 100644 --- a/src/base/base_profile.c +++ b/src/base/base_profile.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #if PROFILE_SPALL diff --git a/src/base/base_profile.h b/src/base/base_profile.h index bbaf9732..3a97d4f3 100644 --- a/src/base/base_profile.h +++ b/src/base/base_profile.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_PROFILE_H diff --git a/src/base/base_strings.c b/src/base/base_strings.c index f98d6e44..9440dafa 100644 --- a/src/base/base_strings.c +++ b/src/base/base_strings.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/base/base_strings.h b/src/base/base_strings.h index b9b155ee..ccf32592 100644 --- a/src/base/base_strings.h +++ b/src/base/base_strings.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_STRINGS_H diff --git a/src/base/base_thread_context.c b/src/base/base_thread_context.c index 7ae3a2c8..43bf16f3 100644 --- a/src/base/base_thread_context.c +++ b/src/base/base_thread_context.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/base/base_thread_context.h b/src/base/base_thread_context.h index 90a396fe..44ff7ab2 100644 --- a/src/base/base_thread_context.h +++ b/src/base/base_thread_context.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef BASE_THREAD_CONTEXT_H diff --git a/src/codeview/codeview.c b/src/codeview/codeview.c index fbae1c89..742ead97 100644 --- a/src/codeview/codeview.c +++ b/src/codeview/codeview.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// @@ -14,30 +14,30 @@ cv_arch_from_coff_machine(COFF_MachineType machine) CV_Arch arch = 0; switch(machine) { - case COFF_MachineType_X64: arch = CV_Arch_X64; break; - case COFF_MachineType_X86: arch = CV_Arch_8086; break; - case COFF_MachineType_Am33: arch = CV_Arch_AM33; break; - case COFF_MachineType_Arm: NotImplemented; break; - case COFF_MachineType_Arm64: arch = CV_Arch_ARM64; break; - case COFF_MachineType_ArmNt: arch = CV_Arch_ARMNT; break; - case COFF_MachineType_Ebc: arch = CV_Arch_EBC; break; - case COFF_MachineType_Ia64: arch = CV_Arch_IA64; break; - case COFF_MachineType_M32R: arch = CV_Arch_M32R; break; - case COFF_MachineType_Mips16: arch = CV_Arch_MIPS16; break; - case COFF_MachineType_MipsFpu: NotImplemented; break; - case COFF_MachineType_MipsFpu16: NotImplemented; break; - case COFF_MachineType_PowerPc: NotImplemented; break; - case COFF_MachineType_PowerPcFp: arch = CV_Arch_PPCFP; break; - case COFF_MachineType_R4000: NotImplemented; break; - case COFF_MachineType_RiscV32: NotImplemented; break; - case COFF_MachineType_RiscV64: NotImplemented; break; - case COFF_MachineType_RiscV128: NotImplemented; break; - case COFF_MachineType_Sh3: arch = CV_Arch_SH3; break; - case COFF_MachineType_Sh3Dsp: arch = CV_Arch_SH3DSP; break; - case COFF_MachineType_Sh4: arch = CV_Arch_SH4; break; - case COFF_MachineType_Sh5: NotImplemented; break; - case COFF_MachineType_Thumb: arch = CV_Arch_THUMB; break; - case COFF_MachineType_WceMipsV2: NotImplemented; break; + case COFF_MachineType_X64: arch = CV_Arch_X64; break; + case COFF_MachineType_X86: arch = CV_Arch_8086; break; + case COFF_MachineType_Am33: arch = CV_Arch_AM33; break; + case COFF_MachineType_Arm: NotImplemented; break; + case COFF_MachineType_Arm64: arch = CV_Arch_ARM64; break; + case COFF_MachineType_ArmNt: arch = CV_Arch_ARMNT; break; + case COFF_MachineType_Ebc: arch = CV_Arch_EBC; break; + case COFF_MachineType_Ia64: arch = CV_Arch_IA64; break; + case COFF_MachineType_M32R: arch = CV_Arch_M32R; break; + case COFF_MachineType_Mips16: arch = CV_Arch_MIPS16; break; + case COFF_MachineType_MipsFpu: NotImplemented; break; + case COFF_MachineType_MipsFpu16: NotImplemented; break; + case COFF_MachineType_PowerPc: NotImplemented; break; + case COFF_MachineType_PowerPcFp: arch = CV_Arch_PPCFP; break; + case COFF_MachineType_R4000: NotImplemented; break; + case COFF_MachineType_RiscV32: NotImplemented; break; + case COFF_MachineType_RiscV64: NotImplemented; break; + case COFF_MachineType_RiscV128: NotImplemented; break; + case COFF_MachineType_Sh3: arch = CV_Arch_SH3; break; + case COFF_MachineType_Sh3Dsp: arch = CV_Arch_SH3DSP; break; + case COFF_MachineType_Sh4: arch = CV_Arch_SH4; break; + case COFF_MachineType_Sh5: NotImplemented; break; + case COFF_MachineType_Thumb: arch = CV_Arch_THUMB; break; + case COFF_MachineType_WceMipsV2: NotImplemented; break; } return arch; } @@ -47,9 +47,9 @@ cv_size_from_reg(CV_Arch arch, CV_Reg reg) { switch(arch) { - case CV_Arch_8086: return cv_size_from_reg_x86(reg); - case CV_Arch_X64 : return cv_size_from_reg_x64(reg); - default: NotImplemented; + case CV_Arch_8086: return cv_size_from_reg_x86(reg); + case CV_Arch_X64 : return cv_size_from_reg_x64(reg); + default: NotImplemented; } return 0; } @@ -59,9 +59,9 @@ cv_is_reg_sp(CV_Arch arch, CV_Reg reg) { switch(arch) { - case CV_Arch_8086: return reg == CV_Regx86_ESP; - case CV_Arch_X64: return reg == CV_Regx64_RSP; - default: NotImplemented; + case CV_Arch_8086: return reg == CV_Regx86_ESP; + case CV_Arch_X64: return reg == CV_Regx64_RSP; + default: NotImplemented; } return 0; } @@ -84,7 +84,7 @@ cv_size_from_reg_x64(CV_Reg reg) switch(reg) { #define X(NAME, CODE, RDI_NAME, BYTE_POS, BYTE_SIZE) case CV_Regx64_##NAME: return BYTE_SIZE; - CV_Reg_X64_XList(X) + CV_Reg_X64_XList(X) #undef X } return 0; @@ -111,30 +111,30 @@ cv_decode_fp_reg(CV_Arch arch, CV_EncodedFramePtrReg encoded_reg) CV_Reg fp_reg = 0; switch (arch) { - case CV_Arch_8086: - { - switch (encoded_reg) - { - case CV_EncodedFramePtrReg_None : break; - case CV_EncodedFramePtrReg_StackPtr: AssertAlways(!"TODO: not tested, this is a guess"); - fp_reg = CV_Regx86_ESP; break; - case CV_EncodedFramePtrReg_FramePtr: fp_reg = CV_Regx86_EBP; break; - case CV_EncodedFramePtrReg_BasePtr : fp_reg = CV_Regx86_EBX; break; - default: InvalidPath; - } - } break; - case CV_Arch_X64: - { - switch (encoded_reg) - { - case CV_EncodedFramePtrReg_None : break; - case CV_EncodedFramePtrReg_StackPtr: fp_reg = CV_Regx64_RSP; break; - case CV_EncodedFramePtrReg_FramePtr: fp_reg = CV_Regx64_RBP; break; - case CV_EncodedFramePtrReg_BasePtr : fp_reg = CV_Regx64_R13; break; - default: InvalidPath; - } - } break; - default: NotImplemented; + case CV_Arch_8086: + { + switch (encoded_reg) + { + case CV_EncodedFramePtrReg_None : break; + case CV_EncodedFramePtrReg_StackPtr: AssertAlways(!"TODO: not tested, this is a guess"); + fp_reg = CV_Regx86_ESP; break; + case CV_EncodedFramePtrReg_FramePtr: fp_reg = CV_Regx86_EBP; break; + case CV_EncodedFramePtrReg_BasePtr : fp_reg = CV_Regx86_EBX; break; + default: InvalidPath; + } + } break; + case CV_Arch_X64: + { + switch (encoded_reg) + { + case CV_EncodedFramePtrReg_None : break; + case CV_EncodedFramePtrReg_StackPtr: fp_reg = CV_Regx64_RSP; break; + case CV_EncodedFramePtrReg_FramePtr: fp_reg = CV_Regx64_RBP; break; + case CV_EncodedFramePtrReg_BasePtr : fp_reg = CV_Regx64_R13; break; + default: InvalidPath; + } + } break; + default: NotImplemented; } return fp_reg; } @@ -144,22 +144,22 @@ cv_map_encoded_base_pointer(CV_Arch arch, U32 encoded_frame_reg) { U32 r = 0; switch (arch) { - case CV_Arch_8086: { - switch (encoded_frame_reg) { - case 0: r = 0; break; - case 1: r = CV_AllReg_VFRAME; break; - case 2: r = CV_Regx86_EBP; break; - case 3: r = CV_Regx86_EBX; break; - } - } break; - case CV_Arch_X64: { - switch (encoded_frame_reg) { - case 0: r = 0; break; - case 1: r = CV_Regx64_RSP; break; - case 2: r = CV_Regx64_RBP; break; - case 3: r = CV_Regx64_R13; break; - } - } break; + case CV_Arch_8086: { + switch (encoded_frame_reg) { + case 0: r = 0; break; + case 1: r = CV_AllReg_VFRAME; break; + case 2: r = CV_Regx86_EBP; break; + case 3: r = CV_Regx86_EBX; break; + } + } break; + case CV_Arch_X64: { + switch (encoded_frame_reg) { + case 0: r = 0; break; + case 1: r = CV_Regx64_RSP; break; + case 2: r = CV_Regx64_RBP; break; + case 3: r = CV_Regx64_R13; break; + } + } break; default: NotImplemented; } return r; diff --git a/src/codeview/codeview.h b/src/codeview/codeview.h index 4caebc98..e70a426d 100644 --- a/src/codeview/codeview.h +++ b/src/codeview/codeview.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef CODEVIEW_H @@ -43,249 +43,249 @@ read_only global CV_TypeId cv_type_id_variadic = 0xFFFFFFFF; // X(NAME, CODE, (RDI_RegCode_X86) NAME, BYTE_POS, BYTE_SIZE) #define CV_Reg_X86_XList(X) \ - X(NONE, 0, nil, 0, 0) \ - X(AL, 1, eax, 0, 1) \ - X(CL, 2, ecx, 0, 1) \ - X(DL, 3, edx, 0, 1) \ - X(BL, 4, ebx, 0, 1) \ - X(AH, 5, eax, 1, 1) \ - X(CH, 6, ecx, 1, 1) \ - X(DH, 7, edx, 1, 1) \ - X(BH, 8, ebx, 1, 1) \ - X(AX, 9, eax, 0, 2) \ - X(CX, 10, ecx, 0, 2) \ - X(DX, 11, edx, 0, 2) \ - X(BX, 12, ebx, 0, 2) \ - X(SP, 13, esp, 0, 2) \ - X(BP, 14, ebp, 0, 2) \ - X(SI, 15, esi, 0, 2) \ - X(DI, 16, edi, 0, 2) \ - X(EAX, 17, eax, 0, 4) \ - X(ECX, 18, ecx, 0, 4) \ - X(EDX, 19, edx, 0, 4) \ - X(EBX, 20, ebx, 0, 4) \ - X(ESP, 21, esp, 0, 4) \ - X(EBP, 22, ebp, 0, 4) \ - X(ESI, 23, esi, 0, 4) \ - X(EDI, 24, edi, 0, 4) \ - X(ES, 25, es, 0, 2) \ - X(CS, 26, cs, 0, 2) \ - X(SS, 27, ss, 0, 2) \ - X(DS, 28, ds, 0, 2) \ - X(FS, 29, fs, 0, 2) \ - X(GS, 30, gs, 0, 2) \ - X(IP, 31, eip, 0, 2) \ - X(FLAGS, 32, eflags, 0, 2) \ - X(EIP, 33, eip, 0, 4) \ - X(EFLAGS, 34, eflags, 0, 4) \ - X(MM0, 146, fpr0, 0, 8) \ - X(MM1, 147, fpr1, 0, 8) \ - X(MM2, 148, fpr2, 0, 8) \ - X(MM3, 149, fpr3, 0, 8) \ - X(MM4, 150, fpr4, 0, 8) \ - X(MM5, 151, fpr5, 0, 8) \ - X(MM6, 152, fpr6, 0, 8) \ - X(MM7, 153, fpr7, 0, 8) \ - X(XMM0, 154, ymm0, 0, 16) \ - X(XMM1, 155, ymm1, 0, 16) \ - X(XMM2, 156, ymm2, 0, 16) \ - X(XMM3, 157, ymm3, 0, 16) \ - X(XMM4, 158, ymm4, 0, 16) \ - X(XMM5, 159, ymm5, 0, 16) \ - X(XMM6, 160, ymm6, 0, 16) \ - X(XMM7, 161, ymm7, 0, 16) \ - X(XMM00, 162, ymm0, 0, 4) \ - X(XMM01, 163, ymm0, 4, 4) \ - X(XMM02, 164, ymm0, 8, 4) \ - X(XMM03, 165, ymm0, 12, 4) \ - X(XMM10, 166, ymm1, 0, 4) \ - X(XMM11, 167, ymm1, 4, 4) \ - X(XMM12, 168, ymm1, 8, 4) \ - X(XMM13, 169, ymm1, 12, 4) \ - X(XMM20, 170, ymm2, 0, 4) \ - X(XMM21, 171, ymm2, 4, 4) \ - X(XMM22, 172, ymm2, 8, 4) \ - X(XMM23, 173, ymm2, 12, 4) \ - X(XMM30, 174, ymm3, 0, 4) \ - X(XMM31, 175, ymm3, 4, 4) \ - X(XMM32, 176, ymm3, 8, 4) \ - X(XMM33, 177, ymm3, 12, 4) \ - X(XMM40, 178, ymm4, 0, 4) \ - X(XMM41, 179, ymm4, 4, 4) \ - X(XMM42, 180, ymm4, 8, 4) \ - X(XMM43, 181, ymm4, 12, 4) \ - X(XMM50, 182, ymm5, 0, 4) \ - X(XMM51, 183, ymm5, 4, 4) \ - X(XMM52, 184, ymm5, 8, 4) \ - X(XMM53, 185, ymm5, 12, 4) \ - X(XMM60, 186, ymm6, 0, 4) \ - X(XMM61, 187, ymm6, 4, 4) \ - X(XMM62, 188, ymm6, 8, 4) \ - X(XMM63, 189, ymm6, 12, 4) \ - X(XMM70, 190, ymm7, 0, 4) \ - X(XMM71, 191, ymm7, 4, 4) \ - X(XMM72, 192, ymm7, 8, 4) \ - X(XMM73, 193, ymm7, 12, 4) \ - X(XMM0L, 194, ymm0, 0, 8) \ - X(XMM1L, 195, ymm1, 0, 8) \ - X(XMM2L, 196, ymm2, 0, 8) \ - X(XMM3L, 197, ymm3, 0, 8) \ - X(XMM4L, 198, ymm4, 0, 8) \ - X(XMM5L, 199, ymm5, 0, 8) \ - X(XMM6L, 200, ymm6, 0, 8) \ - X(XMM7L, 201, ymm7, 0, 8) \ - X(XMM0H, 202, ymm0, 8, 8) \ - X(XMM1H, 203, ymm1, 8, 8) \ - X(XMM2H, 204, ymm2, 8, 8) \ - X(XMM3H, 205, ymm3, 8, 8) \ - X(XMM4H, 206, ymm4, 8, 8) \ - X(XMM5H, 207, ymm5, 8, 8) \ - X(XMM6H, 208, ymm6, 8, 8) \ - X(XMM7H, 209, ymm7, 8, 8) \ - X(YMM0, 252, ymm0, 0, 32) \ - X(YMM1, 253, ymm1, 0, 32) \ - X(YMM2, 254, ymm2, 0, 32) \ - X(YMM3, 255, ymm3, 0, 32) \ - X(YMM4, 256, ymm4, 0, 32) \ - X(YMM5, 257, ymm5, 0, 32) \ - X(YMM6, 258, ymm6, 0, 32) \ - X(YMM7, 259, ymm7, 0, 32) \ - X(YMM0H, 260, ymm0, 16, 16) \ - X(YMM1H, 261, ymm1, 16, 16) \ - X(YMM2H, 262, ymm2, 16, 16) \ - X(YMM3H, 263, ymm3, 16, 16) \ - X(YMM4H, 264, ymm4, 16, 16) \ - X(YMM5H, 265, ymm5, 16, 16) \ - X(YMM6H, 266, ymm6, 16, 16) \ - X(YMM7H, 267, ymm7, 16, 16) \ - X(YMM0I0, 268, ymm0, 0, 8) \ - X(YMM0I1, 269, ymm0, 8, 8) \ - X(YMM0I2, 270, ymm0, 16, 8) \ - X(YMM0I3, 271, ymm0, 24, 8) \ - X(YMM1I0, 272, ymm1, 0, 8) \ - X(YMM1I1, 273, ymm1, 8, 8) \ - X(YMM1I2, 274, ymm1, 16, 8) \ - X(YMM1I3, 275, ymm1, 24, 8) \ - X(YMM2I0, 276, ymm2, 0, 8) \ - X(YMM2I1, 277, ymm2, 8, 8) \ - X(YMM2I2, 278, ymm2, 16, 8) \ - X(YMM2I3, 279, ymm2, 24, 8) \ - X(YMM3I0, 280, ymm3, 0, 8) \ - X(YMM3I1, 281, ymm3, 8, 8) \ - X(YMM3I2, 282, ymm3, 16, 8) \ - X(YMM3I3, 283, ymm3, 24, 8) \ - X(YMM4I0, 284, ymm4, 0, 8) \ - X(YMM4I1, 285, ymm4, 8, 8) \ - X(YMM4I2, 286, ymm4, 16, 8) \ - X(YMM4I3, 287, ymm4, 24, 8) \ - X(YMM5I0, 288, ymm5, 0, 8) \ - X(YMM5I1, 289, ymm5, 8, 8) \ - X(YMM5I2, 290, ymm5, 16, 8) \ - X(YMM5I3, 291, ymm5, 24, 8) \ - X(YMM6I0, 292, ymm6, 0, 8) \ - X(YMM6I1, 293, ymm6, 8, 8) \ - X(YMM6I2, 294, ymm6, 16, 8) \ - X(YMM6I3, 295, ymm6, 24, 8) \ - X(YMM7I0, 296, ymm7, 0, 8) \ - X(YMM7I1, 297, ymm7, 8, 8) \ - X(YMM7I2, 298, ymm7, 16, 8) \ - X(YMM7I3, 299, ymm7, 24, 8) \ - X(YMM0F0, 300, ymm0, 0, 4) \ - X(YMM0F1, 301, ymm0, 4, 4) \ - X(YMM0F2, 302, ymm0, 8, 4) \ - X(YMM0F3, 303, ymm0, 12, 4) \ - X(YMM0F4, 304, ymm0, 16, 4) \ - X(YMM0F5, 305, ymm0, 20, 4) \ - X(YMM0F6, 306, ymm0, 24, 4) \ - X(YMM0F7, 307, ymm0, 28, 4) \ - X(YMM1F0, 308, ymm1, 0, 4) \ - X(YMM1F1, 309, ymm1, 4, 4) \ - X(YMM1F2, 310, ymm1, 8, 4) \ - X(YMM1F3, 311, ymm1, 12, 4) \ - X(YMM1F4, 312, ymm1, 16, 4) \ - X(YMM1F5, 313, ymm1, 20, 4) \ - X(YMM1F6, 314, ymm1, 24, 4) \ - X(YMM1F7, 315, ymm1, 28, 4) \ - X(YMM2F0, 316, ymm2, 0, 4) \ - X(YMM2F1, 317, ymm2, 4, 4) \ - X(YMM2F2, 318, ymm2, 8, 4) \ - X(YMM2F3, 319, ymm2, 12, 4) \ - X(YMM2F4, 320, ymm2, 16, 4) \ - X(YMM2F5, 321, ymm2, 20, 4) \ - X(YMM2F6, 322, ymm2, 24, 4) \ - X(YMM2F7, 323, ymm2, 28, 4) \ - X(YMM3F0, 324, ymm3, 0, 4) \ - X(YMM3F1, 325, ymm3, 4, 4) \ - X(YMM3F2, 326, ymm3, 8, 4) \ - X(YMM3F3, 327, ymm3, 12, 4) \ - X(YMM3F4, 328, ymm3, 16, 4) \ - X(YMM3F5, 329, ymm3, 20, 4) \ - X(YMM3F6, 330, ymm3, 24, 4) \ - X(YMM3F7, 331, ymm3, 28, 4) \ - X(YMM4F0, 332, ymm4, 0, 4) \ - X(YMM4F1, 333, ymm4, 4, 4) \ - X(YMM4F2, 334, ymm4, 8, 4) \ - X(YMM4F3, 335, ymm4, 12, 4) \ - X(YMM4F4, 336, ymm4, 16, 4) \ - X(YMM4F5, 337, ymm4, 20, 4) \ - X(YMM4F6, 338, ymm4, 24, 4) \ - X(YMM4F7, 339, ymm4, 28, 4) \ - X(YMM5F0, 340, ymm5, 0, 4) \ - X(YMM5F1, 341, ymm5, 4, 4) \ - X(YMM5F2, 342, ymm5, 8, 4) \ - X(YMM5F3, 343, ymm5, 12, 4) \ - X(YMM5F4, 344, ymm5, 16, 4) \ - X(YMM5F5, 345, ymm5, 20, 4) \ - X(YMM5F6, 346, ymm5, 24, 4) \ - X(YMM5F7, 347, ymm5, 28, 4) \ - X(YMM6F0, 348, ymm6, 0, 4) \ - X(YMM6F1, 349, ymm6, 4, 4) \ - X(YMM6F2, 350, ymm6, 8, 4) \ - X(YMM6F3, 351, ymm6, 12, 4) \ - X(YMM6F4, 352, ymm6, 16, 4) \ - X(YMM6F5, 353, ymm6, 20, 4) \ - X(YMM6F6, 354, ymm6, 24, 4) \ - X(YMM6F7, 355, ymm6, 28, 4) \ - X(YMM7F0, 356, ymm7, 0, 4) \ - X(YMM7F1, 357, ymm7, 4, 4) \ - X(YMM7F2, 358, ymm7, 8, 4) \ - X(YMM7F3, 359, ymm7, 12, 4) \ - X(YMM7F4, 360, ymm7, 16, 4) \ - X(YMM7F5, 361, ymm7, 20, 4) \ - X(YMM7F6, 362, ymm7, 24, 4) \ - X(YMM7F7, 363, ymm7, 28, 4) \ - X(YMM0D0, 364, ymm0, 0, 8) \ - X(YMM0D1, 365, ymm0, 8, 8) \ - X(YMM0D2, 366, ymm0, 16, 8) \ - X(YMM0D3, 367, ymm0, 24, 8) \ - X(YMM1D0, 368, ymm1, 0, 8) \ - X(YMM1D1, 369, ymm1, 8, 8) \ - X(YMM1D2, 370, ymm1, 16, 8) \ - X(YMM1D3, 371, ymm1, 24, 8) \ - X(YMM2D0, 372, ymm2, 0, 8) \ - X(YMM2D1, 373, ymm2, 8, 8) \ - X(YMM2D2, 374, ymm2, 16, 8) \ - X(YMM2D3, 375, ymm2, 24, 8) \ - X(YMM3D0, 376, ymm3, 0, 8) \ - X(YMM3D1, 377, ymm3, 8, 8) \ - X(YMM3D2, 378, ymm3, 16, 8) \ - X(YMM3D3, 379, ymm3, 24, 8) \ - X(YMM4D0, 380, ymm4, 0, 8) \ - X(YMM4D1, 381, ymm4, 8, 8) \ - X(YMM4D2, 382, ymm4, 16, 8) \ - X(YMM4D3, 383, ymm4, 24, 8) \ - X(YMM5D0, 384, ymm5, 0, 8) \ - X(YMM5D1, 385, ymm5, 8, 8) \ - X(YMM5D2, 386, ymm5, 16, 8) \ - X(YMM5D3, 387, ymm5, 24, 8) \ - X(YMM6D0, 388, ymm6, 0, 8) \ - X(YMM6D1, 389, ymm6, 8, 8) \ - X(YMM6D2, 390, ymm6, 16, 8) \ - X(YMM6D3, 391, ymm6, 24, 8) \ - X(YMM7D0, 392, ymm7, 0, 8) \ - X(YMM7D1, 393, ymm7, 8, 8) \ - X(YMM7D2, 394, ymm7, 16, 8) \ - X(YMM7D3, 395, ymm7, 24, 8) +X(NONE, 0, nil, 0, 0) \ +X(AL, 1, eax, 0, 1) \ +X(CL, 2, ecx, 0, 1) \ +X(DL, 3, edx, 0, 1) \ +X(BL, 4, ebx, 0, 1) \ +X(AH, 5, eax, 1, 1) \ +X(CH, 6, ecx, 1, 1) \ +X(DH, 7, edx, 1, 1) \ +X(BH, 8, ebx, 1, 1) \ +X(AX, 9, eax, 0, 2) \ +X(CX, 10, ecx, 0, 2) \ +X(DX, 11, edx, 0, 2) \ +X(BX, 12, ebx, 0, 2) \ +X(SP, 13, esp, 0, 2) \ +X(BP, 14, ebp, 0, 2) \ +X(SI, 15, esi, 0, 2) \ +X(DI, 16, edi, 0, 2) \ +X(EAX, 17, eax, 0, 4) \ +X(ECX, 18, ecx, 0, 4) \ +X(EDX, 19, edx, 0, 4) \ +X(EBX, 20, ebx, 0, 4) \ +X(ESP, 21, esp, 0, 4) \ +X(EBP, 22, ebp, 0, 4) \ +X(ESI, 23, esi, 0, 4) \ +X(EDI, 24, edi, 0, 4) \ +X(ES, 25, es, 0, 2) \ +X(CS, 26, cs, 0, 2) \ +X(SS, 27, ss, 0, 2) \ +X(DS, 28, ds, 0, 2) \ +X(FS, 29, fs, 0, 2) \ +X(GS, 30, gs, 0, 2) \ +X(IP, 31, eip, 0, 2) \ +X(FLAGS, 32, eflags, 0, 2) \ +X(EIP, 33, eip, 0, 4) \ +X(EFLAGS, 34, eflags, 0, 4) \ +X(MM0, 146, fpr0, 0, 8) \ +X(MM1, 147, fpr1, 0, 8) \ +X(MM2, 148, fpr2, 0, 8) \ +X(MM3, 149, fpr3, 0, 8) \ +X(MM4, 150, fpr4, 0, 8) \ +X(MM5, 151, fpr5, 0, 8) \ +X(MM6, 152, fpr6, 0, 8) \ +X(MM7, 153, fpr7, 0, 8) \ +X(XMM0, 154, ymm0, 0, 16) \ +X(XMM1, 155, ymm1, 0, 16) \ +X(XMM2, 156, ymm2, 0, 16) \ +X(XMM3, 157, ymm3, 0, 16) \ +X(XMM4, 158, ymm4, 0, 16) \ +X(XMM5, 159, ymm5, 0, 16) \ +X(XMM6, 160, ymm6, 0, 16) \ +X(XMM7, 161, ymm7, 0, 16) \ +X(XMM00, 162, ymm0, 0, 4) \ +X(XMM01, 163, ymm0, 4, 4) \ +X(XMM02, 164, ymm0, 8, 4) \ +X(XMM03, 165, ymm0, 12, 4) \ +X(XMM10, 166, ymm1, 0, 4) \ +X(XMM11, 167, ymm1, 4, 4) \ +X(XMM12, 168, ymm1, 8, 4) \ +X(XMM13, 169, ymm1, 12, 4) \ +X(XMM20, 170, ymm2, 0, 4) \ +X(XMM21, 171, ymm2, 4, 4) \ +X(XMM22, 172, ymm2, 8, 4) \ +X(XMM23, 173, ymm2, 12, 4) \ +X(XMM30, 174, ymm3, 0, 4) \ +X(XMM31, 175, ymm3, 4, 4) \ +X(XMM32, 176, ymm3, 8, 4) \ +X(XMM33, 177, ymm3, 12, 4) \ +X(XMM40, 178, ymm4, 0, 4) \ +X(XMM41, 179, ymm4, 4, 4) \ +X(XMM42, 180, ymm4, 8, 4) \ +X(XMM43, 181, ymm4, 12, 4) \ +X(XMM50, 182, ymm5, 0, 4) \ +X(XMM51, 183, ymm5, 4, 4) \ +X(XMM52, 184, ymm5, 8, 4) \ +X(XMM53, 185, ymm5, 12, 4) \ +X(XMM60, 186, ymm6, 0, 4) \ +X(XMM61, 187, ymm6, 4, 4) \ +X(XMM62, 188, ymm6, 8, 4) \ +X(XMM63, 189, ymm6, 12, 4) \ +X(XMM70, 190, ymm7, 0, 4) \ +X(XMM71, 191, ymm7, 4, 4) \ +X(XMM72, 192, ymm7, 8, 4) \ +X(XMM73, 193, ymm7, 12, 4) \ +X(XMM0L, 194, ymm0, 0, 8) \ +X(XMM1L, 195, ymm1, 0, 8) \ +X(XMM2L, 196, ymm2, 0, 8) \ +X(XMM3L, 197, ymm3, 0, 8) \ +X(XMM4L, 198, ymm4, 0, 8) \ +X(XMM5L, 199, ymm5, 0, 8) \ +X(XMM6L, 200, ymm6, 0, 8) \ +X(XMM7L, 201, ymm7, 0, 8) \ +X(XMM0H, 202, ymm0, 8, 8) \ +X(XMM1H, 203, ymm1, 8, 8) \ +X(XMM2H, 204, ymm2, 8, 8) \ +X(XMM3H, 205, ymm3, 8, 8) \ +X(XMM4H, 206, ymm4, 8, 8) \ +X(XMM5H, 207, ymm5, 8, 8) \ +X(XMM6H, 208, ymm6, 8, 8) \ +X(XMM7H, 209, ymm7, 8, 8) \ +X(YMM0, 252, ymm0, 0, 32) \ +X(YMM1, 253, ymm1, 0, 32) \ +X(YMM2, 254, ymm2, 0, 32) \ +X(YMM3, 255, ymm3, 0, 32) \ +X(YMM4, 256, ymm4, 0, 32) \ +X(YMM5, 257, ymm5, 0, 32) \ +X(YMM6, 258, ymm6, 0, 32) \ +X(YMM7, 259, ymm7, 0, 32) \ +X(YMM0H, 260, ymm0, 16, 16) \ +X(YMM1H, 261, ymm1, 16, 16) \ +X(YMM2H, 262, ymm2, 16, 16) \ +X(YMM3H, 263, ymm3, 16, 16) \ +X(YMM4H, 264, ymm4, 16, 16) \ +X(YMM5H, 265, ymm5, 16, 16) \ +X(YMM6H, 266, ymm6, 16, 16) \ +X(YMM7H, 267, ymm7, 16, 16) \ +X(YMM0I0, 268, ymm0, 0, 8) \ +X(YMM0I1, 269, ymm0, 8, 8) \ +X(YMM0I2, 270, ymm0, 16, 8) \ +X(YMM0I3, 271, ymm0, 24, 8) \ +X(YMM1I0, 272, ymm1, 0, 8) \ +X(YMM1I1, 273, ymm1, 8, 8) \ +X(YMM1I2, 274, ymm1, 16, 8) \ +X(YMM1I3, 275, ymm1, 24, 8) \ +X(YMM2I0, 276, ymm2, 0, 8) \ +X(YMM2I1, 277, ymm2, 8, 8) \ +X(YMM2I2, 278, ymm2, 16, 8) \ +X(YMM2I3, 279, ymm2, 24, 8) \ +X(YMM3I0, 280, ymm3, 0, 8) \ +X(YMM3I1, 281, ymm3, 8, 8) \ +X(YMM3I2, 282, ymm3, 16, 8) \ +X(YMM3I3, 283, ymm3, 24, 8) \ +X(YMM4I0, 284, ymm4, 0, 8) \ +X(YMM4I1, 285, ymm4, 8, 8) \ +X(YMM4I2, 286, ymm4, 16, 8) \ +X(YMM4I3, 287, ymm4, 24, 8) \ +X(YMM5I0, 288, ymm5, 0, 8) \ +X(YMM5I1, 289, ymm5, 8, 8) \ +X(YMM5I2, 290, ymm5, 16, 8) \ +X(YMM5I3, 291, ymm5, 24, 8) \ +X(YMM6I0, 292, ymm6, 0, 8) \ +X(YMM6I1, 293, ymm6, 8, 8) \ +X(YMM6I2, 294, ymm6, 16, 8) \ +X(YMM6I3, 295, ymm6, 24, 8) \ +X(YMM7I0, 296, ymm7, 0, 8) \ +X(YMM7I1, 297, ymm7, 8, 8) \ +X(YMM7I2, 298, ymm7, 16, 8) \ +X(YMM7I3, 299, ymm7, 24, 8) \ +X(YMM0F0, 300, ymm0, 0, 4) \ +X(YMM0F1, 301, ymm0, 4, 4) \ +X(YMM0F2, 302, ymm0, 8, 4) \ +X(YMM0F3, 303, ymm0, 12, 4) \ +X(YMM0F4, 304, ymm0, 16, 4) \ +X(YMM0F5, 305, ymm0, 20, 4) \ +X(YMM0F6, 306, ymm0, 24, 4) \ +X(YMM0F7, 307, ymm0, 28, 4) \ +X(YMM1F0, 308, ymm1, 0, 4) \ +X(YMM1F1, 309, ymm1, 4, 4) \ +X(YMM1F2, 310, ymm1, 8, 4) \ +X(YMM1F3, 311, ymm1, 12, 4) \ +X(YMM1F4, 312, ymm1, 16, 4) \ +X(YMM1F5, 313, ymm1, 20, 4) \ +X(YMM1F6, 314, ymm1, 24, 4) \ +X(YMM1F7, 315, ymm1, 28, 4) \ +X(YMM2F0, 316, ymm2, 0, 4) \ +X(YMM2F1, 317, ymm2, 4, 4) \ +X(YMM2F2, 318, ymm2, 8, 4) \ +X(YMM2F3, 319, ymm2, 12, 4) \ +X(YMM2F4, 320, ymm2, 16, 4) \ +X(YMM2F5, 321, ymm2, 20, 4) \ +X(YMM2F6, 322, ymm2, 24, 4) \ +X(YMM2F7, 323, ymm2, 28, 4) \ +X(YMM3F0, 324, ymm3, 0, 4) \ +X(YMM3F1, 325, ymm3, 4, 4) \ +X(YMM3F2, 326, ymm3, 8, 4) \ +X(YMM3F3, 327, ymm3, 12, 4) \ +X(YMM3F4, 328, ymm3, 16, 4) \ +X(YMM3F5, 329, ymm3, 20, 4) \ +X(YMM3F6, 330, ymm3, 24, 4) \ +X(YMM3F7, 331, ymm3, 28, 4) \ +X(YMM4F0, 332, ymm4, 0, 4) \ +X(YMM4F1, 333, ymm4, 4, 4) \ +X(YMM4F2, 334, ymm4, 8, 4) \ +X(YMM4F3, 335, ymm4, 12, 4) \ +X(YMM4F4, 336, ymm4, 16, 4) \ +X(YMM4F5, 337, ymm4, 20, 4) \ +X(YMM4F6, 338, ymm4, 24, 4) \ +X(YMM4F7, 339, ymm4, 28, 4) \ +X(YMM5F0, 340, ymm5, 0, 4) \ +X(YMM5F1, 341, ymm5, 4, 4) \ +X(YMM5F2, 342, ymm5, 8, 4) \ +X(YMM5F3, 343, ymm5, 12, 4) \ +X(YMM5F4, 344, ymm5, 16, 4) \ +X(YMM5F5, 345, ymm5, 20, 4) \ +X(YMM5F6, 346, ymm5, 24, 4) \ +X(YMM5F7, 347, ymm5, 28, 4) \ +X(YMM6F0, 348, ymm6, 0, 4) \ +X(YMM6F1, 349, ymm6, 4, 4) \ +X(YMM6F2, 350, ymm6, 8, 4) \ +X(YMM6F3, 351, ymm6, 12, 4) \ +X(YMM6F4, 352, ymm6, 16, 4) \ +X(YMM6F5, 353, ymm6, 20, 4) \ +X(YMM6F6, 354, ymm6, 24, 4) \ +X(YMM6F7, 355, ymm6, 28, 4) \ +X(YMM7F0, 356, ymm7, 0, 4) \ +X(YMM7F1, 357, ymm7, 4, 4) \ +X(YMM7F2, 358, ymm7, 8, 4) \ +X(YMM7F3, 359, ymm7, 12, 4) \ +X(YMM7F4, 360, ymm7, 16, 4) \ +X(YMM7F5, 361, ymm7, 20, 4) \ +X(YMM7F6, 362, ymm7, 24, 4) \ +X(YMM7F7, 363, ymm7, 28, 4) \ +X(YMM0D0, 364, ymm0, 0, 8) \ +X(YMM0D1, 365, ymm0, 8, 8) \ +X(YMM0D2, 366, ymm0, 16, 8) \ +X(YMM0D3, 367, ymm0, 24, 8) \ +X(YMM1D0, 368, ymm1, 0, 8) \ +X(YMM1D1, 369, ymm1, 8, 8) \ +X(YMM1D2, 370, ymm1, 16, 8) \ +X(YMM1D3, 371, ymm1, 24, 8) \ +X(YMM2D0, 372, ymm2, 0, 8) \ +X(YMM2D1, 373, ymm2, 8, 8) \ +X(YMM2D2, 374, ymm2, 16, 8) \ +X(YMM2D3, 375, ymm2, 24, 8) \ +X(YMM3D0, 376, ymm3, 0, 8) \ +X(YMM3D1, 377, ymm3, 8, 8) \ +X(YMM3D2, 378, ymm3, 16, 8) \ +X(YMM3D3, 379, ymm3, 24, 8) \ +X(YMM4D0, 380, ymm4, 0, 8) \ +X(YMM4D1, 381, ymm4, 8, 8) \ +X(YMM4D2, 382, ymm4, 16, 8) \ +X(YMM4D3, 383, ymm4, 24, 8) \ +X(YMM5D0, 384, ymm5, 0, 8) \ +X(YMM5D1, 385, ymm5, 8, 8) \ +X(YMM5D2, 386, ymm5, 16, 8) \ +X(YMM5D3, 387, ymm5, 24, 8) \ +X(YMM6D0, 388, ymm6, 0, 8) \ +X(YMM6D1, 389, ymm6, 8, 8) \ +X(YMM6D2, 390, ymm6, 16, 8) \ +X(YMM6D3, 391, ymm6, 24, 8) \ +X(YMM7D0, 392, ymm7, 0, 8) \ +X(YMM7D1, 393, ymm7, 8, 8) \ +X(YMM7D2, 394, ymm7, 16, 8) \ +X(YMM7D3, 395, ymm7, 24, 8) typedef U16 CV_Regx86; typedef enum CV_Regx86Enum @@ -298,711 +298,711 @@ CV_Regx86Enum; // X(NAME, CODE, (RDI_RegisterCode_X64) NAME, BYTE_POS, BYTE_SIZE) #define CV_Reg_X64_XList(X) \ - X(NONE, 0, nil, 0, 0) \ - X(AL, 1, rax, 0, 1) \ - X(CL, 2, rcx, 0, 1) \ - X(DL, 3, rdx, 0, 1) \ - X(BL, 4, rbx, 0, 1) \ - X(AH, 5, rax, 1, 1) \ - X(CH, 6, rcx, 1, 1) \ - X(DH, 7, rdx, 1, 1) \ - X(BH, 8, rbx, 1, 1) \ - X(AX, 9, rax, 0, 2) \ - X(CX, 10, rcx, 0, 2) \ - X(DX, 11, rdx, 0, 2) \ - X(BX, 12, rbx, 0, 2) \ - X(SP, 13, rsp, 0, 2) \ - X(BP, 14, rbp, 0, 2) \ - X(SI, 15, rsi, 0, 2) \ - X(DI, 16, rdi, 0, 2) \ - X(EAX, 17, rax, 0, 4) \ - X(ECX, 18, rcx, 0, 4) \ - X(EDX, 19, rdx, 0, 4) \ - X(EBX, 20, rbx, 0, 4) \ - X(ESP, 21, rsp, 0, 4) \ - X(EBP, 22, rbp, 0, 4) \ - X(ESI, 23, rsi, 0, 4) \ - X(EDI, 24, rdi, 0, 4) \ - X(ES, 25, es, 0, 2) \ - X(CS, 26, cs, 0, 2) \ - X(SS, 27, ss, 0, 2) \ - X(DS, 28, ds, 0, 2) \ - X(FS, 29, fs, 0, 2) \ - X(GS, 30, gs, 0, 2) \ - X(FLAGS, 32, rflags, 0, 2) \ - X(RIP, 33, rip, 0, 8) \ - X(EFLAGS, 34, rflags, 0, 4) \ - /* TODO: possibly missing control registers in x64 definitions? */ \ - X(CR0, 80, nil, 0, 0) \ - X(CR1, 81, nil, 0, 0) \ - X(CR2, 82, nil, 0, 0) \ - X(CR3, 83, nil, 0, 0) \ - X(CR4, 84, nil, 0, 0) \ - X(CR8, 88, nil, 0, 0) \ - X(DR0, 90, dr0, 0, 4) \ - X(DR1, 91, dr1, 0, 4) \ - X(DR2, 92, dr2, 0, 4) \ - X(DR3, 93, dr3, 0, 4) \ - X(DR4, 94, dr4, 0, 4) \ - X(DR5, 95, dr5, 0, 4) \ - X(DR6, 96, dr6, 0, 4) \ - X(DR7, 97, dr7, 0, 4) \ - /* TODO: possibly missing debug registers 8-15 in x64 definitions? */ \ - X(DR8, 98, nil, 0, 0) \ - X(DR9, 99, nil, 0, 0) \ - X(DR10, 100, nil, 0, 0) \ - X(DR11, 101, nil, 0, 0) \ - X(DR12, 102, nil, 0, 0) \ - X(DR13, 103, nil, 0, 0) \ - X(DR14, 104, nil, 0, 0) \ - X(DR15, 105, nil, 0, 0) \ - /* TODO: possibly missing ~whatever these are~ in x64 definitions? */ \ - X(GDTR, 110, nil, 0, 0) \ - X(GDTL, 111, nil, 0, 0) \ - X(IDTR, 112, nil, 0, 0) \ - X(IDTL, 113, nil, 0, 0) \ - X(LDTR, 114, nil, 0, 0) \ - X(TR, 115, nil, 0, 0) \ - X(ST0, 128, st0, 0, 10) \ - X(ST1, 129, st1, 0, 10) \ - X(ST2, 130, st2, 0, 10) \ - X(ST3, 131, st3, 0, 10) \ - X(ST4, 132, st4, 0, 10) \ - X(ST5, 133, st5, 0, 10) \ - X(ST6, 134, st6, 0, 10) \ - X(ST7, 135, st7, 0, 10) \ - /* TODO: possibly missing these, or not sure how they map to our x64 definitions? */ \ - X(CTRL, 136, nil, 0, 0) \ - X(STAT, 137, nil, 0, 0) \ - X(TAG, 138, nil, 0, 0) \ - X(FPIP, 139, nil, 0, 0) \ - X(FPCS, 140, nil, 0, 0) \ - X(FPDO, 141, nil, 0, 0) \ - X(FPDS, 142, nil, 0, 0) \ - X(ISEM, 143, nil, 0, 0) \ - X(FPEIP, 144, nil, 0, 0) \ - X(FPEDO, 145, nil, 0, 0) \ - X(MM0, 146, fpr0, 0, 8) \ - X(MM1, 147, fpr1, 0, 8) \ - X(MM2, 148, fpr2, 0, 8) \ - X(MM3, 149, fpr3, 0, 8) \ - X(MM4, 150, fpr4, 0, 8) \ - X(MM5, 151, fpr5, 0, 8) \ - X(MM6, 152, fpr6, 0, 8) \ - X(MM7, 153, fpr7, 0, 8) \ - X(XMM0, 154, zmm0, 0, 16) \ - X(XMM1, 155, zmm1, 0, 16) \ - X(XMM2, 156, zmm2, 0, 16) \ - X(XMM3, 157, zmm3, 0, 16) \ - X(XMM4, 158, zmm4, 0, 16) \ - X(XMM5, 159, zmm5, 0, 16) \ - X(XMM6, 160, zmm6, 0, 16) \ - X(XMM7, 161, zmm7, 0, 16) \ - X(XMM0_0, 162, zmm0, 0, 4) \ - X(XMM0_1, 163, zmm0, 4, 4) \ - X(XMM0_2, 164, zmm0, 8, 4) \ - X(XMM0_3, 165, zmm0, 12, 4) \ - X(XMM1_0, 166, zmm1, 0, 4) \ - X(XMM1_1, 167, zmm1, 4, 4) \ - X(XMM1_2, 168, zmm1, 8, 4) \ - X(XMM1_3, 169, zmm1, 12, 4) \ - X(XMM2_0, 170, zmm2, 0, 4) \ - X(XMM2_1, 171, zmm2, 4, 4) \ - X(XMM2_2, 172, zmm2, 8, 4) \ - X(XMM2_3, 173, zmm2, 12, 4) \ - X(XMM3_0, 174, zmm3, 0, 4) \ - X(XMM3_1, 175, zmm3, 4, 4) \ - X(XMM3_2, 176, zmm3, 8, 4) \ - X(XMM3_3, 177, zmm3, 12, 4) \ - X(XMM4_0, 178, zmm4, 0, 4) \ - X(XMM4_1, 179, zmm4, 4, 4) \ - X(XMM4_2, 180, zmm4, 8, 4) \ - X(XMM4_3, 181, zmm4, 12, 4) \ - X(XMM5_0, 182, zmm5, 0, 4) \ - X(XMM5_1, 183, zmm5, 4, 4) \ - X(XMM5_2, 184, zmm5, 8, 4) \ - X(XMM5_3, 185, zmm5, 12, 4) \ - X(XMM6_0, 186, zmm6, 0, 4) \ - X(XMM6_1, 187, zmm6, 4, 4) \ - X(XMM6_2, 188, zmm6, 8, 4) \ - X(XMM6_3, 189, zmm6, 12, 4) \ - X(XMM7_0, 190, zmm7, 0, 4) \ - X(XMM7_1, 191, zmm7, 4, 4) \ - X(XMM7_2, 192, zmm7, 8, 4) \ - X(XMM7_3, 193, zmm7, 12, 4) \ - X(XMM0L, 194, zmm0, 0, 8) \ - X(XMM1L, 195, zmm1, 0, 8) \ - X(XMM2L, 196, zmm2, 0, 8) \ - X(XMM3L, 197, zmm3, 0, 8) \ - X(XMM4L, 198, zmm4, 0, 8) \ - X(XMM5L, 199, zmm5, 0, 8) \ - X(XMM6L, 200, zmm6, 0, 8) \ - X(XMM7L, 201, zmm7, 0, 8) \ - X(XMM0H, 202, zmm0, 8, 8) \ - X(XMM1H, 203, zmm1, 8, 8) \ - X(XMM2H, 204, zmm2, 8, 8) \ - X(XMM3H, 205, zmm3, 8, 8) \ - X(XMM4H, 206, zmm4, 8, 8) \ - X(XMM5H, 207, zmm5, 8, 8) \ - X(XMM6H, 208, zmm6, 8, 8) \ - X(XMM7H, 209, zmm7, 8, 8) \ - X(MXCSR, 211, mxcsr, 0, 4) \ - X(EMM0L, 220, zmm0, 0, 8) \ - X(EMM1L, 221, zmm1, 0, 8) \ - X(EMM2L, 222, zmm2, 0, 8) \ - X(EMM3L, 223, zmm3, 0, 8) \ - X(EMM4L, 224, zmm4, 0, 8) \ - X(EMM5L, 225, zmm5, 0, 8) \ - X(EMM6L, 226, zmm6, 0, 8) \ - X(EMM7L, 227, zmm7, 0, 8) \ - X(EMM0H, 228, zmm0, 8, 8) \ - X(EMM1H, 229, zmm1, 8, 8) \ - X(EMM2H, 230, zmm2, 8, 8) \ - X(EMM3H, 231, zmm3, 8, 8) \ - X(EMM4H, 232, zmm4, 8, 8) \ - X(EMM5H, 233, zmm5, 8, 8) \ - X(EMM6H, 234, zmm6, 8, 8) \ - X(EMM7H, 235, zmm7, 8, 8) \ - X(MM00, 236, fpr0, 0, 4) \ - X(MM01, 237, fpr0, 4, 4) \ - X(MM10, 238, fpr1, 0, 4) \ - X(MM11, 239, fpr1, 4, 4) \ - X(MM20, 240, fpr2, 0, 4) \ - X(MM21, 241, fpr2, 4, 4) \ - X(MM30, 242, fpr3, 0, 4) \ - X(MM31, 243, fpr3, 4, 4) \ - X(MM40, 244, fpr4, 0, 4) \ - X(MM41, 245, fpr4, 4, 4) \ - X(MM50, 246, fpr5, 0, 4) \ - X(MM51, 247, fpr5, 4, 4) \ - X(MM60, 248, fpr6, 0, 4) \ - X(MM61, 249, fpr6, 4, 4) \ - X(MM70, 250, fpr7, 0, 4) \ - X(MM71, 251, fpr7, 4, 4) \ - X(XMM8, 252, zmm8, 0, 16) \ - X(XMM9, 253, zmm9, 0, 16) \ - X(XMM10, 254, zmm10, 0, 16) \ - X(XMM11, 255, zmm11, 0, 16) \ - X(XMM12, 256, zmm12, 0, 16) \ - X(XMM13, 257, zmm13, 0, 16) \ - X(XMM14, 258, zmm14, 0, 16) \ - X(XMM15, 259, zmm15, 0, 16) \ - X(XMM8_0, 260, zmm8, 0, 16) \ - X(XMM8_1, 261, zmm8, 4, 16) \ - X(XMM8_2, 262, zmm8, 8, 16) \ - X(XMM8_3, 263, zmm8, 12, 16) \ - X(XMM9_0, 264, zmm9, 0, 4) \ - X(XMM9_1, 265, zmm9, 4, 4) \ - X(XMM9_2, 266, zmm9, 8, 4) \ - X(XMM9_3, 267, zmm9, 12, 4) \ - X(XMM10_0, 268, zmm10, 0, 4) \ - X(XMM10_1, 269, zmm10, 4, 4) \ - X(XMM10_2, 270, zmm10, 8, 4) \ - X(XMM10_3, 271, zmm10, 12, 4) \ - X(XMM11_0, 272, zmm11, 0, 4) \ - X(XMM11_1, 273, zmm11, 4, 4) \ - X(XMM11_2, 274, zmm11, 8, 4) \ - X(XMM11_3, 275, zmm11, 12, 4) \ - X(XMM12_0, 276, zmm12, 0, 4) \ - X(XMM12_1, 277, zmm12, 4, 4) \ - X(XMM12_2, 278, zmm12, 8, 4) \ - X(XMM12_3, 279, zmm12, 12, 4) \ - X(XMM13_0, 280, zmm13, 0, 4) \ - X(XMM13_1, 281, zmm13, 4, 4) \ - X(XMM13_2, 282, zmm13, 8, 4) \ - X(XMM13_3, 283, zmm13, 12, 4) \ - X(XMM14_0, 284, zmm14, 0, 4) \ - X(XMM14_1, 285, zmm14, 4, 4) \ - X(XMM14_2, 286, zmm14, 8, 4) \ - X(XMM14_3, 287, zmm14, 12, 4) \ - X(XMM15_0, 288, zmm15, 0, 4) \ - X(XMM15_1, 289, zmm15, 4, 4) \ - X(XMM15_2, 290, zmm15, 8, 4) \ - X(XMM15_3, 291, zmm15, 12, 4) \ - X(XMM8L, 292, zmm8, 0, 8) \ - X(XMM9L, 293, zmm9, 0, 8) \ - X(XMM10L, 294, zmm10, 0, 8) \ - X(XMM11L, 295, zmm11, 0, 8) \ - X(XMM12L, 296, zmm12, 0, 8) \ - X(XMM13L, 297, zmm13, 0, 8) \ - X(XMM14L, 298, zmm14, 0, 8) \ - X(XMM15L, 299, zmm15, 0, 8) \ - X(XMM8H, 300, zmm8, 8, 8) \ - X(XMM9H, 301, zmm9, 8, 8) \ - X(XMM10H, 302, zmm10, 8, 8) \ - X(XMM11H, 303, zmm11, 8, 8) \ - X(XMM12H, 304, zmm12, 8, 8) \ - X(XMM13H, 305, zmm13, 8, 8) \ - X(XMM14H, 306, zmm14, 8, 8) \ - X(XMM15H, 307, zmm15, 8, 8) \ - X(EMM8L, 308, zmm8, 0, 8) \ - X(EMM9L, 309, zmm9, 0, 8) \ - X(EMM10L, 310, zmm10, 0, 8) \ - X(EMM11L, 311, zmm11, 0, 8) \ - X(EMM12L, 312, zmm12, 0, 8) \ - X(EMM13L, 313, zmm13, 0, 8) \ - X(EMM14L, 314, zmm14, 0, 8) \ - X(EMM15L, 315, zmm15, 0, 8) \ - X(EMM8H, 316, zmm8, 8, 8) \ - X(EMM9H, 317, zmm9, 8, 8) \ - X(EMM10H, 318, zmm10, 8, 8) \ - X(EMM11H, 319, zmm11, 8, 8) \ - X(EMM12H, 320, zmm12, 8, 8) \ - X(EMM13H, 321, zmm13, 8, 8) \ - X(EMM14H, 322, zmm14, 8, 8) \ - X(EMM15H, 323, zmm15, 8, 8) \ - X(SIL, 324, rsi, 0, 1) \ - X(DIL, 325, rdi, 0, 1) \ - X(BPL, 326, rbp, 0, 1) \ - X(SPL, 327, rsp, 0, 1) \ - X(RAX, 328, rax, 0, 8) \ - X(RBX, 329, rbx, 0, 8) \ - X(RCX, 330, rcx, 0, 8) \ - X(RDX, 331, rdx, 0, 8) \ - X(RSI, 332, rsi, 0, 8) \ - X(RDI, 333, rdi, 0, 8) \ - X(RBP, 334, rbp, 0, 8) \ - X(RSP, 335, rsp, 0, 8) \ - X(R8, 336, r8, 0, 8) \ - X(R9, 337, r9, 0, 8) \ - X(R10, 338, r10, 0, 8) \ - X(R11, 339, r11, 0, 8) \ - X(R12, 340, r12, 0, 8) \ - X(R13, 341, r13, 0, 8) \ - X(R14, 342, r14, 0, 8) \ - X(R15, 343, r15, 0, 8) \ - X(R8B, 344, r8, 0, 1) \ - X(R9B, 345, r9, 0, 1) \ - X(R10B, 346, r10, 0, 1) \ - X(R11B, 347, r11, 0, 1) \ - X(R12B, 348, r12, 0, 1) \ - X(R13B, 349, r13, 0, 1) \ - X(R14B, 350, r14, 0, 1) \ - X(R15B, 351, r15, 0, 1) \ - X(R8W, 352, r8, 0, 2) \ - X(R9W, 353, r9, 0, 2) \ - X(R10W, 354, r10, 0, 2) \ - X(R11W, 355, r11, 0, 2) \ - X(R12W, 356, r12, 0, 2) \ - X(R13W, 357, r13, 0, 2) \ - X(R14W, 358, r14, 0, 2) \ - X(R15W, 359, r15, 0, 2) \ - X(R8D, 360, r8, 0, 4) \ - X(R9D, 361, r9, 0, 4) \ - X(R10D, 362, r10, 0, 4) \ - X(R11D, 363, r11, 0, 4) \ - X(R12D, 364, r12, 0, 4) \ - X(R13D, 365, r13, 0, 4) \ - X(R14D, 366, r14, 0, 4) \ - X(R15D, 367, r15, 0, 4) \ - X(YMM0, 368, zmm0, 0, 32) \ - X(YMM1, 369, zmm1, 0, 32) \ - X(YMM2, 370, zmm2, 0, 32) \ - X(YMM3, 371, zmm3, 0, 32) \ - X(YMM4, 372, zmm4, 0, 32) \ - X(YMM5, 373, zmm5, 0, 32) \ - X(YMM6, 374, zmm6, 0, 32) \ - X(YMM7, 375, zmm7, 0, 32) \ - X(YMM8, 376, zmm8, 0, 32) \ - X(YMM9, 377, zmm9, 0, 32) \ - X(YMM10, 378, zmm10, 0, 32) \ - X(YMM11, 379, zmm11, 0, 32) \ - X(YMM12, 380, zmm12, 0, 32) \ - X(YMM13, 381, zmm13, 0, 32) \ - X(YMM14, 382, zmm14, 0, 32) \ - X(YMM15, 383, zmm15, 0, 32) \ - X(YMM0H, 384, zmm0, 16, 32) \ - X(YMM1H, 385, zmm1, 16, 32) \ - X(YMM2H, 386, zmm2, 16, 32) \ - X(YMM3H, 387, zmm3, 16, 32) \ - X(YMM4H, 388, zmm4, 16, 32) \ - X(YMM5H, 389, zmm5, 16, 32) \ - X(YMM6H, 390, zmm6, 16, 32) \ - X(YMM7H, 391, zmm7, 16, 32) \ - X(YMM8H, 392, zmm8, 16, 32) \ - X(YMM9H, 393, zmm9, 16, 32) \ - X(YMM10H, 394, zmm10, 16, 32) \ - X(YMM11H, 395, zmm11, 16, 32) \ - X(YMM12H, 396, zmm12, 16, 32) \ - X(YMM13H, 397, zmm13, 16, 32) \ - X(YMM14H, 398, zmm14, 16, 32) \ - X(YMM15H, 399, zmm15, 16, 32) \ - X(XMM0IL, 400, zmm0, 0, 8) \ - X(XMM1IL, 401, zmm1, 0, 8) \ - X(XMM2IL, 402, zmm2, 0, 8) \ - X(XMM3IL, 403, zmm3, 0, 8) \ - X(XMM4IL, 404, zmm4, 0, 8) \ - X(XMM5IL, 405, zmm5, 0, 8) \ - X(XMM6IL, 406, zmm6, 0, 8) \ - X(XMM7IL, 407, zmm7, 0, 8) \ - X(XMM8IL, 408, zmm8, 0, 8) \ - X(XMM9IL, 409, zmm9, 0, 8) \ - X(XMM10IL, 410, zmm10, 0, 8) \ - X(XMM11IL, 411, zmm11, 0, 8) \ - X(XMM12IL, 412, zmm12, 0, 8) \ - X(XMM13IL, 413, zmm13, 0, 8) \ - X(XMM14IL, 414, zmm14, 0, 8) \ - X(XMM15IL, 415, zmm15, 0, 8) \ - X(XMM0IH, 416, zmm0, 8, 8) \ - X(XMM1IH, 417, zmm1, 8, 8) \ - X(XMM2IH, 418, zmm2, 8, 8) \ - X(XMM3IH, 419, zmm3, 8, 8) \ - X(XMM4IH, 420, zmm4, 8, 8) \ - X(XMM5IH, 421, zmm5, 8, 8) \ - X(XMM6IH, 422, zmm6, 8, 8) \ - X(XMM7IH, 423, zmm7, 8, 8) \ - X(XMM8IH, 424, zmm8, 8, 8) \ - X(XMM9IH, 425, zmm9, 8, 8) \ - X(XMM10IH, 426, zmm10, 8, 8) \ - X(XMM11IH, 427, zmm11, 8, 8) \ - X(XMM12IH, 428, zmm12, 8, 8) \ - X(XMM13IH, 429, zmm13, 8, 8) \ - X(XMM14IH, 430, zmm14, 8, 8) \ - X(XMM15IH, 431, zmm15, 8, 8) \ - X(YMM0I0, 432, zmm0, 0, 8) \ - X(YMM0I1, 433, zmm0, 8, 8) \ - X(YMM0I2, 434, zmm0, 16, 8) \ - X(YMM0I3, 435, zmm0, 24, 8) \ - X(YMM1I0, 436, zmm1, 0, 8) \ - X(YMM1I1, 437, zmm1, 8, 8) \ - X(YMM1I2, 438, zmm1, 16, 8) \ - X(YMM1I3, 439, zmm1, 24, 8) \ - X(YMM2I0, 440, zmm2, 0, 8) \ - X(YMM2I1, 441, zmm2, 8, 8) \ - X(YMM2I2, 442, zmm2, 16, 8) \ - X(YMM2I3, 443, zmm2, 24, 8) \ - X(YMM3I0, 444, zmm3, 0, 8) \ - X(YMM3I1, 445, zmm3, 8, 8) \ - X(YMM3I2, 446, zmm3, 16, 8) \ - X(YMM3I3, 447, zmm3, 24, 8) \ - X(YMM4I0, 448, zmm4, 0, 8) \ - X(YMM4I1, 449, zmm4, 8, 8) \ - X(YMM4I2, 450, zmm4, 16, 8) \ - X(YMM4I3, 451, zmm4, 24, 8) \ - X(YMM5I0, 452, zmm5, 0, 8) \ - X(YMM5I1, 453, zmm5, 8, 8) \ - X(YMM5I2, 454, zmm5, 16, 8) \ - X(YMM5I3, 455, zmm5, 24, 8) \ - X(YMM6I0, 456, zmm6, 0, 8) \ - X(YMM6I1, 457, zmm6, 8, 8) \ - X(YMM6I2, 458, zmm6, 16, 8) \ - X(YMM6I3, 459, zmm6, 24, 8) \ - X(YMM7I0, 460, zmm7, 0, 8) \ - X(YMM7I1, 461, zmm7, 8, 8) \ - X(YMM7I2, 462, zmm7, 16, 8) \ - X(YMM7I3, 463, zmm7, 24, 8) \ - X(YMM8I0, 464, zmm8, 0, 8) \ - X(YMM8I1, 465, zmm8, 8, 8) \ - X(YMM8I2, 466, zmm8, 16, 8) \ - X(YMM8I3, 467, zmm8, 24, 8) \ - X(YMM9I0, 468, zmm9, 0, 8) \ - X(YMM9I1, 469, zmm9, 8, 8) \ - X(YMM9I2, 470, zmm9, 16, 8) \ - X(YMM9I3, 471, zmm9, 24, 8) \ - X(YMM10I0, 472, zmm10, 0, 8) \ - X(YMM10I1, 473, zmm10, 8, 8) \ - X(YMM10I2, 474, zmm10, 16, 8) \ - X(YMM10I3, 475, zmm10, 24, 8) \ - X(YMM11I0, 476, zmm11, 0, 8) \ - X(YMM11I1, 477, zmm11, 8, 8) \ - X(YMM11I2, 478, zmm11, 16, 8) \ - X(YMM11I3, 479, zmm11, 24, 8) \ - X(YMM12I0, 480, zmm12, 0, 8) \ - X(YMM12I1, 481, zmm12, 8, 8) \ - X(YMM12I2, 482, zmm12, 16, 8) \ - X(YMM12I3, 483, zmm12, 24, 8) \ - X(YMM13I0, 484, zmm13, 0, 8) \ - X(YMM13I1, 485, zmm13, 8, 8) \ - X(YMM13I2, 486, zmm13, 16, 8) \ - X(YMM13I3, 487, zmm13, 24, 8) \ - X(YMM14I0, 488, zmm14, 0, 8) \ - X(YMM14I1, 489, zmm14, 8, 8) \ - X(YMM14I2, 490, zmm14, 16, 8) \ - X(YMM14I3, 491, zmm14, 24, 8) \ - X(YMM15I0, 492, zmm15, 0, 8) \ - X(YMM15I1, 493, zmm15, 8, 8) \ - X(YMM15I2, 494, zmm15, 16, 8) \ - X(YMM15I3, 495, zmm15, 24, 8) \ - X(YMM0F0, 496, zmm0, 0, 4) \ - X(YMM0F1, 497, zmm0, 4, 4) \ - X(YMM0F2, 498, zmm0, 8, 4) \ - X(YMM0F3, 499, zmm0, 12, 4) \ - X(YMM0F4, 500, zmm0, 16, 4) \ - X(YMM0F5, 501, zmm0, 20, 4) \ - X(YMM0F6, 502, zmm0, 24, 4) \ - X(YMM0F7, 503, zmm0, 28, 4) \ - X(YMM1F0, 504, zmm1, 0, 4) \ - X(YMM1F1, 505, zmm1, 4, 4) \ - X(YMM1F2, 506, zmm1, 8, 4) \ - X(YMM1F3, 507, zmm1, 12, 4) \ - X(YMM1F4, 508, zmm1, 16, 4) \ - X(YMM1F5, 509, zmm1, 20, 4) \ - X(YMM1F6, 510, zmm1, 24, 4) \ - X(YMM1F7, 511, zmm1, 28, 4) \ - X(YMM2F0, 512, zmm2, 0, 4) \ - X(YMM2F1, 513, zmm2, 4, 4) \ - X(YMM2F2, 514, zmm2, 8, 4) \ - X(YMM2F3, 515, zmm2, 12, 4) \ - X(YMM2F4, 516, zmm2, 16, 4) \ - X(YMM2F5, 517, zmm2, 20, 4) \ - X(YMM2F6, 518, zmm2, 24, 4) \ - X(YMM2F7, 519, zmm2, 28, 4) \ - X(YMM3F0, 520, zmm3, 0, 4) \ - X(YMM3F1, 521, zmm3, 4, 4) \ - X(YMM3F2, 522, zmm3, 8, 4) \ - X(YMM3F3, 523, zmm3, 12, 4) \ - X(YMM3F4, 524, zmm3, 16, 4) \ - X(YMM3F5, 525, zmm3, 20, 4) \ - X(YMM3F6, 526, zmm3, 24, 4) \ - X(YMM3F7, 527, zmm3, 28, 4) \ - X(YMM4F0, 528, zmm4, 0, 4) \ - X(YMM4F1, 529, zmm4, 4, 4) \ - X(YMM4F2, 530, zmm4, 8, 4) \ - X(YMM4F3, 531, zmm4, 12, 4) \ - X(YMM4F4, 532, zmm4, 16, 4) \ - X(YMM4F5, 533, zmm4, 20, 4) \ - X(YMM4F6, 534, zmm4, 24, 4) \ - X(YMM4F7, 535, zmm4, 28, 4) \ - X(YMM5F0, 536, zmm5, 0, 4) \ - X(YMM5F1, 537, zmm5, 4, 4) \ - X(YMM5F2, 538, zmm5, 8, 4) \ - X(YMM5F3, 539, zmm5, 12, 4) \ - X(YMM5F4, 540, zmm5, 16, 4) \ - X(YMM5F5, 541, zmm5, 20, 4) \ - X(YMM5F6, 542, zmm5, 24, 4) \ - X(YMM5F7, 543, zmm5, 28, 4) \ - X(YMM6F0, 544, zmm6, 0, 4) \ - X(YMM6F1, 545, zmm6, 4, 4) \ - X(YMM6F2, 546, zmm6, 8, 4) \ - X(YMM6F3, 547, zmm6, 12, 4) \ - X(YMM6F4, 548, zmm6, 16, 4) \ - X(YMM6F5, 549, zmm6, 20, 4) \ - X(YMM6F6, 550, zmm6, 24, 4) \ - X(YMM6F7, 551, zmm6, 28, 4) \ - X(YMM7F0, 552, zmm7, 0, 4) \ - X(YMM7F1, 553, zmm7, 4, 4) \ - X(YMM7F2, 554, zmm7, 8, 4) \ - X(YMM7F3, 555, zmm7, 12, 4) \ - X(YMM7F4, 556, zmm7, 16, 4) \ - X(YMM7F5, 557, zmm7, 20, 4) \ - X(YMM7F6, 558, zmm7, 24, 4) \ - X(YMM7F7, 559, zmm7, 28, 4) \ - X(YMM8F0, 560, zmm8, 0, 4) \ - X(YMM8F1, 561, zmm8, 4, 4) \ - X(YMM8F2, 562, zmm8, 8, 4) \ - X(YMM8F3, 563, zmm8, 12, 4) \ - X(YMM8F4, 564, zmm8, 16, 4) \ - X(YMM8F5, 565, zmm8, 20, 4) \ - X(YMM8F6, 566, zmm8, 24, 4) \ - X(YMM8F7, 567, zmm8, 28, 4) \ - X(YMM9F0, 568, zmm9, 0, 4) \ - X(YMM9F1, 569, zmm9, 4, 4) \ - X(YMM9F2, 570, zmm9, 8, 4) \ - X(YMM9F3, 571, zmm9, 12, 4) \ - X(YMM9F4, 572, zmm9, 16, 4) \ - X(YMM9F5, 573, zmm9, 20, 4) \ - X(YMM9F6, 574, zmm9, 24, 4) \ - X(YMM9F7, 575, zmm9, 28, 4) \ - X(YMM10F0, 576, zmm10, 0, 4) \ - X(YMM10F1, 577, zmm10, 4, 4) \ - X(YMM10F2, 578, zmm10, 8, 4) \ - X(YMM10F3, 579, zmm10, 12, 4) \ - X(YMM10F4, 580, zmm10, 16, 4) \ - X(YMM10F5, 581, zmm10, 20, 4) \ - X(YMM10F6, 582, zmm10, 24, 4) \ - X(YMM10F7, 583, zmm10, 28, 4) \ - X(YMM11F0, 584, zmm11, 0, 4) \ - X(YMM11F1, 585, zmm11, 4, 4) \ - X(YMM11F2, 586, zmm11, 8, 4) \ - X(YMM11F3, 587, zmm11, 12, 4) \ - X(YMM11F4, 588, zmm11, 16, 4) \ - X(YMM11F5, 589, zmm11, 20, 4) \ - X(YMM11F6, 590, zmm11, 24, 4) \ - X(YMM11F7, 591, zmm11, 28, 4) \ - X(YMM12F0, 592, zmm12, 0, 4) \ - X(YMM12F1, 593, zmm12, 4, 4) \ - X(YMM12F2, 594, zmm12, 8, 4) \ - X(YMM12F3, 595, zmm12, 12, 4) \ - X(YMM12F4, 596, zmm12, 16, 4) \ - X(YMM12F5, 597, zmm12, 20, 4) \ - X(YMM12F6, 598, zmm12, 24, 4) \ - X(YMM12F7, 599, zmm12, 28, 4) \ - X(YMM13F0, 600, zmm13, 0, 4) \ - X(YMM13F1, 601, zmm13, 4, 4) \ - X(YMM13F2, 602, zmm13, 8, 4) \ - X(YMM13F3, 603, zmm13, 12, 4) \ - X(YMM13F4, 604, zmm13, 16, 4) \ - X(YMM13F5, 605, zmm13, 20, 4) \ - X(YMM13F6, 606, zmm13, 24, 4) \ - X(YMM13F7, 607, zmm13, 28, 4) \ - X(YMM14F0, 608, zmm14, 0, 4) \ - X(YMM14F1, 609, zmm14, 4, 4) \ - X(YMM14F2, 610, zmm14, 8, 4) \ - X(YMM14F3, 611, zmm14, 12, 4) \ - X(YMM14F4, 612, zmm14, 16, 4) \ - X(YMM14F5, 613, zmm14, 20, 4) \ - X(YMM14F6, 614, zmm14, 24, 4) \ - X(YMM14F7, 615, zmm14, 28, 4) \ - X(YMM15F0, 616, zmm15, 0, 4) \ - X(YMM15F1, 617, zmm15, 4, 4) \ - X(YMM15F2, 618, zmm15, 8, 4) \ - X(YMM15F3, 619, zmm15, 12, 4) \ - X(YMM15F4, 620, zmm15, 16, 4) \ - X(YMM15F5, 621, zmm15, 20, 4) \ - X(YMM15F6, 622, zmm15, 24, 4) \ - X(YMM15F7, 623, zmm15, 28, 4) \ - X(YMM0D0, 624, zmm0, 0, 8) \ - X(YMM0D1, 625, zmm0, 8, 8) \ - X(YMM0D2, 626, zmm0, 16, 8) \ - X(YMM0D3, 627, zmm0, 24, 8) \ - X(YMM1D0, 628, zmm1, 0, 8) \ - X(YMM1D1, 629, zmm1, 8, 8) \ - X(YMM1D2, 630, zmm1, 16, 8) \ - X(YMM1D3, 631, zmm1, 24, 8) \ - X(YMM2D0, 632, zmm2, 0, 8) \ - X(YMM2D1, 633, zmm2, 8, 8) \ - X(YMM2D2, 634, zmm2, 16, 8) \ - X(YMM2D3, 635, zmm2, 24, 8) \ - X(YMM3D0, 636, zmm3, 0, 8) \ - X(YMM3D1, 637, zmm3, 8, 8) \ - X(YMM3D2, 638, zmm3, 16, 8) \ - X(YMM3D3, 639, zmm3, 24, 8) \ - X(YMM4D0, 640, zmm4, 0, 8) \ - X(YMM4D1, 641, zmm4, 8, 8) \ - X(YMM4D2, 642, zmm4, 16, 8) \ - X(YMM4D3, 643, zmm4, 24, 8) \ - X(YMM5D0, 644, zmm5, 0, 8) \ - X(YMM5D1, 645, zmm5, 8, 8) \ - X(YMM5D2, 646, zmm5, 16, 8) \ - X(YMM5D3, 647, zmm5, 24, 8) \ - X(YMM6D0, 648, zmm6, 0, 8) \ - X(YMM6D1, 649, zmm6, 8, 8) \ - X(YMM6D2, 650, zmm6, 16, 8) \ - X(YMM6D3, 651, zmm6, 24, 8) \ - X(YMM7D0, 652, zmm7, 0, 8) \ - X(YMM7D1, 653, zmm7, 8, 8) \ - X(YMM7D2, 654, zmm7, 16, 8) \ - X(YMM7D3, 655, zmm7, 24, 8) \ - X(YMM8D0, 656, zmm8, 0, 8) \ - X(YMM8D1, 657, zmm8, 8, 8) \ - X(YMM8D2, 658, zmm8, 16, 8) \ - X(YMM8D3, 659, zmm8, 24, 8) \ - X(YMM9D0, 660, zmm9, 0, 8) \ - X(YMM9D1, 661, zmm9, 8, 8) \ - X(YMM9D2, 662, zmm9, 16, 8) \ - X(YMM9D3, 663, zmm9, 24, 8) \ - X(YMM10D0, 664, zmm10, 0, 8) \ - X(YMM10D1, 665, zmm10, 8, 8) \ - X(YMM10D2, 666, zmm10, 16, 8) \ - X(YMM10D3, 667, zmm10, 24, 8) \ - X(YMM11D0, 668, zmm11, 0, 8) \ - X(YMM11D1, 669, zmm11, 8, 8) \ - X(YMM11D2, 670, zmm11, 16, 8) \ - X(YMM11D3, 671, zmm11, 24, 8) \ - X(YMM12D0, 672, zmm12, 0, 8) \ - X(YMM12D1, 673, zmm12, 8, 8) \ - X(YMM12D2, 674, zmm12, 16, 8) \ - X(YMM12D3, 675, zmm12, 24, 8) \ - X(YMM13D0, 676, zmm13, 0, 8) \ - X(YMM13D1, 677, zmm13, 8, 8) \ - X(YMM13D2, 678, zmm13, 16, 8) \ - X(YMM13D3, 679, zmm13, 24, 8) \ - X(YMM14D0, 680, zmm14, 0, 8) \ - X(YMM14D1, 681, zmm14, 8, 8) \ - X(YMM14D2, 682, zmm14, 16, 8) \ - X(YMM14D3, 683, zmm14, 24, 8) \ - X(YMM15D0, 684, zmm15, 0, 8) \ - X(YMM15D1, 685, zmm15, 8, 8) \ - X(YMM15D2, 686, zmm15, 16, 8) \ - X(YMM15D3, 687, zmm15, 24, 8) \ - X(XMM16, 694, zmm16, 0, 16) \ - X(XMM17, 695, zmm17, 0, 16) \ - X(XMM18, 696, zmm18, 0, 16) \ - X(XMM19, 697, zmm19, 0, 16) \ - X(XMM20, 698, zmm20, 0, 16) \ - X(XMM21, 699, zmm21, 0, 16) \ - X(XMM22, 700, zmm22, 0, 16) \ - X(XMM23, 701, zmm23, 0, 16) \ - X(XMM24, 702, zmm24, 0, 16) \ - X(XMM25, 703, zmm25, 0, 16) \ - X(XMM26, 704, zmm26, 0, 16) \ - X(XMM27, 705, zmm27, 0, 16) \ - X(XMM28, 706, zmm28, 0, 16) \ - X(XMM29, 707, zmm29, 0, 16) \ - X(XMM30, 708, zmm30, 0, 16) \ - X(XMM31, 709, zmm31, 0, 16) \ - X(YMM16, 710, zmm16, 0, 32) \ - X(YMM17, 711, zmm17, 0, 32) \ - X(YMM18, 712, zmm18, 0, 32) \ - X(YMM19, 713, zmm19, 0, 32) \ - X(YMM20, 714, zmm20, 0, 32) \ - X(YMM21, 715, zmm21, 0, 32) \ - X(YMM22, 716, zmm22, 0, 32) \ - X(YMM23, 717, zmm23, 0, 32) \ - X(YMM24, 718, zmm24, 0, 32) \ - X(YMM25, 719, zmm25, 0, 32) \ - X(YMM26, 720, zmm26, 0, 32) \ - X(YMM27, 721, zmm27, 0, 32) \ - X(YMM28, 722, zmm28, 0, 32) \ - X(YMM29, 723, zmm29, 0, 32) \ - X(YMM30, 724, zmm30, 0, 32) \ - X(YMM31, 725, zmm31, 0, 32) \ - X(ZMM0, 726, zmm0, 0, 64) \ - X(ZMM1, 727, zmm1, 0, 64) \ - X(ZMM2, 728, zmm2, 0, 64) \ - X(ZMM3, 729, zmm3, 0, 64) \ - X(ZMM4, 730, zmm4, 0, 64) \ - X(ZMM5, 731, zmm5, 0, 64) \ - X(ZMM6, 732, zmm6, 0, 64) \ - X(ZMM7, 733, zmm7, 0, 64) \ - X(ZMM8, 734, zmm8, 0, 64) \ - X(ZMM9, 735, zmm9, 0, 64) \ - X(ZMM10, 736, zmm10, 0, 64) \ - X(ZMM11, 737, zmm11, 0, 64) \ - X(ZMM12, 738, zmm12, 0, 64) \ - X(ZMM13, 739, zmm13, 0, 64) \ - X(ZMM14, 740, zmm14, 0, 64) \ - X(ZMM15, 741, zmm15, 0, 64) \ - X(ZMM16, 742, zmm16, 0, 64) \ - X(ZMM17, 743, zmm17, 0, 64) \ - X(ZMM18, 744, zmm18, 0, 64) \ - X(ZMM19, 745, zmm19, 0, 64) \ - X(ZMM20, 746, zmm20, 0, 64) \ - X(ZMM21, 747, zmm21, 0, 64) \ - X(ZMM22, 748, zmm22, 0, 64) \ - X(ZMM23, 749, zmm23, 0, 64) \ - X(ZMM24, 750, zmm24, 0, 64) \ - X(ZMM25, 751, zmm25, 0, 64) \ - X(ZMM26, 752, zmm26, 0, 64) \ - X(ZMM27, 753, zmm27, 0, 64) \ - X(ZMM28, 754, zmm28, 0, 64) \ - X(ZMM29, 755, zmm29, 0, 64) \ - X(ZMM30, 756, zmm30, 0, 64) \ - X(ZMM31, 757, zmm31, 0, 64) \ - X(K0, 758, k0, 0, 8) \ - X(K1, 759, k1, 0, 8) \ - X(K2, 760, k2, 0, 8) \ - X(K3, 761, k3, 0, 8) \ - X(K4, 762, k4, 0, 8) \ - X(K5, 763, k5, 0, 8) \ - X(K6, 764, k6, 0, 8) \ - X(K7, 765, k7, 0, 8) \ - X(ZMM0H, 766, zmm0, 32, 32) \ - X(ZMM1H, 767, zmm1, 32, 32) \ - X(ZMM2H, 768, zmm2, 32, 32) \ - X(ZMM3H, 769, zmm3, 32, 32) \ - X(ZMM4H, 770, zmm4, 32, 32) \ - X(ZMM5H, 771, zmm5, 32, 32) \ - X(ZMM6H, 772, zmm6, 32, 32) \ - X(ZMM7H, 773, zmm7, 32, 32) \ - X(ZMM8H, 774, zmm8, 32, 32) \ - X(ZMM9H, 775, zmm9, 32, 32) \ - X(ZMM10H, 776, zmm10, 32, 32) \ - X(ZMM11H, 777, zmm11, 32, 32) \ - X(ZMM12H, 778, zmm12, 32, 32) \ - X(ZMM13H, 779, zmm13, 32, 32) \ - X(ZMM14H, 780, zmm14, 32, 32) \ - X(ZMM15H, 781, zmm15, 32, 32) +X(NONE, 0, nil, 0, 0) \ +X(AL, 1, rax, 0, 1) \ +X(CL, 2, rcx, 0, 1) \ +X(DL, 3, rdx, 0, 1) \ +X(BL, 4, rbx, 0, 1) \ +X(AH, 5, rax, 1, 1) \ +X(CH, 6, rcx, 1, 1) \ +X(DH, 7, rdx, 1, 1) \ +X(BH, 8, rbx, 1, 1) \ +X(AX, 9, rax, 0, 2) \ +X(CX, 10, rcx, 0, 2) \ +X(DX, 11, rdx, 0, 2) \ +X(BX, 12, rbx, 0, 2) \ +X(SP, 13, rsp, 0, 2) \ +X(BP, 14, rbp, 0, 2) \ +X(SI, 15, rsi, 0, 2) \ +X(DI, 16, rdi, 0, 2) \ +X(EAX, 17, rax, 0, 4) \ +X(ECX, 18, rcx, 0, 4) \ +X(EDX, 19, rdx, 0, 4) \ +X(EBX, 20, rbx, 0, 4) \ +X(ESP, 21, rsp, 0, 4) \ +X(EBP, 22, rbp, 0, 4) \ +X(ESI, 23, rsi, 0, 4) \ +X(EDI, 24, rdi, 0, 4) \ +X(ES, 25, es, 0, 2) \ +X(CS, 26, cs, 0, 2) \ +X(SS, 27, ss, 0, 2) \ +X(DS, 28, ds, 0, 2) \ +X(FS, 29, fs, 0, 2) \ +X(GS, 30, gs, 0, 2) \ +X(FLAGS, 32, rflags, 0, 2) \ +X(RIP, 33, rip, 0, 8) \ +X(EFLAGS, 34, rflags, 0, 4) \ +/* TODO: possibly missing control registers in x64 definitions? */ \ +X(CR0, 80, nil, 0, 0) \ +X(CR1, 81, nil, 0, 0) \ +X(CR2, 82, nil, 0, 0) \ +X(CR3, 83, nil, 0, 0) \ +X(CR4, 84, nil, 0, 0) \ +X(CR8, 88, nil, 0, 0) \ +X(DR0, 90, dr0, 0, 4) \ +X(DR1, 91, dr1, 0, 4) \ +X(DR2, 92, dr2, 0, 4) \ +X(DR3, 93, dr3, 0, 4) \ +X(DR4, 94, dr4, 0, 4) \ +X(DR5, 95, dr5, 0, 4) \ +X(DR6, 96, dr6, 0, 4) \ +X(DR7, 97, dr7, 0, 4) \ +/* TODO: possibly missing debug registers 8-15 in x64 definitions? */ \ +X(DR8, 98, nil, 0, 0) \ +X(DR9, 99, nil, 0, 0) \ +X(DR10, 100, nil, 0, 0) \ +X(DR11, 101, nil, 0, 0) \ +X(DR12, 102, nil, 0, 0) \ +X(DR13, 103, nil, 0, 0) \ +X(DR14, 104, nil, 0, 0) \ +X(DR15, 105, nil, 0, 0) \ +/* TODO: possibly missing ~whatever these are~ in x64 definitions? */ \ +X(GDTR, 110, nil, 0, 0) \ +X(GDTL, 111, nil, 0, 0) \ +X(IDTR, 112, nil, 0, 0) \ +X(IDTL, 113, nil, 0, 0) \ +X(LDTR, 114, nil, 0, 0) \ +X(TR, 115, nil, 0, 0) \ +X(ST0, 128, st0, 0, 10) \ +X(ST1, 129, st1, 0, 10) \ +X(ST2, 130, st2, 0, 10) \ +X(ST3, 131, st3, 0, 10) \ +X(ST4, 132, st4, 0, 10) \ +X(ST5, 133, st5, 0, 10) \ +X(ST6, 134, st6, 0, 10) \ +X(ST7, 135, st7, 0, 10) \ +/* TODO: possibly missing these, or not sure how they map to our x64 definitions? */ \ +X(CTRL, 136, nil, 0, 0) \ +X(STAT, 137, nil, 0, 0) \ +X(TAG, 138, nil, 0, 0) \ +X(FPIP, 139, nil, 0, 0) \ +X(FPCS, 140, nil, 0, 0) \ +X(FPDO, 141, nil, 0, 0) \ +X(FPDS, 142, nil, 0, 0) \ +X(ISEM, 143, nil, 0, 0) \ +X(FPEIP, 144, nil, 0, 0) \ +X(FPEDO, 145, nil, 0, 0) \ +X(MM0, 146, fpr0, 0, 8) \ +X(MM1, 147, fpr1, 0, 8) \ +X(MM2, 148, fpr2, 0, 8) \ +X(MM3, 149, fpr3, 0, 8) \ +X(MM4, 150, fpr4, 0, 8) \ +X(MM5, 151, fpr5, 0, 8) \ +X(MM6, 152, fpr6, 0, 8) \ +X(MM7, 153, fpr7, 0, 8) \ +X(XMM0, 154, zmm0, 0, 16) \ +X(XMM1, 155, zmm1, 0, 16) \ +X(XMM2, 156, zmm2, 0, 16) \ +X(XMM3, 157, zmm3, 0, 16) \ +X(XMM4, 158, zmm4, 0, 16) \ +X(XMM5, 159, zmm5, 0, 16) \ +X(XMM6, 160, zmm6, 0, 16) \ +X(XMM7, 161, zmm7, 0, 16) \ +X(XMM0_0, 162, zmm0, 0, 4) \ +X(XMM0_1, 163, zmm0, 4, 4) \ +X(XMM0_2, 164, zmm0, 8, 4) \ +X(XMM0_3, 165, zmm0, 12, 4) \ +X(XMM1_0, 166, zmm1, 0, 4) \ +X(XMM1_1, 167, zmm1, 4, 4) \ +X(XMM1_2, 168, zmm1, 8, 4) \ +X(XMM1_3, 169, zmm1, 12, 4) \ +X(XMM2_0, 170, zmm2, 0, 4) \ +X(XMM2_1, 171, zmm2, 4, 4) \ +X(XMM2_2, 172, zmm2, 8, 4) \ +X(XMM2_3, 173, zmm2, 12, 4) \ +X(XMM3_0, 174, zmm3, 0, 4) \ +X(XMM3_1, 175, zmm3, 4, 4) \ +X(XMM3_2, 176, zmm3, 8, 4) \ +X(XMM3_3, 177, zmm3, 12, 4) \ +X(XMM4_0, 178, zmm4, 0, 4) \ +X(XMM4_1, 179, zmm4, 4, 4) \ +X(XMM4_2, 180, zmm4, 8, 4) \ +X(XMM4_3, 181, zmm4, 12, 4) \ +X(XMM5_0, 182, zmm5, 0, 4) \ +X(XMM5_1, 183, zmm5, 4, 4) \ +X(XMM5_2, 184, zmm5, 8, 4) \ +X(XMM5_3, 185, zmm5, 12, 4) \ +X(XMM6_0, 186, zmm6, 0, 4) \ +X(XMM6_1, 187, zmm6, 4, 4) \ +X(XMM6_2, 188, zmm6, 8, 4) \ +X(XMM6_3, 189, zmm6, 12, 4) \ +X(XMM7_0, 190, zmm7, 0, 4) \ +X(XMM7_1, 191, zmm7, 4, 4) \ +X(XMM7_2, 192, zmm7, 8, 4) \ +X(XMM7_3, 193, zmm7, 12, 4) \ +X(XMM0L, 194, zmm0, 0, 8) \ +X(XMM1L, 195, zmm1, 0, 8) \ +X(XMM2L, 196, zmm2, 0, 8) \ +X(XMM3L, 197, zmm3, 0, 8) \ +X(XMM4L, 198, zmm4, 0, 8) \ +X(XMM5L, 199, zmm5, 0, 8) \ +X(XMM6L, 200, zmm6, 0, 8) \ +X(XMM7L, 201, zmm7, 0, 8) \ +X(XMM0H, 202, zmm0, 8, 8) \ +X(XMM1H, 203, zmm1, 8, 8) \ +X(XMM2H, 204, zmm2, 8, 8) \ +X(XMM3H, 205, zmm3, 8, 8) \ +X(XMM4H, 206, zmm4, 8, 8) \ +X(XMM5H, 207, zmm5, 8, 8) \ +X(XMM6H, 208, zmm6, 8, 8) \ +X(XMM7H, 209, zmm7, 8, 8) \ +X(MXCSR, 211, mxcsr, 0, 4) \ +X(EMM0L, 220, zmm0, 0, 8) \ +X(EMM1L, 221, zmm1, 0, 8) \ +X(EMM2L, 222, zmm2, 0, 8) \ +X(EMM3L, 223, zmm3, 0, 8) \ +X(EMM4L, 224, zmm4, 0, 8) \ +X(EMM5L, 225, zmm5, 0, 8) \ +X(EMM6L, 226, zmm6, 0, 8) \ +X(EMM7L, 227, zmm7, 0, 8) \ +X(EMM0H, 228, zmm0, 8, 8) \ +X(EMM1H, 229, zmm1, 8, 8) \ +X(EMM2H, 230, zmm2, 8, 8) \ +X(EMM3H, 231, zmm3, 8, 8) \ +X(EMM4H, 232, zmm4, 8, 8) \ +X(EMM5H, 233, zmm5, 8, 8) \ +X(EMM6H, 234, zmm6, 8, 8) \ +X(EMM7H, 235, zmm7, 8, 8) \ +X(MM00, 236, fpr0, 0, 4) \ +X(MM01, 237, fpr0, 4, 4) \ +X(MM10, 238, fpr1, 0, 4) \ +X(MM11, 239, fpr1, 4, 4) \ +X(MM20, 240, fpr2, 0, 4) \ +X(MM21, 241, fpr2, 4, 4) \ +X(MM30, 242, fpr3, 0, 4) \ +X(MM31, 243, fpr3, 4, 4) \ +X(MM40, 244, fpr4, 0, 4) \ +X(MM41, 245, fpr4, 4, 4) \ +X(MM50, 246, fpr5, 0, 4) \ +X(MM51, 247, fpr5, 4, 4) \ +X(MM60, 248, fpr6, 0, 4) \ +X(MM61, 249, fpr6, 4, 4) \ +X(MM70, 250, fpr7, 0, 4) \ +X(MM71, 251, fpr7, 4, 4) \ +X(XMM8, 252, zmm8, 0, 16) \ +X(XMM9, 253, zmm9, 0, 16) \ +X(XMM10, 254, zmm10, 0, 16) \ +X(XMM11, 255, zmm11, 0, 16) \ +X(XMM12, 256, zmm12, 0, 16) \ +X(XMM13, 257, zmm13, 0, 16) \ +X(XMM14, 258, zmm14, 0, 16) \ +X(XMM15, 259, zmm15, 0, 16) \ +X(XMM8_0, 260, zmm8, 0, 16) \ +X(XMM8_1, 261, zmm8, 4, 16) \ +X(XMM8_2, 262, zmm8, 8, 16) \ +X(XMM8_3, 263, zmm8, 12, 16) \ +X(XMM9_0, 264, zmm9, 0, 4) \ +X(XMM9_1, 265, zmm9, 4, 4) \ +X(XMM9_2, 266, zmm9, 8, 4) \ +X(XMM9_3, 267, zmm9, 12, 4) \ +X(XMM10_0, 268, zmm10, 0, 4) \ +X(XMM10_1, 269, zmm10, 4, 4) \ +X(XMM10_2, 270, zmm10, 8, 4) \ +X(XMM10_3, 271, zmm10, 12, 4) \ +X(XMM11_0, 272, zmm11, 0, 4) \ +X(XMM11_1, 273, zmm11, 4, 4) \ +X(XMM11_2, 274, zmm11, 8, 4) \ +X(XMM11_3, 275, zmm11, 12, 4) \ +X(XMM12_0, 276, zmm12, 0, 4) \ +X(XMM12_1, 277, zmm12, 4, 4) \ +X(XMM12_2, 278, zmm12, 8, 4) \ +X(XMM12_3, 279, zmm12, 12, 4) \ +X(XMM13_0, 280, zmm13, 0, 4) \ +X(XMM13_1, 281, zmm13, 4, 4) \ +X(XMM13_2, 282, zmm13, 8, 4) \ +X(XMM13_3, 283, zmm13, 12, 4) \ +X(XMM14_0, 284, zmm14, 0, 4) \ +X(XMM14_1, 285, zmm14, 4, 4) \ +X(XMM14_2, 286, zmm14, 8, 4) \ +X(XMM14_3, 287, zmm14, 12, 4) \ +X(XMM15_0, 288, zmm15, 0, 4) \ +X(XMM15_1, 289, zmm15, 4, 4) \ +X(XMM15_2, 290, zmm15, 8, 4) \ +X(XMM15_3, 291, zmm15, 12, 4) \ +X(XMM8L, 292, zmm8, 0, 8) \ +X(XMM9L, 293, zmm9, 0, 8) \ +X(XMM10L, 294, zmm10, 0, 8) \ +X(XMM11L, 295, zmm11, 0, 8) \ +X(XMM12L, 296, zmm12, 0, 8) \ +X(XMM13L, 297, zmm13, 0, 8) \ +X(XMM14L, 298, zmm14, 0, 8) \ +X(XMM15L, 299, zmm15, 0, 8) \ +X(XMM8H, 300, zmm8, 8, 8) \ +X(XMM9H, 301, zmm9, 8, 8) \ +X(XMM10H, 302, zmm10, 8, 8) \ +X(XMM11H, 303, zmm11, 8, 8) \ +X(XMM12H, 304, zmm12, 8, 8) \ +X(XMM13H, 305, zmm13, 8, 8) \ +X(XMM14H, 306, zmm14, 8, 8) \ +X(XMM15H, 307, zmm15, 8, 8) \ +X(EMM8L, 308, zmm8, 0, 8) \ +X(EMM9L, 309, zmm9, 0, 8) \ +X(EMM10L, 310, zmm10, 0, 8) \ +X(EMM11L, 311, zmm11, 0, 8) \ +X(EMM12L, 312, zmm12, 0, 8) \ +X(EMM13L, 313, zmm13, 0, 8) \ +X(EMM14L, 314, zmm14, 0, 8) \ +X(EMM15L, 315, zmm15, 0, 8) \ +X(EMM8H, 316, zmm8, 8, 8) \ +X(EMM9H, 317, zmm9, 8, 8) \ +X(EMM10H, 318, zmm10, 8, 8) \ +X(EMM11H, 319, zmm11, 8, 8) \ +X(EMM12H, 320, zmm12, 8, 8) \ +X(EMM13H, 321, zmm13, 8, 8) \ +X(EMM14H, 322, zmm14, 8, 8) \ +X(EMM15H, 323, zmm15, 8, 8) \ +X(SIL, 324, rsi, 0, 1) \ +X(DIL, 325, rdi, 0, 1) \ +X(BPL, 326, rbp, 0, 1) \ +X(SPL, 327, rsp, 0, 1) \ +X(RAX, 328, rax, 0, 8) \ +X(RBX, 329, rbx, 0, 8) \ +X(RCX, 330, rcx, 0, 8) \ +X(RDX, 331, rdx, 0, 8) \ +X(RSI, 332, rsi, 0, 8) \ +X(RDI, 333, rdi, 0, 8) \ +X(RBP, 334, rbp, 0, 8) \ +X(RSP, 335, rsp, 0, 8) \ +X(R8, 336, r8, 0, 8) \ +X(R9, 337, r9, 0, 8) \ +X(R10, 338, r10, 0, 8) \ +X(R11, 339, r11, 0, 8) \ +X(R12, 340, r12, 0, 8) \ +X(R13, 341, r13, 0, 8) \ +X(R14, 342, r14, 0, 8) \ +X(R15, 343, r15, 0, 8) \ +X(R8B, 344, r8, 0, 1) \ +X(R9B, 345, r9, 0, 1) \ +X(R10B, 346, r10, 0, 1) \ +X(R11B, 347, r11, 0, 1) \ +X(R12B, 348, r12, 0, 1) \ +X(R13B, 349, r13, 0, 1) \ +X(R14B, 350, r14, 0, 1) \ +X(R15B, 351, r15, 0, 1) \ +X(R8W, 352, r8, 0, 2) \ +X(R9W, 353, r9, 0, 2) \ +X(R10W, 354, r10, 0, 2) \ +X(R11W, 355, r11, 0, 2) \ +X(R12W, 356, r12, 0, 2) \ +X(R13W, 357, r13, 0, 2) \ +X(R14W, 358, r14, 0, 2) \ +X(R15W, 359, r15, 0, 2) \ +X(R8D, 360, r8, 0, 4) \ +X(R9D, 361, r9, 0, 4) \ +X(R10D, 362, r10, 0, 4) \ +X(R11D, 363, r11, 0, 4) \ +X(R12D, 364, r12, 0, 4) \ +X(R13D, 365, r13, 0, 4) \ +X(R14D, 366, r14, 0, 4) \ +X(R15D, 367, r15, 0, 4) \ +X(YMM0, 368, zmm0, 0, 32) \ +X(YMM1, 369, zmm1, 0, 32) \ +X(YMM2, 370, zmm2, 0, 32) \ +X(YMM3, 371, zmm3, 0, 32) \ +X(YMM4, 372, zmm4, 0, 32) \ +X(YMM5, 373, zmm5, 0, 32) \ +X(YMM6, 374, zmm6, 0, 32) \ +X(YMM7, 375, zmm7, 0, 32) \ +X(YMM8, 376, zmm8, 0, 32) \ +X(YMM9, 377, zmm9, 0, 32) \ +X(YMM10, 378, zmm10, 0, 32) \ +X(YMM11, 379, zmm11, 0, 32) \ +X(YMM12, 380, zmm12, 0, 32) \ +X(YMM13, 381, zmm13, 0, 32) \ +X(YMM14, 382, zmm14, 0, 32) \ +X(YMM15, 383, zmm15, 0, 32) \ +X(YMM0H, 384, zmm0, 16, 32) \ +X(YMM1H, 385, zmm1, 16, 32) \ +X(YMM2H, 386, zmm2, 16, 32) \ +X(YMM3H, 387, zmm3, 16, 32) \ +X(YMM4H, 388, zmm4, 16, 32) \ +X(YMM5H, 389, zmm5, 16, 32) \ +X(YMM6H, 390, zmm6, 16, 32) \ +X(YMM7H, 391, zmm7, 16, 32) \ +X(YMM8H, 392, zmm8, 16, 32) \ +X(YMM9H, 393, zmm9, 16, 32) \ +X(YMM10H, 394, zmm10, 16, 32) \ +X(YMM11H, 395, zmm11, 16, 32) \ +X(YMM12H, 396, zmm12, 16, 32) \ +X(YMM13H, 397, zmm13, 16, 32) \ +X(YMM14H, 398, zmm14, 16, 32) \ +X(YMM15H, 399, zmm15, 16, 32) \ +X(XMM0IL, 400, zmm0, 0, 8) \ +X(XMM1IL, 401, zmm1, 0, 8) \ +X(XMM2IL, 402, zmm2, 0, 8) \ +X(XMM3IL, 403, zmm3, 0, 8) \ +X(XMM4IL, 404, zmm4, 0, 8) \ +X(XMM5IL, 405, zmm5, 0, 8) \ +X(XMM6IL, 406, zmm6, 0, 8) \ +X(XMM7IL, 407, zmm7, 0, 8) \ +X(XMM8IL, 408, zmm8, 0, 8) \ +X(XMM9IL, 409, zmm9, 0, 8) \ +X(XMM10IL, 410, zmm10, 0, 8) \ +X(XMM11IL, 411, zmm11, 0, 8) \ +X(XMM12IL, 412, zmm12, 0, 8) \ +X(XMM13IL, 413, zmm13, 0, 8) \ +X(XMM14IL, 414, zmm14, 0, 8) \ +X(XMM15IL, 415, zmm15, 0, 8) \ +X(XMM0IH, 416, zmm0, 8, 8) \ +X(XMM1IH, 417, zmm1, 8, 8) \ +X(XMM2IH, 418, zmm2, 8, 8) \ +X(XMM3IH, 419, zmm3, 8, 8) \ +X(XMM4IH, 420, zmm4, 8, 8) \ +X(XMM5IH, 421, zmm5, 8, 8) \ +X(XMM6IH, 422, zmm6, 8, 8) \ +X(XMM7IH, 423, zmm7, 8, 8) \ +X(XMM8IH, 424, zmm8, 8, 8) \ +X(XMM9IH, 425, zmm9, 8, 8) \ +X(XMM10IH, 426, zmm10, 8, 8) \ +X(XMM11IH, 427, zmm11, 8, 8) \ +X(XMM12IH, 428, zmm12, 8, 8) \ +X(XMM13IH, 429, zmm13, 8, 8) \ +X(XMM14IH, 430, zmm14, 8, 8) \ +X(XMM15IH, 431, zmm15, 8, 8) \ +X(YMM0I0, 432, zmm0, 0, 8) \ +X(YMM0I1, 433, zmm0, 8, 8) \ +X(YMM0I2, 434, zmm0, 16, 8) \ +X(YMM0I3, 435, zmm0, 24, 8) \ +X(YMM1I0, 436, zmm1, 0, 8) \ +X(YMM1I1, 437, zmm1, 8, 8) \ +X(YMM1I2, 438, zmm1, 16, 8) \ +X(YMM1I3, 439, zmm1, 24, 8) \ +X(YMM2I0, 440, zmm2, 0, 8) \ +X(YMM2I1, 441, zmm2, 8, 8) \ +X(YMM2I2, 442, zmm2, 16, 8) \ +X(YMM2I3, 443, zmm2, 24, 8) \ +X(YMM3I0, 444, zmm3, 0, 8) \ +X(YMM3I1, 445, zmm3, 8, 8) \ +X(YMM3I2, 446, zmm3, 16, 8) \ +X(YMM3I3, 447, zmm3, 24, 8) \ +X(YMM4I0, 448, zmm4, 0, 8) \ +X(YMM4I1, 449, zmm4, 8, 8) \ +X(YMM4I2, 450, zmm4, 16, 8) \ +X(YMM4I3, 451, zmm4, 24, 8) \ +X(YMM5I0, 452, zmm5, 0, 8) \ +X(YMM5I1, 453, zmm5, 8, 8) \ +X(YMM5I2, 454, zmm5, 16, 8) \ +X(YMM5I3, 455, zmm5, 24, 8) \ +X(YMM6I0, 456, zmm6, 0, 8) \ +X(YMM6I1, 457, zmm6, 8, 8) \ +X(YMM6I2, 458, zmm6, 16, 8) \ +X(YMM6I3, 459, zmm6, 24, 8) \ +X(YMM7I0, 460, zmm7, 0, 8) \ +X(YMM7I1, 461, zmm7, 8, 8) \ +X(YMM7I2, 462, zmm7, 16, 8) \ +X(YMM7I3, 463, zmm7, 24, 8) \ +X(YMM8I0, 464, zmm8, 0, 8) \ +X(YMM8I1, 465, zmm8, 8, 8) \ +X(YMM8I2, 466, zmm8, 16, 8) \ +X(YMM8I3, 467, zmm8, 24, 8) \ +X(YMM9I0, 468, zmm9, 0, 8) \ +X(YMM9I1, 469, zmm9, 8, 8) \ +X(YMM9I2, 470, zmm9, 16, 8) \ +X(YMM9I3, 471, zmm9, 24, 8) \ +X(YMM10I0, 472, zmm10, 0, 8) \ +X(YMM10I1, 473, zmm10, 8, 8) \ +X(YMM10I2, 474, zmm10, 16, 8) \ +X(YMM10I3, 475, zmm10, 24, 8) \ +X(YMM11I0, 476, zmm11, 0, 8) \ +X(YMM11I1, 477, zmm11, 8, 8) \ +X(YMM11I2, 478, zmm11, 16, 8) \ +X(YMM11I3, 479, zmm11, 24, 8) \ +X(YMM12I0, 480, zmm12, 0, 8) \ +X(YMM12I1, 481, zmm12, 8, 8) \ +X(YMM12I2, 482, zmm12, 16, 8) \ +X(YMM12I3, 483, zmm12, 24, 8) \ +X(YMM13I0, 484, zmm13, 0, 8) \ +X(YMM13I1, 485, zmm13, 8, 8) \ +X(YMM13I2, 486, zmm13, 16, 8) \ +X(YMM13I3, 487, zmm13, 24, 8) \ +X(YMM14I0, 488, zmm14, 0, 8) \ +X(YMM14I1, 489, zmm14, 8, 8) \ +X(YMM14I2, 490, zmm14, 16, 8) \ +X(YMM14I3, 491, zmm14, 24, 8) \ +X(YMM15I0, 492, zmm15, 0, 8) \ +X(YMM15I1, 493, zmm15, 8, 8) \ +X(YMM15I2, 494, zmm15, 16, 8) \ +X(YMM15I3, 495, zmm15, 24, 8) \ +X(YMM0F0, 496, zmm0, 0, 4) \ +X(YMM0F1, 497, zmm0, 4, 4) \ +X(YMM0F2, 498, zmm0, 8, 4) \ +X(YMM0F3, 499, zmm0, 12, 4) \ +X(YMM0F4, 500, zmm0, 16, 4) \ +X(YMM0F5, 501, zmm0, 20, 4) \ +X(YMM0F6, 502, zmm0, 24, 4) \ +X(YMM0F7, 503, zmm0, 28, 4) \ +X(YMM1F0, 504, zmm1, 0, 4) \ +X(YMM1F1, 505, zmm1, 4, 4) \ +X(YMM1F2, 506, zmm1, 8, 4) \ +X(YMM1F3, 507, zmm1, 12, 4) \ +X(YMM1F4, 508, zmm1, 16, 4) \ +X(YMM1F5, 509, zmm1, 20, 4) \ +X(YMM1F6, 510, zmm1, 24, 4) \ +X(YMM1F7, 511, zmm1, 28, 4) \ +X(YMM2F0, 512, zmm2, 0, 4) \ +X(YMM2F1, 513, zmm2, 4, 4) \ +X(YMM2F2, 514, zmm2, 8, 4) \ +X(YMM2F3, 515, zmm2, 12, 4) \ +X(YMM2F4, 516, zmm2, 16, 4) \ +X(YMM2F5, 517, zmm2, 20, 4) \ +X(YMM2F6, 518, zmm2, 24, 4) \ +X(YMM2F7, 519, zmm2, 28, 4) \ +X(YMM3F0, 520, zmm3, 0, 4) \ +X(YMM3F1, 521, zmm3, 4, 4) \ +X(YMM3F2, 522, zmm3, 8, 4) \ +X(YMM3F3, 523, zmm3, 12, 4) \ +X(YMM3F4, 524, zmm3, 16, 4) \ +X(YMM3F5, 525, zmm3, 20, 4) \ +X(YMM3F6, 526, zmm3, 24, 4) \ +X(YMM3F7, 527, zmm3, 28, 4) \ +X(YMM4F0, 528, zmm4, 0, 4) \ +X(YMM4F1, 529, zmm4, 4, 4) \ +X(YMM4F2, 530, zmm4, 8, 4) \ +X(YMM4F3, 531, zmm4, 12, 4) \ +X(YMM4F4, 532, zmm4, 16, 4) \ +X(YMM4F5, 533, zmm4, 20, 4) \ +X(YMM4F6, 534, zmm4, 24, 4) \ +X(YMM4F7, 535, zmm4, 28, 4) \ +X(YMM5F0, 536, zmm5, 0, 4) \ +X(YMM5F1, 537, zmm5, 4, 4) \ +X(YMM5F2, 538, zmm5, 8, 4) \ +X(YMM5F3, 539, zmm5, 12, 4) \ +X(YMM5F4, 540, zmm5, 16, 4) \ +X(YMM5F5, 541, zmm5, 20, 4) \ +X(YMM5F6, 542, zmm5, 24, 4) \ +X(YMM5F7, 543, zmm5, 28, 4) \ +X(YMM6F0, 544, zmm6, 0, 4) \ +X(YMM6F1, 545, zmm6, 4, 4) \ +X(YMM6F2, 546, zmm6, 8, 4) \ +X(YMM6F3, 547, zmm6, 12, 4) \ +X(YMM6F4, 548, zmm6, 16, 4) \ +X(YMM6F5, 549, zmm6, 20, 4) \ +X(YMM6F6, 550, zmm6, 24, 4) \ +X(YMM6F7, 551, zmm6, 28, 4) \ +X(YMM7F0, 552, zmm7, 0, 4) \ +X(YMM7F1, 553, zmm7, 4, 4) \ +X(YMM7F2, 554, zmm7, 8, 4) \ +X(YMM7F3, 555, zmm7, 12, 4) \ +X(YMM7F4, 556, zmm7, 16, 4) \ +X(YMM7F5, 557, zmm7, 20, 4) \ +X(YMM7F6, 558, zmm7, 24, 4) \ +X(YMM7F7, 559, zmm7, 28, 4) \ +X(YMM8F0, 560, zmm8, 0, 4) \ +X(YMM8F1, 561, zmm8, 4, 4) \ +X(YMM8F2, 562, zmm8, 8, 4) \ +X(YMM8F3, 563, zmm8, 12, 4) \ +X(YMM8F4, 564, zmm8, 16, 4) \ +X(YMM8F5, 565, zmm8, 20, 4) \ +X(YMM8F6, 566, zmm8, 24, 4) \ +X(YMM8F7, 567, zmm8, 28, 4) \ +X(YMM9F0, 568, zmm9, 0, 4) \ +X(YMM9F1, 569, zmm9, 4, 4) \ +X(YMM9F2, 570, zmm9, 8, 4) \ +X(YMM9F3, 571, zmm9, 12, 4) \ +X(YMM9F4, 572, zmm9, 16, 4) \ +X(YMM9F5, 573, zmm9, 20, 4) \ +X(YMM9F6, 574, zmm9, 24, 4) \ +X(YMM9F7, 575, zmm9, 28, 4) \ +X(YMM10F0, 576, zmm10, 0, 4) \ +X(YMM10F1, 577, zmm10, 4, 4) \ +X(YMM10F2, 578, zmm10, 8, 4) \ +X(YMM10F3, 579, zmm10, 12, 4) \ +X(YMM10F4, 580, zmm10, 16, 4) \ +X(YMM10F5, 581, zmm10, 20, 4) \ +X(YMM10F6, 582, zmm10, 24, 4) \ +X(YMM10F7, 583, zmm10, 28, 4) \ +X(YMM11F0, 584, zmm11, 0, 4) \ +X(YMM11F1, 585, zmm11, 4, 4) \ +X(YMM11F2, 586, zmm11, 8, 4) \ +X(YMM11F3, 587, zmm11, 12, 4) \ +X(YMM11F4, 588, zmm11, 16, 4) \ +X(YMM11F5, 589, zmm11, 20, 4) \ +X(YMM11F6, 590, zmm11, 24, 4) \ +X(YMM11F7, 591, zmm11, 28, 4) \ +X(YMM12F0, 592, zmm12, 0, 4) \ +X(YMM12F1, 593, zmm12, 4, 4) \ +X(YMM12F2, 594, zmm12, 8, 4) \ +X(YMM12F3, 595, zmm12, 12, 4) \ +X(YMM12F4, 596, zmm12, 16, 4) \ +X(YMM12F5, 597, zmm12, 20, 4) \ +X(YMM12F6, 598, zmm12, 24, 4) \ +X(YMM12F7, 599, zmm12, 28, 4) \ +X(YMM13F0, 600, zmm13, 0, 4) \ +X(YMM13F1, 601, zmm13, 4, 4) \ +X(YMM13F2, 602, zmm13, 8, 4) \ +X(YMM13F3, 603, zmm13, 12, 4) \ +X(YMM13F4, 604, zmm13, 16, 4) \ +X(YMM13F5, 605, zmm13, 20, 4) \ +X(YMM13F6, 606, zmm13, 24, 4) \ +X(YMM13F7, 607, zmm13, 28, 4) \ +X(YMM14F0, 608, zmm14, 0, 4) \ +X(YMM14F1, 609, zmm14, 4, 4) \ +X(YMM14F2, 610, zmm14, 8, 4) \ +X(YMM14F3, 611, zmm14, 12, 4) \ +X(YMM14F4, 612, zmm14, 16, 4) \ +X(YMM14F5, 613, zmm14, 20, 4) \ +X(YMM14F6, 614, zmm14, 24, 4) \ +X(YMM14F7, 615, zmm14, 28, 4) \ +X(YMM15F0, 616, zmm15, 0, 4) \ +X(YMM15F1, 617, zmm15, 4, 4) \ +X(YMM15F2, 618, zmm15, 8, 4) \ +X(YMM15F3, 619, zmm15, 12, 4) \ +X(YMM15F4, 620, zmm15, 16, 4) \ +X(YMM15F5, 621, zmm15, 20, 4) \ +X(YMM15F6, 622, zmm15, 24, 4) \ +X(YMM15F7, 623, zmm15, 28, 4) \ +X(YMM0D0, 624, zmm0, 0, 8) \ +X(YMM0D1, 625, zmm0, 8, 8) \ +X(YMM0D2, 626, zmm0, 16, 8) \ +X(YMM0D3, 627, zmm0, 24, 8) \ +X(YMM1D0, 628, zmm1, 0, 8) \ +X(YMM1D1, 629, zmm1, 8, 8) \ +X(YMM1D2, 630, zmm1, 16, 8) \ +X(YMM1D3, 631, zmm1, 24, 8) \ +X(YMM2D0, 632, zmm2, 0, 8) \ +X(YMM2D1, 633, zmm2, 8, 8) \ +X(YMM2D2, 634, zmm2, 16, 8) \ +X(YMM2D3, 635, zmm2, 24, 8) \ +X(YMM3D0, 636, zmm3, 0, 8) \ +X(YMM3D1, 637, zmm3, 8, 8) \ +X(YMM3D2, 638, zmm3, 16, 8) \ +X(YMM3D3, 639, zmm3, 24, 8) \ +X(YMM4D0, 640, zmm4, 0, 8) \ +X(YMM4D1, 641, zmm4, 8, 8) \ +X(YMM4D2, 642, zmm4, 16, 8) \ +X(YMM4D3, 643, zmm4, 24, 8) \ +X(YMM5D0, 644, zmm5, 0, 8) \ +X(YMM5D1, 645, zmm5, 8, 8) \ +X(YMM5D2, 646, zmm5, 16, 8) \ +X(YMM5D3, 647, zmm5, 24, 8) \ +X(YMM6D0, 648, zmm6, 0, 8) \ +X(YMM6D1, 649, zmm6, 8, 8) \ +X(YMM6D2, 650, zmm6, 16, 8) \ +X(YMM6D3, 651, zmm6, 24, 8) \ +X(YMM7D0, 652, zmm7, 0, 8) \ +X(YMM7D1, 653, zmm7, 8, 8) \ +X(YMM7D2, 654, zmm7, 16, 8) \ +X(YMM7D3, 655, zmm7, 24, 8) \ +X(YMM8D0, 656, zmm8, 0, 8) \ +X(YMM8D1, 657, zmm8, 8, 8) \ +X(YMM8D2, 658, zmm8, 16, 8) \ +X(YMM8D3, 659, zmm8, 24, 8) \ +X(YMM9D0, 660, zmm9, 0, 8) \ +X(YMM9D1, 661, zmm9, 8, 8) \ +X(YMM9D2, 662, zmm9, 16, 8) \ +X(YMM9D3, 663, zmm9, 24, 8) \ +X(YMM10D0, 664, zmm10, 0, 8) \ +X(YMM10D1, 665, zmm10, 8, 8) \ +X(YMM10D2, 666, zmm10, 16, 8) \ +X(YMM10D3, 667, zmm10, 24, 8) \ +X(YMM11D0, 668, zmm11, 0, 8) \ +X(YMM11D1, 669, zmm11, 8, 8) \ +X(YMM11D2, 670, zmm11, 16, 8) \ +X(YMM11D3, 671, zmm11, 24, 8) \ +X(YMM12D0, 672, zmm12, 0, 8) \ +X(YMM12D1, 673, zmm12, 8, 8) \ +X(YMM12D2, 674, zmm12, 16, 8) \ +X(YMM12D3, 675, zmm12, 24, 8) \ +X(YMM13D0, 676, zmm13, 0, 8) \ +X(YMM13D1, 677, zmm13, 8, 8) \ +X(YMM13D2, 678, zmm13, 16, 8) \ +X(YMM13D3, 679, zmm13, 24, 8) \ +X(YMM14D0, 680, zmm14, 0, 8) \ +X(YMM14D1, 681, zmm14, 8, 8) \ +X(YMM14D2, 682, zmm14, 16, 8) \ +X(YMM14D3, 683, zmm14, 24, 8) \ +X(YMM15D0, 684, zmm15, 0, 8) \ +X(YMM15D1, 685, zmm15, 8, 8) \ +X(YMM15D2, 686, zmm15, 16, 8) \ +X(YMM15D3, 687, zmm15, 24, 8) \ +X(XMM16, 694, zmm16, 0, 16) \ +X(XMM17, 695, zmm17, 0, 16) \ +X(XMM18, 696, zmm18, 0, 16) \ +X(XMM19, 697, zmm19, 0, 16) \ +X(XMM20, 698, zmm20, 0, 16) \ +X(XMM21, 699, zmm21, 0, 16) \ +X(XMM22, 700, zmm22, 0, 16) \ +X(XMM23, 701, zmm23, 0, 16) \ +X(XMM24, 702, zmm24, 0, 16) \ +X(XMM25, 703, zmm25, 0, 16) \ +X(XMM26, 704, zmm26, 0, 16) \ +X(XMM27, 705, zmm27, 0, 16) \ +X(XMM28, 706, zmm28, 0, 16) \ +X(XMM29, 707, zmm29, 0, 16) \ +X(XMM30, 708, zmm30, 0, 16) \ +X(XMM31, 709, zmm31, 0, 16) \ +X(YMM16, 710, zmm16, 0, 32) \ +X(YMM17, 711, zmm17, 0, 32) \ +X(YMM18, 712, zmm18, 0, 32) \ +X(YMM19, 713, zmm19, 0, 32) \ +X(YMM20, 714, zmm20, 0, 32) \ +X(YMM21, 715, zmm21, 0, 32) \ +X(YMM22, 716, zmm22, 0, 32) \ +X(YMM23, 717, zmm23, 0, 32) \ +X(YMM24, 718, zmm24, 0, 32) \ +X(YMM25, 719, zmm25, 0, 32) \ +X(YMM26, 720, zmm26, 0, 32) \ +X(YMM27, 721, zmm27, 0, 32) \ +X(YMM28, 722, zmm28, 0, 32) \ +X(YMM29, 723, zmm29, 0, 32) \ +X(YMM30, 724, zmm30, 0, 32) \ +X(YMM31, 725, zmm31, 0, 32) \ +X(ZMM0, 726, zmm0, 0, 64) \ +X(ZMM1, 727, zmm1, 0, 64) \ +X(ZMM2, 728, zmm2, 0, 64) \ +X(ZMM3, 729, zmm3, 0, 64) \ +X(ZMM4, 730, zmm4, 0, 64) \ +X(ZMM5, 731, zmm5, 0, 64) \ +X(ZMM6, 732, zmm6, 0, 64) \ +X(ZMM7, 733, zmm7, 0, 64) \ +X(ZMM8, 734, zmm8, 0, 64) \ +X(ZMM9, 735, zmm9, 0, 64) \ +X(ZMM10, 736, zmm10, 0, 64) \ +X(ZMM11, 737, zmm11, 0, 64) \ +X(ZMM12, 738, zmm12, 0, 64) \ +X(ZMM13, 739, zmm13, 0, 64) \ +X(ZMM14, 740, zmm14, 0, 64) \ +X(ZMM15, 741, zmm15, 0, 64) \ +X(ZMM16, 742, zmm16, 0, 64) \ +X(ZMM17, 743, zmm17, 0, 64) \ +X(ZMM18, 744, zmm18, 0, 64) \ +X(ZMM19, 745, zmm19, 0, 64) \ +X(ZMM20, 746, zmm20, 0, 64) \ +X(ZMM21, 747, zmm21, 0, 64) \ +X(ZMM22, 748, zmm22, 0, 64) \ +X(ZMM23, 749, zmm23, 0, 64) \ +X(ZMM24, 750, zmm24, 0, 64) \ +X(ZMM25, 751, zmm25, 0, 64) \ +X(ZMM26, 752, zmm26, 0, 64) \ +X(ZMM27, 753, zmm27, 0, 64) \ +X(ZMM28, 754, zmm28, 0, 64) \ +X(ZMM29, 755, zmm29, 0, 64) \ +X(ZMM30, 756, zmm30, 0, 64) \ +X(ZMM31, 757, zmm31, 0, 64) \ +X(K0, 758, k0, 0, 8) \ +X(K1, 759, k1, 0, 8) \ +X(K2, 760, k2, 0, 8) \ +X(K3, 761, k3, 0, 8) \ +X(K4, 762, k4, 0, 8) \ +X(K5, 763, k5, 0, 8) \ +X(K6, 764, k6, 0, 8) \ +X(K7, 765, k7, 0, 8) \ +X(ZMM0H, 766, zmm0, 32, 32) \ +X(ZMM1H, 767, zmm1, 32, 32) \ +X(ZMM2H, 768, zmm2, 32, 32) \ +X(ZMM3H, 769, zmm3, 32, 32) \ +X(ZMM4H, 770, zmm4, 32, 32) \ +X(ZMM5H, 771, zmm5, 32, 32) \ +X(ZMM6H, 772, zmm6, 32, 32) \ +X(ZMM7H, 773, zmm7, 32, 32) \ +X(ZMM8H, 774, zmm8, 32, 32) \ +X(ZMM9H, 775, zmm9, 32, 32) \ +X(ZMM10H, 776, zmm10, 32, 32) \ +X(ZMM11H, 777, zmm11, 32, 32) \ +X(ZMM12H, 778, zmm12, 32, 32) \ +X(ZMM13H, 779, zmm13, 32, 32) \ +X(ZMM14H, 780, zmm14, 32, 32) \ +X(ZMM15H, 781, zmm15, 32, 32) typedef U16 CV_Regx64; typedef enum CV_Regx64Enum @@ -1015,11 +1015,11 @@ CV_Regx64Enum; #define CV_SignatureXList(X) \ - X(C6, 0) \ - X(C7, 1) \ - X(C11, 2) \ - X(C13, 4) \ - X(RESERVED, 5) +X(C6, 0) \ +X(C7, 1) \ +X(C11, 2) \ +X(C13, 4) \ +X(RESERVED, 5) typedef U32 CV_Signature; typedef enum CV_SignatureEnum @@ -1032,23 +1032,23 @@ CV_SignatureEnum; #define CV_LanguageXList(X) \ - X(C, 0x00) \ - X(CXX, 0x01) \ - X(FORTRAN, 0x02) \ - X(MASM, 0x03) \ - X(PASCAL, 0x04) \ - X(BASIC, 0x05) \ - X(COBOL, 0x06) \ - X(LINK, 0x07) \ - X(CVTRES, 0x08) \ - X(CVTPGD, 0x09) \ - X(CSHARP, 0x0A) \ - X(VB, 0x0B) \ - X(ILASM, 0x0C) \ - X(JAVA, 0x0D) \ - X(JSCRIPT, 0x0E) \ - X(MSIL, 0x0F) \ - X(HLSL, 0x10) +X(C, 0x00) \ +X(CXX, 0x01) \ +X(FORTRAN, 0x02) \ +X(MASM, 0x03) \ +X(PASCAL, 0x04) \ +X(BASIC, 0x05) \ +X(COBOL, 0x06) \ +X(LINK, 0x07) \ +X(CVTRES, 0x08) \ +X(CVTPGD, 0x09) \ +X(CSHARP, 0x0A) \ +X(VB, 0x0B) \ +X(ILASM, 0x0C) \ +X(JAVA, 0x0D) \ +X(JSCRIPT, 0x0E) \ +X(MSIL, 0x0F) \ +X(HLSL, 0x10) typedef U16 CV_Language; typedef enum CV_LanguageEnum @@ -1732,7 +1732,7 @@ enum CV_Compile3Flag_SDL = (1 << 17), CV_Compile3Flag_PGO = (1 << 18), CV_Compile3Flag_EXP = (1 << 19), - + CV_Compile3Flag_Language_Shift = 0, CV_Compile3Flag_Language_Mask = 0xff, }; @@ -2111,13 +2111,13 @@ struct CV_SymInlinees #define CV_TypeId_Variadic 0 #define CV_BasicPointerKindXList(X) \ - X(VALUE, 0x0) \ - X(16BIT, 0x1) \ - X(FAR_16BIT, 0x2) \ - X(HUGE_16BIT, 0x3) \ - X(32BIT, 0x4) \ - X(16_32BIT, 0x5) \ - X(64BIT, 0x6) +X(VALUE, 0x0) \ +X(16BIT, 0x1) \ +X(FAR_16BIT, 0x2) \ +X(HUGE_16BIT, 0x3) \ +X(32BIT, 0x4) \ +X(16_32BIT, 0x5) \ +X(64BIT, 0x6) typedef U8 CV_BasicPointerKind; typedef enum @@ -2781,21 +2781,21 @@ struct CV_LeafUDTModSrcLine #define CV_C13SubSectionKind_IgnoreFlag 0x80000000 #define CV_C13SubSectionKindXList(X) \ - X(Symbols, 0xF1) \ - X(Lines, 0xF2) \ - X(StringTable, 0xF3) \ - X(FileChksms, 0xF4) \ - X(FrameData, 0xF5) \ - X(InlineeLines, 0xF6) \ - X(CrossScopeImports, 0xF7) \ - X(CrossScopeExports, 0xF8) \ - X(IlLines, 0xF9) \ - X(FuncMDTokenMap, 0xFA) \ - X(TypeMDTokenMap, 0xFB) \ - X(MergedAssemblyInput, 0xFC) \ - X(CoffSymbolRVA, 0xFD) \ - X(XfgHashType, 0xFF) \ - X(XfgHashVirtual, 0x100) +X(Symbols, 0xF1) \ +X(Lines, 0xF2) \ +X(StringTable, 0xF3) \ +X(FileChksms, 0xF4) \ +X(FrameData, 0xF5) \ +X(InlineeLines, 0xF6) \ +X(CrossScopeImports, 0xF7) \ +X(CrossScopeExports, 0xF8) \ +X(IlLines, 0xF9) \ +X(FuncMDTokenMap, 0xFA) \ +X(TypeMDTokenMap, 0xFB) \ +X(MergedAssemblyInput, 0xFC) \ +X(CoffSymbolRVA, 0xFD) \ +X(XfgHashType, 0xFF) \ +X(XfgHashVirtual, 0x100) typedef U32 CV_C13SubSectionKind; typedef enum CV_C13SubSectionKindEnum @@ -2974,4 +2974,4 @@ internal U32 cv_map_encoded_base_pointer(CV_Arch arch, U32 enc internal String8 cv_string_from_inline_range_kind(CV_InlineRangeKind kind); #endif // CODEVIEW_H - + diff --git a/src/codeview/codeview_enum.c b/src/codeview/codeview_enum.c index 4413fcca..061210ce 100644 --- a/src/codeview/codeview_enum.c +++ b/src/codeview/codeview_enum.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal String8 @@ -11,10 +11,10 @@ internal String8 cv_string_from_type_index_source(CV_TypeIndexSource ti_source) { switch (ti_source) { - case CV_TypeIndexSource_NULL: return str8_lit(""); break; - case CV_TypeIndexSource_TPI: return str8_lit("TPI"); break; - case CV_TypeIndexSource_IPI: return str8_lit("IPI"); break; - case CV_TypeIndexSource_COUNT: break; + case CV_TypeIndexSource_NULL: return str8_lit(""); break; + case CV_TypeIndexSource_TPI: return str8_lit("TPI"); break; + case CV_TypeIndexSource_IPI: return str8_lit("IPI"); break; + case CV_TypeIndexSource_COUNT: break; } return str8_zero(); } @@ -23,9 +23,9 @@ internal String8 cv_string_from_language(CV_Language x) { switch (x) { - #define X(_n,_i) case _i: return str8_lit(Stringify(_n)); -CV_LanguageXList(X) - #undef X +#define X(_n,_i) case _i: return str8_lit(Stringify(_n)); + CV_LanguageXList(X) +#undef X } return str8_zero(); } @@ -57,21 +57,21 @@ cv_string_from_reg_id(Arena *arena, CV_Arch arch, U32 id) { String8 result = str8_zero(); switch (arch) { - case CV_Arch_8086: { + case CV_Arch_8086: { switch (id) { - #define X(_N, _ID, ...) case _ID: result = str8_lit(Stringify(_N)); break; - CV_Reg_X86_XList(X) - #undef X +#define X(_N, _ID, ...) case _ID: result = str8_lit(Stringify(_N)); break; + CV_Reg_X86_XList(X) +#undef X } - } break; - case CV_Arch_X64: { + } break; + case CV_Arch_X64: { switch (id) { - #define X(_N, _ID, ...) case _ID: result = str8_lit(Stringify(_N)); break; - CV_Reg_X64_XList(X) - #undef X +#define X(_N, _ID, ...) case _ID: result = str8_lit(Stringify(_N)); break; + CV_Reg_X64_XList(X) +#undef X } - } break; - default: NotImplemented; break; + } break; + default: NotImplemented; break; } if (result.size == 0) { result = push_str8f(arena, "%x", id); @@ -327,9 +327,9 @@ internal String8 cv_string_from_c13_subsection_kind(CV_C13SubSectionKind x) { switch (x) { - #define X(_N, _ID) case CV_C13SubSectionKind_##_N: return str8_lit(Stringify(_N)); +#define X(_N, _ID) case CV_C13SubSectionKind_##_N: return str8_lit(Stringify(_N)); CV_C13SubSectionKindXList(X) - #undef X +#undef X } return str8_zero(); } @@ -357,7 +357,7 @@ internal String8 cv_string_from_pointer_attribs(Arena *arena, CV_PointerAttribs x) { Temp scratch = scratch_begin(&arena, 1); - + String8List list = {0}; if (x & CV_PointerAttrib_IsFlat) { x &= ~CV_PointerAttrib_IsFlat; @@ -391,13 +391,13 @@ cv_string_from_pointer_attribs(Arena *arena, CV_PointerAttribs x) x &= ~CV_PointerAttrib_RRef; str8_list_pushf(scratch.arena, &list, "RRef"); } - + CV_PointerKind kind = CV_PointerAttribs_Extract_Kind(x); CV_PointerMode mode = CV_PointerAttribs_Extract_Mode(x); U64 size = CV_PointerAttribs_Extract_Size(x); - + x &= ~(0x1f|(0x7<<5)|(0x3f<<13)); - + if (kind) { String8 kind_str = cv_string_from_pointer_kind(kind); str8_list_pushf(scratch.arena, &list, "Kind=%S", kind_str); @@ -409,11 +409,11 @@ cv_string_from_pointer_attribs(Arena *arena, CV_PointerAttribs x) if (size) { str8_list_pushf(scratch.arena, &list, "Size=%llu", size); } - + if (x != 0) { str8_list_pushf(scratch.arena, &list, "Unknown=%x", x); } - + String8 result = str8_list_join(arena, &list, &(StringJoin){.sep=str8_lit(", ")}); scratch_end(scratch); return result; @@ -591,13 +591,13 @@ internal String8 cv_string_from_type_props(Arena *arena, CV_TypeProps32 x) { Temp scratch = scratch_begin(&arena, 1); - + U32 hfa = CV_TypeProps_Extract_HFA(x); U32 mcom = CV_TypeProps_Extract_MOCOM(x); - + String8 hfa_str = cv_string_from_hfa(hfa); String8 mcom_str = cv_string_from_mcom(mcom); - + String8 flags_str; { String8List list = {0}; @@ -653,7 +653,7 @@ cv_string_from_type_props(Arena *arena, CV_TypeProps32 x) str8_list_pushf(scratch.arena, &list, "%x", x); } flags_str = str8_list_join(scratch.arena, &list, &(StringJoin){.sep=str8_lit(", ") }); - + if (hfa) { str8_list_pushf(scratch.arena, &list, "HFA = %S", hfa_str); } @@ -663,7 +663,7 @@ cv_string_from_type_props(Arena *arena, CV_TypeProps32 x) } String8 result = push_str8f(arena, "%S", flags_str); - + scratch_end(scratch); return result; } @@ -785,14 +785,14 @@ internal String8 cv_string_from_field_attribs(Arena *arena, CV_FieldAttribs attribs) { Temp scratch = scratch_begin(&arena, 1); - + U32 access = CV_FieldAttribs_Extract_Access(attribs); U32 mprop = CV_FieldAttribs_Extract_MethodProp(attribs); attribs &= ~(0x3 | 0x7); - + String8 access_str = cv_string_from_member_access(access); String8 mprop_str = cv_string_from_method_prop(mprop); - + String8List list = {0}; { if (attribs & CV_FieldAttrib_Pseudo) { @@ -819,16 +819,16 @@ cv_string_from_field_attribs(Arena *arena, CV_FieldAttribs attribs) str8_list_pushf(scratch.arena, &list, "Unknown: %x", attribs); } } - + if (access) { str8_list_pushf(scratch.arena, &list, "%S", access_str); } if (mprop) { str8_list_pushf(scratch.arena, &list, "%S", mprop_str); } - + String8 result = str8_list_join(scratch.arena, &list, &(StringJoin){.sep=str8_lit(", ")}); - + scratch_end(scratch); return result; } @@ -841,7 +841,7 @@ cv_string_from_itype(Arena *arena, CV_TypeIndex min_itype, CV_TypeIndex itype) String8 n = cv_type_name_from_basic_type((CV_BasicType)itype); if (n.size) { Temp scratch = scratch_begin(&arena, 1); - + U64 type = CV_BasicTypeFromTypeId(itype); char *type_str = "???"; switch (type) { @@ -899,7 +899,7 @@ cv_string_from_itype(Arena *arena, CV_TypeIndex min_itype, CV_TypeIndex itype) case CV_BasicType_CHAR8: type_str = "CHAR8"; break; case CV_BasicType_PTR: type_str = "PTR"; break; } - + U64 ptr = CV_BasicPointerKindFromTypeId(itype); char *ptr_str = ""; switch (ptr) { @@ -910,7 +910,7 @@ cv_string_from_itype(Arena *arena, CV_TypeIndex min_itype, CV_TypeIndex itype) case 0x5: ptr_str = "32PF"; break; case 0x6: ptr_str = "64P"; break; } - + n = upper_from_str8(scratch.arena, n); result = push_str8f(arena, "T_%s%s(%x)", ptr_str, type_str, itype); scratch_end(scratch); diff --git a/src/codeview/codeview_enum.h b/src/codeview/codeview_enum.h index 67095f78..1dd0615a 100644 --- a/src/codeview/codeview_enum.h +++ b/src/codeview/codeview_enum.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef CODEVIEW_ENUM_H diff --git a/src/codeview/codeview_parse.c b/src/codeview/codeview_parse.c index 57a0020c..391ad855 100644 --- a/src/codeview/codeview_parse.c +++ b/src/codeview/codeview_parse.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- Hasher diff --git a/src/codeview/codeview_parse.h b/src/codeview/codeview_parse.h index e2b0fb01..d77e2913 100644 --- a/src/codeview/codeview_parse.h +++ b/src/codeview/codeview_parse.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef CODEVIEW_PARSE_H diff --git a/src/codeview/generated/codeview.meta.c b/src/codeview/generated/codeview.meta.c index 898e4989..672e674a 100644 --- a/src/codeview/generated/codeview.meta.c +++ b/src/codeview/generated/codeview.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/codeview/generated/codeview.meta.h b/src/codeview/generated/codeview.meta.h index 9606dbf5..84612e5e 100644 --- a/src/codeview/generated/codeview.meta.h +++ b/src/codeview/generated/codeview.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/coff/coff.c b/src/coff/coff.c index 11e5d92a..582c38b2 100644 --- a/src/coff/coff.c +++ b/src/coff/coff.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal U64 @@ -32,20 +32,20 @@ coff_section_flag_from_align_size(U64 align) { COFF_SectionFlags flags = 0; switch (align) { - case 1: flags = COFF_SectionAlign_1Bytes; break; - case 2: flags = COFF_SectionAlign_2Bytes; break; - case 4: flags = COFF_SectionAlign_4Bytes; break; - case 8: flags = COFF_SectionAlign_8Bytes; break; - case 16: flags = COFF_SectionAlign_16Bytes; break; - case 32: flags = COFF_SectionAlign_32Bytes; break; - case 64: flags = COFF_SectionAlign_64Bytes; break; - case 128: flags = COFF_SectionAlign_128Bytes; break; - case 256: flags = COFF_SectionAlign_256Bytes; break; - case 512: flags = COFF_SectionAlign_512Bytes; break; - case 1024: flags = COFF_SectionAlign_1024Bytes; break; - case 2048: flags = COFF_SectionAlign_2048Bytes; break; - case 4096: flags = COFF_SectionAlign_4096Bytes; break; - case 8192: flags = COFF_SectionAlign_8192Bytes; break; + case 1: flags = COFF_SectionAlign_1Bytes; break; + case 2: flags = COFF_SectionAlign_2Bytes; break; + case 4: flags = COFF_SectionAlign_4Bytes; break; + case 8: flags = COFF_SectionAlign_8Bytes; break; + case 16: flags = COFF_SectionAlign_16Bytes; break; + case 32: flags = COFF_SectionAlign_32Bytes; break; + case 64: flags = COFF_SectionAlign_64Bytes; break; + case 128: flags = COFF_SectionAlign_128Bytes; break; + case 256: flags = COFF_SectionAlign_256Bytes; break; + case 512: flags = COFF_SectionAlign_512Bytes; break; + case 1024: flags = COFF_SectionAlign_1024Bytes; break; + case 2048: flags = COFF_SectionAlign_2048Bytes; break; + case 4096: flags = COFF_SectionAlign_4096Bytes; break; + case 8192: flags = COFF_SectionAlign_8192Bytes; break; } flags <<= COFF_SectionFlag_AlignShift; return flags; @@ -127,12 +127,12 @@ coff_apply_size_from_reloc_x64(COFF_Reloc_X64 x) case COFF_Reloc_X64_Section: return 2; case COFF_Reloc_X64_SecRel: return 4; case COFF_Reloc_X64_SRel32: return 4; - + case COFF_Reloc_X64_SecRel7: case COFF_Reloc_X64_Token: case COFF_Reloc_X64_Pair: case COFF_Reloc_X64_SSpan32: - NotImplemented; + NotImplemented; break; } return 0; @@ -153,7 +153,7 @@ coff_apply_size_from_reloc_x86(COFF_Reloc_X86 x) case COFF_Reloc_X86_Token: return 4; case COFF_Reloc_X86_SecRel7: return 1; case COFF_Reloc_X86_Rel32: return 4; - + case COFF_Reloc_X86_Unknown0: case COFF_Reloc_X86_Unknown2: case COFF_Reloc_X86_Unknown3: @@ -162,7 +162,7 @@ coff_apply_size_from_reloc_x86(COFF_Reloc_X86 x) case COFF_Reloc_X86_Unknown7: case COFF_Reloc_X86_Unknown8: case COFF_Reloc_X86_Unknown9: - NotImplemented; + NotImplemented; break; } return 0; @@ -217,7 +217,7 @@ coff_make_import_header_by_name(Arena *arena, COFF_ImportHeaderFlags flags = 0; flags |= (type & COFF_ImportHeader_TypeMask) << COFF_ImportHeader_TypeShift; flags |= COFF_ImportBy_Name << COFF_ImportHeader_ImportByShift; - + COFF_ImportHeader header = {0}; header.sig1 = COFF_MachineType_Unknown; header.sig2 = max_U16; @@ -260,7 +260,7 @@ coff_make_import_header_by_ordinal(Arena *arena, COFF_ImportHeaderFlags flags = 0; flags |= (type & COFF_ImportHeader_TypeMask) << COFF_ImportHeader_TypeShift; flags |= COFF_ImportBy_Ordinal << COFF_ImportHeader_ImportByShift; - + COFF_ImportHeader header = {0}; header.sig1 = COFF_MachineType_Unknown; header.sig2 = max_U16; @@ -296,8 +296,8 @@ coff_word_size_from_machine(COFF_MachineType machine) { U64 result = 0; switch (machine) { - case COFF_MachineType_X64: result = 8; break; - case COFF_MachineType_X86: result = 4; break; + case COFF_MachineType_X64: result = 8; break; + case COFF_MachineType_X86: result = 4; break; } return result; } @@ -307,8 +307,8 @@ coff_default_exe_base_from_machine(COFF_MachineType machine) { U64 exe_base = 0; switch (coff_word_size_from_machine(machine)) { - case 4: exe_base = 0x400000; break; - case 8: exe_base = 0x140000000; break; + case 4: exe_base = 0x400000; break; + case 8: exe_base = 0x140000000; break; } return exe_base; } @@ -318,8 +318,8 @@ coff_default_dll_base_from_machine(COFF_MachineType machine) { U64 dll_base = 0; switch (coff_word_size_from_machine(machine)) { - case 4: dll_base = 0x10000000; break; - case 8: dll_base = 0x180000000; break; + case 4: dll_base = 0x10000000; break; + case 8: dll_base = 0x180000000; break; } return dll_base; } diff --git a/src/coff/coff.h b/src/coff/coff.h index 33cec229..8961ca3c 100644 --- a/src/coff/coff.h +++ b/src/coff/coff.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef COFF_H diff --git a/src/coff/coff_enum.c b/src/coff/coff_enum.c index ccd96eeb..430f139d 100644 --- a/src/coff/coff_enum.c +++ b/src/coff/coff_enum.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal String8 @@ -62,13 +62,13 @@ coff_string_from_comdat_select_type(COFF_ComdatSelectType type) { String8 result = str8_zero(); switch (type) { - case COFF_ComdatSelect_Null: result = str8_lit("Null"); break; - case COFF_ComdatSelect_NoDuplicates: result = str8_lit("NoDuplicates"); break; - case COFF_ComdatSelect_Any: result = str8_lit("Any"); break; - case COFF_ComdatSelect_SameSize: result = str8_lit("SameSize"); break; - case COFF_ComdatSelect_ExactMatch: result = str8_lit("ExactMatch"); break; - case COFF_ComdatSelect_Associative: result = str8_lit("Associative"); break; - case COFF_ComdatSelect_Largest: result = str8_lit("Largest"); break; + case COFF_ComdatSelect_Null: result = str8_lit("Null"); break; + case COFF_ComdatSelect_NoDuplicates: result = str8_lit("NoDuplicates"); break; + case COFF_ComdatSelect_Any: result = str8_lit("Any"); break; + case COFF_ComdatSelect_SameSize: result = str8_lit("SameSize"); break; + case COFF_ComdatSelect_ExactMatch: result = str8_lit("ExactMatch"); break; + case COFF_ComdatSelect_Associative: result = str8_lit("Associative"); break; + case COFF_ComdatSelect_Largest: result = str8_lit("Largest"); break; } return result; } @@ -89,7 +89,7 @@ coff_string_from_flags(Arena *arena, COFF_FileHeaderFlags flags) { Temp scratch = scratch_begin(&arena, 1); String8List list = {0}; - + if (flags & COFF_FileHeaderFlag_RelocStripped) { str8_list_pushf(scratch.arena, &list, "Relocs Stripped"); } @@ -126,9 +126,9 @@ coff_string_from_flags(Arena *arena, COFF_FileHeaderFlags flags) if (flags & COFF_FileHeaderFlag_UpSystemOnly) { str8_list_pushf(scratch.arena, &list, "Up System Only"); } - + String8 result = str8_list_join(arena, &list, &(StringJoin){.sep=str8_lit(", ")}); - + scratch_end(scratch); return result; } @@ -201,7 +201,7 @@ coff_string_from_section_flags(Arena *arena, COFF_SectionFlags flags) if (align) { str8_list_pushf(scratch.arena, &list, "Align=%u", align); } - + if (!list.node_count) { str8_list_pushf(scratch.arena, &list, "None"); } @@ -218,9 +218,9 @@ internal String8 coff_string_from_resource_memory_flags(Arena *arena, COFF_ResourceMemoryFlags flags) { Temp scratch = scratch_begin(&arena, 1); - + String8List list = {0}; - + if (flags & COFF_ResourceMemoryFlag_Moveable) { flags &= COFF_ResourceMemoryFlag_Moveable; str8_list_pushf(scratch.arena, &list, "Moveable"); @@ -236,9 +236,9 @@ coff_string_from_resource_memory_flags(Arena *arena, COFF_ResourceMemoryFlags fl if (flags != 0) { str8_list_pushf(scratch.arena, &list, "%#x", flags); } - + String8 result = str8_list_join(arena, &list, &(StringJoin){.sep=str8_lit(", ")}); - + scratch_end(scratch); return result; } diff --git a/src/coff/coff_enum.h b/src/coff/coff_enum.h index 1ea360a7..0c52eb28 100644 --- a/src/coff/coff_enum.h +++ b/src/coff/coff_enum.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef COFF_ENUM_H diff --git a/src/coff/coff_parse.c b/src/coff/coff_parse.c index 15a918a5..3a53e8ba 100644 --- a/src/coff/coff_parse.c +++ b/src/coff/coff_parse.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal B32 @@ -8,9 +8,9 @@ coff_is_big_obj(String8 raw_coff) if (raw_coff.size >= sizeof(COFF_BigObjHeader)) { COFF_BigObjHeader *file_header32 = (COFF_BigObjHeader*)(raw_coff.str); is_big_obj = file_header32->sig1 == COFF_MachineType_Unknown && - file_header32->sig2 == max_U16 && - file_header32->version >= 2 && - MemoryCompare(file_header32->magic, g_coff_big_header_magic, sizeof(file_header32->magic)) == 0; + file_header32->sig2 == max_U16 && + file_header32->version >= 2 && + MemoryCompare(file_header32->magic, g_coff_big_header_magic, sizeof(file_header32->magic)) == 0; } return is_big_obj; } @@ -163,11 +163,11 @@ coff_symbol_array_from_data_16(Arena *arena, String8 raw_coff, U64 symbol_array_ Rng1U64 sym16_arr_range = rng_1u64(symbol_array_off, symbol_array_off + sizeof(COFF_Symbol16) * symbol_count); String8 raw_sym16_arr = str8_substr(raw_coff, sym16_arr_range); COFF_Symbol16 *sym16_arr = (COFF_Symbol16 *)raw_sym16_arr.str; - + for (U64 isymbol = 0, count = raw_sym16_arr.size / sizeof(COFF_Symbol16); isymbol < count; isymbol += 1) { COFF_Symbol16 *sym16 = &sym16_arr[isymbol]; COFF_Symbol32 *sym32 = &result.v[isymbol]; - + sym32->name = sym16->name; sym32->value = sym16->value; if (sym16->section_number == COFF_Symbol_DebugSection16) { @@ -185,7 +185,7 @@ coff_symbol_array_from_data_16(Arena *arena, String8 raw_coff, U64 symbol_array_ for (U64 iaux = isymbol+1, iaux_hi = Min(count, iaux+sym16->aux_symbol_count); iaux < iaux_hi; iaux += 1) { COFF_Symbol16 *aux16 = sym16_arr + iaux; COFF_Symbol32 *aux32 = result.v + iaux; - + // 32bit COFF uses 16bit aux symbols MemoryCopy(aux32, aux16, sizeof(COFF_Symbol16)); MemoryZero((U8 *)aux32 + sizeof(COFF_Symbol16), sizeof(COFF_Symbol32)-sizeof(COFF_Symbol16)); @@ -286,11 +286,11 @@ coff_resource_string_from_str16(Arena *arena, String16 string) { AssertAlways(string.size <= max_U16); U16 size16 = (U16)string.size; - + U16 *buffer = push_array_no_zero(arena, U16, size16 + 1); MemoryCopy(buffer + 0, &size16, sizeof(size16)); MemoryCopy(buffer + 1, string.str, size16 * sizeof(string.str[0])); - + return str8_array(buffer, size16 + 1); } @@ -358,14 +358,14 @@ coff_read_resource(Arena *arena, String8 raw_res, U64 off, COFF_ParsedResource * { String8 raw_header = str8_skip(raw_res, off); U64 header_cursor = 0; - + // prefix COFF_ResourceHeaderPrefix prefix = {0}; header_cursor += str8_deserial_read_struct(raw_header, header_cursor, &prefix); - + Assert(prefix.header_size >= sizeof(COFF_ResourceHeaderPrefix)); raw_header = str8_prefix(raw_header, prefix.header_size); - + // header COFF_ResourceID16 type_16 = {0}; COFF_ResourceID16 name_16 = {0}; @@ -377,11 +377,11 @@ coff_read_resource(Arena *arena, String8 raw_res, U64 off, COFF_ParsedResource * header_cursor += str8_deserial_read_struct(raw_header, header_cursor, &res_out->version); header_cursor += str8_deserial_read_struct(raw_header, header_cursor, &res_out->characteristics); Assert(prefix.header_size == header_cursor); - + // convert utf-16 resource ids to utf-8 res_out->type = coff_utf8_resource_id_from_utf16(arena, &type_16); res_out->name = coff_utf8_resource_id_from_utf16(arena, &name_16); - + // read data U64 data_read_size = str8_deserial_read_block(raw_res, off + prefix.header_size, prefix.data_size, &res_out->data); Assert(prefix.data_size == data_read_size); @@ -411,14 +411,14 @@ coff_write_resource_id(Arena *arena, COFF_ResourceID id) { String8 result = str8_zero(); switch (id.type) { - case COFF_ResourceIDType_Null: break; - case COFF_ResourceIDType_Number: { - result = coff_resource_number_from_u16(arena, id.u.number); - } break; - case COFF_ResourceIDType_String: { - result = coff_resource_string_from_str8(arena, id.u.string); - } break; - default: InvalidPath; + case COFF_ResourceIDType_Null: break; + case COFF_ResourceIDType_Number: { + result = coff_resource_number_from_u16(arena, id.u.number); + } break; + case COFF_ResourceIDType_String: { + result = coff_resource_string_from_str8(arena, id.u.string); + } break; + default: InvalidPath; } return result; } @@ -435,13 +435,13 @@ coff_write_resource(Arena *arena, String8 data) { Temp scratch = scratch_begin(&arena, 1); - + String8List list = {0}; - + COFF_ResourceHeaderPrefix *prefix = push_array(scratch.arena, COFF_ResourceHeaderPrefix, 1); String8 packed_type = coff_write_resource_id(scratch.arena, type); String8 packed_name = coff_write_resource_id(scratch.arena, name); - + // prefix + header str8_list_push(scratch.arena, &list, str8_struct(prefix)); str8_list_push(scratch.arena, &list, packed_type); @@ -451,24 +451,24 @@ coff_write_resource(Arena *arena, str8_list_push(scratch.arena, &list, str8_struct(&language_id)); str8_list_push(scratch.arena, &list, str8_struct(&version)); str8_list_push(scratch.arena, &list, str8_struct(&characteristics)); - + prefix->data_size = safe_cast_u32(data.size); prefix->header_size = safe_cast_u32(list.total_size); - + // data str8_list_push(scratch.arena, &list, data); - + // magic str8_list_push_front(scratch.arena, &list, str8_array_fixed(g_coff_res_magic)); - + // align U64 align_size = AlignPow2(list.total_size, COFF_ResourceAlign) - list.total_size; U8 *align = push_array(scratch.arena, U8, align_size); str8_list_push(scratch.arena, &list, str8(align, align_size)); - + // join String8 res = str8_list_join(arena, &list, 0); - + scratch_end(scratch); return res; } @@ -481,10 +481,10 @@ coff_resource_id_compar(void *raw_a, void *raw_b) COFF_ResourceID *b = raw_b; if (a->type == b->type) { switch (a->type) { - default: - case COFF_ResourceIDType_Null: cmp = 0; break; - case COFF_ResourceIDType_Number: cmp = MemoryCompare(&a->u.number, &b->u.number, sizeof(a->u.number)); break; - case COFF_ResourceIDType_String: cmp = strncmp((char *)a->u.string.str, (char *)b->u.string.str, Min(a->u.string.size, b->u.string.size)); break; + default: + case COFF_ResourceIDType_Null: cmp = 0; break; + case COFF_ResourceIDType_Number: cmp = MemoryCompare(&a->u.number, &b->u.number, sizeof(a->u.number)); break; + case COFF_ResourceIDType_String: cmp = strncmp((char *)a->u.string.str, (char *)b->u.string.str, Min(a->u.string.size, b->u.string.size)); break; } } else { cmp = a->type < b->type ? -1 : a->type > b->type ? +1 : 0; @@ -563,10 +563,10 @@ coff_parse_archive_member_header(String8 raw_archive, U64 offset, COFF_ParsedArc String8 mode = str8_skip_chop_whitespace(str8_cstring_capped(header->mode, header->mode + sizeof(header->mode) )); String8 size = str8_skip_chop_whitespace(str8_cstring_capped(header->size, header->size + sizeof(header->size) )); String8 end = str8_cstring_capped(header->end, header->end + sizeof(header->end)); - + U32 data_size = u32_from_str8(size, 10); U64 data_off = offset + sizeof(COFF_ArchiveMemberHeader); - + header_out->name = name; header_out->time_stamp = u32_from_str8(date, 10); header_out->user_id = u32_from_str8(user_id, 10); @@ -574,7 +574,7 @@ coff_parse_archive_member_header(String8 raw_archive, U64 offset, COFF_ParsedArc header_out->mode = mode; header_out->is_end_correct = str8_match_lit("`\n", end, 0); header_out->data_range = rng_1u64(data_off, data_off + data_size); - + return sizeof(*header); } return 0; @@ -584,7 +584,7 @@ internal COFF_ArchiveFirstMember coff_parse_first_archive_member(COFF_ArchiveMember *member) { Assert(str8_match_lit("/", member->header.name, 0)); - + U64 cursor = 0; U32 symbol_count = 0; @@ -597,17 +597,17 @@ coff_parse_first_archive_member(COFF_ArchiveMember *member) Rng1U64 string_table_range = rng_1u64(cursor, member->data.size); cursor += dim_1u64(string_table_range); - + String8 raw_member_offsets = str8_substr(member->data, member_offsets_range); U32 *member_offsets = (U32 *)raw_member_offsets.str; U64 member_offset_count = raw_member_offsets.size / sizeof(member_offsets[0]); - + COFF_ArchiveFirstMember result = {0}; result.symbol_count = symbol_count; result.member_offset_count = member_offset_count; result.member_offsets = member_offsets; result.string_table = str8_substr(member->data, string_table_range); - + return result; } @@ -615,7 +615,7 @@ internal COFF_ArchiveSecondMember coff_parse_second_archive_member(COFF_ArchiveMember *member) { COFF_ArchiveSecondMember result = {0}; - + if (str8_match_lit("/", member->header.name, 0)) { U64 cursor = 0; @@ -632,13 +632,13 @@ coff_parse_second_archive_member(COFF_ArchiveMember *member) cursor += dim_1u64(symbol_indices_range); Rng1U64 string_table_range = rng_1u64(cursor, member->data.size); - + String8 raw_member_offsets = str8_substr(member->data, member_offsets_range); String8 raw_indices = str8_substr(member->data, symbol_indices_range); - + U32 *member_offsets = (U32 *)raw_member_offsets.str; U64 member_offset_count = raw_member_offsets.size / sizeof(member_offsets[0]); - + U16 *symbol_indices = (U16 *)raw_indices.str; U64 symbol_index_count = raw_indices.size / sizeof(symbol_indices[0]); @@ -650,7 +650,7 @@ coff_parse_second_archive_member(COFF_ArchiveMember *member) result.symbol_index_count = symbol_index_count; result.string_table = str8_substr(member->data, string_table_range); } - + return result; } @@ -683,7 +683,7 @@ coff_parse_import(String8 raw_archive_member, U64 offset, COFF_ParsedArchiveImpo Rng1U64 data_range = rng_1u64(offset + sizeof(*header), offset + sizeof(*header) + header->data_size); String8 raw_data = str8_substr(raw_archive_member, data_range); U64 data_cursor = 0; - + header_out->version = header->version; header_out->machine = header->machine; header_out->time_stamp = header->time_stamp; @@ -744,7 +744,7 @@ coff_regular_archive_member_iter_next(String8 raw_archive, U64 *offset, COFF_Arc if (member_out->header.is_end_correct) { member_out->offset = *offset; member_out->data = str8_substr(raw_archive, member_out->header.data_range); - + U64 read_size = AlignPow2(header_size + dim_1u64(member_out->header.data_range), COFF_Archive_MemberAlign); *offset += read_size; @@ -771,19 +771,19 @@ coff_thin_archive_member_iter_next(String8 raw_archive, U64 *offset, COFF_Archiv member_out->header.is_end_correct = 0; U64 header_size = coff_parse_archive_member_header(raw_archive, *offset, &member_out->header); - + if (member_out->header.is_end_correct) { Rng1U64 data_in_archive_range = {0}; if (str8_match_lit("/", member_out->header.name, 0) || str8_match_lit("//", member_out->header.name, 0)) { data_in_archive_range = member_out->header.data_range; } - + member_out->offset = *offset; member_out->data = str8_substr(raw_archive, data_in_archive_range); - + U64 read_size = AlignPow2(header_size + dim_1u64(data_in_archive_range), COFF_Archive_MemberAlign); *offset += read_size; - + is_parsed = 1; } @@ -806,9 +806,9 @@ coff_archive_parse_from_member_list(COFF_ArchiveMemberList member_list) COFF_ArchiveMember first_header = {0}; COFF_ArchiveMember second_header = {0}; COFF_ArchiveMember long_names_member = {0}; - + COFF_ArchiveMemberNode *ptr = member_list.first; - + if (ptr) { if (str8_match_lit("/", ptr->data.header.name, 0)) { if (ptr->data.header.is_end_correct) { @@ -821,7 +821,7 @@ coff_archive_parse_from_member_list(COFF_ArchiveMemberList member_list) } else { error = str8_lit("missing first header"); } - + if (!error.size && ptr) { if (str8_match_lit("/", ptr->data.header.name, 0)) { if (ptr->data.header.is_end_correct) { @@ -833,7 +833,7 @@ coff_archive_parse_from_member_list(COFF_ArchiveMemberList member_list) } } } - + if (!error.size && ptr) { if (str8_match_lit("//", ptr->data.header.name, 0)) { if (ptr->data.header.is_end_correct) { @@ -853,7 +853,7 @@ coff_archive_parse_from_member_list(COFF_ArchiveMemberList member_list) parse.second_member = coff_parse_second_archive_member(&second_header); parse.long_names = long_names_member.data; parse.error = error; - + return parse; } @@ -894,9 +894,9 @@ coff_archive_parse_from_data(String8 raw_archive) { COFF_ArchiveType type = coff_archive_type_from_data(raw_archive); switch (type) { - case COFF_Archive_Null: break; - case COFF_Archive_Regular: return coff_regular_archive_parse_from_data(raw_archive); - case COFF_Archive_Thin: return coff_thin_archive_parse_from_data(raw_archive); + case COFF_Archive_Null: break; + case COFF_Archive_Regular: return coff_regular_archive_parse_from_data(raw_archive); + case COFF_Archive_Thin: return coff_thin_archive_parse_from_data(raw_archive); } COFF_ArchiveParse null_parse = {0}; return null_parse; diff --git a/src/coff/coff_parse.h b/src/coff/coff_parse.h index 7e237646..69c57ff3 100644 --- a/src/coff/coff_parse.h +++ b/src/coff/coff_parse.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef COFF_PARSE_H diff --git a/src/ctrl/ctrl.mdesk b/src/ctrl/ctrl.mdesk index ceb2fca1..d3f74faf 100644 --- a/src/ctrl/ctrl.mdesk +++ b/src/ctrl/ctrl.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 9b612b75..04d4dadc 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index 1eb83b5e..d29a5f41 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef CTRL_CORE_H diff --git a/src/ctrl/ctrl_inc.c b/src/ctrl/ctrl_inc.c index d2dcdb61..45213b22 100644 --- a/src/ctrl/ctrl_inc.c +++ b/src/ctrl/ctrl_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/ctrl/ctrl_inc.h b/src/ctrl/ctrl_inc.h index 5a0fcb0d..3226e1b2 100644 --- a/src/ctrl/ctrl_inc.h +++ b/src/ctrl/ctrl_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef CTRL_INC_H diff --git a/src/ctrl/generated/ctrl.meta.c b/src/ctrl/generated/ctrl.meta.c index c7d5dd88..7f498081 100644 --- a/src/ctrl/generated/ctrl.meta.c +++ b/src/ctrl/generated/ctrl.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/ctrl/generated/ctrl.meta.h b/src/ctrl/generated/ctrl.meta.h index 56f7b8db..732dbfc2 100644 --- a/src/ctrl/generated/ctrl.meta.h +++ b/src/ctrl/generated/ctrl.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/dasm_cache/dasm_cache.c b/src/dasm_cache/dasm_cache.c index 26d6df9f..c4ac8bd2 100644 --- a/src/dasm_cache/dasm_cache.c +++ b/src/dasm_cache/dasm_cache.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/dasm_cache/dasm_cache.h b/src/dasm_cache/dasm_cache.h index 25a222fe..521e359a 100644 --- a/src/dasm_cache/dasm_cache.h +++ b/src/dasm_cache/dasm_cache.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DASM_CACHE_H diff --git a/src/dbg_engine/dbg_engine.mdesk b/src/dbg_engine/dbg_engine.mdesk index cbfe3352..a92649e2 100644 --- a/src/dbg_engine/dbg_engine.mdesk +++ b/src/dbg_engine/dbg_engine.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/dbg_engine/dbg_engine_core.c b/src/dbg_engine/dbg_engine_core.c index 80d0b912..befefe05 100644 --- a/src/dbg_engine/dbg_engine_core.c +++ b/src/dbg_engine/dbg_engine_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/dbg_engine/dbg_engine_core.h b/src/dbg_engine/dbg_engine_core.h index 042ffd3a..e6e535db 100644 --- a/src/dbg_engine/dbg_engine_core.h +++ b/src/dbg_engine/dbg_engine_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DBG_ENGINE_CORE_H diff --git a/src/dbg_engine/dbg_engine_inc.c b/src/dbg_engine/dbg_engine_inc.c index 81f3a28d..b3d11c5b 100644 --- a/src/dbg_engine/dbg_engine_inc.c +++ b/src/dbg_engine/dbg_engine_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "dbg_engine_core.c" diff --git a/src/dbg_engine/dbg_engine_inc.h b/src/dbg_engine/dbg_engine_inc.h index 96ca410a..5dcf2fb4 100644 --- a/src/dbg_engine/dbg_engine_inc.h +++ b/src/dbg_engine/dbg_engine_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DBG_ENGINE_INC_H diff --git a/src/dbg_engine/generated/dbg_engine.meta.c b/src/dbg_engine/generated/dbg_engine.meta.c index 3d32a4c2..437ae10e 100644 --- a/src/dbg_engine/generated/dbg_engine.meta.c +++ b/src/dbg_engine/generated/dbg_engine.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/dbg_engine/generated/dbg_engine.meta.h b/src/dbg_engine/generated/dbg_engine.meta.h index 8451a246..d91994c8 100644 --- a/src/dbg_engine/generated/dbg_engine.meta.h +++ b/src/dbg_engine/generated/dbg_engine.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/dbgi/dbgi.c b/src/dbgi/dbgi.c index 96f0b480..941449bc 100644 --- a/src/dbgi/dbgi.c +++ b/src/dbgi/dbgi.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/dbgi/dbgi.h b/src/dbgi/dbgi.h index ca8b8e77..555e5e03 100644 --- a/src/dbgi/dbgi.h +++ b/src/dbgi/dbgi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DBGI_H diff --git a/src/demon/demon_core.c b/src/demon/demon_core.c index 99df924f..75cca59e 100644 --- a/src/demon/demon_core.c +++ b/src/demon/demon_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/demon/demon_core.h b/src/demon/demon_core.h index 681bd820..7904fbf1 100644 --- a/src/demon/demon_core.h +++ b/src/demon/demon_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DEMON_CORE_H diff --git a/src/demon/demon_inc.c b/src/demon/demon_inc.c index 0f0507c2..d733b612 100644 --- a/src/demon/demon_inc.c +++ b/src/demon/demon_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "demon/demon_core.c" diff --git a/src/demon/demon_inc.h b/src/demon/demon_inc.h index 8bd7b092..eec32998 100644 --- a/src/demon/demon_inc.h +++ b/src/demon/demon_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DEMON_INC_H diff --git a/src/demon/generated/demon.meta.c b/src/demon/generated/demon.meta.c index 47406944..70a2272d 100644 --- a/src/demon/generated/demon.meta.c +++ b/src/demon/generated/demon.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/demon/generated/demon.meta.h b/src/demon/generated/demon.meta.h index 4a8b5b80..94140c1f 100644 --- a/src/demon/generated/demon.meta.h +++ b/src/demon/generated/demon.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/demon/linux/demon_core_linux.c b/src/demon/linux/demon_core_linux.c index ffa705af..c6edab7f 100644 --- a/src/demon/linux/demon_core_linux.c +++ b/src/demon/linux/demon_core_linux.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/demon/linux/demon_core_linux.h b/src/demon/linux/demon_core_linux.h index a0bae69a..e11072f7 100644 --- a/src/demon/linux/demon_core_linux.h +++ b/src/demon/linux/demon_core_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DEMON_CORE_LINUX_H diff --git a/src/demon/linux/demon_os_linux.c b/src/demon/linux/demon_os_linux.c index b0b3c972..39c1aa1f 100644 --- a/src/demon/linux/demon_os_linux.c +++ b/src/demon/linux/demon_os_linux.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) // TODO(allen): run controls: ignore_previous_exception diff --git a/src/demon/linux/demon_os_linux.h b/src/demon/linux/demon_os_linux.h index 915e29de..ae737f75 100644 --- a/src/demon/linux/demon_os_linux.h +++ b/src/demon/linux/demon_os_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DEMON_OS_LINUX_H diff --git a/src/demon/win32/demon_core_win32.c b/src/demon/win32/demon_core_win32.c index d9fe31df..76399ae1 100644 --- a/src/demon/win32/demon_core_win32.c +++ b/src/demon/win32/demon_core_win32.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/demon/win32/demon_core_win32.h b/src/demon/win32/demon_core_win32.h index 05483e26..bc6a2e0a 100644 --- a/src/demon/win32/demon_core_win32.h +++ b/src/demon/win32/demon_core_win32.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DEMON_CORE_WIN32_H diff --git a/src/draw/draw.c b/src/draw/draw.c index db34c9b0..5c31e93e 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/draw/draw.h b/src/draw/draw.h index f338e0fd..acc7ce64 100644 --- a/src/draw/draw.h +++ b/src/draw/draw.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DRAW_H diff --git a/src/draw/draw.mdesk b/src/draw/draw.mdesk index 981b3bb2..d412ac7c 100644 --- a/src/draw/draw.mdesk +++ b/src/draw/draw.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) @table(name, name_lower, type, default_init) diff --git a/src/draw/generated/draw.meta.c b/src/draw/generated/draw.meta.c index aa5e65c0..2efd51aa 100644 --- a/src/draw/generated/draw.meta.c +++ b/src/draw/generated/draw.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/draw/generated/draw.meta.h b/src/draw/generated/draw.meta.h index 350048e1..58db1f4e 100644 --- a/src/draw/generated/draw.meta.h +++ b/src/draw/generated/draw.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/dwarf/dwarf.c b/src/dwarf/dwarf.c index 05f72bc0..f0877ff8 100644 --- a/src/dwarf/dwarf.c +++ b/src/dwarf/dwarf.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal U64 @@ -49,10 +49,10 @@ internal U64 dw_reg_size_from_code(Arch arch, DW_Reg reg_code) { switch (arch) { - case Arch_Null: break; - case Arch_x86: return dw_reg_size_from_code_x86(reg_code); - case Arch_x64: return dw_reg_size_from_code_x64(reg_code); - default: NotImplemented; break; + case Arch_Null: break; + case Arch_x86: return dw_reg_size_from_code_x86(reg_code); + case Arch_x64: return dw_reg_size_from_code_x64(reg_code); + default: NotImplemented; break; } return 0; } @@ -61,10 +61,10 @@ internal U64 dw_reg_pos_from_code(Arch arch, DW_Reg reg_code) { switch (arch) { - case Arch_Null: break; - case Arch_x86: return dw_reg_pos_from_code_x86(reg_code); - case Arch_x64: return dw_reg_pos_from_code_x64(reg_code); - default: NotImplemented; break; + case Arch_Null: break; + case Arch_x86: return dw_reg_pos_from_code_x86(reg_code); + case Arch_x64: return dw_reg_pos_from_code_x64(reg_code); + default: NotImplemented; break; } return max_U64; } @@ -73,9 +73,9 @@ internal DW_AttribClass dw_attrib_class_from_attrib_kind_v2(DW_AttribKind k) { switch (k) { - #define X(_N,_C) case DW_Attrib_##_N: return _C; +#define X(_N,_C) case DW_Attrib_##_N: return _C; DW_AttribKind_ClassFlags_V2_XList(X) - #undef X +#undef X } return DW_AttribClass_Null; } @@ -84,9 +84,9 @@ internal DW_AttribClass dw_attrib_class_from_attrib_kind_v3(DW_AttribKind k) { switch (k) { - #define X(_N,_C) case DW_Attrib_##_N: return _C; +#define X(_N,_C) case DW_Attrib_##_N: return _C; DW_AttribKind_ClassFlags_V3_XList(X) - #undef X +#undef X } return DW_AttribClass_Null; } @@ -95,9 +95,9 @@ internal DW_AttribClass dw_attrib_class_from_attrib_kind_v4(DW_AttribKind k) { switch (k) { - #define X(_N,_C) case DW_Attrib_##_N: return _C; +#define X(_N,_C) case DW_Attrib_##_N: return _C; DW_AttribKind_ClassFlags_V4_XList(X) - #undef X +#undef X } return DW_AttribClass_Null; } @@ -106,9 +106,9 @@ internal DW_AttribClass dw_attrib_class_from_attrib_kind_v5(DW_AttribKind k) { switch (k) { - #define X(_N,_C) case DW_Attrib_##_N: return _C; +#define X(_N,_C) case DW_Attrib_##_N: return _C; DW_AttribKind_ClassFlags_V5_XList(X) - #undef X +#undef X } return DW_AttribClass_Null; } @@ -117,9 +117,9 @@ internal DW_AttribClass dw_attrib_class_from_attrib_kind_gnu(DW_AttribKind k) { switch (k) { - #define X(_N,_C) case DW_Attrib_##_N: return _C; +#define X(_N,_C) case DW_Attrib_##_N: return _C; DW_AttribKind_ClassFlags_GNU_XList(X) - #undef X +#undef X } return DW_AttribClass_Null; } @@ -128,9 +128,9 @@ internal DW_AttribClass dw_attrib_class_from_attrib_kind_llvm(DW_AttribKind k) { switch (k) { - #define X(_N,_C) case DW_Attrib_##_N: return _C; +#define X(_N,_C) case DW_Attrib_##_N: return _C; DW_AttribKind_ClassFlags_LLVM_XList(X) - #undef X +#undef X } return DW_AttribClass_Null; } @@ -139,9 +139,9 @@ internal DW_AttribClass dw_attrib_class_from_attrib_kind_apple(DW_AttribKind k) { switch (k) { - #define X(_N,_C) case DW_Attrib_##_N: return _C; +#define X(_N,_C) case DW_Attrib_##_N: return _C; DW_AttribKind_ClassFlags_APPLE_XList(X) - #undef X +#undef X } return DW_AttribClass_Null; } @@ -150,9 +150,9 @@ internal DW_AttribClass dw_attrib_class_from_attrib_kind_mips(DW_AttribKind k) { switch (k) { - #define X(_N,_C) case DW_Attrib_##_N: return _C; +#define X(_N,_C) case DW_Attrib_##_N: return _C; DW_AttribKind_ClassFlags_MIPS_XList(X) - #undef X +#undef X } return DW_AttribClass_Null; } @@ -161,7 +161,7 @@ internal DW_AttribClass dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k) { DW_AttribClass result = DW_AttribClass_Null; - + while (ext) { U64 z = 64-clz64(ext); if (z == 0) { @@ -169,7 +169,7 @@ dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k) } U64 flag = 1 << (z-1); ext &= ~flag; - + switch (flag) { case DW_Ext_Null: break; case DW_Ext_GNU: result = dw_attrib_class_from_attrib_kind_gnu(k); break; @@ -178,12 +178,12 @@ dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k) case DW_Ext_MIPS: result = dw_attrib_class_from_attrib_kind_mips(k); break; default: InvalidPath; break; } - + if (result != DW_AttribClass_Null) { break; } } - + if (result == DW_AttribClass_Null) { switch (ver) { case DW_Version_Null: break; @@ -195,19 +195,19 @@ dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k) default: InvalidPath; break; } } - + return result; } internal DW_AttribClass dw_attrib_class_from_form_kind(DW_Version ver, DW_FormKind k) { - #define X(_N,_C) case DW_Form_##_N: return _C; - +#define X(_N,_C) case DW_Form_##_N: return _C; + switch (k) { DW_Form_AttribClass_GNU_XList(X) } - + switch (ver) { case DW_Version_5: { switch (k) { @@ -233,8 +233,8 @@ dw_attrib_class_from_form_kind(DW_Version ver, DW_FormKind k) } break; case DW_Version_Null: break; } - #undef X - +#undef X + return DW_AttribClass_Null; } @@ -250,9 +250,9 @@ internal String8 dw_name_string_from_section_kind(DW_SectionKind k) { switch (k) { - #define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L); +#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L); DW_SectionKind_XList(X) - #undef X +#undef X } return str8_zero(); } @@ -261,9 +261,9 @@ internal String8 dw_mach_name_string_from_section_kind(DW_SectionKind k) { switch (k) { - #define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M); +#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M); DW_SectionKind_XList(X) - #undef X +#undef X } return str8_zero(); } @@ -272,9 +272,9 @@ internal String8 dw_dwo_name_string_from_section_kind(DW_SectionKind k) { switch (k) { - #define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D); +#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D); DW_SectionKind_XList(X) - #undef X +#undef X } return str8_zero(); } @@ -301,10 +301,10 @@ dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKin // // This function's purpose is to find the overlapping class between an // DW_AttribKind and DW_FormKind. - + DW_AttribClass attrib_class = dw_attrib_class_from_attrib_kind(ver, ext, attrib_kind); DW_AttribClass form_class = dw_attrib_class_from_form_kind(ver, form_kind); - + if(relaxed) { if(attrib_class == DW_AttribClass_Null || form_class == DW_AttribClass_Null) @@ -313,12 +313,12 @@ dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKin form_class = dw_attrib_class_from_form_kind(DW_Version_Last, form_kind); } } - + DW_AttribClass result = DW_AttribClass_Null; if(attrib_class != DW_AttribClass_Null && form_class != DW_AttribClass_Null) { result = DW_AttribClass_Undefined; - + for(U32 i = 0; i < 32; ++i) { U32 n = 1u << i; @@ -329,7 +329,7 @@ dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKin } } } - + return result; } @@ -338,50 +338,50 @@ dw_pick_default_lower_bound(DW_Language lang) { U64 lower_bound = max_U64; switch (lang) { - case DW_Language_Null: break; - case DW_Language_C89: - case DW_Language_C: - case DW_Language_CPlusPlus: - case DW_Language_C99: - case DW_Language_CPlusPlus03: - case DW_Language_CPlusPlus11: - case DW_Language_C11: - case DW_Language_CPlusPlus14: - case DW_Language_Java: - case DW_Language_ObjC: - case DW_Language_ObjCPlusPlus: - case DW_Language_UPC: - case DW_Language_D: - case DW_Language_Python: - case DW_Language_OpenCL: - case DW_Language_Go: - case DW_Language_Haskell: - case DW_Language_OCaml: - case DW_Language_Rust: - case DW_Language_Swift: - case DW_Language_Dylan: - case DW_Language_RenderScript: - case DW_Language_BLISS: - lower_bound = 0; - break; - case DW_Language_Ada83: - case DW_Language_Cobol74: - case DW_Language_Cobol85: - case DW_Language_Fortran77: - case DW_Language_Fortran90: - case DW_Language_Pascal83: - case DW_Language_Modula2: - case DW_Language_Ada95: - case DW_Language_Fortran95: - case DW_Language_PLI: - case DW_Language_Modula3: - case DW_Language_Julia: - case DW_Language_Fortran03: - case DW_Language_Fortran08: - lower_bound = 1; - default: - NotImplemented; - break; + case DW_Language_Null: break; + case DW_Language_C89: + case DW_Language_C: + case DW_Language_CPlusPlus: + case DW_Language_C99: + case DW_Language_CPlusPlus03: + case DW_Language_CPlusPlus11: + case DW_Language_C11: + case DW_Language_CPlusPlus14: + case DW_Language_Java: + case DW_Language_ObjC: + case DW_Language_ObjCPlusPlus: + case DW_Language_UPC: + case DW_Language_D: + case DW_Language_Python: + case DW_Language_OpenCL: + case DW_Language_Go: + case DW_Language_Haskell: + case DW_Language_OCaml: + case DW_Language_Rust: + case DW_Language_Swift: + case DW_Language_Dylan: + case DW_Language_RenderScript: + case DW_Language_BLISS: + lower_bound = 0; + break; + case DW_Language_Ada83: + case DW_Language_Cobol74: + case DW_Language_Cobol85: + case DW_Language_Fortran77: + case DW_Language_Fortran90: + case DW_Language_Pascal83: + case DW_Language_Modula2: + case DW_Language_Ada95: + case DW_Language_Fortran95: + case DW_Language_PLI: + case DW_Language_Modula3: + case DW_Language_Julia: + case DW_Language_Fortran03: + case DW_Language_Fortran08: + lower_bound = 1; + default: + NotImplemented; + break; } return lower_bound; } diff --git a/src/dwarf/dwarf.h b/src/dwarf/dwarf.h index 4c7132a4..d56adfdb 100644 --- a/src/dwarf/dwarf.h +++ b/src/dwarf/dwarf.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DWARF_H @@ -20,12 +20,12 @@ typedef U64 DW_Ext; typedef enum DW_ExtEnum { DW_Ext_Null, - + DW_Ext_GNU = (1 << 0), DW_Ext_LLVM = (1 << 1), DW_Ext_APPLE = (1 << 2), DW_Ext_MIPS = (1 << 3), - + DW_Ext_All = DW_Ext_GNU|DW_Ext_LLVM|DW_Ext_APPLE|DW_Ext_MIPS, } DW_ExtEnum; @@ -40,24 +40,24 @@ typedef enum DW_Format #define DW_SentinelFromSize(address_size) ((address_size) == 4 ? max_U32 : (address_size) == 8 ? max_U64 : 0) #define DW_SectionKind_XList(X )\ - X(Null, "", "", "" )\ - X(Abbrev, ".debug_abbrev", "__debug_abbrev", ".debug_abbrev.dwo" )\ - X(ARanges, ".debug_aranges", "__debug_aranges", ".debug_aranges.dwo" )\ - X(Frame, ".debug_frame", "__debug_frame", ".debug_frame.dwo" )\ - X(Info, ".debug_info", "__debug_info", ".debug_info.dwo" )\ - X(Line, ".debug_line", "__debug_line", ".debug_line.dwo" )\ - X(Loc, ".debug_loc", "__debug_loc", ".debug_loc.dwo" )\ - X(MacInfo, ".debug_macinfo", "__debug_macinfo", ".debug_macinfo.dwo" )\ - X(PubNames, ".debug_pubnames", "__debug_pubnames", ".debug_pubnames.dwo" )\ - X(PubTypes, ".debug_pubtypes", "__debug_pubtypes", ".debug_pubtypes.dwo" )\ - X(Ranges, ".debug_ranges", "__debug_ranges", ".debug_ranges.dwo" )\ - X(Str, ".debug_str", "__debug_str", ".debug_str.dwo" )\ - X(Addr, ".debug_addr", "__debug_addr", ".debug_addr.dwo" )\ - X(LocLists, ".debug_loclists", "__debug_loclists", ".debug_loclists.dwo" )\ - X(RngLists, ".debug_rnglists", "__debug_rnglists", ".debug_rnglists.dwo" )\ - X(StrOffsets, ".debug_str_offsets", "__debug_str_offsets", ".debug_str_offsets.dwo")\ - X(LineStr, ".debug_line_str", "__debug_line_str", ".debug_line_str.dwo" )\ - X(Names, ".debug_names", "__debug_names", ".debug_names.dwo" ) +X(Null, "", "", "" )\ +X(Abbrev, ".debug_abbrev", "__debug_abbrev", ".debug_abbrev.dwo" )\ +X(ARanges, ".debug_aranges", "__debug_aranges", ".debug_aranges.dwo" )\ +X(Frame, ".debug_frame", "__debug_frame", ".debug_frame.dwo" )\ +X(Info, ".debug_info", "__debug_info", ".debug_info.dwo" )\ +X(Line, ".debug_line", "__debug_line", ".debug_line.dwo" )\ +X(Loc, ".debug_loc", "__debug_loc", ".debug_loc.dwo" )\ +X(MacInfo, ".debug_macinfo", "__debug_macinfo", ".debug_macinfo.dwo" )\ +X(PubNames, ".debug_pubnames", "__debug_pubnames", ".debug_pubnames.dwo" )\ +X(PubTypes, ".debug_pubtypes", "__debug_pubtypes", ".debug_pubtypes.dwo" )\ +X(Ranges, ".debug_ranges", "__debug_ranges", ".debug_ranges.dwo" )\ +X(Str, ".debug_str", "__debug_str", ".debug_str.dwo" )\ +X(Addr, ".debug_addr", "__debug_addr", ".debug_addr.dwo" )\ +X(LocLists, ".debug_loclists", "__debug_loclists", ".debug_loclists.dwo" )\ +X(RngLists, ".debug_rnglists", "__debug_rnglists", ".debug_rnglists.dwo" )\ +X(StrOffsets, ".debug_str_offsets", "__debug_str_offsets", ".debug_str_offsets.dwo")\ +X(LineStr, ".debug_line_str", "__debug_line_str", ".debug_line_str.dwo" )\ +X(Names, ".debug_names", "__debug_names", ".debug_names.dwo" ) typedef U64 DW_SectionKind; typedef enum DW_SectionKindEnum @@ -69,48 +69,48 @@ typedef enum DW_SectionKindEnum } DW_SectionKindEnum; #define DW_Language_XList(X) \ - X(Null, 0x00) \ - X(C89, 0x01) \ - X(C, 0x02) \ - X(Ada83, 0x03) \ - X(CPlusPlus, 0x04) \ - X(Cobol74, 0x05) \ - X(Cobol85, 0x06) \ - X(Fortran77, 0x07) \ - X(Fortran90, 0x08) \ - X(Pascal83, 0x09) \ - X(Modula2, 0x0A) \ - X(Java, 0x0B) \ - X(C99, 0x0C) \ - X(Ada95, 0x0D) \ - X(Fortran95, 0x0E) \ - X(PLI, 0x0F) \ - X(ObjC, 0x10) \ - X(ObjCPlusPlus, 0x11) \ - X(UPC, 0x12) \ - X(D, 0x13) \ - X(Python, 0x14) \ - X(OpenCL, 0x15) \ - X(Go, 0x16) \ - X(Modula3, 0x17) \ - X(Haskell, 0x18) \ - X(CPlusPlus03, 0x19) \ - X(CPlusPlus11, 0x1a) \ - X(OCaml, 0x1b) \ - X(Rust, 0x1c) \ - X(C11, 0x1d) \ - X(Swift, 0x1e) \ - X(Julia, 0x1f) \ - X(Dylan, 0x20) \ - X(CPlusPlus14, 0x21) \ - X(Fortran03, 0x22) \ - X(Fortran08, 0x23) \ - X(RenderScript, 0x24) \ - X(BLISS, 0x25) \ - X(MipsAssembler, 0x8001) \ - X(GoogleRenderScript, 0x8E57) \ - X(SunAssembler, 0x9001) \ - X(BorlandDelphi, 0xB000) +X(Null, 0x00) \ +X(C89, 0x01) \ +X(C, 0x02) \ +X(Ada83, 0x03) \ +X(CPlusPlus, 0x04) \ +X(Cobol74, 0x05) \ +X(Cobol85, 0x06) \ +X(Fortran77, 0x07) \ +X(Fortran90, 0x08) \ +X(Pascal83, 0x09) \ +X(Modula2, 0x0A) \ +X(Java, 0x0B) \ +X(C99, 0x0C) \ +X(Ada95, 0x0D) \ +X(Fortran95, 0x0E) \ +X(PLI, 0x0F) \ +X(ObjC, 0x10) \ +X(ObjCPlusPlus, 0x11) \ +X(UPC, 0x12) \ +X(D, 0x13) \ +X(Python, 0x14) \ +X(OpenCL, 0x15) \ +X(Go, 0x16) \ +X(Modula3, 0x17) \ +X(Haskell, 0x18) \ +X(CPlusPlus03, 0x19) \ +X(CPlusPlus11, 0x1a) \ +X(OCaml, 0x1b) \ +X(Rust, 0x1c) \ +X(C11, 0x1d) \ +X(Swift, 0x1e) \ +X(Julia, 0x1f) \ +X(Dylan, 0x20) \ +X(CPlusPlus14, 0x21) \ +X(Fortran03, 0x22) \ +X(Fortran08, 0x23) \ +X(RenderScript, 0x24) \ +X(BLISS, 0x25) \ +X(MipsAssembler, 0x8001) \ +X(GoogleRenderScript, 0x8E57) \ +X(SunAssembler, 0x9001) \ +X(BorlandDelphi, 0xB000) typedef U32 DW_Language; typedef enum DW_LanguageEnum @@ -123,10 +123,10 @@ typedef enum DW_LanguageEnum } DW_LanguageEnum; #define DW_Inl_XList(X) \ - X(NotInlined, 0) \ - X(Inlined, 1) \ - X(DeclaredNotInlined, 2) \ - X(DeclaredInlined, 3) +X(NotInlined, 0) \ +X(Inlined, 1) \ +X(DeclaredNotInlined, 2) \ +X(DeclaredInlined, 3) typedef U32 DW_InlKind; typedef enum DW_InlKindEnum @@ -137,19 +137,19 @@ typedef enum DW_InlKindEnum } DW_InlKindEnum; #define DW_StdOpcode_XList(X) \ - X(ExtendedOpcode, 0x00) \ - X(Copy, 0x01) \ - X(AdvancePc, 0x02) \ - X(AdvanceLine, 0x03) \ - X(SetFile, 0x04) \ - X(SetColumn, 0x05) \ - X(NegateStmt, 0x06) \ - X(SetBasicBlock, 0x07) \ - X(ConstAddPc, 0x08) \ - X(FixedAdvancePc, 0x09) \ - X(SetPrologueEnd, 0x0A) \ - X(SetEpilogueBegin, 0x0B) \ - X(SetIsa, 0x0C) \ +X(ExtendedOpcode, 0x00) \ +X(Copy, 0x01) \ +X(AdvancePc, 0x02) \ +X(AdvanceLine, 0x03) \ +X(SetFile, 0x04) \ +X(SetColumn, 0x05) \ +X(NegateStmt, 0x06) \ +X(SetBasicBlock, 0x07) \ +X(ConstAddPc, 0x08) \ +X(FixedAdvancePc, 0x09) \ +X(SetPrologueEnd, 0x0A) \ +X(SetEpilogueBegin, 0x0B) \ +X(SetIsa, 0x0C) \ typedef enum DW_StdOpcode { @@ -159,13 +159,13 @@ typedef enum DW_StdOpcode } DW_StdOpcode; #define DW_ExtOpcode_XList(X) \ - X(Undefined, 0x00) \ - X(EndSequence, 0x01) \ - X(SetAddress, 0x02) \ - X(DefineFile, 0x03) \ - X(SetDiscriminator, 0x04) \ - X(UserLo, 0x80) \ - X(UserHi, 0xff) +X(Undefined, 0x00) \ +X(EndSequence, 0x01) \ +X(SetAddress, 0x02) \ +X(DefineFile, 0x03) \ +X(SetDiscriminator, 0x04) \ +X(UserLo, 0x80) \ +X(UserHi, 0xff) typedef enum DW_ExtOpcode { @@ -175,10 +175,10 @@ typedef enum DW_ExtOpcode } DW_ExtOpcode; #define DW_IDCaseKind_XList(X) \ - X(CaseSensitive, 0x00) \ - X(UpCase, 0x01) \ - X(DownCase, 0x02) \ - X(CaseInsensitive, 0x03) +X(CaseSensitive, 0x00) \ +X(UpCase, 0x01) \ +X(DownCase, 0x02) \ +X(CaseInsensitive, 0x03) typedef U64 DW_IDCaseKind; typedef enum DW_IDCaseKindEnum @@ -189,80 +189,80 @@ typedef enum DW_IDCaseKindEnum } DW_IDCaseKindEnum; #define DW_Tag_V3_XList(X) \ - X(ArrayType, 0x01) \ - X(ClassType, 0x02) \ - X(EntryPoint, 0x03) \ - X(EnumerationType, 0x04) \ - X(FormalParameter, 0x05) \ - X(ImportedDeclaration, 0x08) \ - X(Label, 0x0a) \ - X(LexicalBlock, 0x0b) \ - X(Member, 0x0d) \ - X(PointerType, 0x0f) \ - X(ReferenceType, 0x10) \ - X(CompileUnit, 0x11) \ - X(StringType, 0x12) \ - X(StructureType, 0x13) \ - X(SubroutineType, 0x15) \ - X(Typedef, 0x16) \ - X(UnionType, 0x17) \ - X(UnspecifiedParameters, 0x18) \ - X(Variant, 0x19) \ - X(CommonBlock, 0x1a) \ - X(CommonInclusion, 0x1b) \ - X(Inheritance, 0x1c) \ - X(InlinedSubroutine, 0x1d) \ - X(Module, 0x1e) \ - X(PtrToMemberType, 0x1f) \ - X(SetType, 0x20) \ - X(SubrangeType, 0x21) \ - X(WithStmt, 0x22) \ - X(AccessDeclaration, 0x23) \ - X(BaseType, 0x24) \ - X(CatchBlock, 0x25) \ - X(ConstType, 0x26) \ - X(Constant, 0x27) \ - X(Enumerator, 0x28) \ - X(FileType, 0x29) \ - X(Friend, 0x2a) \ - X(NameList, 0x2b) \ - X(NameListItem, 0x2c) \ - X(PackedType, 0x2d) \ - X(SubProgram, 0x2e) \ - X(TemplateTypeParameter, 0x2f) \ - X(TemplateValueParameter, 0x30) \ - X(ThrownType, 0x31) \ - X(TryBlock, 0x32) \ - X(VariantPart, 0x33) \ - X(Variable, 0x34) \ - X(VolatileType, 0x35) \ - X(DwarfProcedure, 0x36) \ - X(RestrictType, 0x37) \ - X(InterfaceType, 0x38) \ - X(Namespace, 0x39) \ - X(ImportedModule, 0x3a) \ - X(UnspecifiedType, 0x3b) \ - X(PartialUnit, 0x3c) \ - X(ImportedUnit, 0x3d) \ - X(Condition, 0x3f) \ - X(SharedType, 0x40) +X(ArrayType, 0x01) \ +X(ClassType, 0x02) \ +X(EntryPoint, 0x03) \ +X(EnumerationType, 0x04) \ +X(FormalParameter, 0x05) \ +X(ImportedDeclaration, 0x08) \ +X(Label, 0x0a) \ +X(LexicalBlock, 0x0b) \ +X(Member, 0x0d) \ +X(PointerType, 0x0f) \ +X(ReferenceType, 0x10) \ +X(CompileUnit, 0x11) \ +X(StringType, 0x12) \ +X(StructureType, 0x13) \ +X(SubroutineType, 0x15) \ +X(Typedef, 0x16) \ +X(UnionType, 0x17) \ +X(UnspecifiedParameters, 0x18) \ +X(Variant, 0x19) \ +X(CommonBlock, 0x1a) \ +X(CommonInclusion, 0x1b) \ +X(Inheritance, 0x1c) \ +X(InlinedSubroutine, 0x1d) \ +X(Module, 0x1e) \ +X(PtrToMemberType, 0x1f) \ +X(SetType, 0x20) \ +X(SubrangeType, 0x21) \ +X(WithStmt, 0x22) \ +X(AccessDeclaration, 0x23) \ +X(BaseType, 0x24) \ +X(CatchBlock, 0x25) \ +X(ConstType, 0x26) \ +X(Constant, 0x27) \ +X(Enumerator, 0x28) \ +X(FileType, 0x29) \ +X(Friend, 0x2a) \ +X(NameList, 0x2b) \ +X(NameListItem, 0x2c) \ +X(PackedType, 0x2d) \ +X(SubProgram, 0x2e) \ +X(TemplateTypeParameter, 0x2f) \ +X(TemplateValueParameter, 0x30) \ +X(ThrownType, 0x31) \ +X(TryBlock, 0x32) \ +X(VariantPart, 0x33) \ +X(Variable, 0x34) \ +X(VolatileType, 0x35) \ +X(DwarfProcedure, 0x36) \ +X(RestrictType, 0x37) \ +X(InterfaceType, 0x38) \ +X(Namespace, 0x39) \ +X(ImportedModule, 0x3a) \ +X(UnspecifiedType, 0x3b) \ +X(PartialUnit, 0x3c) \ +X(ImportedUnit, 0x3d) \ +X(Condition, 0x3f) \ +X(SharedType, 0x40) #define DW_Tag_V5_XList(X) \ - X(TypeUnit, 0x41) \ - X(RValueReferenceType, 0x42) \ - X(TemplateAlias, 0x43) \ - X(CoarrayType, 0x44) \ - X(GenericSubrange, 0x45) \ - X(DynamicType, 0x46) \ - X(AtomicType, 0x47) \ - X(CallSite, 0x48) \ - X(CallSiteParameter, 0x49) \ - X(SkeletonUnit, 0x4A) \ - X(ImmutableType, 0x4B) +X(TypeUnit, 0x41) \ +X(RValueReferenceType, 0x42) \ +X(TemplateAlias, 0x43) \ +X(CoarrayType, 0x44) \ +X(GenericSubrange, 0x45) \ +X(DynamicType, 0x46) \ +X(AtomicType, 0x47) \ +X(CallSite, 0x48) \ +X(CallSiteParameter, 0x49) \ +X(SkeletonUnit, 0x4A) \ +X(ImmutableType, 0x4B) #define DW_Tag_GNU_XList(X) \ - X(GNU_CallSite, 0x4109) \ - X(GNU_CallSiteParameter, 0x410a) +X(GNU_CallSite, 0x4109) \ +X(GNU_CallSiteParameter, 0x410a) typedef U64 DW_TagKind; typedef enum DW_TagKindEnum @@ -270,8 +270,8 @@ typedef enum DW_TagKindEnum DW_Tag_Null, #define X(_N,_ID) DW_Tag_##_N = _ID, DW_Tag_V3_XList(X) - DW_Tag_V5_XList(X) - DW_Tag_GNU_XList(X) + DW_Tag_V5_XList(X) + DW_Tag_GNU_XList(X) #undef X DW_Tag_UserLo = 0x4080, DW_Tag_UserHi = 0xffff @@ -280,202 +280,202 @@ typedef enum DW_TagKindEnum //- Attrib Class Encodings #define DW_AttribClass_V3_XList(X) \ - X(Null, 0) \ - X(Undefined, 1) \ - X(Address, 2) \ - X(Block, 3) \ - X(Const, 4) \ - X(ExprLoc, 5) \ - X(Flag, 6) \ - X(LinePtr, 7) \ - X(LocListPtr, 8) \ - X(MacPtr, 9) \ - X(RngListPtr, 10) \ - X(Reference, 11) \ - X(String, 12) +X(Null, 0) \ +X(Undefined, 1) \ +X(Address, 2) \ +X(Block, 3) \ +X(Const, 4) \ +X(ExprLoc, 5) \ +X(Flag, 6) \ +X(LinePtr, 7) \ +X(LocListPtr, 8) \ +X(MacPtr, 9) \ +X(RngListPtr, 10) \ +X(Reference, 11) \ +X(String, 12) #define DW_AttribClass_V4_XList(X) \ - X(LocList, 13) \ - X(RngList, 14) +X(LocList, 13) \ +X(RngList, 14) #define DW_AttribClass_V5_XList(X) \ - X(StrOffsetsPtr, 15) \ - X(AddrPtr, 16) +X(StrOffsetsPtr, 15) \ +X(AddrPtr, 16) typedef U32 DW_AttribClass; typedef enum DW_AttribClassEnum { #define X(_N,_ID) DW_AttribClass_##_N = (1 << _ID), DW_AttribClass_V3_XList(X) - DW_AttribClass_V4_XList(X) - DW_AttribClass_V5_XList(X) + DW_AttribClass_V4_XList(X) + DW_AttribClass_V5_XList(X) #undef X } DW_AttribClassEnum; //- Form Encodings #define DW_Form_V2_XList(X) \ - X(Addr, 0x1) \ - X(Block2, 0x3) \ - X(Block4, 0x4) \ - X(Data2, 0x5) \ - X(Data4, 0x6) \ - X(Data8, 0x7) \ - X(String, 0x8) \ - X(Block, 0x9) \ - X(Block1, 0xa) \ - X(Data1, 0xb) \ - X(Flag, 0xc) \ - X(SData, 0xd) \ - X(Strp, 0xe) \ - X(UData, 0xf) \ - X(RefAddr, 0x10) \ - X(Ref1, 0x11) \ - X(Ref2, 0x12) \ - X(Ref4, 0x13) \ - X(Ref8, 0x14) \ - X(RefUData, 0x15) \ - X(Indirect, 0x16) +X(Addr, 0x1) \ +X(Block2, 0x3) \ +X(Block4, 0x4) \ +X(Data2, 0x5) \ +X(Data4, 0x6) \ +X(Data8, 0x7) \ +X(String, 0x8) \ +X(Block, 0x9) \ +X(Block1, 0xa) \ +X(Data1, 0xb) \ +X(Flag, 0xc) \ +X(SData, 0xd) \ +X(Strp, 0xe) \ +X(UData, 0xf) \ +X(RefAddr, 0x10) \ +X(Ref1, 0x11) \ +X(Ref2, 0x12) \ +X(Ref4, 0x13) \ +X(Ref8, 0x14) \ +X(RefUData, 0x15) \ +X(Indirect, 0x16) #define DW_Form_AttribClass_V2_XList(X) \ - X(Addr, DW_AttribClass_Address) \ - X(Block2, DW_AttribClass_Block) \ - X(Block4, DW_AttribClass_Block) \ - X(Data2, DW_AttribClass_Const) \ - X(Data4, DW_AttribClass_Const) \ - X(Data8, DW_AttribClass_Const) \ - X(String, DW_AttribClass_String) \ - X(Block, DW_AttribClass_Block) \ - X(Block1, DW_AttribClass_Block) \ - X(Data1, DW_AttribClass_Const) \ - X(Flag, DW_AttribClass_Flag) \ - X(SData, DW_AttribClass_Const) \ - X(Strp, DW_AttribClass_String) \ - X(UData, DW_AttribClass_Const) \ - X(RefAddr, DW_AttribClass_Reference) \ - X(Ref1, DW_AttribClass_Reference) \ - X(Ref2, DW_AttribClass_Reference) \ - X(Ref4, DW_AttribClass_Reference) \ - X(Ref8, DW_AttribClass_Reference) \ - X(RefUData, DW_AttribClass_Reference) \ - X(Indirect, DW_AttribClass_Null) +X(Addr, DW_AttribClass_Address) \ +X(Block2, DW_AttribClass_Block) \ +X(Block4, DW_AttribClass_Block) \ +X(Data2, DW_AttribClass_Const) \ +X(Data4, DW_AttribClass_Const) \ +X(Data8, DW_AttribClass_Const) \ +X(String, DW_AttribClass_String) \ +X(Block, DW_AttribClass_Block) \ +X(Block1, DW_AttribClass_Block) \ +X(Data1, DW_AttribClass_Const) \ +X(Flag, DW_AttribClass_Flag) \ +X(SData, DW_AttribClass_Const) \ +X(Strp, DW_AttribClass_String) \ +X(UData, DW_AttribClass_Const) \ +X(RefAddr, DW_AttribClass_Reference) \ +X(Ref1, DW_AttribClass_Reference) \ +X(Ref2, DW_AttribClass_Reference) \ +X(Ref4, DW_AttribClass_Reference) \ +X(Ref8, DW_AttribClass_Reference) \ +X(RefUData, DW_AttribClass_Reference) \ +X(Indirect, DW_AttribClass_Null) #define DW_Form_V4_XList(X) \ - X(SecOffset, 0x17) \ - X(ExprLoc, 0x18) \ - X(FlagPresent, 0x19) \ - X(RefSig8, 0x20) +X(SecOffset, 0x17) \ +X(ExprLoc, 0x18) \ +X(FlagPresent, 0x19) \ +X(RefSig8, 0x20) #define DW_Form_AttribClass_V4_XList(X) \ - X(Addr, DW_AttribClass_Address) \ - X(Block2, DW_AttribClass_Block) \ - X(Block4, DW_AttribClass_Block) \ - X(Data2, DW_AttribClass_Const) \ - X(Data4, DW_AttribClass_Const) \ - X(Data8, DW_AttribClass_Const) \ - X(String, DW_AttribClass_String) \ - X(Block, DW_AttribClass_Block) \ - X(Block1, DW_AttribClass_Block) \ - X(Data1, DW_AttribClass_Const) \ - X(Flag, DW_AttribClass_Flag) \ - X(SData, DW_AttribClass_Const) \ - X(Strp, DW_AttribClass_String) \ - X(UData, DW_AttribClass_Const) \ - X(RefAddr, DW_AttribClass_Reference) \ - X(Ref1, DW_AttribClass_Reference) \ - X(Ref2, DW_AttribClass_Reference) \ - X(Ref4, DW_AttribClass_Reference) \ - X(Ref8, DW_AttribClass_Reference) \ - X(RefUData, DW_AttribClass_Reference) \ - X(Indirect, DW_AttribClass_Null) \ - X(SecOffset, DW_AttribClass_LinePtr|DW_AttribClass_LocListPtr|DW_AttribClass_MacPtr|DW_AttribClass_RngListPtr) \ - X(ExprLoc, DW_AttribClass_ExprLoc) \ - X(FlagPresent, DW_AttribClass_Flag) \ - X(RefSig8, DW_AttribClass_Reference) +X(Addr, DW_AttribClass_Address) \ +X(Block2, DW_AttribClass_Block) \ +X(Block4, DW_AttribClass_Block) \ +X(Data2, DW_AttribClass_Const) \ +X(Data4, DW_AttribClass_Const) \ +X(Data8, DW_AttribClass_Const) \ +X(String, DW_AttribClass_String) \ +X(Block, DW_AttribClass_Block) \ +X(Block1, DW_AttribClass_Block) \ +X(Data1, DW_AttribClass_Const) \ +X(Flag, DW_AttribClass_Flag) \ +X(SData, DW_AttribClass_Const) \ +X(Strp, DW_AttribClass_String) \ +X(UData, DW_AttribClass_Const) \ +X(RefAddr, DW_AttribClass_Reference) \ +X(Ref1, DW_AttribClass_Reference) \ +X(Ref2, DW_AttribClass_Reference) \ +X(Ref4, DW_AttribClass_Reference) \ +X(Ref8, DW_AttribClass_Reference) \ +X(RefUData, DW_AttribClass_Reference) \ +X(Indirect, DW_AttribClass_Null) \ +X(SecOffset, DW_AttribClass_LinePtr|DW_AttribClass_LocListPtr|DW_AttribClass_MacPtr|DW_AttribClass_RngListPtr) \ +X(ExprLoc, DW_AttribClass_ExprLoc) \ +X(FlagPresent, DW_AttribClass_Flag) \ +X(RefSig8, DW_AttribClass_Reference) #define DW_Form_V5_XList(X) \ - X(Strx, 0x1a) \ - X(Addrx, 0x1b) \ - X(RefSup4, 0x1c) \ - X(StrpSup, 0x1d) \ - X(Data16, 0x1e) \ - X(LineStrp, 0x1f) \ - X(ImplicitConst, 0x21) \ - X(LocListx, 0x22) \ - X(RngListx, 0x23) \ - X(RefSup8, 0x24) \ - X(Strx1, 0x25) \ - X(Strx2, 0x26) \ - X(Strx3, 0x27) \ - X(Strx4, 0x28) \ - X(Addrx1, 0x29) \ - X(Addrx2, 0x2a) \ - X(Addrx3, 0x2b) \ - X(Addrx4, 0x2c) +X(Strx, 0x1a) \ +X(Addrx, 0x1b) \ +X(RefSup4, 0x1c) \ +X(StrpSup, 0x1d) \ +X(Data16, 0x1e) \ +X(LineStrp, 0x1f) \ +X(ImplicitConst, 0x21) \ +X(LocListx, 0x22) \ +X(RngListx, 0x23) \ +X(RefSup8, 0x24) \ +X(Strx1, 0x25) \ +X(Strx2, 0x26) \ +X(Strx3, 0x27) \ +X(Strx4, 0x28) \ +X(Addrx1, 0x29) \ +X(Addrx2, 0x2a) \ +X(Addrx3, 0x2b) \ +X(Addrx4, 0x2c) #define DW_Form_AttribClass_V5_XList(X) \ - X(Addr, DW_AttribClass_Address) \ - X(Block2, DW_AttribClass_Block) \ - X(Block4, DW_AttribClass_Block) \ - X(Data2, DW_AttribClass_Const) \ - X(Data4, DW_AttribClass_Const) \ - X(Data8, DW_AttribClass_Const) \ - X(String, DW_AttribClass_String) \ - X(Block, DW_AttribClass_Block) \ - X(Block1, DW_AttribClass_Block) \ - X(Data1, DW_AttribClass_Const) \ - X(Flag, DW_AttribClass_Flag) \ - X(SData, DW_AttribClass_Const) \ - X(Strp, DW_AttribClass_String) \ - X(UData, DW_AttribClass_Const) \ - X(RefAddr, DW_AttribClass_Reference) \ - X(Ref1, DW_AttribClass_Reference) \ - X(Ref2, DW_AttribClass_Reference) \ - X(Ref4, DW_AttribClass_Reference) \ - X(Ref8, DW_AttribClass_Reference) \ - X(RefUData, DW_AttribClass_Reference) \ - X(Indirect, DW_AttribClass_Null) \ - X(SecOffset, DW_AttribClass_AddrPtr| \ - DW_AttribClass_LinePtr| \ - DW_AttribClass_LocList| \ - DW_AttribClass_LocListPtr| \ - DW_AttribClass_MacPtr| \ - DW_AttribClass_RngList| \ - DW_AttribClass_RngListPtr| \ - DW_AttribClass_StrOffsetsPtr) \ - X(ExprLoc, DW_AttribClass_ExprLoc) \ - X(FlagPresent, DW_AttribClass_Flag) \ - X(RefSig8, DW_AttribClass_Reference) \ - X(Strx, DW_AttribClass_String) \ - X(Addrx, DW_AttribClass_Address) \ - X(RefSup4, DW_AttribClass_Reference) \ - X(StrpSup, DW_AttribClass_String) \ - X(Data16, DW_AttribClass_Const) \ - X(LineStrp, DW_AttribClass_String) \ - X(ImplicitConst, DW_AttribClass_Const) \ - X(LocListx, DW_AttribClass_LocListPtr) \ - X(RngListx, DW_AttribClass_RngList) \ - X(RefSup8, DW_AttribClass_Reference) \ - X(Strx1, DW_AttribClass_String) \ - X(Strx2, DW_AttribClass_String) \ - X(Strx3, DW_AttribClass_String) \ - X(Strx4, DW_AttribClass_String) \ - X(Addrx1, DW_AttribClass_Address) \ - X(Addrx2, DW_AttribClass_Address) \ - X(Addrx3, DW_AttribClass_Address) \ - X(Addrx4, DW_AttribClass_Address) +X(Addr, DW_AttribClass_Address) \ +X(Block2, DW_AttribClass_Block) \ +X(Block4, DW_AttribClass_Block) \ +X(Data2, DW_AttribClass_Const) \ +X(Data4, DW_AttribClass_Const) \ +X(Data8, DW_AttribClass_Const) \ +X(String, DW_AttribClass_String) \ +X(Block, DW_AttribClass_Block) \ +X(Block1, DW_AttribClass_Block) \ +X(Data1, DW_AttribClass_Const) \ +X(Flag, DW_AttribClass_Flag) \ +X(SData, DW_AttribClass_Const) \ +X(Strp, DW_AttribClass_String) \ +X(UData, DW_AttribClass_Const) \ +X(RefAddr, DW_AttribClass_Reference) \ +X(Ref1, DW_AttribClass_Reference) \ +X(Ref2, DW_AttribClass_Reference) \ +X(Ref4, DW_AttribClass_Reference) \ +X(Ref8, DW_AttribClass_Reference) \ +X(RefUData, DW_AttribClass_Reference) \ +X(Indirect, DW_AttribClass_Null) \ +X(SecOffset, DW_AttribClass_AddrPtr| \ +DW_AttribClass_LinePtr| \ +DW_AttribClass_LocList| \ +DW_AttribClass_LocListPtr| \ +DW_AttribClass_MacPtr| \ +DW_AttribClass_RngList| \ +DW_AttribClass_RngListPtr| \ +DW_AttribClass_StrOffsetsPtr) \ +X(ExprLoc, DW_AttribClass_ExprLoc) \ +X(FlagPresent, DW_AttribClass_Flag) \ +X(RefSig8, DW_AttribClass_Reference) \ +X(Strx, DW_AttribClass_String) \ +X(Addrx, DW_AttribClass_Address) \ +X(RefSup4, DW_AttribClass_Reference) \ +X(StrpSup, DW_AttribClass_String) \ +X(Data16, DW_AttribClass_Const) \ +X(LineStrp, DW_AttribClass_String) \ +X(ImplicitConst, DW_AttribClass_Const) \ +X(LocListx, DW_AttribClass_LocListPtr) \ +X(RngListx, DW_AttribClass_RngList) \ +X(RefSup8, DW_AttribClass_Reference) \ +X(Strx1, DW_AttribClass_String) \ +X(Strx2, DW_AttribClass_String) \ +X(Strx3, DW_AttribClass_String) \ +X(Strx4, DW_AttribClass_String) \ +X(Addrx1, DW_AttribClass_Address) \ +X(Addrx2, DW_AttribClass_Address) \ +X(Addrx3, DW_AttribClass_Address) \ +X(Addrx4, DW_AttribClass_Address) #define DW_Form_GNU_XList(X) \ - X(GNU_AddrIndex, 0x1f01) \ - X(GNU_StrIndex, 0x1f02) \ - X(GNU_RefAlt, 0x1f20) \ - X(GNU_StrpAlt, 0x1f21) +X(GNU_AddrIndex, 0x1f01) \ +X(GNU_StrIndex, 0x1f02) \ +X(GNU_RefAlt, 0x1f20) \ +X(GNU_StrpAlt, 0x1f21) #define DW_Form_AttribClass_GNU_XList(X) \ - X(GNU_AddrIndex, DW_AttribClass_Undefined) \ - X(GNU_StrIndex, DW_AttribClass_Undefined) \ - X(GNU_RefAlt, DW_AttribClass_Undefined) \ - X(GNU_StrpAlt, DW_AttribClass_String) +X(GNU_AddrIndex, DW_AttribClass_Undefined) \ +X(GNU_StrIndex, DW_AttribClass_Undefined) \ +X(GNU_RefAlt, DW_AttribClass_Undefined) \ +X(GNU_StrpAlt, DW_AttribClass_String) typedef U64 DW_FormKind; typedef enum DW_FormEnum @@ -483,678 +483,678 @@ typedef enum DW_FormEnum DW_Form_Null, #define X(_N, _ID) DW_Form_##_N = _ID, DW_Form_V2_XList(X) - DW_Form_V4_XList(X) - DW_Form_V5_XList(X) - DW_Form_GNU_XList(X) + DW_Form_V4_XList(X) + DW_Form_V5_XList(X) + DW_Form_GNU_XList(X) #undef X } DW_FormEnum; //- Attributes DWARF2 #define DW_AttribKind_V2_XList(X) \ - X(Sibling, 0x1) \ - X(Location, 0x2) \ - X(Name, 0x3) \ - X(Ordering, 0x9) \ - X(ByteSize, 0xB) \ - X(BitOffset, 0xC) \ - X(BitSize, 0xD) \ - X(StmtList, 0x10) \ - X(LowPc, 0x11) \ - X(HighPc, 0x12) \ - X(Language, 0x13) \ - X(Discr, 0x15) \ - X(DiscrValue, 0x16) \ - X(Visibility, 0x17) \ - X(Import, 0x18) \ - X(StringLength, 0x19) \ - X(CommonReference, 0x1a) \ - X(CompDir, 0x1b) \ - X(ConstValue, 0x1c) \ - X(ContainingType, 0x1d) \ - X(DefaultValue, 0x1e) \ - X(Inline, 0x20) \ - X(IsOptional, 0x21) \ - X(LowerBound, 0x22) \ - X(Producer, 0x25) \ - X(Prototyped, 0x27) \ - X(ReturnAddr, 0x2a) \ - X(StartScope, 0x2c) \ - X(BitStride, 0x2e) \ - X(UpperBound, 0x2f) \ - X(AbstractOrigin, 0x31) \ - X(Accessibility, 0x32) \ - X(AddressClass, 0x33) \ - X(Artificial, 0x34) \ - X(BaseTypes, 0x35) \ - X(CallingConvention, 0x36) \ - X(Count, 0x37) \ - X(DataMemberLocation, 0x38) \ - X(DeclColumn, 0x39) \ - X(DeclFile, 0x3a) \ - X(DeclLine, 0x3b) \ - X(Declaration, 0x3c) \ - X(DiscrList, 0x3d) \ - X(Encoding, 0x3e) \ - X(External, 0x3f) \ - X(FrameBase, 0x40) \ - X(Friend, 0x41) \ - X(IdentifierCase, 0x42) \ - X(MacroInfo, 0x43) \ - X(NameListItem, 0x44) \ - X(Priority, 0x45) \ - X(Segment, 0x46) \ - X(Specification, 0x47) \ - X(StaticLink, 0x48) \ - X(Type, 0x49) \ - X(UseLocation, 0x4a) \ - X(VariableParameter, 0x4b) \ - X(Virtuality, 0x4c) \ - X(VTableElemLocation, 0x4d) +X(Sibling, 0x1) \ +X(Location, 0x2) \ +X(Name, 0x3) \ +X(Ordering, 0x9) \ +X(ByteSize, 0xB) \ +X(BitOffset, 0xC) \ +X(BitSize, 0xD) \ +X(StmtList, 0x10) \ +X(LowPc, 0x11) \ +X(HighPc, 0x12) \ +X(Language, 0x13) \ +X(Discr, 0x15) \ +X(DiscrValue, 0x16) \ +X(Visibility, 0x17) \ +X(Import, 0x18) \ +X(StringLength, 0x19) \ +X(CommonReference, 0x1a) \ +X(CompDir, 0x1b) \ +X(ConstValue, 0x1c) \ +X(ContainingType, 0x1d) \ +X(DefaultValue, 0x1e) \ +X(Inline, 0x20) \ +X(IsOptional, 0x21) \ +X(LowerBound, 0x22) \ +X(Producer, 0x25) \ +X(Prototyped, 0x27) \ +X(ReturnAddr, 0x2a) \ +X(StartScope, 0x2c) \ +X(BitStride, 0x2e) \ +X(UpperBound, 0x2f) \ +X(AbstractOrigin, 0x31) \ +X(Accessibility, 0x32) \ +X(AddressClass, 0x33) \ +X(Artificial, 0x34) \ +X(BaseTypes, 0x35) \ +X(CallingConvention, 0x36) \ +X(Count, 0x37) \ +X(DataMemberLocation, 0x38) \ +X(DeclColumn, 0x39) \ +X(DeclFile, 0x3a) \ +X(DeclLine, 0x3b) \ +X(Declaration, 0x3c) \ +X(DiscrList, 0x3d) \ +X(Encoding, 0x3e) \ +X(External, 0x3f) \ +X(FrameBase, 0x40) \ +X(Friend, 0x41) \ +X(IdentifierCase, 0x42) \ +X(MacroInfo, 0x43) \ +X(NameListItem, 0x44) \ +X(Priority, 0x45) \ +X(Segment, 0x46) \ +X(Specification, 0x47) \ +X(StaticLink, 0x48) \ +X(Type, 0x49) \ +X(UseLocation, 0x4a) \ +X(VariableParameter, 0x4b) \ +X(Virtuality, 0x4c) \ +X(VTableElemLocation, 0x4d) #define DW_AttribKind_ClassFlags_V2_XList(X) \ - X(Sibling, DW_AttribClass_Reference) \ - X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Name, DW_AttribClass_String) \ - X(Ordering, DW_AttribClass_Const) \ - X(ByteSize, DW_AttribClass_Const) \ - X(BitOffset, DW_AttribClass_Const) \ - X(BitSize, DW_AttribClass_Const) \ - X(StmtList, DW_AttribClass_Const) \ - X(LowPc, DW_AttribClass_Address) \ - X(HighPc, DW_AttribClass_Address) \ - X(Language, DW_AttribClass_Const) \ - X(Discr, DW_AttribClass_Reference) \ - X(DiscrValue, DW_AttribClass_Const) \ - X(Visibility, DW_AttribClass_Const) \ - X(Import, DW_AttribClass_Reference) \ - X(StringLength, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(CommonReference, DW_AttribClass_Reference) \ - X(CompDir, DW_AttribClass_String) \ - X(ConstValue, DW_AttribClass_String|DW_AttribClass_Const|DW_AttribClass_Block) \ - X(ContainingType, DW_AttribClass_Reference) \ - X(DefaultValue, DW_AttribClass_Reference) \ - X(Inline, DW_AttribClass_Const) \ - X(IsOptional, DW_AttribClass_Flag) \ - X(LowerBound, DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(Producer, DW_AttribClass_String) \ - X(Prototyped, DW_AttribClass_Flag) \ - X(ReturnAddr, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(StartScope, DW_AttribClass_Const) \ - X(BitStride, DW_AttribClass_Const) /* dwarf-v1 DW_Attrib_stride_size*/ \ - X(UpperBound, DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(AbstractOrigin, DW_AttribClass_Reference) \ - X(Accessibility, DW_AttribClass_Const) \ - X(AddressClass, DW_AttribClass_Const) \ - X(Artificial, DW_AttribClass_Flag) \ - X(BaseTypes, DW_AttribClass_Reference) \ - X(CallingConvention, DW_AttribClass_Const) \ - X(Count, DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(DataMemberLocation, DW_AttribClass_Block|DW_AttribClass_Reference) \ - X(DeclColumn, DW_AttribClass_Const) \ - X(DeclFile, DW_AttribClass_Const) \ - X(DeclLine, DW_AttribClass_Const) \ - X(Declaration, DW_AttribClass_Flag) \ - X(DiscrList, DW_AttribClass_Block) \ - X(Encoding, DW_AttribClass_Const) \ - X(External, DW_AttribClass_Flag) \ - X(FrameBase, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(Friend, DW_AttribClass_Reference) \ - X(IdentifierCase, DW_AttribClass_Const) \ - X(MacroInfo, DW_AttribClass_Const) \ - X(NameListItem, DW_AttribClass_Block) \ - X(Priority, DW_AttribClass_Reference) \ - X(Segment, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(Specification, DW_AttribClass_Reference) \ - X(StaticLink, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(Type, DW_AttribClass_Reference) \ - X(UseLocation, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(VariableParameter, DW_AttribClass_Flag) \ - X(Virtuality, DW_AttribClass_Const) \ - X(VTableElemLocation, DW_AttribClass_Block|DW_AttribClass_Reference) +X(Sibling, DW_AttribClass_Reference) \ +X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Name, DW_AttribClass_String) \ +X(Ordering, DW_AttribClass_Const) \ +X(ByteSize, DW_AttribClass_Const) \ +X(BitOffset, DW_AttribClass_Const) \ +X(BitSize, DW_AttribClass_Const) \ +X(StmtList, DW_AttribClass_Const) \ +X(LowPc, DW_AttribClass_Address) \ +X(HighPc, DW_AttribClass_Address) \ +X(Language, DW_AttribClass_Const) \ +X(Discr, DW_AttribClass_Reference) \ +X(DiscrValue, DW_AttribClass_Const) \ +X(Visibility, DW_AttribClass_Const) \ +X(Import, DW_AttribClass_Reference) \ +X(StringLength, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(CommonReference, DW_AttribClass_Reference) \ +X(CompDir, DW_AttribClass_String) \ +X(ConstValue, DW_AttribClass_String|DW_AttribClass_Const|DW_AttribClass_Block) \ +X(ContainingType, DW_AttribClass_Reference) \ +X(DefaultValue, DW_AttribClass_Reference) \ +X(Inline, DW_AttribClass_Const) \ +X(IsOptional, DW_AttribClass_Flag) \ +X(LowerBound, DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(Producer, DW_AttribClass_String) \ +X(Prototyped, DW_AttribClass_Flag) \ +X(ReturnAddr, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(StartScope, DW_AttribClass_Const) \ +X(BitStride, DW_AttribClass_Const) /* dwarf-v1 DW_Attrib_stride_size*/ \ +X(UpperBound, DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(AbstractOrigin, DW_AttribClass_Reference) \ +X(Accessibility, DW_AttribClass_Const) \ +X(AddressClass, DW_AttribClass_Const) \ +X(Artificial, DW_AttribClass_Flag) \ +X(BaseTypes, DW_AttribClass_Reference) \ +X(CallingConvention, DW_AttribClass_Const) \ +X(Count, DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(DataMemberLocation, DW_AttribClass_Block|DW_AttribClass_Reference) \ +X(DeclColumn, DW_AttribClass_Const) \ +X(DeclFile, DW_AttribClass_Const) \ +X(DeclLine, DW_AttribClass_Const) \ +X(Declaration, DW_AttribClass_Flag) \ +X(DiscrList, DW_AttribClass_Block) \ +X(Encoding, DW_AttribClass_Const) \ +X(External, DW_AttribClass_Flag) \ +X(FrameBase, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(Friend, DW_AttribClass_Reference) \ +X(IdentifierCase, DW_AttribClass_Const) \ +X(MacroInfo, DW_AttribClass_Const) \ +X(NameListItem, DW_AttribClass_Block) \ +X(Priority, DW_AttribClass_Reference) \ +X(Segment, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(Specification, DW_AttribClass_Reference) \ +X(StaticLink, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(Type, DW_AttribClass_Reference) \ +X(UseLocation, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(VariableParameter, DW_AttribClass_Flag) \ +X(Virtuality, DW_AttribClass_Const) \ +X(VTableElemLocation, DW_AttribClass_Block|DW_AttribClass_Reference) //- Attributes DWARF3 #define DW_AttribKind_V3_XList(X) \ - X(Allocated, 0x4e) \ - X(Associated, 0x4f) \ - X(DataLocation, 0x50) \ - X(ByteStride, 0x51) \ - X(EntryPc, 0x52) \ - X(UseUtf8, 0x53) \ - X(Extension, 0x54) \ - X(Ranges, 0x55) \ - X(Trampoline, 0x56) \ - X(CallColumn, 0x57) \ - X(CallFile, 0x58) \ - X(CallLine, 0x59) \ - X(Description, 0x5a) \ - X(BinaryScale, 0x5b) \ - X(DecimalScale, 0x5c) \ - X(Small, 0x5d) \ - X(DecimalSign, 0x5e) \ - X(DigitCount, 0x5f) \ - X(PictureString, 0x60) \ - X(Mutable, 0x61) \ - X(ThreadsScaled, 0x62) \ - X(Explicit, 0x63) \ - X(ObjectPointer, 0x64) \ - X(Endianity, 0x65) \ - X(Elemental, 0x66) \ - X(Pure, 0x67) \ - X(Recursive, 0x68) +X(Allocated, 0x4e) \ +X(Associated, 0x4f) \ +X(DataLocation, 0x50) \ +X(ByteStride, 0x51) \ +X(EntryPc, 0x52) \ +X(UseUtf8, 0x53) \ +X(Extension, 0x54) \ +X(Ranges, 0x55) \ +X(Trampoline, 0x56) \ +X(CallColumn, 0x57) \ +X(CallFile, 0x58) \ +X(CallLine, 0x59) \ +X(Description, 0x5a) \ +X(BinaryScale, 0x5b) \ +X(DecimalScale, 0x5c) \ +X(Small, 0x5d) \ +X(DecimalSign, 0x5e) \ +X(DigitCount, 0x5f) \ +X(PictureString, 0x60) \ +X(Mutable, 0x61) \ +X(ThreadsScaled, 0x62) \ +X(Explicit, 0x63) \ +X(ObjectPointer, 0x64) \ +X(Endianity, 0x65) \ +X(Elemental, 0x66) \ +X(Pure, 0x67) \ +X(Recursive, 0x68) #define DW_AttribKind_ClassFlags_V3_XList(X) \ - X(Sibling, DW_AttribClass_Reference) \ - X(Location, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Name, DW_AttribClass_String) \ - X(Ordering, DW_AttribClass_Const) \ - X(ByteSize, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(BitOffset, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(BitSize, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(StmtList, DW_AttribClass_LinePtr) \ - X(LowPc, DW_AttribClass_Address) \ - X(HighPc, DW_AttribClass_Address) \ - X(Language, DW_AttribClass_Const) \ - X(Discr, DW_AttribClass_Reference) \ - X(DiscrValue, DW_AttribClass_Const) \ - X(Visibility, DW_AttribClass_Const) \ - X(Import, DW_AttribClass_Reference) \ - X(StringLength, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(CommonReference, DW_AttribClass_Reference) \ - X(CompDir, DW_AttribClass_String) \ - X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ - X(ContainingType, DW_AttribClass_Reference) \ - X(DefaultValue, DW_AttribClass_Reference) \ - X(Inline, DW_AttribClass_Const) \ - X(IsOptional, DW_AttribClass_Flag) \ - X(LowerBound, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(Producer, DW_AttribClass_String) \ - X(Prototyped, DW_AttribClass_Flag) \ - X(ReturnAddr, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(StartScope, DW_AttribClass_Const) \ - X(BitStride, DW_AttribClass_Const) \ - X(UpperBound, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(AbstractOrigin, DW_AttribClass_Reference) \ - X(Accessibility, DW_AttribClass_Const) \ - X(AddressClass, DW_AttribClass_Const) \ - X(Artificial, DW_AttribClass_Flag) \ - X(BaseTypes, DW_AttribClass_Reference) \ - X(CallingConvention, DW_AttribClass_Const) \ - X(Count, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(DataMemberLocation, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_LocListPtr) \ - X(DeclColumn, DW_AttribClass_Const) \ - X(DeclFile, DW_AttribClass_Const) \ - X(DeclLine, DW_AttribClass_Const) \ - X(Declaration, DW_AttribClass_Flag) \ - X(DiscrList, DW_AttribClass_Block) \ - X(Encoding, DW_AttribClass_Const) \ - X(External, DW_AttribClass_Flag) \ - X(FrameBase, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Friend, DW_AttribClass_Reference) \ - X(IdentifierCase, DW_AttribClass_Const) \ - X(MacroInfo, DW_AttribClass_MacPtr) \ - X(NameListItem, DW_AttribClass_Block) \ - X(Priority, DW_AttribClass_Reference) \ - X(Segment, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Specification, DW_AttribClass_Reference) \ - X(StaticLink, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Type, DW_AttribClass_Reference) \ - X(UseLocation, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(VariableParameter, DW_AttribClass_Flag) \ - X(Virtuality, DW_AttribClass_Const) \ - X(VTableElemLocation, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Allocated, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(Associated, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(DataLocation, DW_AttribClass_Block) \ - X(ByteStride, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(EntryPc, DW_AttribClass_Address) \ - X(UseUtf8, DW_AttribClass_Flag) \ - X(Extension, DW_AttribClass_Reference) \ - X(Ranges, DW_AttribClass_RngListPtr) \ - X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ - X(CallColumn, DW_AttribClass_Const) \ - X(CallFile, DW_AttribClass_Const) \ - X(CallLine, DW_AttribClass_Const) \ - X(Description, DW_AttribClass_String) \ - X(BinaryScale, DW_AttribClass_Const) \ - X(DecimalScale, DW_AttribClass_Const) \ - X(Small, DW_AttribClass_Reference) \ - X(DecimalSign, DW_AttribClass_Const) \ - X(DigitCount, DW_AttribClass_Const) \ - X(PictureString, DW_AttribClass_String) \ - X(Mutable, DW_AttribClass_Flag) \ - X(ThreadsScaled, DW_AttribClass_Flag) \ - X(Explicit, DW_AttribClass_Flag) \ - X(ObjectPointer, DW_AttribClass_Reference) \ - X(Endianity, DW_AttribClass_Const) \ - X(Elemental, DW_AttribClass_Flag) \ - X(Pure, DW_AttribClass_Flag) \ - X(Recursive, DW_AttribClass_Flag) +X(Sibling, DW_AttribClass_Reference) \ +X(Location, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Name, DW_AttribClass_String) \ +X(Ordering, DW_AttribClass_Const) \ +X(ByteSize, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(BitOffset, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(BitSize, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(StmtList, DW_AttribClass_LinePtr) \ +X(LowPc, DW_AttribClass_Address) \ +X(HighPc, DW_AttribClass_Address) \ +X(Language, DW_AttribClass_Const) \ +X(Discr, DW_AttribClass_Reference) \ +X(DiscrValue, DW_AttribClass_Const) \ +X(Visibility, DW_AttribClass_Const) \ +X(Import, DW_AttribClass_Reference) \ +X(StringLength, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(CommonReference, DW_AttribClass_Reference) \ +X(CompDir, DW_AttribClass_String) \ +X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ +X(ContainingType, DW_AttribClass_Reference) \ +X(DefaultValue, DW_AttribClass_Reference) \ +X(Inline, DW_AttribClass_Const) \ +X(IsOptional, DW_AttribClass_Flag) \ +X(LowerBound, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(Producer, DW_AttribClass_String) \ +X(Prototyped, DW_AttribClass_Flag) \ +X(ReturnAddr, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(StartScope, DW_AttribClass_Const) \ +X(BitStride, DW_AttribClass_Const) \ +X(UpperBound, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(AbstractOrigin, DW_AttribClass_Reference) \ +X(Accessibility, DW_AttribClass_Const) \ +X(AddressClass, DW_AttribClass_Const) \ +X(Artificial, DW_AttribClass_Flag) \ +X(BaseTypes, DW_AttribClass_Reference) \ +X(CallingConvention, DW_AttribClass_Const) \ +X(Count, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(DataMemberLocation, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_LocListPtr) \ +X(DeclColumn, DW_AttribClass_Const) \ +X(DeclFile, DW_AttribClass_Const) \ +X(DeclLine, DW_AttribClass_Const) \ +X(Declaration, DW_AttribClass_Flag) \ +X(DiscrList, DW_AttribClass_Block) \ +X(Encoding, DW_AttribClass_Const) \ +X(External, DW_AttribClass_Flag) \ +X(FrameBase, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Friend, DW_AttribClass_Reference) \ +X(IdentifierCase, DW_AttribClass_Const) \ +X(MacroInfo, DW_AttribClass_MacPtr) \ +X(NameListItem, DW_AttribClass_Block) \ +X(Priority, DW_AttribClass_Reference) \ +X(Segment, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Specification, DW_AttribClass_Reference) \ +X(StaticLink, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Type, DW_AttribClass_Reference) \ +X(UseLocation, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(VariableParameter, DW_AttribClass_Flag) \ +X(Virtuality, DW_AttribClass_Const) \ +X(VTableElemLocation, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Allocated, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(Associated, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(DataLocation, DW_AttribClass_Block) \ +X(ByteStride, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(EntryPc, DW_AttribClass_Address) \ +X(UseUtf8, DW_AttribClass_Flag) \ +X(Extension, DW_AttribClass_Reference) \ +X(Ranges, DW_AttribClass_RngListPtr) \ +X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ +X(CallColumn, DW_AttribClass_Const) \ +X(CallFile, DW_AttribClass_Const) \ +X(CallLine, DW_AttribClass_Const) \ +X(Description, DW_AttribClass_String) \ +X(BinaryScale, DW_AttribClass_Const) \ +X(DecimalScale, DW_AttribClass_Const) \ +X(Small, DW_AttribClass_Reference) \ +X(DecimalSign, DW_AttribClass_Const) \ +X(DigitCount, DW_AttribClass_Const) \ +X(PictureString, DW_AttribClass_String) \ +X(Mutable, DW_AttribClass_Flag) \ +X(ThreadsScaled, DW_AttribClass_Flag) \ +X(Explicit, DW_AttribClass_Flag) \ +X(ObjectPointer, DW_AttribClass_Reference) \ +X(Endianity, DW_AttribClass_Const) \ +X(Elemental, DW_AttribClass_Flag) \ +X(Pure, DW_AttribClass_Flag) \ +X(Recursive, DW_AttribClass_Flag) //- Attributes DWARF4 #define DW_AttribKind_V4_XList(X) \ - X(Signature, 0x69) \ - X(MainSubProgram, 0x6a) \ - X(DataBitOffset, 0x6b) \ - X(ConstExpr, 0x6c) \ - X(EnumClass, 0x6d) \ - X(LinkageName, 0x6e) +X(Signature, 0x69) \ +X(MainSubProgram, 0x6a) \ +X(DataBitOffset, 0x6b) \ +X(ConstExpr, 0x6c) \ +X(EnumClass, 0x6d) \ +X(LinkageName, 0x6e) #define DW_AttribKind_ClassFlags_V4_XList(X) \ - X(Sibling, DW_AttribClass_Reference) \ - X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Name, DW_AttribClass_String) \ - X(Ordering, DW_AttribClass_Const) \ - X(ByteSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(BitOffset, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(BitSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(StmtList, DW_AttribClass_LinePtr) \ - X(LowPc, DW_AttribClass_Address) \ - X(HighPc, DW_AttribClass_Address|DW_AttribClass_Const) \ - X(Language, DW_AttribClass_Const) \ - X(Discr, DW_AttribClass_Reference) \ - X(DiscrValue, DW_AttribClass_Const) \ - X(Visibility, DW_AttribClass_Const) \ - X(Import, DW_AttribClass_Reference) \ - X(StringLength, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(CommonReference, DW_AttribClass_Reference) \ - X(CompDir, DW_AttribClass_String) \ - X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ - X(ContainingType, DW_AttribClass_Reference) \ - X(DefaultValue, DW_AttribClass_Reference) \ - X(Inline, DW_AttribClass_Const) \ - X(IsOptional, DW_AttribClass_Flag) \ - X(LowerBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(Producer, DW_AttribClass_String) \ - X(Prototyped, DW_AttribClass_Flag) \ - X(ReturnAddr, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(StartScope, DW_AttribClass_Const|DW_AttribClass_RngListPtr) \ - X(BitStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(UpperBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(AbstractOrigin, DW_AttribClass_Reference) \ - X(Accessibility, DW_AttribClass_Const) \ - X(AddressClass, DW_AttribClass_Const) \ - X(Artificial, DW_AttribClass_Flag) \ - X(BaseTypes, DW_AttribClass_Reference) \ - X(CallingConvention, DW_AttribClass_Const) \ - X(Count, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(DataMemberLocation, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(DeclColumn, DW_AttribClass_Const) \ - X(DeclFile, DW_AttribClass_Const) \ - X(DeclLine, DW_AttribClass_Const) \ - X(Declaration, DW_AttribClass_Flag) \ - X(DiscrList, DW_AttribClass_Block) \ - X(Encoding, DW_AttribClass_Const) \ - X(External, DW_AttribClass_Flag) \ - X(FrameBase, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Friend, DW_AttribClass_Reference) \ - X(IdentifierCase, DW_AttribClass_Const) \ - X(MacroInfo, DW_AttribClass_MacPtr) \ - X(NameListItem, DW_AttribClass_Reference) \ - X(Priority, DW_AttribClass_Reference) \ - X(Segment, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Specification, DW_AttribClass_Reference) \ - X(StaticLink, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Type, DW_AttribClass_Reference) \ - X(UseLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(VariableParameter, DW_AttribClass_Flag) \ - X(Virtuality, DW_AttribClass_Const) \ - X(VTableElemLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Allocated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(Associated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(DataLocation, DW_AttribClass_ExprLoc) \ - X(ByteStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(EntryPc, DW_AttribClass_Address) \ - X(UseUtf8, DW_AttribClass_Flag) \ - X(Extension, DW_AttribClass_Reference) \ - X(Ranges, DW_AttribClass_RngListPtr) \ - X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ - X(CallColumn, DW_AttribClass_Const) \ - X(CallFile, DW_AttribClass_Const) \ - X(CallLine, DW_AttribClass_Const) \ - X(Description, DW_AttribClass_String) \ - X(BinaryScale, DW_AttribClass_Const) \ - X(DecimalScale, DW_AttribClass_Const) \ - X(Small, DW_AttribClass_Reference) \ - X(DecimalSign, DW_AttribClass_Const) \ - X(DigitCount, DW_AttribClass_Const) \ - X(PictureString, DW_AttribClass_String) \ - X(Mutable, DW_AttribClass_Flag) \ - X(ThreadsScaled, DW_AttribClass_Flag) \ - X(Explicit, DW_AttribClass_Flag) \ - X(ObjectPointer, DW_AttribClass_Reference) \ - X(Endianity, DW_AttribClass_Const) \ - X(Elemental, DW_AttribClass_Flag) \ - X(Pure, DW_AttribClass_Flag) \ - X(Recursive, DW_AttribClass_Flag) \ - X(Signature, DW_AttribClass_Reference) \ - X(MainSubProgram, DW_AttribClass_Flag) \ - X(DataBitOffset, DW_AttribClass_Const) \ - X(ConstExpr, DW_AttribClass_Flag) \ - X(EnumClass, DW_AttribClass_Flag) \ - X(LinkageName, DW_AttribClass_String) +X(Sibling, DW_AttribClass_Reference) \ +X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Name, DW_AttribClass_String) \ +X(Ordering, DW_AttribClass_Const) \ +X(ByteSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(BitOffset, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(BitSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(StmtList, DW_AttribClass_LinePtr) \ +X(LowPc, DW_AttribClass_Address) \ +X(HighPc, DW_AttribClass_Address|DW_AttribClass_Const) \ +X(Language, DW_AttribClass_Const) \ +X(Discr, DW_AttribClass_Reference) \ +X(DiscrValue, DW_AttribClass_Const) \ +X(Visibility, DW_AttribClass_Const) \ +X(Import, DW_AttribClass_Reference) \ +X(StringLength, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(CommonReference, DW_AttribClass_Reference) \ +X(CompDir, DW_AttribClass_String) \ +X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ +X(ContainingType, DW_AttribClass_Reference) \ +X(DefaultValue, DW_AttribClass_Reference) \ +X(Inline, DW_AttribClass_Const) \ +X(IsOptional, DW_AttribClass_Flag) \ +X(LowerBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(Producer, DW_AttribClass_String) \ +X(Prototyped, DW_AttribClass_Flag) \ +X(ReturnAddr, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(StartScope, DW_AttribClass_Const|DW_AttribClass_RngListPtr) \ +X(BitStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(UpperBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(AbstractOrigin, DW_AttribClass_Reference) \ +X(Accessibility, DW_AttribClass_Const) \ +X(AddressClass, DW_AttribClass_Const) \ +X(Artificial, DW_AttribClass_Flag) \ +X(BaseTypes, DW_AttribClass_Reference) \ +X(CallingConvention, DW_AttribClass_Const) \ +X(Count, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(DataMemberLocation, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(DeclColumn, DW_AttribClass_Const) \ +X(DeclFile, DW_AttribClass_Const) \ +X(DeclLine, DW_AttribClass_Const) \ +X(Declaration, DW_AttribClass_Flag) \ +X(DiscrList, DW_AttribClass_Block) \ +X(Encoding, DW_AttribClass_Const) \ +X(External, DW_AttribClass_Flag) \ +X(FrameBase, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Friend, DW_AttribClass_Reference) \ +X(IdentifierCase, DW_AttribClass_Const) \ +X(MacroInfo, DW_AttribClass_MacPtr) \ +X(NameListItem, DW_AttribClass_Reference) \ +X(Priority, DW_AttribClass_Reference) \ +X(Segment, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Specification, DW_AttribClass_Reference) \ +X(StaticLink, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Type, DW_AttribClass_Reference) \ +X(UseLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(VariableParameter, DW_AttribClass_Flag) \ +X(Virtuality, DW_AttribClass_Const) \ +X(VTableElemLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Allocated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(Associated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(DataLocation, DW_AttribClass_ExprLoc) \ +X(ByteStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(EntryPc, DW_AttribClass_Address) \ +X(UseUtf8, DW_AttribClass_Flag) \ +X(Extension, DW_AttribClass_Reference) \ +X(Ranges, DW_AttribClass_RngListPtr) \ +X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ +X(CallColumn, DW_AttribClass_Const) \ +X(CallFile, DW_AttribClass_Const) \ +X(CallLine, DW_AttribClass_Const) \ +X(Description, DW_AttribClass_String) \ +X(BinaryScale, DW_AttribClass_Const) \ +X(DecimalScale, DW_AttribClass_Const) \ +X(Small, DW_AttribClass_Reference) \ +X(DecimalSign, DW_AttribClass_Const) \ +X(DigitCount, DW_AttribClass_Const) \ +X(PictureString, DW_AttribClass_String) \ +X(Mutable, DW_AttribClass_Flag) \ +X(ThreadsScaled, DW_AttribClass_Flag) \ +X(Explicit, DW_AttribClass_Flag) \ +X(ObjectPointer, DW_AttribClass_Reference) \ +X(Endianity, DW_AttribClass_Const) \ +X(Elemental, DW_AttribClass_Flag) \ +X(Pure, DW_AttribClass_Flag) \ +X(Recursive, DW_AttribClass_Flag) \ +X(Signature, DW_AttribClass_Reference) \ +X(MainSubProgram, DW_AttribClass_Flag) \ +X(DataBitOffset, DW_AttribClass_Const) \ +X(ConstExpr, DW_AttribClass_Flag) \ +X(EnumClass, DW_AttribClass_Flag) \ +X(LinkageName, DW_AttribClass_String) //- Attributes DWARF5 #define DW_AttribKind_V5_XList(X) \ - X(StringLengthBitSize, 0x6f) \ - X(StringLengthByteSize, 0x70) \ - X(Rank, 0x71) \ - X(StrOffsetsBase, 0x72) \ - X(AddrBase, 0x73) \ - X(RngListsBase, 0x74) \ - X(DwoName, 0x76) \ - X(Reference, 0x77) \ - X(RValueReference, 0x78) \ - X(Macros, 0x79) \ - X(CallAllCalls, 0x7a) \ - X(CallAllSourceCalls, 0x7b) \ - X(CallAllTailCalls, 0x7c) \ - X(CallReturnPc, 0x7d) \ - X(CallValue, 0x7e) \ - X(CallOrigin, 0x7f) \ - X(CallParameter, 0x80) \ - X(CallPc, 0x81) \ - X(CallTailCall, 0x82) \ - X(CallTarget, 0x83) \ - X(CallTargetClobbered, 0x84) \ - X(CallDataLocation, 0x85) \ - X(CallDataValue, 0x86) \ - X(NoReturn, 0x87) \ - X(Alignment, 0x88) \ - X(ExportSymbols, 0x89) \ - X(Deleted, 0x8a) \ - X(Defaulted, 0x8b) \ - X(LocListsBase, 0x8c) +X(StringLengthBitSize, 0x6f) \ +X(StringLengthByteSize, 0x70) \ +X(Rank, 0x71) \ +X(StrOffsetsBase, 0x72) \ +X(AddrBase, 0x73) \ +X(RngListsBase, 0x74) \ +X(DwoName, 0x76) \ +X(Reference, 0x77) \ +X(RValueReference, 0x78) \ +X(Macros, 0x79) \ +X(CallAllCalls, 0x7a) \ +X(CallAllSourceCalls, 0x7b) \ +X(CallAllTailCalls, 0x7c) \ +X(CallReturnPc, 0x7d) \ +X(CallValue, 0x7e) \ +X(CallOrigin, 0x7f) \ +X(CallParameter, 0x80) \ +X(CallPc, 0x81) \ +X(CallTailCall, 0x82) \ +X(CallTarget, 0x83) \ +X(CallTargetClobbered, 0x84) \ +X(CallDataLocation, 0x85) \ +X(CallDataValue, 0x86) \ +X(NoReturn, 0x87) \ +X(Alignment, 0x88) \ +X(ExportSymbols, 0x89) \ +X(Deleted, 0x8a) \ +X(Defaulted, 0x8b) \ +X(LocListsBase, 0x8c) #define DW_AttribKind_ClassFlags_V5_XList(X) \ - X(Sibling, DW_AttribClass_Reference) \ - X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Name, DW_AttribClass_String) \ - X(Ordering, DW_AttribClass_Const) \ - X(ByteSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(BitOffset, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(BitSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(StmtList, DW_AttribClass_LinePtr) \ - X(LowPc, DW_AttribClass_Address) \ - X(HighPc, DW_AttribClass_Address|DW_AttribClass_Const) \ - X(Language, DW_AttribClass_Const) \ - X(Discr, DW_AttribClass_Reference) \ - X(DiscrValue, DW_AttribClass_Const) \ - X(Visibility, DW_AttribClass_Const) \ - X(Import, DW_AttribClass_Reference) \ - X(StringLength, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(CommonReference, DW_AttribClass_Reference) \ - X(CompDir, DW_AttribClass_String) \ - X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ - X(ContainingType, DW_AttribClass_Reference) \ - X(DefaultValue, DW_AttribClass_Reference) \ - X(Inline, DW_AttribClass_Const) \ - X(IsOptional, DW_AttribClass_Flag) \ - X(LowerBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(Producer, DW_AttribClass_String) \ - X(Prototyped, DW_AttribClass_Flag) \ - X(ReturnAddr, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(StartScope, DW_AttribClass_Const|DW_AttribClass_RngListPtr) \ - X(BitStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(UpperBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(AbstractOrigin, DW_AttribClass_Reference) \ - X(Accessibility, DW_AttribClass_Const) \ - X(AddressClass, DW_AttribClass_Const) \ - X(Artificial, DW_AttribClass_Flag) \ - X(BaseTypes, DW_AttribClass_Reference) \ - X(CallingConvention, DW_AttribClass_Const) \ - X(Count, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(DataMemberLocation, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(DeclColumn, DW_AttribClass_Const) \ - X(DeclFile, DW_AttribClass_Const) \ - X(DeclLine, DW_AttribClass_Const) \ - X(Declaration, DW_AttribClass_Flag) \ - X(DiscrList, DW_AttribClass_Block) \ - X(Encoding, DW_AttribClass_Const) \ - X(External, DW_AttribClass_Flag) \ - X(FrameBase, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(Friend, DW_AttribClass_Reference) \ - X(IdentifierCase, DW_AttribClass_Const) \ - X(MacroInfo, DW_AttribClass_MacPtr) \ - X(NameListItem, DW_AttribClass_Reference) \ - X(Priority, DW_AttribClass_Reference) \ - X(Segment, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(Specification, DW_AttribClass_Reference) \ - X(StaticLink, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(Type, DW_AttribClass_Reference) \ - X(UseLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(VariableParameter, DW_AttribClass_Flag) \ - X(Virtuality, DW_AttribClass_Const) \ - X(VTableElemLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(Allocated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(Associated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(DataLocation, DW_AttribClass_ExprLoc) \ - X(ByteStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(EntryPc, DW_AttribClass_Address|DW_AttribClass_Const) \ - X(UseUtf8, DW_AttribClass_Flag) \ - X(Extension, DW_AttribClass_Reference) \ - X(Ranges, DW_AttribClass_RngList) \ - X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ - X(CallColumn, DW_AttribClass_Const) \ - X(CallFile, DW_AttribClass_Const) \ - X(CallLine, DW_AttribClass_Const) \ - X(Description, DW_AttribClass_String) \ - X(BinaryScale, DW_AttribClass_Const) \ - X(DecimalScale, DW_AttribClass_Const) \ - X(Small, DW_AttribClass_Reference) \ - X(DecimalSign, DW_AttribClass_Const) \ - X(DigitCount, DW_AttribClass_Const) \ - X(PictureString, DW_AttribClass_String) \ - X(Mutable, DW_AttribClass_Flag) \ - X(ThreadsScaled, DW_AttribClass_Flag) \ - X(Explicit, DW_AttribClass_Flag) \ - X(ObjectPointer, DW_AttribClass_Reference) \ - X(Endianity, DW_AttribClass_Const) \ - X(Elemental, DW_AttribClass_Flag) \ - X(Pure, DW_AttribClass_Flag) \ - X(Recursive, DW_AttribClass_Flag) \ - X(Signature, DW_AttribClass_Reference) \ - X(MainSubProgram, DW_AttribClass_Flag) \ - X(DataBitOffset, DW_AttribClass_Const) \ - X(ConstExpr, DW_AttribClass_Flag) \ - X(EnumClass, DW_AttribClass_Flag) \ - X(LinkageName, DW_AttribClass_String) \ - X(StringLengthBitSize, DW_AttribClass_Const) \ - X(StringLengthByteSize, DW_AttribClass_Const) \ - X(Rank, DW_AttribClass_Const|DW_AttribClass_ExprLoc) \ - X(StrOffsetsBase, DW_AttribClass_StrOffsetsPtr) \ - X(AddrBase, DW_AttribClass_AddrPtr) \ - X(RngListsBase, DW_AttribClass_RngListPtr) \ - X(DwoName, DW_AttribClass_String) \ - X(Reference, DW_AttribClass_Flag) \ - X(RValueReference, DW_AttribClass_Flag) \ - X(Macros, DW_AttribClass_MacPtr) \ - X(CallAllCalls, DW_AttribClass_Flag) \ - X(CallAllSourceCalls, DW_AttribClass_Flag) \ - X(CallAllTailCalls, DW_AttribClass_Flag) \ - X(CallReturnPc, DW_AttribClass_Address) \ - X(CallValue, DW_AttribClass_ExprLoc) \ - X(CallOrigin, DW_AttribClass_ExprLoc) \ - X(CallParameter, DW_AttribClass_Reference) \ - X(CallPc, DW_AttribClass_Address) \ - X(CallTailCall, DW_AttribClass_Flag) \ - X(CallTarget, DW_AttribClass_ExprLoc) \ - X(CallTargetClobbered, DW_AttribClass_ExprLoc) \ - X(CallDataLocation, DW_AttribClass_ExprLoc) \ - X(CallDataValue, DW_AttribClass_ExprLoc) \ - X(NoReturn, DW_AttribClass_Flag) \ - X(Alignment, DW_AttribClass_Const) \ - X(ExportSymbols, DW_AttribClass_Flag) \ - X(Deleted, DW_AttribClass_Flag) \ - X(Defaulted, DW_AttribClass_Const) \ - X(LocListsBase, DW_AttribClass_LocListPtr) +X(Sibling, DW_AttribClass_Reference) \ +X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Name, DW_AttribClass_String) \ +X(Ordering, DW_AttribClass_Const) \ +X(ByteSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(BitOffset, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(BitSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(StmtList, DW_AttribClass_LinePtr) \ +X(LowPc, DW_AttribClass_Address) \ +X(HighPc, DW_AttribClass_Address|DW_AttribClass_Const) \ +X(Language, DW_AttribClass_Const) \ +X(Discr, DW_AttribClass_Reference) \ +X(DiscrValue, DW_AttribClass_Const) \ +X(Visibility, DW_AttribClass_Const) \ +X(Import, DW_AttribClass_Reference) \ +X(StringLength, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(CommonReference, DW_AttribClass_Reference) \ +X(CompDir, DW_AttribClass_String) \ +X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ +X(ContainingType, DW_AttribClass_Reference) \ +X(DefaultValue, DW_AttribClass_Reference) \ +X(Inline, DW_AttribClass_Const) \ +X(IsOptional, DW_AttribClass_Flag) \ +X(LowerBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(Producer, DW_AttribClass_String) \ +X(Prototyped, DW_AttribClass_Flag) \ +X(ReturnAddr, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(StartScope, DW_AttribClass_Const|DW_AttribClass_RngListPtr) \ +X(BitStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(UpperBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(AbstractOrigin, DW_AttribClass_Reference) \ +X(Accessibility, DW_AttribClass_Const) \ +X(AddressClass, DW_AttribClass_Const) \ +X(Artificial, DW_AttribClass_Flag) \ +X(BaseTypes, DW_AttribClass_Reference) \ +X(CallingConvention, DW_AttribClass_Const) \ +X(Count, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(DataMemberLocation, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(DeclColumn, DW_AttribClass_Const) \ +X(DeclFile, DW_AttribClass_Const) \ +X(DeclLine, DW_AttribClass_Const) \ +X(Declaration, DW_AttribClass_Flag) \ +X(DiscrList, DW_AttribClass_Block) \ +X(Encoding, DW_AttribClass_Const) \ +X(External, DW_AttribClass_Flag) \ +X(FrameBase, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(Friend, DW_AttribClass_Reference) \ +X(IdentifierCase, DW_AttribClass_Const) \ +X(MacroInfo, DW_AttribClass_MacPtr) \ +X(NameListItem, DW_AttribClass_Reference) \ +X(Priority, DW_AttribClass_Reference) \ +X(Segment, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(Specification, DW_AttribClass_Reference) \ +X(StaticLink, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(Type, DW_AttribClass_Reference) \ +X(UseLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(VariableParameter, DW_AttribClass_Flag) \ +X(Virtuality, DW_AttribClass_Const) \ +X(VTableElemLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(Allocated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(Associated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(DataLocation, DW_AttribClass_ExprLoc) \ +X(ByteStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(EntryPc, DW_AttribClass_Address|DW_AttribClass_Const) \ +X(UseUtf8, DW_AttribClass_Flag) \ +X(Extension, DW_AttribClass_Reference) \ +X(Ranges, DW_AttribClass_RngList) \ +X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ +X(CallColumn, DW_AttribClass_Const) \ +X(CallFile, DW_AttribClass_Const) \ +X(CallLine, DW_AttribClass_Const) \ +X(Description, DW_AttribClass_String) \ +X(BinaryScale, DW_AttribClass_Const) \ +X(DecimalScale, DW_AttribClass_Const) \ +X(Small, DW_AttribClass_Reference) \ +X(DecimalSign, DW_AttribClass_Const) \ +X(DigitCount, DW_AttribClass_Const) \ +X(PictureString, DW_AttribClass_String) \ +X(Mutable, DW_AttribClass_Flag) \ +X(ThreadsScaled, DW_AttribClass_Flag) \ +X(Explicit, DW_AttribClass_Flag) \ +X(ObjectPointer, DW_AttribClass_Reference) \ +X(Endianity, DW_AttribClass_Const) \ +X(Elemental, DW_AttribClass_Flag) \ +X(Pure, DW_AttribClass_Flag) \ +X(Recursive, DW_AttribClass_Flag) \ +X(Signature, DW_AttribClass_Reference) \ +X(MainSubProgram, DW_AttribClass_Flag) \ +X(DataBitOffset, DW_AttribClass_Const) \ +X(ConstExpr, DW_AttribClass_Flag) \ +X(EnumClass, DW_AttribClass_Flag) \ +X(LinkageName, DW_AttribClass_String) \ +X(StringLengthBitSize, DW_AttribClass_Const) \ +X(StringLengthByteSize, DW_AttribClass_Const) \ +X(Rank, DW_AttribClass_Const|DW_AttribClass_ExprLoc) \ +X(StrOffsetsBase, DW_AttribClass_StrOffsetsPtr) \ +X(AddrBase, DW_AttribClass_AddrPtr) \ +X(RngListsBase, DW_AttribClass_RngListPtr) \ +X(DwoName, DW_AttribClass_String) \ +X(Reference, DW_AttribClass_Flag) \ +X(RValueReference, DW_AttribClass_Flag) \ +X(Macros, DW_AttribClass_MacPtr) \ +X(CallAllCalls, DW_AttribClass_Flag) \ +X(CallAllSourceCalls, DW_AttribClass_Flag) \ +X(CallAllTailCalls, DW_AttribClass_Flag) \ +X(CallReturnPc, DW_AttribClass_Address) \ +X(CallValue, DW_AttribClass_ExprLoc) \ +X(CallOrigin, DW_AttribClass_ExprLoc) \ +X(CallParameter, DW_AttribClass_Reference) \ +X(CallPc, DW_AttribClass_Address) \ +X(CallTailCall, DW_AttribClass_Flag) \ +X(CallTarget, DW_AttribClass_ExprLoc) \ +X(CallTargetClobbered, DW_AttribClass_ExprLoc) \ +X(CallDataLocation, DW_AttribClass_ExprLoc) \ +X(CallDataValue, DW_AttribClass_ExprLoc) \ +X(NoReturn, DW_AttribClass_Flag) \ +X(Alignment, DW_AttribClass_Const) \ +X(ExportSymbols, DW_AttribClass_Flag) \ +X(Deleted, DW_AttribClass_Flag) \ +X(Defaulted, DW_AttribClass_Const) \ +X(LocListsBase, DW_AttribClass_LocListPtr) //- Attributes GNU #define DW_AttribKind_GNU_XList(X) \ - X(GNU_Vector, 0x2107) \ - X(GNU_GuardedBy, 0x2108) \ - X(GNU_PtGuardedBy, 0x2109) \ - X(GNU_Guarded, 0x210a) \ - X(GNU_PtGuarded, 0x210b) \ - X(GNU_LocksExcluded, 0x210c) \ - X(GNU_ExclusiveLocksRequired, 0x210d) \ - X(GNU_SharedLocksRequired, 0x210e) \ - X(GNU_OdrSignature, 0x210f) \ - X(GNU_TemplateName, 0x2110) \ - X(GNU_CallSiteValue, 0x2111) \ - X(GNU_CallSiteDataValue, 0x2112) \ - X(GNU_CallSiteTarget, 0x2113) \ - X(GNU_CallSiteTargetClobbered, 0x2114) \ - X(GNU_TailCall, 0x2115) \ - X(GNU_AllTailCallsSites, 0x2116) \ - X(GNU_AllCallSites, 0x2117) \ - X(GNU_AllSourceCallSites, 0x2118) \ - X(GNU_Macros, 0x2119) \ - X(GNU_Deleted, 0x211a) \ - X(GNU_DwoName, 0x2130) \ - X(GNU_DwoId, 0x2131) \ - X(GNU_RangesBase, 0x2132) \ - X(GNU_AddrBase, 0x2133) \ - X(GNU_PubNames, 0x2134) \ - X(GNU_PubTypes, 0x2135) \ - X(GNU_Discriminator, 0x2136) \ - X(GNU_LocViews, 0x2137) \ - X(GNU_EntryView, 0x2138) \ - X(GNU_DescriptiveType, 0x2302) \ - X(GNU_Numerator, 0x2303) \ - X(GNU_Denominator, 0x2304) \ - X(GNU_Bias, 0x2305) +X(GNU_Vector, 0x2107) \ +X(GNU_GuardedBy, 0x2108) \ +X(GNU_PtGuardedBy, 0x2109) \ +X(GNU_Guarded, 0x210a) \ +X(GNU_PtGuarded, 0x210b) \ +X(GNU_LocksExcluded, 0x210c) \ +X(GNU_ExclusiveLocksRequired, 0x210d) \ +X(GNU_SharedLocksRequired, 0x210e) \ +X(GNU_OdrSignature, 0x210f) \ +X(GNU_TemplateName, 0x2110) \ +X(GNU_CallSiteValue, 0x2111) \ +X(GNU_CallSiteDataValue, 0x2112) \ +X(GNU_CallSiteTarget, 0x2113) \ +X(GNU_CallSiteTargetClobbered, 0x2114) \ +X(GNU_TailCall, 0x2115) \ +X(GNU_AllTailCallsSites, 0x2116) \ +X(GNU_AllCallSites, 0x2117) \ +X(GNU_AllSourceCallSites, 0x2118) \ +X(GNU_Macros, 0x2119) \ +X(GNU_Deleted, 0x211a) \ +X(GNU_DwoName, 0x2130) \ +X(GNU_DwoId, 0x2131) \ +X(GNU_RangesBase, 0x2132) \ +X(GNU_AddrBase, 0x2133) \ +X(GNU_PubNames, 0x2134) \ +X(GNU_PubTypes, 0x2135) \ +X(GNU_Discriminator, 0x2136) \ +X(GNU_LocViews, 0x2137) \ +X(GNU_EntryView, 0x2138) \ +X(GNU_DescriptiveType, 0x2302) \ +X(GNU_Numerator, 0x2303) \ +X(GNU_Denominator, 0x2304) \ +X(GNU_Bias, 0x2305) #define DW_AttribKind_ClassFlags_GNU_XList(X) \ - X(GNU_Vector, DW_AttribClass_Flag) \ - X(GNU_GuardedBy, DW_AttribClass_Undefined) \ - X(GNU_PtGuardedBy, DW_AttribClass_Undefined) \ - X(GNU_Guarded, DW_AttribClass_Undefined) \ - X(GNU_PtGuarded, DW_AttribClass_Undefined) \ - X(GNU_LocksExcluded, DW_AttribClass_Undefined) \ - X(GNU_ExclusiveLocksRequired, DW_AttribClass_Undefined) \ - X(GNU_SharedLocksRequired, DW_AttribClass_Undefined) \ - X(GNU_OdrSignature, DW_AttribClass_Undefined) \ - X(GNU_TemplateName, DW_AttribClass_Undefined) \ - X(GNU_CallSiteValue, DW_AttribClass_ExprLoc) \ - X(GNU_CallSiteDataValue, DW_AttribClass_ExprLoc) \ - X(GNU_CallSiteTarget, DW_AttribClass_ExprLoc) \ - X(GNU_CallSiteTargetClobbered, DW_AttribClass_ExprLoc) \ - X(GNU_TailCall, DW_AttribClass_Flag) \ - X(GNU_AllTailCallsSites, DW_AttribClass_Flag) \ - X(GNU_AllCallSites, DW_AttribClass_Flag) \ - X(GNU_AllSourceCallSites, DW_AttribClass_Flag) \ - X(GNU_Macros, DW_AttribClass_Flag) \ - X(GNU_Deleted, DW_AttribClass_Undefined) \ - X(GNU_DwoName, DW_AttribClass_String) \ - X(GNU_DwoId, DW_AttribClass_Const) \ - X(GNU_RangesBase, DW_AttribClass_Undefined) \ - X(GNU_AddrBase, DW_AttribClass_AddrPtr) \ - X(GNU_PubNames, DW_AttribClass_Flag) \ - X(GNU_PubTypes, DW_AttribClass_Undefined) \ - X(GNU_Discriminator, DW_AttribClass_Const) \ - X(GNU_LocViews, DW_AttribClass_Undefined) \ - X(GNU_EntryView, DW_AttribClass_Undefined) \ - X(GNU_DescriptiveType, DW_AttribClass_Undefined) \ - X(GNU_Numerator, DW_AttribClass_Undefined) \ - X(GNU_Denominator, DW_AttribClass_Undefined) \ - X(GNU_Bias, DW_AttribClass_Undefined) +X(GNU_Vector, DW_AttribClass_Flag) \ +X(GNU_GuardedBy, DW_AttribClass_Undefined) \ +X(GNU_PtGuardedBy, DW_AttribClass_Undefined) \ +X(GNU_Guarded, DW_AttribClass_Undefined) \ +X(GNU_PtGuarded, DW_AttribClass_Undefined) \ +X(GNU_LocksExcluded, DW_AttribClass_Undefined) \ +X(GNU_ExclusiveLocksRequired, DW_AttribClass_Undefined) \ +X(GNU_SharedLocksRequired, DW_AttribClass_Undefined) \ +X(GNU_OdrSignature, DW_AttribClass_Undefined) \ +X(GNU_TemplateName, DW_AttribClass_Undefined) \ +X(GNU_CallSiteValue, DW_AttribClass_ExprLoc) \ +X(GNU_CallSiteDataValue, DW_AttribClass_ExprLoc) \ +X(GNU_CallSiteTarget, DW_AttribClass_ExprLoc) \ +X(GNU_CallSiteTargetClobbered, DW_AttribClass_ExprLoc) \ +X(GNU_TailCall, DW_AttribClass_Flag) \ +X(GNU_AllTailCallsSites, DW_AttribClass_Flag) \ +X(GNU_AllCallSites, DW_AttribClass_Flag) \ +X(GNU_AllSourceCallSites, DW_AttribClass_Flag) \ +X(GNU_Macros, DW_AttribClass_Flag) \ +X(GNU_Deleted, DW_AttribClass_Undefined) \ +X(GNU_DwoName, DW_AttribClass_String) \ +X(GNU_DwoId, DW_AttribClass_Const) \ +X(GNU_RangesBase, DW_AttribClass_Undefined) \ +X(GNU_AddrBase, DW_AttribClass_AddrPtr) \ +X(GNU_PubNames, DW_AttribClass_Flag) \ +X(GNU_PubTypes, DW_AttribClass_Undefined) \ +X(GNU_Discriminator, DW_AttribClass_Const) \ +X(GNU_LocViews, DW_AttribClass_Undefined) \ +X(GNU_EntryView, DW_AttribClass_Undefined) \ +X(GNU_DescriptiveType, DW_AttribClass_Undefined) \ +X(GNU_Numerator, DW_AttribClass_Undefined) \ +X(GNU_Denominator, DW_AttribClass_Undefined) \ +X(GNU_Bias, DW_AttribClass_Undefined) //- Attributes LLVM #define DW_AttribKind_LLVM_XList(X) \ - X(LLVM_IncludePath, 0x3e00) \ - X(LLVM_ConfigMacros, 0x3e01) \ - X(LLVM_SysRoot, 0x3e02) \ - X(LLVM_TagOffset, 0x3e03) \ - X(LLVM_ApiNotes, 0x3e07) +X(LLVM_IncludePath, 0x3e00) \ +X(LLVM_ConfigMacros, 0x3e01) \ +X(LLVM_SysRoot, 0x3e02) \ +X(LLVM_TagOffset, 0x3e03) \ +X(LLVM_ApiNotes, 0x3e07) #define DW_AttribKind_ClassFlags_LLVM_XList(X) \ - X(LLVM_IncludePath, DW_AttribClass_String) \ - X(LLVM_ConfigMacros, DW_AttribClass_String) \ - X(LLVM_SysRoot, DW_AttribClass_String) \ - X(LLVM_TagOffset, DW_AttribClass_Undefined) \ - X(LLVM_ApiNotes, DW_AttribClass_String) +X(LLVM_IncludePath, DW_AttribClass_String) \ +X(LLVM_ConfigMacros, DW_AttribClass_String) \ +X(LLVM_SysRoot, DW_AttribClass_String) \ +X(LLVM_TagOffset, DW_AttribClass_Undefined) \ +X(LLVM_ApiNotes, DW_AttribClass_String) //- Attributes Apple #define DW_AttribKind_APPLE_XList(X) \ - X(APPLE_Optimized, 0x3fe1) \ - X(APPLE_Flags, 0x3fe2) \ - X(APPLE_Isa, 0x3fe3) \ - X(APPLE_Block, 0x3fe4) \ - X(APPLE_MajorRuntimeVers, 0x3fe5) \ - X(APPLE_RuntimeClass, 0x3fe6) \ - X(APPLE_OmitFramePtr, 0x3fe7) \ - X(APPLE_PropertyName, 0x3fe8) \ - X(APPLE_PropertyGetter, 0x3fe9) \ - X(APPLE_PropertySetter, 0x3fea) \ - X(APPLE_PropertyAttribute, 0x3feb) \ - X(APPLE_ObjcCompleteType, 0x3fec) \ - X(APPLE_Property, 0x3fed) \ - X(APPLE_ObjDirect, 0x3fee) \ - X(APPLE_Sdk, 0x3fef) +X(APPLE_Optimized, 0x3fe1) \ +X(APPLE_Flags, 0x3fe2) \ +X(APPLE_Isa, 0x3fe3) \ +X(APPLE_Block, 0x3fe4) \ +X(APPLE_MajorRuntimeVers, 0x3fe5) \ +X(APPLE_RuntimeClass, 0x3fe6) \ +X(APPLE_OmitFramePtr, 0x3fe7) \ +X(APPLE_PropertyName, 0x3fe8) \ +X(APPLE_PropertyGetter, 0x3fe9) \ +X(APPLE_PropertySetter, 0x3fea) \ +X(APPLE_PropertyAttribute, 0x3feb) \ +X(APPLE_ObjcCompleteType, 0x3fec) \ +X(APPLE_Property, 0x3fed) \ +X(APPLE_ObjDirect, 0x3fee) \ +X(APPLE_Sdk, 0x3fef) #define DW_AttribKind_ClassFlags_APPLE_XList(X) \ - X(APPLE_Optimized, DW_AttribClass_Flag) \ - X(APPLE_Flags, DW_AttribClass_Flag) \ - X(APPLE_Isa, DW_AttribClass_Flag) \ - X(APPLE_Block, DW_AttribClass_Undefined) \ - X(APPLE_MajorRuntimeVers, DW_AttribClass_Undefined) \ - X(APPLE_RuntimeClass, DW_AttribClass_Undefined) \ - X(APPLE_OmitFramePtr, DW_AttribClass_Flag) \ - X(APPLE_PropertyName, DW_AttribClass_Undefined) \ - X(APPLE_PropertyGetter, DW_AttribClass_Undefined) \ - X(APPLE_PropertySetter, DW_AttribClass_Undefined) \ - X(APPLE_PropertyAttribute, DW_AttribClass_Undefined) \ - X(APPLE_ObjcCompleteType, DW_AttribClass_Undefined) \ - X(APPLE_Property, DW_AttribClass_Undefined) \ - X(APPLE_ObjDirect, DW_AttribClass_Undefined) \ - X(APPLE_Sdk, DW_AttribClass_String) +X(APPLE_Optimized, DW_AttribClass_Flag) \ +X(APPLE_Flags, DW_AttribClass_Flag) \ +X(APPLE_Isa, DW_AttribClass_Flag) \ +X(APPLE_Block, DW_AttribClass_Undefined) \ +X(APPLE_MajorRuntimeVers, DW_AttribClass_Undefined) \ +X(APPLE_RuntimeClass, DW_AttribClass_Undefined) \ +X(APPLE_OmitFramePtr, DW_AttribClass_Flag) \ +X(APPLE_PropertyName, DW_AttribClass_Undefined) \ +X(APPLE_PropertyGetter, DW_AttribClass_Undefined) \ +X(APPLE_PropertySetter, DW_AttribClass_Undefined) \ +X(APPLE_PropertyAttribute, DW_AttribClass_Undefined) \ +X(APPLE_ObjcCompleteType, DW_AttribClass_Undefined) \ +X(APPLE_Property, DW_AttribClass_Undefined) \ +X(APPLE_ObjDirect, DW_AttribClass_Undefined) \ +X(APPLE_Sdk, DW_AttribClass_String) //- Attributes MIPS #define DW_AttribKind_MIPS_XList(X) \ - X(MIPS_Fde, 0x2001) \ - X(MIPS_LoopBegin, 0x2002) \ - X(MIPS_TailLoopBegin, 0x2003) \ - X(MIPS_EpilogBegin, 0x2004) \ - X(MIPS_LoopUnrollFactor, 0x2005) \ - X(MIPS_SoftwarePipelineDepth, 0x2006) \ - X(MIPS_LinkageName, 0x2007) \ - X(MIPS_Stride, 0x2008) \ - X(MIPS_AbstractName, 0x2009) \ - X(MIPS_CloneOrigin, 0x200a) \ - X(MIPS_HasInlines, 0x200b) \ - X(MIPS_StrideByte, 0x200c) \ - X(MIPS_StrideElem, 0x200d) \ - X(MIPS_PtrDopeType, 0x200e) \ - X(MIPS_AllocatableDopeType, 0x200f) \ - X(MIPS_AssumedShapeDopeType, 0x2010) \ - X(MIPS_AssumedSize, 0x2011) +X(MIPS_Fde, 0x2001) \ +X(MIPS_LoopBegin, 0x2002) \ +X(MIPS_TailLoopBegin, 0x2003) \ +X(MIPS_EpilogBegin, 0x2004) \ +X(MIPS_LoopUnrollFactor, 0x2005) \ +X(MIPS_SoftwarePipelineDepth, 0x2006) \ +X(MIPS_LinkageName, 0x2007) \ +X(MIPS_Stride, 0x2008) \ +X(MIPS_AbstractName, 0x2009) \ +X(MIPS_CloneOrigin, 0x200a) \ +X(MIPS_HasInlines, 0x200b) \ +X(MIPS_StrideByte, 0x200c) \ +X(MIPS_StrideElem, 0x200d) \ +X(MIPS_PtrDopeType, 0x200e) \ +X(MIPS_AllocatableDopeType, 0x200f) \ +X(MIPS_AssumedShapeDopeType, 0x2010) \ +X(MIPS_AssumedSize, 0x2011) #define DW_AttribKind_ClassFlags_MIPS_XList(X) \ - X(MIPS_Fde, DW_AttribClass_Block) \ - X(MIPS_LoopBegin, DW_AttribClass_Block) \ - X(MIPS_TailLoopBegin, DW_AttribClass_Block) \ - X(MIPS_EpilogBegin, DW_AttribClass_Block) \ - X(MIPS_LoopUnrollFactor, DW_AttribClass_Block) \ - X(MIPS_SoftwarePipelineDepth, DW_AttribClass_Block) \ - X(MIPS_LinkageName, DW_AttribClass_String) \ - X(MIPS_Stride, DW_AttribClass_Block) \ - X(MIPS_AbstractName, DW_AttribClass_String) \ - X(MIPS_CloneOrigin, DW_AttribClass_String) \ - X(MIPS_HasInlines, DW_AttribClass_Reference) \ - X(MIPS_StrideByte, DW_AttribClass_Reference) \ - X(MIPS_StrideElem, DW_AttribClass_Reference) \ - X(MIPS_PtrDopeType, DW_AttribClass_Reference) \ - X(MIPS_AllocatableDopeType, DW_AttribClass_Reference) \ - X(MIPS_AssumedShapeDopeType, DW_AttribClass_Reference) \ - X(MIPS_AssumedSize, DW_AttribClass_Reference) +X(MIPS_Fde, DW_AttribClass_Block) \ +X(MIPS_LoopBegin, DW_AttribClass_Block) \ +X(MIPS_TailLoopBegin, DW_AttribClass_Block) \ +X(MIPS_EpilogBegin, DW_AttribClass_Block) \ +X(MIPS_LoopUnrollFactor, DW_AttribClass_Block) \ +X(MIPS_SoftwarePipelineDepth, DW_AttribClass_Block) \ +X(MIPS_LinkageName, DW_AttribClass_String) \ +X(MIPS_Stride, DW_AttribClass_Block) \ +X(MIPS_AbstractName, DW_AttribClass_String) \ +X(MIPS_CloneOrigin, DW_AttribClass_String) \ +X(MIPS_HasInlines, DW_AttribClass_Reference) \ +X(MIPS_StrideByte, DW_AttribClass_Reference) \ +X(MIPS_StrideElem, DW_AttribClass_Reference) \ +X(MIPS_PtrDopeType, DW_AttribClass_Reference) \ +X(MIPS_AllocatableDopeType, DW_AttribClass_Reference) \ +X(MIPS_AssumedShapeDopeType, DW_AttribClass_Reference) \ +X(MIPS_AssumedSize, DW_AttribClass_Reference) typedef U32 DW_AttribKind; typedef enum DW_AttribKindEnum @@ -1162,38 +1162,38 @@ typedef enum DW_AttribKindEnum DW_Attrib_Null, #define X(_N,_ID,...) DW_Attrib_##_N = _ID, DW_AttribKind_V2_XList(X) - DW_AttribKind_V3_XList(X) - DW_AttribKind_V4_XList(X) - DW_AttribKind_V5_XList(X) - DW_AttribKind_GNU_XList(X) - DW_AttribKind_LLVM_XList(X) - DW_AttribKind_APPLE_XList(X) - DW_AttribKind_MIPS_XList(X) + DW_AttribKind_V3_XList(X) + DW_AttribKind_V4_XList(X) + DW_AttribKind_V5_XList(X) + DW_AttribKind_GNU_XList(X) + DW_AttribKind_LLVM_XList(X) + DW_AttribKind_APPLE_XList(X) + DW_AttribKind_MIPS_XList(X) #undef X DW_Attrib_UserLo = 0x2000, DW_Attrib_UserHi = 0x3fff } DW_AttribKindEnum; #define DW_ATE_XList(X) \ - X(Null, 0x00) \ - X(Address, 0x01) \ - X(Boolean, 0x02) \ - X(ComplexFloat, 0x03) \ - X(Float, 0x04) \ - X(Signed, 0x05) \ - X(SignedChar, 0x06) \ - X(Unsigned, 0x07) \ - X(UnsignedChar, 0x08) \ - X(ImaginaryFloat, 0x09) \ - X(PackedDecimal, 0x0A) \ - X(NumericString, 0x0B) \ - X(Edited, 0x0C) \ - X(SignedFixed, 0x0D) \ - X(UnsignedFixed, 0x0E) \ - X(DecimalFloat, 0x0F) \ - X(Utf, 0x10) \ - X(Ucs, 0x11) \ - X(Ascii, 0x12) +X(Null, 0x00) \ +X(Address, 0x01) \ +X(Boolean, 0x02) \ +X(ComplexFloat, 0x03) \ +X(Float, 0x04) \ +X(Signed, 0x05) \ +X(SignedChar, 0x06) \ +X(Unsigned, 0x07) \ +X(UnsignedChar, 0x08) \ +X(ImaginaryFloat, 0x09) \ +X(PackedDecimal, 0x0A) \ +X(NumericString, 0x0B) \ +X(Edited, 0x0C) \ +X(SignedFixed, 0x0D) \ +X(UnsignedFixed, 0x0E) \ +X(DecimalFloat, 0x0F) \ +X(Utf, 0x10) \ +X(Ucs, 0x11) \ +X(Ascii, 0x12) typedef U64 DW_ATE; typedef enum DW_ATEEnum @@ -1204,11 +1204,11 @@ typedef enum DW_ATEEnum } DW_ATEnum; #define DW_CallingConventionKind_XList(X) \ - X(Normal, 0x0) \ - X(Program, 0x1) \ - X(NoCall, 0x3) \ - X(PassByValue, 0x4) \ - X(PassByReference, 0x5) +X(Normal, 0x0) \ +X(Program, 0x1) \ +X(NoCall, 0x3) \ +X(PassByValue, 0x4) \ +X(PassByReference, 0x5) typedef U64 DW_CallingConventionKind; typedef enum DW_CallingConventionKindEnum @@ -1219,10 +1219,10 @@ typedef enum DW_CallingConventionKindEnum } DW_CallingConventionKindEnum; #define DW_AccessKind_XList(X) \ - X(Public, 0x00) \ - X(Private, 0x01) \ - X(Protected, 0x02) - +X(Public, 0x00) \ +X(Private, 0x01) \ +X(Protected, 0x02) + typedef U64 DW_AccessKind; typedef enum DW_AccessKindEnum { @@ -1232,9 +1232,9 @@ typedef enum DW_AccessKindEnum } DW_AccessKindEnum; #define DW_VirtualityKind_XList(X) \ - X(None, 0x00) \ - X(Virtual, 0x01) \ - X(PureVirtual, 0x02) +X(None, 0x00) \ +X(Virtual, 0x01) \ +X(PureVirtual, 0x02) typedef U64 DW_VirtualityKind; typedef enum DW_VirtualityEnum @@ -1245,14 +1245,14 @@ typedef enum DW_VirtualityEnum } DW_VirtualityEnum; #define DW_RngListEntryKind(X) \ - X(EndOfList, 0x00) \ - X(BaseAddressx, 0x01) \ - X(StartxEndx, 0x02) \ - X(StartxLength, 0x03) \ - X(OffsetPair, 0x04) \ - X(BaseAddress, 0x05) \ - X(StartEnd, 0x06) \ - X(StartLength, 0x07) +X(EndOfList, 0x00) \ +X(BaseAddressx, 0x01) \ +X(StartxEndx, 0x02) \ +X(StartxLength, 0x03) \ +X(OffsetPair, 0x04) \ +X(BaseAddress, 0x05) \ +X(StartEnd, 0x06) \ +X(StartLength, 0x07) typedef U8 DW_RLE; typedef enum DW_RLE_Enum @@ -1263,18 +1263,18 @@ typedef enum DW_RLE_Enum } DW_RLE_Enum; #define DW_LocListEntry_XList(X) \ - X(EndOfList, 0x00) \ - X(BaseAddressx, 0x01) \ - X(StartxEndx, 0x02) \ - X(StartxLength, 0x03) \ - X(OffsetPair, 0x04) \ - X(DefaultLocation, 0x05) \ - X(BaseAddress, 0x06) \ - X(StartEnd, 0x07) \ - X(StartLength, 0x08) +X(EndOfList, 0x00) \ +X(BaseAddressx, 0x01) \ +X(StartxEndx, 0x02) \ +X(StartxLength, 0x03) \ +X(OffsetPair, 0x04) \ +X(DefaultLocation, 0x05) \ +X(BaseAddress, 0x06) \ +X(StartEnd, 0x07) \ +X(StartLength, 0x08) #define DW_LocListEntry_GNU_XList(X) \ - X(GNU_ViewPair, 0x9) +X(GNU_ViewPair, 0x9) typedef U8 DW_LLE; typedef enum DW_LLE_Enum @@ -1285,12 +1285,12 @@ typedef enum DW_LLE_Enum } DW_LLEEnum; #define DW_AddrClass_XList(X) \ - X(None, 0) \ - X(Near16, 1) \ - X(Far16, 2) \ - X(Huge16, 3) \ - X(Near32, 4) \ - X(Far32, 5) +X(None, 0) \ +X(Near16, 1) \ +X(Far16, 2) \ +X(Huge16, 3) \ +X(Near32, 4) \ +X(Far32, 5) typedef U64 DW_AddrClass; typedef enum DW_AddrClassEnum @@ -1301,13 +1301,13 @@ typedef enum DW_AddrClassEnum } DW_AddrClassEnum; #define DW_CompUnitKind_XList(X) \ - X(Reserved, 0) \ - X(Compile, 1) \ - X(Type, 2) \ - X(Partial, 3) \ - X(Skeleton, 4) \ - X(SplitCompile, 5) \ - X(SplitType, 6) +X(Reserved, 0) \ +X(Compile, 1) \ +X(Type, 2) \ +X(Partial, 3) \ +X(Skeleton, 4) \ +X(SplitCompile, 5) \ +X(SplitType, 6) typedef U8 DW_CompUnitKind; typedef enum DW_CompUnitKindEnum @@ -1320,12 +1320,12 @@ typedef enum DW_CompUnitKindEnum } DW_CompUnitKindEnum; #define DW_LNCT_XList(X) \ - X(Path, 0x1) \ - X(DirectoryIndex, 0x2) \ - X(TimeStamp, 0x3) \ - X(Size, 0x4) \ - X(MD5, 0x5) \ - X(LLVM_Source, 0x2001) +X(Path, 0x1) \ +X(DirectoryIndex, 0x2) \ +X(TimeStamp, 0x3) \ +X(Size, 0x4) \ +X(MD5, 0x5) \ +X(LLVM_Source, 0x2001) typedef U64 DW_LNCT; typedef enum DW_LNCTEnum @@ -1338,43 +1338,43 @@ typedef enum DW_LNCTEnum } DW_LNCTEnum; #define DW_CFA_Kind1_XList(X) \ - X(Nop, 0x0) \ - X(SetLoc, 0x1) \ - X(AdvanceLoc1, 0x2) \ - X(AdvanceLoc2, 0x3) \ - X(AdvanceLoc4, 0x4) \ - X(OffsetExt, 0x5) \ - X(RestoreExt, 0x6) \ - X(Undefined, 0x7) \ - X(SameValue, 0x8) \ - X(Register, 0x9) \ - X(RememberState, 0xA) \ - X(RestoreState, 0xB) \ - X(DefCfa, 0xC) \ - X(DefCfaRegister, 0xD) \ - X(DefCfaOffset, 0xE) \ - X(DefCfaExpr, 0xF) \ - X(Expr, 0x10) \ - X(OffsetExtSf, 0x11) \ - X(DefCfaSf, 0x12) \ - X(DefCfaOffsetSf, 0x13) \ - X(ValOffset, 0x14) \ - X(ValOffsetSf, 0x15) \ - X(ValExpr, 0x16) +X(Nop, 0x0) \ +X(SetLoc, 0x1) \ +X(AdvanceLoc1, 0x2) \ +X(AdvanceLoc2, 0x3) \ +X(AdvanceLoc4, 0x4) \ +X(OffsetExt, 0x5) \ +X(RestoreExt, 0x6) \ +X(Undefined, 0x7) \ +X(SameValue, 0x8) \ +X(Register, 0x9) \ +X(RememberState, 0xA) \ +X(RestoreState, 0xB) \ +X(DefCfa, 0xC) \ +X(DefCfaRegister, 0xD) \ +X(DefCfaOffset, 0xE) \ +X(DefCfaExpr, 0xF) \ +X(Expr, 0x10) \ +X(OffsetExtSf, 0x11) \ +X(DefCfaSf, 0x12) \ +X(DefCfaOffsetSf, 0x13) \ +X(ValOffset, 0x14) \ +X(ValOffsetSf, 0x15) \ +X(ValExpr, 0x16) #define DW_CFA_Kind2_XList(X) \ - X(AdvanceLoc, 0x40) \ - X(Offset, 0x80) \ - X(Restore, 0xC0) +X(AdvanceLoc, 0x40) \ +X(Offset, 0x80) \ +X(Restore, 0xC0) typedef U8 DW_CFA; typedef enum DW_CFAEnum { #define X(_N, _ID) DW_CFA_##_N = _ID, DW_CFA_Kind1_XList(X) - DW_CFA_Kind2_XList(X) + DW_CFA_Kind2_XList(X) #undef X - + DW_CFA_OplKind1 = DW_CFA_ValExpr, DW_CFA_OplKind2 = DW_CFA_Restore, } DW_CFAEnum; @@ -1392,327 +1392,327 @@ enum // Expression Opcodes #define DW_Expr_V3_XList(X) \ - X(Null, 0x00) \ - X(Addr, 0x03) \ - X(Deref, 0x06) \ - X(Const1U, 0x08) \ - X(Const1S, 0x09) \ - X(Const2U, 0x0a) \ - X(Const2S, 0x0b) \ - X(Const4U, 0x0c) \ - X(Const4S, 0x0d) \ - X(Const8U, 0x0e) \ - X(Const8S, 0x0f) \ - X(ConstU, 0x10) \ - X(ConstS, 0x11) \ - X(Dup, 0x12) \ - X(Drop, 0x13) \ - X(Over, 0x14) \ - X(Pick, 0x15) \ - X(Swap, 0x16) \ - X(Rot, 0x17) \ - X(XDeref, 0x18) \ - X(Abs, 0x19) \ - X(And, 0x1a) \ - X(Div, 0x1b) \ - X(Minus, 0x1c) \ - X(Mod, 0x1d) \ - X(Mul, 0x1e) \ - X(Neg, 0x1f) \ - X(Not, 0x20) \ - X(Or, 0x21) \ - X(Plus, 0x22) \ - X(PlusUConst, 0x23) \ - X(Shl, 0x24) \ - X(Shr, 0x25) \ - X(Shra, 0x26) \ - X(Xor, 0x27) \ - X(Skip, 0x2f) \ - X(Bra, 0x28) \ - X(Eq, 0x29) \ - X(Ge, 0x2a) \ - X(Gt, 0x2b) \ - X(Le, 0x2c) \ - X(Lt, 0x2d) \ - X(Ne, 0x2e) \ - X(Lit0, 0x30) \ - X(Lit1, 0x31) \ - X(Lit2, 0x32) \ - X(Lit3, 0x33) \ - X(Lit4, 0x34) \ - X(Lit5, 0x35) \ - X(Lit6, 0x36) \ - X(Lit7, 0x37) \ - X(Lit8, 0x38) \ - X(Lit9, 0x39) \ - X(Lit10, 0x3a) \ - X(Lit11, 0x3b) \ - X(Lit12, 0x3c) \ - X(Lit13, 0x3d) \ - X(Lit14, 0x3e) \ - X(Lit15, 0x3f) \ - X(Lit16, 0x40) \ - X(Lit17, 0x41) \ - X(Lit18, 0x42) \ - X(Lit19, 0x43) \ - X(Lit20, 0x44) \ - X(Lit21, 0x45) \ - X(Lit22, 0x46) \ - X(Lit23, 0x47) \ - X(Lit24, 0x48) \ - X(Lit25, 0x49) \ - X(Lit26, 0x4a) \ - X(Lit27, 0x4b) \ - X(Lit28, 0x4c) \ - X(Lit29, 0x4d) \ - X(Lit30, 0x4e) \ - X(Lit31, 0x4f) \ - X(Reg0, 0x50) \ - X(Reg1, 0x51) \ - X(Reg2, 0x52) \ - X(Reg3, 0x53) \ - X(Reg4, 0x54) \ - X(Reg5, 0x55) \ - X(Reg6, 0x56) \ - X(Reg7, 0x57) \ - X(Reg8, 0x58) \ - X(Reg9, 0x59) \ - X(Reg10, 0x5a) \ - X(Reg11, 0x5b) \ - X(Reg12, 0x5c) \ - X(Reg13, 0x5d) \ - X(Reg14, 0x5e) \ - X(Reg15, 0x5f) \ - X(Reg16, 0x60) \ - X(Reg17, 0x61) \ - X(Reg18, 0x62) \ - X(Reg19, 0x63) \ - X(Reg20, 0x64) \ - X(Reg21, 0x65) \ - X(Reg22, 0x66) \ - X(Reg23, 0x67) \ - X(Reg24, 0x68) \ - X(Reg25, 0x69) \ - X(Reg26, 0x6a) \ - X(Reg27, 0x6b) \ - X(Reg28, 0x6c) \ - X(Reg29, 0x6d) \ - X(Reg30, 0x6e) \ - X(Reg31, 0x6f) \ - X(BReg0, 0x70) \ - X(BReg1, 0x71) \ - X(BReg2, 0x72) \ - X(BReg3, 0x73) \ - X(BReg4, 0x74) \ - X(BReg5, 0x75) \ - X(BReg6, 0x76) \ - X(BReg7, 0x77) \ - X(BReg8, 0x78) \ - X(BReg9, 0x79) \ - X(BReg10, 0x7a) \ - X(BReg11, 0x7b) \ - X(BReg12, 0x7c) \ - X(BReg13, 0x7d) \ - X(BReg14, 0x7e) \ - X(BReg15, 0x7f) \ - X(BReg16, 0x80) \ - X(BReg17, 0x81) \ - X(BReg18, 0x82) \ - X(BReg19, 0x83) \ - X(BReg20, 0x84) \ - X(BReg21, 0x85) \ - X(BReg22, 0x86) \ - X(BReg23, 0x87) \ - X(BReg24, 0x88) \ - X(BReg25, 0x89) \ - X(BReg26, 0x8a) \ - X(BReg27, 0x8b) \ - X(BReg28, 0x8c) \ - X(BReg29, 0x8d) \ - X(BReg30, 0x8e) \ - X(BReg31, 0x8f) \ - X(RegX, 0x90) \ - X(FBReg, 0x91) \ - X(BRegX, 0x92) \ - X(Piece, 0x93) \ - X(DerefSize, 0x94) \ - X(XDerefSize, 0x95) \ - X(Nop, 0x96) \ - X(PushObjectAddress, 0x97) \ - X(Call2, 0x98) \ - X(Call4, 0x99) \ - X(CallRef, 0x9a) \ - X(FormTlsAddress, 0x9b) \ - X(CallFrameCfa, 0x9c) \ - X(BitPiece, 0x9d) +X(Null, 0x00) \ +X(Addr, 0x03) \ +X(Deref, 0x06) \ +X(Const1U, 0x08) \ +X(Const1S, 0x09) \ +X(Const2U, 0x0a) \ +X(Const2S, 0x0b) \ +X(Const4U, 0x0c) \ +X(Const4S, 0x0d) \ +X(Const8U, 0x0e) \ +X(Const8S, 0x0f) \ +X(ConstU, 0x10) \ +X(ConstS, 0x11) \ +X(Dup, 0x12) \ +X(Drop, 0x13) \ +X(Over, 0x14) \ +X(Pick, 0x15) \ +X(Swap, 0x16) \ +X(Rot, 0x17) \ +X(XDeref, 0x18) \ +X(Abs, 0x19) \ +X(And, 0x1a) \ +X(Div, 0x1b) \ +X(Minus, 0x1c) \ +X(Mod, 0x1d) \ +X(Mul, 0x1e) \ +X(Neg, 0x1f) \ +X(Not, 0x20) \ +X(Or, 0x21) \ +X(Plus, 0x22) \ +X(PlusUConst, 0x23) \ +X(Shl, 0x24) \ +X(Shr, 0x25) \ +X(Shra, 0x26) \ +X(Xor, 0x27) \ +X(Skip, 0x2f) \ +X(Bra, 0x28) \ +X(Eq, 0x29) \ +X(Ge, 0x2a) \ +X(Gt, 0x2b) \ +X(Le, 0x2c) \ +X(Lt, 0x2d) \ +X(Ne, 0x2e) \ +X(Lit0, 0x30) \ +X(Lit1, 0x31) \ +X(Lit2, 0x32) \ +X(Lit3, 0x33) \ +X(Lit4, 0x34) \ +X(Lit5, 0x35) \ +X(Lit6, 0x36) \ +X(Lit7, 0x37) \ +X(Lit8, 0x38) \ +X(Lit9, 0x39) \ +X(Lit10, 0x3a) \ +X(Lit11, 0x3b) \ +X(Lit12, 0x3c) \ +X(Lit13, 0x3d) \ +X(Lit14, 0x3e) \ +X(Lit15, 0x3f) \ +X(Lit16, 0x40) \ +X(Lit17, 0x41) \ +X(Lit18, 0x42) \ +X(Lit19, 0x43) \ +X(Lit20, 0x44) \ +X(Lit21, 0x45) \ +X(Lit22, 0x46) \ +X(Lit23, 0x47) \ +X(Lit24, 0x48) \ +X(Lit25, 0x49) \ +X(Lit26, 0x4a) \ +X(Lit27, 0x4b) \ +X(Lit28, 0x4c) \ +X(Lit29, 0x4d) \ +X(Lit30, 0x4e) \ +X(Lit31, 0x4f) \ +X(Reg0, 0x50) \ +X(Reg1, 0x51) \ +X(Reg2, 0x52) \ +X(Reg3, 0x53) \ +X(Reg4, 0x54) \ +X(Reg5, 0x55) \ +X(Reg6, 0x56) \ +X(Reg7, 0x57) \ +X(Reg8, 0x58) \ +X(Reg9, 0x59) \ +X(Reg10, 0x5a) \ +X(Reg11, 0x5b) \ +X(Reg12, 0x5c) \ +X(Reg13, 0x5d) \ +X(Reg14, 0x5e) \ +X(Reg15, 0x5f) \ +X(Reg16, 0x60) \ +X(Reg17, 0x61) \ +X(Reg18, 0x62) \ +X(Reg19, 0x63) \ +X(Reg20, 0x64) \ +X(Reg21, 0x65) \ +X(Reg22, 0x66) \ +X(Reg23, 0x67) \ +X(Reg24, 0x68) \ +X(Reg25, 0x69) \ +X(Reg26, 0x6a) \ +X(Reg27, 0x6b) \ +X(Reg28, 0x6c) \ +X(Reg29, 0x6d) \ +X(Reg30, 0x6e) \ +X(Reg31, 0x6f) \ +X(BReg0, 0x70) \ +X(BReg1, 0x71) \ +X(BReg2, 0x72) \ +X(BReg3, 0x73) \ +X(BReg4, 0x74) \ +X(BReg5, 0x75) \ +X(BReg6, 0x76) \ +X(BReg7, 0x77) \ +X(BReg8, 0x78) \ +X(BReg9, 0x79) \ +X(BReg10, 0x7a) \ +X(BReg11, 0x7b) \ +X(BReg12, 0x7c) \ +X(BReg13, 0x7d) \ +X(BReg14, 0x7e) \ +X(BReg15, 0x7f) \ +X(BReg16, 0x80) \ +X(BReg17, 0x81) \ +X(BReg18, 0x82) \ +X(BReg19, 0x83) \ +X(BReg20, 0x84) \ +X(BReg21, 0x85) \ +X(BReg22, 0x86) \ +X(BReg23, 0x87) \ +X(BReg24, 0x88) \ +X(BReg25, 0x89) \ +X(BReg26, 0x8a) \ +X(BReg27, 0x8b) \ +X(BReg28, 0x8c) \ +X(BReg29, 0x8d) \ +X(BReg30, 0x8e) \ +X(BReg31, 0x8f) \ +X(RegX, 0x90) \ +X(FBReg, 0x91) \ +X(BRegX, 0x92) \ +X(Piece, 0x93) \ +X(DerefSize, 0x94) \ +X(XDerefSize, 0x95) \ +X(Nop, 0x96) \ +X(PushObjectAddress, 0x97) \ +X(Call2, 0x98) \ +X(Call4, 0x99) \ +X(CallRef, 0x9a) \ +X(FormTlsAddress, 0x9b) \ +X(CallFrameCfa, 0x9c) \ +X(BitPiece, 0x9d) #define DW_Expr_V4_XList(X) \ - X(ImplicitValue, 0x9e) \ - X(StackValue, 0x9f) +X(ImplicitValue, 0x9e) \ +X(StackValue, 0x9f) #define DW_Expr_V5_XList(X) \ - X(ImplicitPointer, 0xa0) \ - X(Addrx, 0xa1) \ - X(Constx, 0xa2) \ - X(EntryValue, 0xa3) \ - X(ConstType, 0xa4) \ - X(RegvalType, 0xa5) \ - X(DerefType, 0xa6) \ - X(XderefType, 0xa7) \ - X(Convert, 0xa8) \ - X(ReInterpret, 0xa9) +X(ImplicitPointer, 0xa0) \ +X(Addrx, 0xa1) \ +X(Constx, 0xa2) \ +X(EntryValue, 0xa3) \ +X(ConstType, 0xa4) \ +X(RegvalType, 0xa5) \ +X(DerefType, 0xa6) \ +X(XderefType, 0xa7) \ +X(Convert, 0xa8) \ +X(ReInterpret, 0xa9) #define DW_Expr_GNU_XList(X) \ - X(GNU_PushTlsAddress, 0xe0) \ - X(GNU_UnInit, 0xf0) \ - X(GNU_ImplicitPointer, 0xf2) \ - X(GNU_EntryValue, 0xf3) \ - X(GNU_ConstType, 0xf4) \ - X(GNU_RegvalType, 0xf5) \ - X(GNU_DerefType, 0xf6) \ - X(GNU_Convert, 0xf7) \ - X(GNU_ParameterRef, 0xfa) \ - X(GNU_AddrIndex, 0xfb) \ - X(GNU_ConstIndex, 0xfc) - +X(GNU_PushTlsAddress, 0xe0) \ +X(GNU_UnInit, 0xf0) \ +X(GNU_ImplicitPointer, 0xf2) \ +X(GNU_EntryValue, 0xf3) \ +X(GNU_ConstType, 0xf4) \ +X(GNU_RegvalType, 0xf5) \ +X(GNU_DerefType, 0xf6) \ +X(GNU_Convert, 0xf7) \ +X(GNU_ParameterRef, 0xfa) \ +X(GNU_AddrIndex, 0xfb) \ +X(GNU_ConstIndex, 0xfc) + typedef U64 DW_ExprOp; typedef enum DW_ExprOpEnum { #define X(_N, _ID) DW_ExprOp_##_N = _ID, DW_Expr_V3_XList(X) - DW_Expr_V4_XList(X) - DW_Expr_V5_XList(X) - DW_Expr_GNU_XList(X) + DW_Expr_V4_XList(X) + DW_Expr_V5_XList(X) + DW_Expr_GNU_XList(X) #undef X } DW_ExprOpEnum; //- Regs #define DW_Regs_X86_XList(X) \ - X(Eax, 0, eax, 0, 4) \ - X(Ecx, 1, ecx, 0, 4) \ - X(Edx, 2, edx, 0, 4) \ - X(Ebx, 3, ebx, 0, 4) \ - X(Esp, 4, esp, 0, 4) \ - X(Ebp, 5, ebp, 0, 4) \ - X(Esi, 6, esi, 0, 4) \ - X(Edi, 7, edi, 0, 4) \ - X(Eip, 8, eip, 0, 4) \ - X(Eflags, 9, eflags, 0, 4) \ - X(Trapno, 10, nil, 0, 0) \ - X(St0, 11, st0, 0, 10) \ - X(St1, 12, st1, 0, 10) \ - X(St2, 13, st2, 0, 10) \ - X(St3, 14, st3, 0, 10) \ - X(St4, 15, st4, 0, 10) \ - X(St5, 16, st5, 0, 10) \ - X(St6, 17, st6, 0, 10) \ - X(St7, 18, st7, 0, 10) \ - X(Xmm0, 21, ymm0, 0, 16) \ - X(Xmm1, 22, ymm1, 0, 16) \ - X(Xmm2, 23, ymm2, 0, 16) \ - X(Xmm3, 24, ymm3, 0, 16) \ - X(Xmm4, 25, ymm4, 0, 16) \ - X(Xmm5, 26, ymm5, 0, 16) \ - X(Xmm6, 27, ymm6, 0, 16) \ - X(Xmm7, 28, ymm7, 0, 16) \ - X(Mm0, 29, fpr0, 0, 8) \ - X(Mm1, 30, fpr1, 0, 8) \ - X(Mm2, 31, fpr2, 0, 8) \ - X(Mm3, 32, fpr3, 0, 8) \ - X(Mm4, 33, fpr4, 0, 8) \ - X(Mm5, 34, fpr5, 0, 8) \ - X(Mm6, 35, fpr6, 0, 8) \ - X(Mm7, 36, fpr7, 0, 8) \ - X(Fcw, 37, fcw, 0, 2) \ - X(Fsw, 38, fsw, 0, 2) \ - X(Mxcsr, 39, mxcsr, 0, 4) \ - X(Es, 40, es, 0, 2) \ - X(Cs, 41, cs, 0, 2) \ - X(Ss, 42, ss, 0, 2) \ - X(Ds, 43, ds, 0, 2) \ - X(Fs, 44, fs, 0, 2) \ - X(Gs, 45, gs, 0, 2) \ - X(Tr, 48, nil, 0, 0) \ - X(Ldtr, 49, nil, 0, 0) +X(Eax, 0, eax, 0, 4) \ +X(Ecx, 1, ecx, 0, 4) \ +X(Edx, 2, edx, 0, 4) \ +X(Ebx, 3, ebx, 0, 4) \ +X(Esp, 4, esp, 0, 4) \ +X(Ebp, 5, ebp, 0, 4) \ +X(Esi, 6, esi, 0, 4) \ +X(Edi, 7, edi, 0, 4) \ +X(Eip, 8, eip, 0, 4) \ +X(Eflags, 9, eflags, 0, 4) \ +X(Trapno, 10, nil, 0, 0) \ +X(St0, 11, st0, 0, 10) \ +X(St1, 12, st1, 0, 10) \ +X(St2, 13, st2, 0, 10) \ +X(St3, 14, st3, 0, 10) \ +X(St4, 15, st4, 0, 10) \ +X(St5, 16, st5, 0, 10) \ +X(St6, 17, st6, 0, 10) \ +X(St7, 18, st7, 0, 10) \ +X(Xmm0, 21, ymm0, 0, 16) \ +X(Xmm1, 22, ymm1, 0, 16) \ +X(Xmm2, 23, ymm2, 0, 16) \ +X(Xmm3, 24, ymm3, 0, 16) \ +X(Xmm4, 25, ymm4, 0, 16) \ +X(Xmm5, 26, ymm5, 0, 16) \ +X(Xmm6, 27, ymm6, 0, 16) \ +X(Xmm7, 28, ymm7, 0, 16) \ +X(Mm0, 29, fpr0, 0, 8) \ +X(Mm1, 30, fpr1, 0, 8) \ +X(Mm2, 31, fpr2, 0, 8) \ +X(Mm3, 32, fpr3, 0, 8) \ +X(Mm4, 33, fpr4, 0, 8) \ +X(Mm5, 34, fpr5, 0, 8) \ +X(Mm6, 35, fpr6, 0, 8) \ +X(Mm7, 36, fpr7, 0, 8) \ +X(Fcw, 37, fcw, 0, 2) \ +X(Fsw, 38, fsw, 0, 2) \ +X(Mxcsr, 39, mxcsr, 0, 4) \ +X(Es, 40, es, 0, 2) \ +X(Cs, 41, cs, 0, 2) \ +X(Ss, 42, ss, 0, 2) \ +X(Ds, 43, ds, 0, 2) \ +X(Fs, 44, fs, 0, 2) \ +X(Gs, 45, gs, 0, 2) \ +X(Tr, 48, nil, 0, 0) \ +X(Ldtr, 49, nil, 0, 0) #define DW_Regs_X64_XList(X) \ - X(Rax, 0, rax, 0, 8) \ - X(Rdx, 1, rdx, 0, 8) \ - X(Rcx, 2, rcx, 0, 8) \ - X(Rbx, 3, rbx, 0, 8) \ - X(Rsi, 4, rsi, 0, 8) \ - X(Rdi, 5, rdi, 0, 8) \ - X(Rbp, 6, rbp, 0, 8) \ - X(Rsp, 7, rsp, 0, 8) \ - X(R8, 8, r8, 0, 8) \ - X(R9, 9, r9, 0, 8) \ - X(R10, 10, r10, 0, 8) \ - X(R11, 11, r11, 0, 8) \ - X(R12, 12, r12, 0, 8) \ - X(R13, 13, r13, 0, 8) \ - X(R14, 14, r14, 0, 8) \ - X(R15, 15, r15, 0, 8) \ - X(Rip, 16, rip, 0, 8) \ - X(Xmm0, 17, zmm0, 0, 16) \ - X(Xmm1, 18, zmm1, 0, 16) \ - X(Xmm2, 19, zmm2, 0, 16) \ - X(Xmm3, 20, zmm3, 0, 16) \ - X(Xmm4, 21, zmm4, 0, 16) \ - X(Xmm5, 22, zmm5, 0, 16) \ - X(Xmm6, 23, zmm6, 0, 16) \ - X(Xmm7, 24, zmm7, 0, 16) \ - X(Xmm8, 25, zmm8, 0, 16) \ - X(Xmm9, 26, zmm9, 0, 16) \ - X(Xmm10, 27, zmm10, 0, 16) \ - X(Xmm11, 28, zmm11, 0, 16) \ - X(Xmm12, 29, zmm12, 0, 16) \ - X(Xmm13, 30, zmm13, 0, 16) \ - X(Xmm14, 31, zmm14, 0, 16) \ - X(Xmm15, 32, zmm15, 0, 16) \ - X(Xmm16, 67, zmm16, 0, 16) \ - X(Xmm17, 68, zmm17, 0, 16) \ - X(Xmm18, 69, zmm18, 0, 16) \ - X(Xmm19, 70, zmm19, 0, 16) \ - X(Xmm20, 71, zmm20, 0, 16) \ - X(Xmm21, 72, zmm21, 0, 16) \ - X(Xmm22, 73, zmm22, 0, 16) \ - X(Xmm23, 74, zmm23, 0, 16) \ - X(Xmm24, 75, zmm24, 0, 16) \ - X(Xmm25, 76, zmm25, 0, 16) \ - X(Xmm26, 77, zmm26, 0, 16) \ - X(Xmm27, 78, zmm27, 0, 16) \ - X(Xmm28, 79, zmm28, 0, 16) \ - X(Xmm29, 80, zmm29, 0, 16) \ - X(Xmm30, 81, zmm30, 0, 16) \ - X(Xmm31, 82, zmm31, 0, 16) \ - X(St0, 33, st0, 0, 10) \ - X(St1, 34, st1, 0, 10) \ - X(St2, 35, st2, 0, 10) \ - X(St3, 36, st3, 0, 10) \ - X(St4, 37, st4, 0, 10) \ - X(St5, 38, st5, 0, 10) \ - X(St6, 39, st6, 0, 10) \ - X(St7, 40, st7, 0, 10) \ - X(Mm0, 41, fpr0, 0, 8) \ - X(Mm1, 42, fpr1, 0, 8) \ - X(Mm2, 43, fpr2, 0, 8) \ - X(Mm3, 44, fpr3, 0, 8) \ - X(Mm4, 45, fpr4, 0, 8) \ - X(Mm5, 46, fpr5, 0, 8) \ - X(Mm6, 47, fpr6, 0, 8) \ - X(Mm7, 48, fpr7, 0, 8) \ - X(Rflags, 49, rflags, 0, 4) \ - X(Es, 50, es, 0, 2) \ - X(Cs, 51, cs, 0, 2) \ - X(Ss, 52, ss, 0, 2) \ - X(Ds, 53, ds, 0, 2) \ - X(Fs, 54, fs, 0, 2) \ - X(Gs, 55, gs, 0, 2) \ - X(FsBase, 58, nil, 0, 0) \ - X(GsBase, 59, nil, 0, 0) \ - X(Tr, 62, nil, 0, 0) \ - X(Ldtr, 63, nil, 0, 0) +X(Rax, 0, rax, 0, 8) \ +X(Rdx, 1, rdx, 0, 8) \ +X(Rcx, 2, rcx, 0, 8) \ +X(Rbx, 3, rbx, 0, 8) \ +X(Rsi, 4, rsi, 0, 8) \ +X(Rdi, 5, rdi, 0, 8) \ +X(Rbp, 6, rbp, 0, 8) \ +X(Rsp, 7, rsp, 0, 8) \ +X(R8, 8, r8, 0, 8) \ +X(R9, 9, r9, 0, 8) \ +X(R10, 10, r10, 0, 8) \ +X(R11, 11, r11, 0, 8) \ +X(R12, 12, r12, 0, 8) \ +X(R13, 13, r13, 0, 8) \ +X(R14, 14, r14, 0, 8) \ +X(R15, 15, r15, 0, 8) \ +X(Rip, 16, rip, 0, 8) \ +X(Xmm0, 17, zmm0, 0, 16) \ +X(Xmm1, 18, zmm1, 0, 16) \ +X(Xmm2, 19, zmm2, 0, 16) \ +X(Xmm3, 20, zmm3, 0, 16) \ +X(Xmm4, 21, zmm4, 0, 16) \ +X(Xmm5, 22, zmm5, 0, 16) \ +X(Xmm6, 23, zmm6, 0, 16) \ +X(Xmm7, 24, zmm7, 0, 16) \ +X(Xmm8, 25, zmm8, 0, 16) \ +X(Xmm9, 26, zmm9, 0, 16) \ +X(Xmm10, 27, zmm10, 0, 16) \ +X(Xmm11, 28, zmm11, 0, 16) \ +X(Xmm12, 29, zmm12, 0, 16) \ +X(Xmm13, 30, zmm13, 0, 16) \ +X(Xmm14, 31, zmm14, 0, 16) \ +X(Xmm15, 32, zmm15, 0, 16) \ +X(Xmm16, 67, zmm16, 0, 16) \ +X(Xmm17, 68, zmm17, 0, 16) \ +X(Xmm18, 69, zmm18, 0, 16) \ +X(Xmm19, 70, zmm19, 0, 16) \ +X(Xmm20, 71, zmm20, 0, 16) \ +X(Xmm21, 72, zmm21, 0, 16) \ +X(Xmm22, 73, zmm22, 0, 16) \ +X(Xmm23, 74, zmm23, 0, 16) \ +X(Xmm24, 75, zmm24, 0, 16) \ +X(Xmm25, 76, zmm25, 0, 16) \ +X(Xmm26, 77, zmm26, 0, 16) \ +X(Xmm27, 78, zmm27, 0, 16) \ +X(Xmm28, 79, zmm28, 0, 16) \ +X(Xmm29, 80, zmm29, 0, 16) \ +X(Xmm30, 81, zmm30, 0, 16) \ +X(Xmm31, 82, zmm31, 0, 16) \ +X(St0, 33, st0, 0, 10) \ +X(St1, 34, st1, 0, 10) \ +X(St2, 35, st2, 0, 10) \ +X(St3, 36, st3, 0, 10) \ +X(St4, 37, st4, 0, 10) \ +X(St5, 38, st5, 0, 10) \ +X(St6, 39, st6, 0, 10) \ +X(St7, 40, st7, 0, 10) \ +X(Mm0, 41, fpr0, 0, 8) \ +X(Mm1, 42, fpr1, 0, 8) \ +X(Mm2, 43, fpr2, 0, 8) \ +X(Mm3, 44, fpr3, 0, 8) \ +X(Mm4, 45, fpr4, 0, 8) \ +X(Mm5, 46, fpr5, 0, 8) \ +X(Mm6, 47, fpr6, 0, 8) \ +X(Mm7, 48, fpr7, 0, 8) \ +X(Rflags, 49, rflags, 0, 4) \ +X(Es, 50, es, 0, 2) \ +X(Cs, 51, cs, 0, 2) \ +X(Ss, 52, ss, 0, 2) \ +X(Ds, 53, ds, 0, 2) \ +X(Fs, 54, fs, 0, 2) \ +X(Gs, 55, gs, 0, 2) \ +X(FsBase, 58, nil, 0, 0) \ +X(GsBase, 59, nil, 0, 0) \ +X(Tr, 62, nil, 0, 0) \ +X(Ldtr, 63, nil, 0, 0) typedef U32 DW_Reg; diff --git a/src/dwarf/dwarf_coff.c b/src/dwarf/dwarf_coff.c index 423761bc..a89ec810 100644 --- a/src/dwarf/dwarf_coff.c +++ b/src/dwarf/dwarf_coff.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal B32 @@ -8,22 +8,22 @@ dw_is_dwarf_present_coff_section_table(String8 raw_image, COFF_SectionHeader *section_table) { B32 is_dwarf_present = 0; - + for (U64 i = 0; i < section_count; ++i) { COFF_SectionHeader *header = §ion_table[i]; String8 name = coff_name_from_section_header(string_table, header); - + DW_SectionKind s = dw_section_kind_from_string(name); if (s == DW_Section_Null) { s = dw_section_dwo_kind_from_string(name); } - + is_dwarf_present = s != DW_Section_Null; if (is_dwarf_present) { break; } } - + return is_dwarf_present; } @@ -36,19 +36,19 @@ dw_input_from_coff_section_table(Arena *arena, { DW_Input input = {0}; B32 sect_status[ArrayCount(input.sec)] = {0}; - + for (U64 i = 0; i < section_count; ++i) { COFF_SectionHeader *header = §ion_table[i]; Rng1U64 raw_data_range = rng_1u64(header->foff, header->foff + header->fsize); String8 name = coff_name_from_section_header(string_table, header); - + DW_SectionKind s = dw_section_kind_from_string(name); B32 is_dwo = 0; if (s == DW_Section_Null) { s = dw_section_dwo_kind_from_string(name); is_dwo = 1; } - + if (s != DW_Section_Null) { if (sect_status[s]) { Assert(!"too many debug sections with identical name, picking first"); @@ -61,7 +61,7 @@ dw_input_from_coff_section_table(Arena *arena, } } } - + return input; } diff --git a/src/dwarf/dwarf_coff.h b/src/dwarf/dwarf_coff.h index e612897a..27441198 100644 --- a/src/dwarf/dwarf_coff.h +++ b/src/dwarf/dwarf_coff.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DWARF_COFF_H diff --git a/src/dwarf/dwarf_enum.c b/src/dwarf/dwarf_enum.c index ae41b06b..bbbba08c 100644 --- a/src/dwarf/dwarf_enum.c +++ b/src/dwarf/dwarf_enum.c @@ -1,18 +1,18 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal String8 dw_string_from_expr_op(Arena *arena, DW_Version ver, DW_Ext ext, DW_ExprOp op) { String8 result = {0}; - - #define X(_N,...) case DW_ExprOp_##_N: result = str8_lit(Stringify(_N)); goto exit; + +#define X(_N,...) case DW_ExprOp_##_N: result = str8_lit(Stringify(_N)); goto exit; if (ext & DW_Ext_GNU) { switch (op) { DW_Expr_GNU_XList(X); } } - + switch (ver) { case DW_Version_5: { switch (op) { @@ -32,13 +32,13 @@ dw_string_from_expr_op(Arena *arena, DW_Version ver, DW_Ext ext, DW_ExprOp op) case DW_Version_2: case DW_Version_1: case DW_Version_Null: - break; + break; } - #undef X - +#undef X + result = push_str8f(arena, "%x", op); - -exit:; + + exit:; return result; } @@ -46,12 +46,12 @@ internal String8 dw_string_from_tag_kind(Arena *arena, DW_TagKind kind) { switch (kind) { - case DW_Tag_Null: return str8_lit("Null"); - #define X(_N,_ID) case DW_Tag_##_N: return str8_lit(Stringify(_N)); + case DW_Tag_Null: return str8_lit("Null"); +#define X(_N,_ID) case DW_Tag_##_N: return str8_lit(Stringify(_N)); DW_Tag_V3_XList(X) - DW_Tag_V5_XList(X) - DW_Tag_GNU_XList(X) - #undef X + DW_Tag_V5_XList(X) + DW_Tag_GNU_XList(X) +#undef X } return push_str8f(arena, "%llx", kind); } @@ -59,8 +59,8 @@ dw_string_from_tag_kind(Arena *arena, DW_TagKind kind) internal String8 dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKind kind) { - #define X(_N,...) case DW_Attrib_##_N: return str8_lit(Stringify(_N)); - +#define X(_N,...) case DW_Attrib_##_N: return str8_lit(Stringify(_N)); + while (ext) { U64 z = 64-clz64(ext); if (z == 0) { @@ -68,7 +68,7 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi } U64 flag = 1 << (z-1); ext &= ~flag; - + switch (flag) { case DW_Ext_Null: break; case DW_Ext_GNU: switch (kind) { DW_AttribKind_GNU_XList(X) } break; @@ -78,7 +78,7 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi default: InvalidPath; break; } } - + switch (ver) { case DW_Version_5: { switch (kind) { @@ -104,15 +104,15 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi } // fall-through case DW_Version_Null: break; } - #undef X - +#undef X + return str8_zero(); } internal String8 dw_string_from_form_kind(Arena *arena, DW_Version ver, DW_FormKind kind) { - #define X(_N,...) case DW_Form_##_N: return str8_lit(Stringify(_N)); +#define X(_N,...) case DW_Form_##_N: return str8_lit(Stringify(_N)); switch (ver) { case DW_Version_5: { switch (kind) { @@ -132,7 +132,7 @@ dw_string_from_form_kind(Arena *arena, DW_Version ver, DW_FormKind kind) } // fall-through case DW_Version_Null: break; } - #undef X +#undef X String8 result = push_str8f(arena, "%x", kind); return result; } @@ -141,9 +141,9 @@ internal String8 dw_string_from_language(Arena *arena, DW_Language kind) { switch (kind) { - #define X(_N,_ID) case DW_Language_##_N: return str8_lit(Stringify(_N)); +#define X(_N,_ID) case DW_Language_##_N: return str8_lit(Stringify(_N)); DW_Language_XList(X) - #undef X +#undef X } return push_str8f(arena, "%x", kind); } @@ -196,9 +196,9 @@ internal String8 dw_string_from_std_opcode(Arena *arena, DW_StdOpcode kind) { switch (kind) { - #define X(_N,_ID) case DW_StdOpcode_##_N: return str8_lit(Stringify(_N)); +#define X(_N,_ID) case DW_StdOpcode_##_N: return str8_lit(Stringify(_N)); DW_StdOpcode_XList(X) - #undef X +#undef X } return push_str8f(arena, "%x", kind); } @@ -207,9 +207,9 @@ internal String8 dw_string_from_ext_opcode(Arena *arena, DW_ExtOpcode kind) { switch (kind) { - #define X(_N,_ID) case DW_ExtOpcode_##_N: return str8_lit(Stringify(_N)); +#define X(_N,_ID) case DW_ExtOpcode_##_N: return str8_lit(Stringify(_N)); DW_ExtOpcode_XList(X) - #undef X +#undef X default: InvalidPath; break; } return push_str8f(arena, "%x", kind); @@ -244,16 +244,16 @@ dw_string_from_register(Arena *arena, Arch arch, U64 reg_id) case Arch_Null: break; case Arch_x86: { switch (reg_id) { - #define X(_N, _ID, ...) case DW_RegX86_##_N: reg_str = str8_lit(Stringify(_N)); break; +#define X(_N, _ID, ...) case DW_RegX86_##_N: reg_str = str8_lit(Stringify(_N)); break; DW_Regs_X86_XList(X) - #undef X +#undef X } } break; case Arch_x64: { switch (reg_id) { - #define X(_N, _ID, ...) case DW_RegX64_##_N: reg_str = str8_lit(Stringify(_N)); break; +#define X(_N, _ID, ...) case DW_RegX64_##_N: reg_str = str8_lit(Stringify(_N)); break; DW_Regs_X64_XList(X) - #undef X +#undef X } } break; case Arch_arm32: NotImplemented; break; diff --git a/src/dwarf/dwarf_enum.h b/src/dwarf/dwarf_enum.h index 1a770ee9..add27760 100644 --- a/src/dwarf/dwarf_enum.h +++ b/src/dwarf/dwarf_enum.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DWARF_ENUM_H diff --git a/src/dwarf/dwarf_expr.c b/src/dwarf/dwarf_expr.c index 98309b97..63e1ea29 100644 --- a/src/dwarf/dwarf_expr.c +++ b/src/dwarf/dwarf_expr.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- analyzers @@ -10,7 +10,7 @@ dw_expr__analyze_fast(void *base, Rng1U64 range, U64 text_section_base) DW_SimpleLoc result = {DW_SimpleLocKind_Empty}; String8 expr_data = str8((U8*)data+range.min, (U8*)data+range.max); - + U8 op = 0; if (str8_deserial_read_struct(expr_data, 0, &op)) { // step params @@ -52,11 +52,11 @@ dw_expr__analyze_fast(void *base, Rng1U64 range, U64 text_section_base) { U64 x = 0; step_cursor += dw_based_range_read(base, range, step_cursor, size_param, &x); - + if (is_signed) { x = extend_sign64(x, size_param); } - + result.kind = DW_SimpleLocKind_Address; result.addr = x; } break; @@ -180,7 +180,7 @@ internal DW_ExprAnalysis dw_expr__analyze_details(void *in_base, Rng1U64 in_range, DW_ExprMachineCallConfig *call_config) { Temp scratch = scratch_begin(0, 0); - + DW_ExprAnalysis result = {0}; // are we resolving calls? @@ -560,7 +560,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp { #if 0 Temp scratch = scratch_begin(&arena_optional, 1); - + DW_Location result = {0}; // setup stack @@ -655,7 +655,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp { U64 offset = 0; step_cursor += dw_based_range_read(base, range, step_cursor, 8, &offset); - + // earlier versions of GCC emit TLS offset with DW_ExprOp_Addr. B32 is_text_relative; { @@ -663,9 +663,9 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp dw_based_range_read_struct(base, range, step_cursor, &next_op); is_text_relative = (next_op != DW_ExprOp_GNU_PushTlsAddress); } - + U64 addr = offset; - + if (is_text_relative) { if (config->text_section_base != 0) { addr += *config->text_section_base; @@ -675,7 +675,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp goto finish; } } - + dw_expr__stack_push(scratch.arena, &stack, addr); } break; @@ -748,7 +748,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp U64 reg_idx = 0; S64 offset = 0; step_cursor += dw_based_range_read_uleb128(base, range, step_cursor, ®_idx); step_cursor += dw_based_range_read_sleb128(base, range, step_cursor, &offset); - + DW_RegsX64 *regs = config->regs; if (regs != 0) { if (reg_idx < ArrayCount(regs->r)) { @@ -816,7 +816,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp case DW_ExprOp_Deref: { U64 addr = dw_expr__stack_pop(&stack); - + B32 read_success = 0; if (config->read_memory) { U64 x = 0; @@ -825,7 +825,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp read_success = 1; } } - + if (!read_success) { stashed_loc.kind = DW_SimpleLocKind_Fail; stashed_loc.fail_kind = DW_LocFailKind_MissingMemory; @@ -838,10 +838,10 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp { U64 raw_size = 0; step_cursor += dw_based_range_read(base, range, step_cursor, 1, &raw_size); - + U64 size = ClampTop(raw_size, 8); U64 addr = dw_expr__stack_pop(&stack); - + B32 read_success = 0; if (config->read_memory) { U64 x = 0; @@ -883,7 +883,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp case DW_ExprOp_FormTlsAddress: { S64 s = (S64)dw_expr__stack_pop(&stack); - + if (config->tls_address != 0) { U64 x = *config->tls_address + s; dw_expr__stack_push(scratch.arena, &stack, x); diff --git a/src/dwarf/dwarf_expr.h b/src/dwarf/dwarf_expr.h index 0d8cb10a..9daf7f73 100644 --- a/src/dwarf/dwarf_expr.h +++ b/src/dwarf/dwarf_expr.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DWARF_EXPR_H diff --git a/src/dwarf/dwarf_parse.c b/src/dwarf/dwarf_parse.c index a8722d0e..67fd831d 100644 --- a/src/dwarf/dwarf_parse.c +++ b/src/dwarf/dwarf_parse.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal U64 @@ -30,14 +30,14 @@ str8_deserial_read_dwarf_uint(String8 string, U64 off, DW_Format format, U64 *ui { U64 bytes_read = 0; switch (format) { - case DW_Format_Null: break; - case DW_Format_32Bit: { - *uint_out &= (U64)max_U32; - bytes_read = str8_deserial_read(string, off, uint_out, sizeof(U32), sizeof(U32)); - } break; - case DW_Format_64Bit: { - bytes_read = str8_deserial_read_struct(string, off, uint_out); - } break; + case DW_Format_Null: break; + case DW_Format_32Bit: { + *uint_out &= (U64)max_U32; + bytes_read = str8_deserial_read(string, off, uint_out, sizeof(U32), sizeof(U32)); + } break; + case DW_Format_64Bit: { + bytes_read = str8_deserial_read_struct(string, off, uint_out); + } break; } return bytes_read; } @@ -52,18 +52,18 @@ str8_deserial_read_uleb128(String8 string, U64 off, U64 *value_out) { U8 byte = 0; U64 bytes_read = str8_deserial_read_struct(string, cursor, &byte); - + if(bytes_read != sizeof(byte)) { break; } - + U8 val = byte & 0x7fu; value |= ((U64)val) << shift; - + cursor += bytes_read; shift += 7u; - + if((byte & 0x80u) == 0) { break; @@ -91,13 +91,13 @@ str8_deserial_read_sleb128(String8 string, U64 off, S64 *value_out) { break; } - + U8 val = byte & 0x7fu; value |= ((U64)val) << shift; - + cursor += bytes_read; shift += 7u; - + if((byte & 0x80u) == 0) { if(shift < sizeof(value) * 8 && (byte & 0x40u) != 0) @@ -119,7 +119,7 @@ internal U64 str8_deserial_read_uleb128_array(Arena *arena, String8 string, U64 off, U64 count, U64 **arr_out) { Temp temp = temp_begin(arena); - + U64 *arr = push_array(arena, U64, count); U64 i, cursor; for (i = 0, cursor = off; i < count; ++i) { @@ -129,7 +129,7 @@ str8_deserial_read_uleb128_array(Arena *arena, String8 string, U64 off, U64 coun } cursor += read_size; } - + U64 bytes_read = 0; if (i == count) { *arr_out = arr; @@ -138,7 +138,7 @@ str8_deserial_read_uleb128_array(Arena *arena, String8 string, U64 off, U64 coun temp_end(temp); *arr_out = 0; } - + return bytes_read; } @@ -146,7 +146,7 @@ internal U64 str8_deserial_read_sleb128_array(Arena *arena, String8 string, U64 off, U64 count, S64 **arr_out) { Temp temp = temp_begin(arena); - + S64 *arr = push_array(arena, S64, count); U64 i, cursor; for (i = 0, cursor = off; i < count; ++i) { @@ -156,7 +156,7 @@ str8_deserial_read_sleb128_array(Arena *arena, String8 string, U64 off, U64 coun } cursor += read_size; } - + U64 bytes_read = 0; if (i == count) { *arr_out = arr; @@ -165,7 +165,7 @@ str8_deserial_read_sleb128_array(Arena *arena, String8 string, U64 off, U64 coun temp_end(temp); *arr_out = 0; } - + return bytes_read; } @@ -174,8 +174,8 @@ dw_section_kind_from_string(String8 string) { DW_SectionKind s = DW_Section_Null; #define X(_K,_L,_M,_W) \ - if (str8_match_lit(_L, string, 0)) { s = DW_Section_##_K; } \ - if (str8_match_lit(_M, string, 0)) { s = DW_Section_##_K; } +if (str8_match_lit(_L, string, 0)) { s = DW_Section_##_K; } \ +if (str8_match_lit(_M, string, 0)) { s = DW_Section_##_K; } DW_SectionKind_XList(X) #undef X return s; @@ -186,7 +186,7 @@ dw_section_dwo_kind_from_string(String8 string) { DW_SectionKind s = DW_Section_Null; #define X(_K,_L,_M,_W) \ - if (str8_match_lit(_W, string, 0)) { s = DW_Section_##_K; } +if (str8_match_lit(_W, string, 0)) { s = DW_Section_##_K; } DW_SectionKind_XList(X) #undef X return s; @@ -196,27 +196,27 @@ internal Rng1U64List dw_unit_ranges_from_data(Arena *arena, String8 data) { Rng1U64List result = {0}; - + for (U64 cursor = 0; cursor < data.size; ) { // read CU size U64 cu_size = 0; U64 cu_size_size = str8_deserial_read_dwarf_packed_size(data, cursor, &cu_size); - + // was read ok? if (cu_size_size == 0) { break; } - + if (cu_size > 0) { // push unit range rng1u64_list_push(arena, &result, rng_1u64(cursor, cursor+cu_size+cu_size_size)); } - + // advance cursor += cu_size_size; cursor += cu_size; } - + return result; } @@ -224,21 +224,21 @@ internal U64 dw_read_list_unit_header_addr(String8 unit_data, DW_ListUnit *lu_out) { U64 header_size = 0; - + U64 unit_length = 0; U64 unit_length_size = str8_deserial_read_dwarf_packed_size(unit_data, 0, &unit_length); - + if (unit_length_size) { DW_Version version = DW_Version_Null; U64 version_size = str8_deserial_read_struct(unit_data, unit_length_size, &version); - + if (version_size) { if (version >= DW_Version_5) { U8 address_size = 0; U64 address_size_size = str8_deserial_read_struct(unit_data, unit_length_size + version_size, &address_size); - + if (address_size_size && address_size) { U8 segment_selector_size = 0; U64 segment_selector_size_size = str8_deserial_read_struct(unit_data, @@ -246,7 +246,7 @@ dw_read_list_unit_header_addr(String8 unit_data, DW_ListUnit *lu_out) &segment_selector_size); if (segment_selector_size_size) { header_size = unit_length_size + version_size + address_size_size + segment_selector_size_size; - + lu_out->version = version; lu_out->segment_selector_size = segment_selector_size; lu_out->address_size = address_size; @@ -257,7 +257,7 @@ dw_read_list_unit_header_addr(String8 unit_data, DW_ListUnit *lu_out) } } } - + return header_size; } @@ -265,21 +265,21 @@ internal U64 dw_read_list_unit_header_str_offsets(String8 unit_data, DW_ListUnit *lu_out) { U64 header_size = 0; - + U64 unit_length = 0; U64 unit_length_size = str8_deserial_read_dwarf_packed_size(unit_data, 0, &unit_length); - + if (unit_length_size) { DW_Version version = DW_Version_Null; U64 version_size = str8_deserial_read_struct(unit_data, unit_length_size, &version); - + if (version >= DW_Version_5) { U16 padding = 0; U64 padding_size = str8_deserial_read_struct(unit_data, unit_length_size + version_size, &padding); - + if (padding_size && padding == 0) { header_size = unit_length_size + version_size + padding_size; - + lu_out->version = version; lu_out->address_size = 0; lu_out->segment_selector_size = 0; @@ -288,7 +288,7 @@ dw_read_list_unit_header_str_offsets(String8 unit_data, DW_ListUnit *lu_out) } } } - + return header_size; } @@ -296,29 +296,29 @@ internal U64 dw_read_list_unit_header_list(String8 unit_data, DW_ListUnit *lu_out) { U64 header_size = 0; - + U64 unit_length = 0; U64 unit_length_size = str8_deserial_read_dwarf_packed_size(unit_data, 0, &unit_length); - + if (unit_length_size) { DW_Version version = DW_Version_Null; U64 version_size = str8_deserial_read_struct(unit_data, unit_length_size, &version); - + if (version >= DW_Version_5) { U8 address_size = 0; U64 address_size_size = str8_deserial_read_struct(unit_data, unit_length_size + version_size, &address_size); - + if (address_size_size && address_size > 0) { U8 segment_selector_size = 0; U64 segment_selector_size_size = str8_deserial_read_struct(unit_data, unit_length_size + version_size + address_size_size, &segment_selector_size); - + if (segment_selector_size_size) { U32 offset_entry_count = 0; U64 offset_entry_count_size = str8_deserial_read_struct(unit_data, unit_length_size + version_size + address_size_size + segment_selector_size, &offset_entry_count); - + if (offset_entry_count_size) { header_size = unit_length_size + version_size + address_size_size + segment_selector_size_size + offset_entry_count_size; - + lu_out->version = version; lu_out->address_size = address_size; lu_out->segment_selector_size = segment_selector_size; @@ -329,7 +329,7 @@ dw_read_list_unit_header_list(String8 unit_data, DW_ListUnit *lu_out) } } } - + return header_size; } @@ -337,69 +337,69 @@ internal DW_ListUnitInput dw_list_unit_input_from_input(Arena *arena, DW_Input *input) { Temp scratch = scratch_begin(&arena, 1); - + DW_ListUnitInput result = {0}; - + DW_Section debug_addr = input->sec[DW_Section_Addr]; { String8 data = debug_addr.data; Rng1U64List unit_ranges = dw_unit_ranges_from_data(scratch.arena, data); - + result.addr_ranges = rng1u64_array_from_list(arena, &unit_ranges); result.addr_count = unit_ranges.count; result.addrs = push_array(arena, DW_ListUnit, unit_ranges.count); - + for (U64 unit_idx = 0; unit_idx < result.addr_ranges.count; ++unit_idx) { String8 unit_data = str8_substr(debug_addr.data, result.addr_ranges.v[unit_idx]); dw_read_list_unit_header_addr(unit_data, &result.addrs[unit_idx]); } } - + DW_Section debug_str_offsets = input->sec[DW_Section_StrOffsets]; { String8 data = debug_str_offsets.data; Rng1U64List unit_ranges = dw_unit_ranges_from_data(scratch.arena, data); - + result.str_offset_ranges = rng1u64_array_from_list(arena, &unit_ranges); result.str_offset_count = unit_ranges.count; result.str_offsets = push_array(arena, DW_ListUnit, unit_ranges.count); - + for (U64 unit_idx = 0; unit_idx < result.str_offset_ranges.count; ++unit_idx) { String8 unit_data = str8_substr(data, result.str_offset_ranges.v[unit_idx]); dw_read_list_unit_header_str_offsets(unit_data, &result.str_offsets[unit_idx]); } } - + DW_Section debug_rnglists = input->sec[DW_Section_RngLists]; { String8 data = debug_rnglists.data; Rng1U64List unit_ranges = dw_unit_ranges_from_data(scratch.arena, data); - + result.rnglist_ranges = rng1u64_array_from_list(arena, &unit_ranges); result.rnglist_count = unit_ranges.count; result.rnglists = push_array(arena, DW_ListUnit, unit_ranges.count); - + for (U64 unit_idx = 0; unit_idx < result.rnglist_ranges.count; ++unit_idx) { String8 unit_data = str8_substr(data, result.rnglist_ranges.v[unit_idx]); dw_read_list_unit_header_list(unit_data, &result.rnglists[unit_idx]); } } - + DW_Section debug_loclists = input->sec[DW_Section_LocLists]; { String8 data = debug_loclists.data; Rng1U64List unit_ranges = dw_unit_ranges_from_data(scratch.arena, data); - + result.loclist_ranges = rng1u64_array_from_list(arena, &unit_ranges); result.loclist_count = unit_ranges.count; result.loclists = push_array(arena, DW_ListUnit, unit_ranges.count); - + for (U64 unit_idx = 0; unit_idx < result.loclist_ranges.count; ++unit_idx) { String8 unit_data = str8_substr(data, result.loclist_ranges.v[unit_idx]); dw_read_list_unit_header_list(unit_data, &result.loclists[unit_idx]); } } - + scratch_end(scratch); return result; } @@ -570,12 +570,12 @@ dw_make_abbrev_table(Arena *arena, String8 abbrev_data, U64 abbrev_offset) table.count = tag_count; table.entries = push_array(arena, DW_AbbrevTableEntry, table.count); MemorySet(table.entries, 0, sizeof(DW_AbbrevTableEntry)*table.count); - + U64 tag_idx = 0; for(U64 abbrev_read_off = abbrev_offset;;) { U64 tag_abbrev_off = abbrev_read_off; - + DW_Abbrev tag; { U64 bytes_read = dw_read_abbrev_tag(abbrev_data, abbrev_read_off, &tag); @@ -643,178 +643,178 @@ dw_read_form(String8 data, DW_Form form = {0}; switch (form_kind) { - case DW_Form_Null: break; - - case DW_Form_Addr: { - bytes_read = str8_deserial_read_block(data, off, address_size, &form.addr); - } break; - case DW_Form_Block2: { - U16 size = 0; - U64 size_size = str8_deserial_read_struct(data, off, &size); - if (size_size) { - U64 block_size = str8_deserial_read_block(data, off + size_size, size, &form.block); - if (block_size) { - bytes_read = size_size + block_size; + case DW_Form_Null: break; + + case DW_Form_Addr: { + bytes_read = str8_deserial_read_block(data, off, address_size, &form.addr); + } break; + case DW_Form_Block2: { + U16 size = 0; + U64 size_size = str8_deserial_read_struct(data, off, &size); + if (size_size) { + U64 block_size = str8_deserial_read_block(data, off + size_size, size, &form.block); + if (block_size) { + bytes_read = size_size + block_size; + } } - } - } break; - case DW_Form_Block4: { - U32 size = 0; - U64 size_size = str8_deserial_read_struct(data, off, &size); - if (size_size) { - U64 block_size = str8_deserial_read_block(data, off + size_size, size, &form.block); - if (block_size) { - bytes_read = size_size + block_size; + } break; + case DW_Form_Block4: { + U32 size = 0; + U64 size_size = str8_deserial_read_struct(data, off, &size); + if (size_size) { + U64 block_size = str8_deserial_read_block(data, off + size_size, size, &form.block); + if (block_size) { + bytes_read = size_size + block_size; + } } - } - } break; - case DW_Form_Data2: { - bytes_read = str8_deserial_read_block(data, off, sizeof(U16), &form.data); - } break; - case DW_Form_Data4: { - bytes_read = str8_deserial_read_block(data, off, sizeof(U32), &form.data); - } break; - case DW_Form_Data8: { - bytes_read = str8_deserial_read_block(data, off, sizeof(U64), &form.data); - } break; - case DW_Form_String: { - bytes_read = str8_deserial_read_cstr(data, off, &form.string); - } break; - case DW_Form_Block: { - U64 size = 0; - U64 size_size = str8_deserial_read_uleb128(data, off, &size); - if (size_size) { - U64 block_size = str8_deserial_read_block(data, off + size_size, size, &form.block); - if (block_size) { - bytes_read = size_size + block_size; + } break; + case DW_Form_Data2: { + bytes_read = str8_deserial_read_block(data, off, sizeof(U16), &form.data); + } break; + case DW_Form_Data4: { + bytes_read = str8_deserial_read_block(data, off, sizeof(U32), &form.data); + } break; + case DW_Form_Data8: { + bytes_read = str8_deserial_read_block(data, off, sizeof(U64), &form.data); + } break; + case DW_Form_String: { + bytes_read = str8_deserial_read_cstr(data, off, &form.string); + } break; + case DW_Form_Block: { + U64 size = 0; + U64 size_size = str8_deserial_read_uleb128(data, off, &size); + if (size_size) { + U64 block_size = str8_deserial_read_block(data, off + size_size, size, &form.block); + if (block_size) { + bytes_read = size_size + block_size; + } } - } - } break; - case DW_Form_Block1: { - U8 size = 0; - U64 size_size = str8_deserial_read_struct(data, off, &size); - if (size_size) { - U64 block_size = str8_deserial_read_block(data, off, size, &form.block); - if (block_size == size) { - bytes_read = size_size + block_size; + } break; + case DW_Form_Block1: { + U8 size = 0; + U64 size_size = str8_deserial_read_struct(data, off, &size); + if (size_size) { + U64 block_size = str8_deserial_read_block(data, off, size, &form.block); + if (block_size == size) { + bytes_read = size_size + block_size; + } } - } - } break; - case DW_Form_Data1: { - bytes_read = str8_deserial_read_block(data, off, sizeof(U8), &form.data); - } break; - case DW_Form_Flag: { - bytes_read = str8_deserial_read_struct(data, off, &form.flag); - } break; - case DW_Form_SData: { - bytes_read = str8_deserial_read_sleb128(data, off, &form.sdata); - } break; - case DW_Form_UData: { - bytes_read = str8_deserial_read_uleb128(data, off, &form.udata); - } break; - case DW_Form_RefAddr: { - if (version < DW_Version_3) { - bytes_read = str8_deserial_read(data, off, &form.ref, address_size, address_size); - } else { + } break; + case DW_Form_Data1: { + bytes_read = str8_deserial_read_block(data, off, sizeof(U8), &form.data); + } break; + case DW_Form_Flag: { + bytes_read = str8_deserial_read_struct(data, off, &form.flag); + } break; + case DW_Form_SData: { + bytes_read = str8_deserial_read_sleb128(data, off, &form.sdata); + } break; + case DW_Form_UData: { + bytes_read = str8_deserial_read_uleb128(data, off, &form.udata); + } break; + case DW_Form_RefAddr: { + if (version < DW_Version_3) { + bytes_read = str8_deserial_read(data, off, &form.ref, address_size, address_size); + } else { + bytes_read = str8_deserial_read_dwarf_uint(data, off, unit_format, &form.ref); + } + } break; + case DW_Form_GNU_RefAlt: { bytes_read = str8_deserial_read_dwarf_uint(data, off, unit_format, &form.ref); - } - } break; - case DW_Form_GNU_RefAlt: { - bytes_read = str8_deserial_read_dwarf_uint(data, off, unit_format, &form.ref); - } break; - case DW_Form_Ref1: { - bytes_read = str8_deserial_read(data, off, &form.ref, 1, 1); - } break; - case DW_Form_Ref2: { - bytes_read = str8_deserial_read(data, off, &form.ref, 2, 2); - } break; - case DW_Form_Ref4: { - bytes_read = str8_deserial_read(data, off, &form.ref, 4, 4); - } break; - case DW_Form_Ref8: { - bytes_read = str8_deserial_read(data, off, &form.ref, 8, 8); - } break; - case DW_Form_RefUData: { - bytes_read = str8_deserial_read_uleb128(data, off, &form.ref); - } break; - case DW_Form_SecOffset: - case DW_Form_LineStrp: - case DW_Form_GNU_StrpAlt: - case DW_Form_Strp: { - bytes_read = str8_deserial_read_dwarf_uint(data, off, unit_format, &form.sec_offset); - } break; - case DW_Form_ExprLoc: { - U64 expr_size = 0; - U64 expr_size_size = str8_deserial_read_uleb128(data, off, &expr_size); - if (expr_size_size) { - if (str8_deserial_read_block(data, off + expr_size_size, expr_size, &form.exprloc)) { - bytes_read = expr_size_size + expr_size; + } break; + case DW_Form_Ref1: { + bytes_read = str8_deserial_read(data, off, &form.ref, 1, 1); + } break; + case DW_Form_Ref2: { + bytes_read = str8_deserial_read(data, off, &form.ref, 2, 2); + } break; + case DW_Form_Ref4: { + bytes_read = str8_deserial_read(data, off, &form.ref, 4, 4); + } break; + case DW_Form_Ref8: { + bytes_read = str8_deserial_read(data, off, &form.ref, 8, 8); + } break; + case DW_Form_RefUData: { + bytes_read = str8_deserial_read_uleb128(data, off, &form.ref); + } break; + case DW_Form_SecOffset: + case DW_Form_LineStrp: + case DW_Form_GNU_StrpAlt: + case DW_Form_Strp: { + bytes_read = str8_deserial_read_dwarf_uint(data, off, unit_format, &form.sec_offset); + } break; + case DW_Form_ExprLoc: { + U64 expr_size = 0; + U64 expr_size_size = str8_deserial_read_uleb128(data, off, &expr_size); + if (expr_size_size) { + if (str8_deserial_read_block(data, off + expr_size_size, expr_size, &form.exprloc)) { + bytes_read = expr_size_size + expr_size; + } } - } - } break; - case DW_Form_FlagPresent: { - form.flag = 1; - } break; - case DW_Form_RefSig8: { - //U64 ref = 0; - //bytes_read = str8_deserial_read_struct(data, off, &ref); - NotImplemented; - } break; - case DW_Form_Addrx: - case DW_Form_RngListx: - case DW_Form_Strx: { - bytes_read = str8_deserial_read_uleb128(data, off, &form.xval); - } break; - case DW_Form_RefSup4: { - //U32 ref_sup4 = 0; - //bytes_read = str8_deserial_read_struct(data, off, &ref_sup4); - NotImplemented; - } break; - case DW_Form_StrpSup: { - bytes_read = str8_deserial_read_dwarf_uint(data, off, unit_format, &form.strp_sup); - } break; - case DW_Form_Data16: { - bytes_read = str8_deserial_read_block(data, off, 16, &form.data); - } break; - case DW_Form_ImplicitConst: { - // Special case. - // Unlike other forms that have their values stored in the .debug_info section, - // This one defines it's value in the .debug_abbrev section. - form.implicit_const = implicit_const; - } break; - case DW_Form_LocListx: { + } break; + case DW_Form_FlagPresent: { + form.flag = 1; + } break; + case DW_Form_RefSig8: { + //U64 ref = 0; + //bytes_read = str8_deserial_read_struct(data, off, &ref); + NotImplemented; + } break; + case DW_Form_Addrx: + case DW_Form_RngListx: + case DW_Form_Strx: { bytes_read = str8_deserial_read_uleb128(data, off, &form.xval); - } break; - case DW_Form_RefSup8: { - NotImplemented; - } break; - case DW_Form_Strx1: { - bytes_read = str8_deserial_read(data, off, &form.xval, 1, 1); - } break; - case DW_Form_Strx2: { - bytes_read = str8_deserial_read(data, off, &form.xval, 2, 2); - } break; - case DW_Form_Strx3: { - bytes_read = str8_deserial_read(data, off, &form.xval, 3, 3); - } break; - case DW_Form_Strx4: { - bytes_read = str8_deserial_read(data, off, &form.xval, 4, 4); - } break; - case DW_Form_Addrx1: { - bytes_read = str8_deserial_read(data, off, &form.xval, 1, 1); - } break; - case DW_Form_Addrx2: { - bytes_read = str8_deserial_read(data, off, &form.xval, 2, 2); - } break; - case DW_Form_Addrx3: { - bytes_read = str8_deserial_read(data, off, &form.xval, 3, 3); - } break; - case DW_Form_Addrx4: { - bytes_read = str8_deserial_read(data, off, &form.xval, 4, 4); - } break; - default: InvalidPath; break; + } break; + case DW_Form_RefSup4: { + //U32 ref_sup4 = 0; + //bytes_read = str8_deserial_read_struct(data, off, &ref_sup4); + NotImplemented; + } break; + case DW_Form_StrpSup: { + bytes_read = str8_deserial_read_dwarf_uint(data, off, unit_format, &form.strp_sup); + } break; + case DW_Form_Data16: { + bytes_read = str8_deserial_read_block(data, off, 16, &form.data); + } break; + case DW_Form_ImplicitConst: { + // Special case. + // Unlike other forms that have their values stored in the .debug_info section, + // This one defines it's value in the .debug_abbrev section. + form.implicit_const = implicit_const; + } break; + case DW_Form_LocListx: { + bytes_read = str8_deserial_read_uleb128(data, off, &form.xval); + } break; + case DW_Form_RefSup8: { + NotImplemented; + } break; + case DW_Form_Strx1: { + bytes_read = str8_deserial_read(data, off, &form.xval, 1, 1); + } break; + case DW_Form_Strx2: { + bytes_read = str8_deserial_read(data, off, &form.xval, 2, 2); + } break; + case DW_Form_Strx3: { + bytes_read = str8_deserial_read(data, off, &form.xval, 3, 3); + } break; + case DW_Form_Strx4: { + bytes_read = str8_deserial_read(data, off, &form.xval, 4, 4); + } break; + case DW_Form_Addrx1: { + bytes_read = str8_deserial_read(data, off, &form.xval, 1, 1); + } break; + case DW_Form_Addrx2: { + bytes_read = str8_deserial_read(data, off, &form.xval, 2, 2); + } break; + case DW_Form_Addrx3: { + bytes_read = str8_deserial_read(data, off, &form.xval, 3, 3); + } break; + case DW_Form_Addrx4: { + bytes_read = str8_deserial_read(data, off, &form.xval, 4, 4); + } break; + default: InvalidPath; break; } - + if (form_out) { *form_out = form; } @@ -835,53 +835,53 @@ dw_read_tag(Arena *arena, DW_Tag *tag_out) { U64 tag_cursor = tag_off; - + // read tag abbrev id U64 tag_abbrev_id = 0; U64 tag_abbrev_id_size = str8_deserial_read_uleb128(tag_data, tag_cursor, &tag_abbrev_id); Assert(tag_abbrev_id_size); tag_cursor += tag_abbrev_id_size; - + // read tag abbrev U64 abbrev_cursor = dw_abbrev_offset_from_abbrev_id(abbrev_table, tag_abbrev_id); DW_Abbrev tag_abbrev = {0}; U64 tag_abbrev_size = dw_read_abbrev_tag(abbrev_data, abbrev_cursor, &tag_abbrev); - + // read attribs DW_AttribList attribs = {0}; if (tag_abbrev_size > 0) { abbrev_cursor += tag_abbrev_size; - + for (; tag_cursor < tag_data.size && abbrev_cursor < abbrev_data.size; ) { U64 attrib_tag_cursor = tag_cursor; U64 attrib_abbrev_off = abbrev_cursor; - + // read attrib abbrev DW_Abbrev attrib_abbrev = {0}; abbrev_cursor += dw_read_abbrev_attrib(abbrev_data, abbrev_cursor, &attrib_abbrev); if (attrib_abbrev.id == 0) { break; } - + DW_AttribKind attrib_kind = (DW_AttribKind)attrib_abbrev.id; DW_FormKind form_kind = (DW_FormKind)attrib_abbrev.sub_kind; - + // special case, allows producer to embed form in .debug_info if (form_kind == DW_Form_Indirect) { U64 form_kind_size = str8_deserial_read_uleb128(tag_data, tag_cursor, &form_kind); - + if (form_kind_size == 0) { Assert(!"unable to read indirect form kind"); break; } - + tag_cursor += form_kind_size; } - + // read form value DW_Form form = {0}; tag_cursor += dw_read_form(tag_data, tag_cursor, version, unit_format, address_size, form_kind, attrib_abbrev.const_value, &form); - + // fill out node DW_AttribNode *attrib_n = push_array(arena, DW_AttribNode, 1); attrib_n->v.info_off = tag_base + attrib_tag_cursor; @@ -890,20 +890,20 @@ dw_read_tag(Arena *arena, attrib_n->v.attrib_kind = attrib_kind; attrib_n->v.form_kind = form_kind; attrib_n->v.form = form; - + // push node to list SLLQueuePush(attribs.first, attribs.last, attrib_n); ++attribs.count; } } - + // fill out tag tag_out->abbrev_id = tag_abbrev_id; tag_out->has_children = !!(tag_abbrev.flags & DW_AbbrevFlag_HasChildren); tag_out->kind = (DW_TagKind)tag_abbrev.sub_kind; tag_out->attribs = attribs; tag_out->info_off = tag_base + tag_off; - + U64 bytes_read = tag_cursor - tag_off; return bytes_read; } @@ -1156,7 +1156,7 @@ internal DW_LocList dw_interp_loclist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form) { DW_LocList loclist = {0}; - + if (cu->version < DW_Version_5) { if (form_kind == DW_Form_SecOffset) { U64 sec_offset = max_U64; @@ -1170,7 +1170,7 @@ dw_interp_loclist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind fo } else if (form_kind == DW_Form_Null) { Assert(!"unexpected form"); } - + String8 sec = str8_skip(input->sec[DW_Section_Loc].data, sec_offset); U64 base_addr = cu->low_pc; U64 base_sel = DW_SentinelFromSize(cu->address_size); @@ -1188,7 +1188,7 @@ dw_interp_loclist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind fo break; } cursor += cu->address_size * 2; - + // series terminator if (range_min == 0 && range_max == 0) { break; @@ -1206,17 +1206,17 @@ dw_interp_loclist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind fo break; } cursor += expr_size_size; - + Assert(cursor + expr_size <= sec.size); Rng1U64 expr_range = rng_1u64(cursor, ClampTop(cursor + expr_size, sec.size)); - + DW_LocNode *loc_n = push_array(arena, DW_LocNode, 1); loc_n->v.range = rng_1u64(base_addr + range_min, base_addr + range_max); loc_n->v.expr = str8_substr(sec, expr_range); - + SLLQueuePush(loclist.first, loclist.last, loc_n); ++loclist.count; - + // advance past expression cursor += expr_size; } @@ -1239,162 +1239,162 @@ dw_interp_loclist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind fo } else if (form_kind != DW_Form_Null) { AssertAlways(!"unexpected form"); } - + for (U64 cursor = 0, keep_parsing = 1, base_addr = cu->low_pc; cursor < raw_lle.size && keep_parsing; ) { DW_LLE kind = DW_LLE_EndOfList; cursor += str8_deserial_read_struct(raw_lle, cursor, &kind); - + Rng1U64 range = {0}; switch (kind) { - default: + default: Assert(!"unknown kind"); - case DW_LLE_EndOfList: { - keep_parsing = 0; - } break; - case DW_LLE_BaseAddressx: { - if (!cu->addr_lu) { + case DW_LLE_EndOfList: { keep_parsing = 0; - break; - } - - U64 addrx = 0; - U64 addrx_size = str8_deserial_read_uleb128(raw_lle, cursor, &addrx); - if (addrx_size == 0) { - keep_parsing = 0; - break; - } - - U64 base_addr_new = dw_addr_from_list_unit(cu->addr_lu, addrx); - if (base_addr_new == max_U64) { - InvalidPath; - break; - } - - base_addr = base_addr_new; - cursor += addrx_size; - } break; - case DW_LLE_StartxEndx: { - U64 start_addrx = 0; - U64 start_addrx_size = str8_deserial_read_uleb128(raw_lle, cursor, &start_addrx); - if (start_addrx_size == 0) { - keep_parsing = 0; - break; - } - U64 end_addrx = 0; - U64 end_addrx_size = str8_deserial_read_uleb128(raw_lle, cursor + start_addrx_size, &end_addrx); - if (end_addrx_size == 0) { - keep_parsing = 0; - break; - } - cursor += start_addrx_size; - cursor += end_addrx_size; - - U64 start = dw_addr_from_list_unit(cu->addr_lu, start_addrx); - U64 end = dw_addr_from_list_unit(cu->addr_lu, end_addrx); - Assert(start != max_U64); - Assert(end != max_U64); - - range = rng_1u64(start, end); - } break; - case DW_LLE_StartxLength: { - U64 start_addrx = 0; - U64 start_addrx_size = str8_deserial_read_uleb128(raw_lle, cursor, &start_addrx); - if (start_addrx_size == 0) { - keep_parsing = 0; - break; - } - - // parse pre-standard & standard length - U64 length_off = cursor + start_addrx_size; - U64 length = 0; - U64 length_size = str8_deserial_read_uleb128(raw_lle, length_off, &length); - if (length_size == 0) { - keep_parsing = 0; - break; - } - - cursor += start_addrx_size; - cursor += length_size; - - if (cu->addr_lu) { + } break; + case DW_LLE_BaseAddressx: { + if (!cu->addr_lu) { + keep_parsing = 0; + break; + } + + U64 addrx = 0; + U64 addrx_size = str8_deserial_read_uleb128(raw_lle, cursor, &addrx); + if (addrx_size == 0) { + keep_parsing = 0; + break; + } + + U64 base_addr_new = dw_addr_from_list_unit(cu->addr_lu, addrx); + if (base_addr_new == max_U64) { + InvalidPath; + break; + } + + base_addr = base_addr_new; + cursor += addrx_size; + } break; + case DW_LLE_StartxEndx: { + U64 start_addrx = 0; + U64 start_addrx_size = str8_deserial_read_uleb128(raw_lle, cursor, &start_addrx); + if (start_addrx_size == 0) { + keep_parsing = 0; + break; + } + U64 end_addrx = 0; + U64 end_addrx_size = str8_deserial_read_uleb128(raw_lle, cursor + start_addrx_size, &end_addrx); + if (end_addrx_size == 0) { + keep_parsing = 0; + break; + } + cursor += start_addrx_size; + cursor += end_addrx_size; + U64 start = dw_addr_from_list_unit(cu->addr_lu, start_addrx); - Assert(start < max_U64); - + U64 end = dw_addr_from_list_unit(cu->addr_lu, end_addrx); + Assert(start != max_U64); + Assert(end != max_U64); + + range = rng_1u64(start, end); + } break; + case DW_LLE_StartxLength: { + U64 start_addrx = 0; + U64 start_addrx_size = str8_deserial_read_uleb128(raw_lle, cursor, &start_addrx); + if (start_addrx_size == 0) { + keep_parsing = 0; + break; + } + + // parse pre-standard & standard length + U64 length_off = cursor + start_addrx_size; + U64 length = 0; + U64 length_size = str8_deserial_read_uleb128(raw_lle, length_off, &length); + if (length_size == 0) { + keep_parsing = 0; + break; + } + + cursor += start_addrx_size; + cursor += length_size; + + if (cu->addr_lu) { + U64 start = dw_addr_from_list_unit(cu->addr_lu, start_addrx); + Assert(start < max_U64); + + range = rng_1u64(start, start + length); + } else { + Assert(!".debug_addr section is missing -- unable to interpret address index"); + } + } break; + case DW_LLE_OffsetPair: { + U64 start = 0; + U64 start_size = str8_deserial_read_uleb128(raw_lle, cursor, &start); + if (start_size == 0) { + keep_parsing = 0; + break; + } + U64 end = 0; + U64 end_size = str8_deserial_read_uleb128(raw_lle, cursor + start_size, &end); + if (end_size == 0) { + keep_parsing = 0; + break; + } + cursor += start_size; + cursor += end_size; + + range = rng_1u64(base_addr + start, base_addr + end); + } break; + case DW_LLE_DefaultLocation: { + // no range + int x = 0; + } break; + case DW_LLE_BaseAddress: { + U64 base_addr_size = str8_deserial_read(raw_lle, cursor, &base_addr, cu->address_size, cu->address_size); + if (base_addr_size == 0) { + keep_parsing = 0; + break; + } + cursor += base_addr_size; + } break; + case DW_LLE_StartEnd: { + U64 start = 0; + U64 start_size = str8_deserial_read(raw_lle, cursor, &start, cu->address_size, cu->address_size); + if (start_size == 0) { + keep_parsing = 0; + break; + } + + U64 end = 0; + U64 end_size = str8_deserial_read(raw_lle, cursor + start_size, &end, cu->address_size, cu->address_size); + if (end_size == 0) { + keep_parsing = 0; + break; + } + cursor += start_size; + cursor += end_size; + + range = rng_1u64(start, end); + } break; + case DW_LLE_StartLength: { + U64 start = 0; + U64 start_size = str8_deserial_read(raw_lle, cursor, &start, cu->address_size, cu->address_size); + if (start_size == 0) { + keep_parsing = 0; + break; + } + U64 length = 0; + U64 length_size = str8_deserial_read_uleb128(raw_lle, cursor + start_size, &length); + if (length_size == 0) { + keep_parsing = 0; + break; + } + cursor += start_size; + cursor += length_size; + range = rng_1u64(start, start + length); - } else { - Assert(!".debug_addr section is missing -- unable to interpret address index"); - } - } break; - case DW_LLE_OffsetPair: { - U64 start = 0; - U64 start_size = str8_deserial_read_uleb128(raw_lle, cursor, &start); - if (start_size == 0) { - keep_parsing = 0; - break; - } - U64 end = 0; - U64 end_size = str8_deserial_read_uleb128(raw_lle, cursor + start_size, &end); - if (end_size == 0) { - keep_parsing = 0; - break; - } - cursor += start_size; - cursor += end_size; - - range = rng_1u64(base_addr + start, base_addr + end); - } break; - case DW_LLE_DefaultLocation: { - // no range - int x = 0; - } break; - case DW_LLE_BaseAddress: { - U64 base_addr_size = str8_deserial_read(raw_lle, cursor, &base_addr, cu->address_size, cu->address_size); - if (base_addr_size == 0) { - keep_parsing = 0; - break; - } - cursor += base_addr_size; - } break; - case DW_LLE_StartEnd: { - U64 start = 0; - U64 start_size = str8_deserial_read(raw_lle, cursor, &start, cu->address_size, cu->address_size); - if (start_size == 0) { - keep_parsing = 0; - break; - } - - U64 end = 0; - U64 end_size = str8_deserial_read(raw_lle, cursor + start_size, &end, cu->address_size, cu->address_size); - if (end_size == 0) { - keep_parsing = 0; - break; - } - cursor += start_size; - cursor += end_size; - - range = rng_1u64(start, end); - } break; - case DW_LLE_StartLength: { - U64 start = 0; - U64 start_size = str8_deserial_read(raw_lle, cursor, &start, cu->address_size, cu->address_size); - if (start_size == 0) { - keep_parsing = 0; - break; - } - U64 length = 0; - U64 length_size = str8_deserial_read_uleb128(raw_lle, cursor + start_size, &length); - if (length_size == 0) { - keep_parsing = 0; - break; - } - cursor += start_size; - cursor += length_size; - - range = rng_1u64(start, start + length); - } break; + } break; } - + B32 has_expr = keep_parsing && kind != DW_LLE_BaseAddressx && kind != DW_LLE_BaseAddress; if (has_expr) { U64 expr_size = 0; @@ -1403,27 +1403,27 @@ dw_interp_loclist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind fo keep_parsing = 0; break; } - + String8 expr = {0}; U64 expr_read_size = str8_deserial_read_block(raw_lle, cursor + expr_size_size, expr_size, &expr); if (expr_read_size != expr_size) { keep_parsing = 0; break; } - + cursor += expr_size_size; cursor += expr_size; - + DW_LocNode *loc_n = push_array(arena, DW_LocNode, 1); loc_n->v.range = range; loc_n->v.expr = expr; - + SLLQueuePush(loclist.first, loclist.last, loc_n); ++loclist.count; } } } - + return loclist; } @@ -1443,7 +1443,7 @@ internal Rng1U64List dw_interp_rnglist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form) { Rng1U64List rnglist = {0}; - + if (cu->version < DW_Version_5) { // decode section offset U64 sec_offset = max_U64; @@ -1457,7 +1457,7 @@ dw_interp_rnglist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind fo } else if (form_kind != DW_Form_Null) { Assert(!"unexpected form"); } - + String8 sec = str8_skip(input->sec[DW_Section_Ranges].data, sec_offset); U64 base_addr = cu->low_pc; U64 base_sel = DW_SentinelFromSize(cu->address_size); @@ -1475,7 +1475,7 @@ dw_interp_rnglist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind fo break; } cursor += cu->address_size * 2; - + // series terminator if (range_min == 0 && range_max == 0) { break; @@ -1503,130 +1503,130 @@ dw_interp_rnglist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind fo } else if (form_kind != DW_Form_Null) { AssertAlways(!"unexpected form"); } - + U64 rle_invalid_value = DW_SentinelFromSize(cu->address_size); U64 base_addr = cu->low_pc; for (U64 cursor = 0, keep_parsing = 1; cursor < raw_rle.size && keep_parsing; ) { DW_RLE kind = DW_RLE_EndOfList; cursor += str8_deserial_read_struct(raw_rle, cursor, &kind); - + Rng1U64 range = rng_1u64(rle_invalid_value, rle_invalid_value); switch (kind) { - default: - case DW_RLE_EndOfList: { - keep_parsing = 0; - } break; - case DW_RLE_BaseAddressx: { - U64 addrx = 0; - U64 addrx_size = str8_deserial_read_uleb128(raw_rle, cursor, &addrx); - if (addrx_size == 0) { + default: + case DW_RLE_EndOfList: { keep_parsing = 0; - break; - } - if (cu->addr_lu == 0) { - keep_parsing = 0; - break; - } - U64 base_addr_new = dw_addr_from_list_unit(cu->addr_lu, addrx); - if (base_addr_new < max_U64) { - base_addr = base_addr_new; - cursor += addrx_size; - } else { - keep_parsing = 0; - Assert(!"invalid addrx"); - } - } break; - case DW_RLE_StartxLength: { - U64 start_addrx = 0; - U64 start_addrx_size = str8_deserial_read_uleb128(raw_rle, cursor, &start_addrx); - if (start_addrx_size == 0) { - keep_parsing = 0; - break; - } - U64 length = 0; - U64 length_size = str8_deserial_read_uleb128(raw_rle, cursor + start_addrx_size, &length); - if (length_size == 0) { - keep_parsing = 0; - break; - } - cursor += start_addrx_size; - cursor += length_size; - - if (cu->addr_lu) { - U64 start = dw_addr_from_list_unit(cu->addr_lu, start_addrx); - AssertAlways(start < max_U64); + } break; + case DW_RLE_BaseAddressx: { + U64 addrx = 0; + U64 addrx_size = str8_deserial_read_uleb128(raw_rle, cursor, &addrx); + if (addrx_size == 0) { + keep_parsing = 0; + break; + } + if (cu->addr_lu == 0) { + keep_parsing = 0; + break; + } + U64 base_addr_new = dw_addr_from_list_unit(cu->addr_lu, addrx); + if (base_addr_new < max_U64) { + base_addr = base_addr_new; + cursor += addrx_size; + } else { + keep_parsing = 0; + Assert(!"invalid addrx"); + } + } break; + case DW_RLE_StartxLength: { + U64 start_addrx = 0; + U64 start_addrx_size = str8_deserial_read_uleb128(raw_rle, cursor, &start_addrx); + if (start_addrx_size == 0) { + keep_parsing = 0; + break; + } + U64 length = 0; + U64 length_size = str8_deserial_read_uleb128(raw_rle, cursor + start_addrx_size, &length); + if (length_size == 0) { + keep_parsing = 0; + break; + } + cursor += start_addrx_size; + cursor += length_size; + + if (cu->addr_lu) { + U64 start = dw_addr_from_list_unit(cu->addr_lu, start_addrx); + AssertAlways(start < max_U64); + range = rng_1u64(start, start + length); + } + } break; + case DW_RLE_OffsetPair: { + U64 offset_start, offset_end = 0; + U64 offset_start_size = str8_deserial_read_uleb128(raw_rle, cursor, &offset_start); + if (offset_start_size == 0) { + keep_parsing = 0; + break; + } + U64 offset_end_size = str8_deserial_read_uleb128(raw_rle, cursor + offset_start_size, &offset_end); + if (offset_end_size == 0) { + keep_parsing = 0; + break; + } + cursor += offset_start_size; + cursor += offset_end_size; + + range = rng_1u64(base_addr + offset_start, base_addr + offset_end); + } break; + case DW_RLE_BaseAddress: { + U64 base_addr_size = str8_deserial_read(raw_rle, cursor, &base_addr, cu->address_size, cu->address_size); + if (base_addr_size == 0) { + keep_parsing = 0; + break; + } + cursor += base_addr_size; + } break; + case DW_RLE_StartEnd: { + U64 start = 0, end = 0; + + U64 start_size = str8_deserial_read(raw_rle, cursor, &start, cu->address_size, cu->address_size); + if (start_size == 0) { + keep_parsing = 0; + break; + } + U64 end_size = str8_deserial_read(raw_rle, cursor + start_size, &end, cu->address_size, cu->address_size); + if (end_size == 0) { + keep_parsing = 0; + break; + } + cursor += start_size; + cursor += end_size; + + range = rng_1u64(start, end); + } break; + case DW_RLE_StartLength: { + U64 start = 0, length = 0; + + U64 start_size = str8_deserial_read(raw_rle, cursor, &start, cu->address_size, cu->address_size); + if (start_size == 0) { + keep_parsing = 0; + break; + } + U64 length_size = str8_deserial_read_uleb128(raw_rle, cursor + start_size, &length); + if (length_size == 0) { + keep_parsing = 0; + break; + } + cursor += start_size; + cursor += length_size; + range = rng_1u64(start, start + length); - } - } break; - case DW_RLE_OffsetPair: { - U64 offset_start, offset_end = 0; - U64 offset_start_size = str8_deserial_read_uleb128(raw_rle, cursor, &offset_start); - if (offset_start_size == 0) { - keep_parsing = 0; - break; - } - U64 offset_end_size = str8_deserial_read_uleb128(raw_rle, cursor + offset_start_size, &offset_end); - if (offset_end_size == 0) { - keep_parsing = 0; - break; - } - cursor += offset_start_size; - cursor += offset_end_size; - - range = rng_1u64(base_addr + offset_start, base_addr + offset_end); - } break; - case DW_RLE_BaseAddress: { - U64 base_addr_size = str8_deserial_read(raw_rle, cursor, &base_addr, cu->address_size, cu->address_size); - if (base_addr_size == 0) { - keep_parsing = 0; - break; - } - cursor += base_addr_size; - } break; - case DW_RLE_StartEnd: { - U64 start = 0, end = 0; - - U64 start_size = str8_deserial_read(raw_rle, cursor, &start, cu->address_size, cu->address_size); - if (start_size == 0) { - keep_parsing = 0; - break; - } - U64 end_size = str8_deserial_read(raw_rle, cursor + start_size, &end, cu->address_size, cu->address_size); - if (end_size == 0) { - keep_parsing = 0; - break; - } - cursor += start_size; - cursor += end_size; - - range = rng_1u64(start, end); - } break; - case DW_RLE_StartLength: { - U64 start = 0, length = 0; - - U64 start_size = str8_deserial_read(raw_rle, cursor, &start, cu->address_size, cu->address_size); - if (start_size == 0) { - keep_parsing = 0; - break; - } - U64 length_size = str8_deserial_read_uleb128(raw_rle, cursor + start_size, &length); - if (length_size == 0) { - keep_parsing = 0; - break; - } - cursor += start_size; - cursor += length_size; - - range = rng_1u64(start, start + length); - } break; + } break; } - + if (range.min != rle_invalid_value) { rng1u64_list_push(arena, &rnglist, range); } } } - + return rnglist; } @@ -1740,15 +1740,15 @@ dw_address_from_attrib_ptr(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) DW_FormKind form_kind = attrib->form_kind; DW_Form form = attrib->form; if (value_class == DW_AttribClass_AddrPtr) { - + if (attrib->form_kind == DW_Form_SecOffset) { - + } else { AssertAlways(!"unexpected form"); } - - + + form_kind = DW_Form_Addr; form.addr = dw_interp_addrptr(input, attrib->form_kind, attrib->form); } @@ -1836,7 +1836,7 @@ internal DW_Attrib * dw_attrib_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { DW_Attrib *attrib = dw_attrib_from_tag_(tag, kind); - + if (attrib->attrib_kind == DW_Attrib_Null) { if (cu && cu->tag_ht) { DW_Attrib *ao_attrib = dw_attrib_from_tag_(tag, DW_Attrib_AbstractOrigin); @@ -1847,7 +1847,7 @@ dw_attrib_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind k } } } - + return attrib; } @@ -1942,11 +1942,11 @@ dw_try_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, U64 *byt { B32 has_byte_size = dw_tag_has_attrib(input, cu, tag, DW_Attrib_ByteSize); B32 has_bit_size = dw_tag_has_attrib(input, cu, tag, DW_Attrib_BitSize ); - + if (has_byte_size && has_bit_size) { Assert(!"ill formated byte size"); } - + if (has_byte_size) { *byte_size_out = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_ByteSize); return 1; @@ -1955,7 +1955,7 @@ dw_try_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, U64 *byt *byte_size_out = bit_size / 8; return 1; } - + return 0; } @@ -2011,24 +2011,24 @@ internal DW_CompUnit dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U64 offset, B32 relaxed) { DW_CompUnit cu = {0}; - + String8 info_data = input->sec[DW_Section_Info].data; - + // read unit size in bytes U64 length = 0; U64 length_size = str8_deserial_read_dwarf_packed_size(info_data, offset, &length); - + if (length_size) { // compute unit range Rng1U64 range = rng_1u64(offset, offset + length_size + length); String8 data = str8_substr(info_data, range); U64 cursor = length_size; - + // read version DW_Version version = 0; U64 version_size = str8_deserial_read_struct(data, cursor, &version); cursor += version_size; - + if (version_size) { DW_Format format = DW_FormatFromSize(length); B32 is_header_ok = 0; @@ -2036,123 +2036,123 @@ dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U6 U8 address_size = 0; DW_CompUnitKind unit_kind = DW_CompUnitKind_Reserved; U64 spec_dwo_id = max_U64; - + switch (version) { - default: - case DW_Version_Null: - case DW_Version_1: + default: + case DW_Version_Null: + case DW_Version_1: break; - case DW_Version_2: { - U32 abbrev_base32 = 0; - U64 abbrev_base_off = cursor; - U64 abbrev_base_size = str8_deserial_read_struct(data, abbrev_base_off, &abbrev_base32); - if (!abbrev_base_size) { - break; - } - - U64 address_size_off = abbrev_base_off + abbrev_base_size; - U64 address_size_size = str8_deserial_read_struct(data, address_size_off, &address_size); - if (!address_size_size) { - break; - } - - abbrev_base = abbrev_base32; - cursor = address_size_off + address_size_size; - is_header_ok = 1; - } break; - case DW_Version_3: - case DW_Version_4: { - U64 abbrev_base_off = cursor; - U64 abbrev_base_size = str8_deserial_read_dwarf_uint(data, abbrev_base_off, format, &abbrev_base); - if (!abbrev_base_size) { - break; - } - - U64 address_size_off = abbrev_base_off + abbrev_base_size; - U64 address_size_size = str8_deserial_read_struct(data, address_size_off, &address_size); - if (!address_size_size) { - break; - } - - cursor = address_size_off + address_size_size; - is_header_ok = 1; - } break; - case DW_Version_5: { - U64 unit_kind_off = cursor; - U64 unit_kind_size = str8_deserial_read_struct(data, unit_kind_off, &unit_kind); - if (unit_kind_size == 0) { - break; - } - - U64 address_size_off = unit_kind_off + unit_kind_size; - U64 address_size_size = str8_deserial_read_struct(data, address_size_off, &address_size); - if (!address_size_size) { - break; - } - - U64 abbrev_base_off = address_size_off + address_size_size; - U64 abbrev_base_size = str8_deserial_read_dwarf_uint(data, abbrev_base_off, format, &abbrev_base); - if (!abbrev_base_size) { - break; - } - - U64 spec_dwo_id_off = abbrev_base_off + abbrev_base_size; - U64 spec_dwo_id_size = 0; - if (unit_kind == DW_CompUnitKind_Skeleton || input->sec[DW_Section_Info].is_dwo) { - spec_dwo_id_size = str8_deserial_read_struct(data, spec_dwo_id_off, &spec_dwo_id); - if (!spec_dwo_id_size) { + case DW_Version_2: { + U32 abbrev_base32 = 0; + U64 abbrev_base_off = cursor; + U64 abbrev_base_size = str8_deserial_read_struct(data, abbrev_base_off, &abbrev_base32); + if (!abbrev_base_size) { break; } - } - - cursor = spec_dwo_id_off + spec_dwo_id_size; - is_header_ok = 1; - } break; + + U64 address_size_off = abbrev_base_off + abbrev_base_size; + U64 address_size_size = str8_deserial_read_struct(data, address_size_off, &address_size); + if (!address_size_size) { + break; + } + + abbrev_base = abbrev_base32; + cursor = address_size_off + address_size_size; + is_header_ok = 1; + } break; + case DW_Version_3: + case DW_Version_4: { + U64 abbrev_base_off = cursor; + U64 abbrev_base_size = str8_deserial_read_dwarf_uint(data, abbrev_base_off, format, &abbrev_base); + if (!abbrev_base_size) { + break; + } + + U64 address_size_off = abbrev_base_off + abbrev_base_size; + U64 address_size_size = str8_deserial_read_struct(data, address_size_off, &address_size); + if (!address_size_size) { + break; + } + + cursor = address_size_off + address_size_size; + is_header_ok = 1; + } break; + case DW_Version_5: { + U64 unit_kind_off = cursor; + U64 unit_kind_size = str8_deserial_read_struct(data, unit_kind_off, &unit_kind); + if (unit_kind_size == 0) { + break; + } + + U64 address_size_off = unit_kind_off + unit_kind_size; + U64 address_size_size = str8_deserial_read_struct(data, address_size_off, &address_size); + if (!address_size_size) { + break; + } + + U64 abbrev_base_off = address_size_off + address_size_size; + U64 abbrev_base_size = str8_deserial_read_dwarf_uint(data, abbrev_base_off, format, &abbrev_base); + if (!abbrev_base_size) { + break; + } + + U64 spec_dwo_id_off = abbrev_base_off + abbrev_base_size; + U64 spec_dwo_id_size = 0; + if (unit_kind == DW_CompUnitKind_Skeleton || input->sec[DW_Section_Info].is_dwo) { + spec_dwo_id_size = str8_deserial_read_struct(data, spec_dwo_id_off, &spec_dwo_id); + if (!spec_dwo_id_size) { + break; + } + } + + cursor = spec_dwo_id_off + spec_dwo_id_size; + is_header_ok = 1; + } break; } - + if (is_header_ok) { Temp temp = temp_begin(arena); - + // TODO: cache abbrev tables with identical offsets String8 abbrev_data = input->sec[DW_Section_Abbrev].data; DW_AbbrevTable abbrev_table = dw_make_abbrev_table(arena, abbrev_data, abbrev_base); - + DW_Tag cu_tag = {0}; dw_read_tag(arena, data, cursor, range.min, abbrev_table, abbrev_data, version, format, address_size, &cu_tag); - + // TODO: handle these unit types Assert(cu_tag.kind != DW_Tag_SkeletonUnit); Assert(cu_tag.kind != DW_Tag_TypeUnit); - + if (cu_tag.kind == DW_Tag_CompileUnit || cu_tag.kind == DW_Tag_PartialUnit) { // fetch attribs for list sections DW_Attrib *addr_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_AddrBase ); DW_Attrib *str_offsets_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_StrOffsetsBase); DW_Attrib *rnglists_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_RngListsBase ); DW_Attrib *loclists_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_LocListsBase ); - + // interp attribs as section offsets U64 addr_sec_off = dw_interp_sec_offset(addr_base_attrib->form_kind, addr_base_attrib->form ); U64 str_offsets_sec_off = dw_interp_sec_offset(str_offsets_base_attrib->form_kind, str_offsets_base_attrib->form); U64 rnglists_sec_off = dw_interp_sec_offset(rnglists_base_attrib->form_kind, rnglists_base_attrib->form ); U64 loclists_sec_off = dw_interp_sec_offset(loclists_base_attrib->form_kind, loclists_base_attrib->form ); - + // map section offset to unit index U64 addr_lu_idx = rng_1u64_array_bsearch(lu_input.addr_ranges, addr_sec_off ); U64 str_offsets_lu_idx = rng_1u64_array_bsearch(lu_input.str_offset_ranges, str_offsets_sec_off); U64 rnglists_lu_idx = rng_1u64_array_bsearch(lu_input.rnglist_ranges, rnglists_sec_off ); U64 loclists_lu_idx = rng_1u64_array_bsearch(lu_input.loclist_ranges, loclists_sec_off ); - + // map index to unit DW_ListUnit *addr_lu = addr_lu_idx < lu_input.addr_count ? &lu_input.addrs[addr_lu_idx] : 0; DW_ListUnit *str_offsets_lu = str_offsets_lu_idx < lu_input.str_offset_count ? &lu_input.str_offsets[str_offsets_lu_idx] : 0; DW_ListUnit *rnglists_lu = rnglists_lu_idx < lu_input.rnglist_count ? &lu_input.rnglists[rnglists_lu_idx] : 0; DW_ListUnit *loclists_lu = loclists_lu_idx < lu_input.loclist_count ? &lu_input.loclists[loclists_lu_idx] : 0; - + // find compile unit base address DW_Attrib *low_pc_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_LowPc); U64 low_pc = dw_interp_address(address_size, max_U64, addr_lu, low_pc_attrib->form_kind, low_pc_attrib->form); - + // fill out compile unit cu.relaxed = relaxed; cu.ext = DW_Ext_All; @@ -2178,7 +2178,7 @@ dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U6 } } } - + return cu; } @@ -2193,21 +2193,21 @@ dw_tag_tree_from_data(Arena *arena, String8 info_data, String8 abbrev_data, DW_C break; } *cursor += tag_size; - + // is this sentinel tag? if (tag.kind == DW_Tag_Null) { break; } - + // normal tag DW_TagNode *tag_n = push_array(arena, DW_TagNode, 1); tag_n->tag = tag; - + SLLQueuePush_N(parent->first_child, parent->last_child, tag_n, sibling); - + // update tag count *tag_count += 1; - + if (tag.has_children) { dw_tag_tree_from_data(arena, info_data, abbrev_data, cu, tag_n, cursor, tag_count); } @@ -2223,11 +2223,11 @@ dw_tag_tree_from_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu) U64 cursor = cu->first_tag_info_off; U64 tag_count = 0; dw_tag_tree_from_data(arena, info_data, abbrev_data, cu, &root, &cursor, &tag_count); - + DW_TagTree result = {0}; result.root = root.first_child; result.tag_count = tag_count; - + return result; } @@ -2235,22 +2235,22 @@ internal HashTable * dw_make_tag_hash_table(Arena *arena, DW_TagTree tag_tree) { Temp scratch = scratch_begin(&arena, 1); - + struct Frame { struct Frame *next; DW_TagNode *node; }; - + struct Frame *free_frames = 0; struct Frame *stack = push_array(scratch.arena, struct Frame, 1); stack->node = tag_tree.root; - + HashTable *ht = hash_table_init(arena, (U64)((F64)tag_tree.tag_count * 1.3)); - + while (stack) { while (stack->node) { hash_table_push_u64_raw(arena, ht, stack->node->tag.info_off, stack->node); - + if (stack->node->first_child) { struct Frame *frame = free_frames; if (frame) { @@ -2265,17 +2265,17 @@ dw_make_tag_hash_table(Arena *arena, DW_TagTree tag_tree) stack->node = stack->node->sibling; } } - + // recycle free frame struct Frame *frame = stack; SLLStackPop(stack); SLLStackPush(free_frames, frame); - + if (stack) { stack->node = stack->node->sibling; } } - + scratch_end(scratch); return ht; } @@ -2293,7 +2293,7 @@ dw_line_vm_file_array_from_list(Arena *arena, DW_LineVMFileList list) DW_LineVMFileArray result = {0}; result.count = 0; result.v = push_array(arena, DW_LineFile, list.node_count); - + for (DW_LineVMFileNode *src = list.first; src != 0; src = src->next) { DW_LineFile *dst = &result.v[result.count++]; dst->file_name = push_str8_copy(arena, src->file.file_name); @@ -2301,7 +2301,7 @@ dw_line_vm_file_array_from_list(Arena *arena, DW_LineVMFileList list) dst->modify_time = src->file.modify_time; dst->file_size = src->file.file_size; } - + return result; } @@ -2326,38 +2326,38 @@ dw_read_line_file(String8 data, DW_Form form = {0}; U64 bytes_read; switch (lnct) { - case DW_LNCT_Path: { - bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); - line_file_out->file_name = dw_interp_string(input, format, str_offsets, form_kind, form); - } break; - case DW_LNCT_DirectoryIndex: { - bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); - line_file_out->dir_idx = dw_interp_const_u64(form_kind, form); - } break; - case DW_LNCT_TimeStamp: { - bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); - line_file_out->modify_time = dw_interp_const_u64(form_kind, form); - } break; - case DW_LNCT_Size: { - bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); - line_file_out->file_size = dw_interp_const_u64(form_kind, form); - } break; - case DW_LNCT_MD5: { - bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); - line_file_out->md5_digest = dw_interp_const_u128(form_kind, form); - } break; - case DW_LNCT_LLVM_Source: { - if (ext & DW_Ext_LLVM) { + case DW_LNCT_Path: { bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); - line_file_out->source = dw_interp_string(input, format, str_offsets, form_kind, form); - } else { - Assert(!"extension not supported"); - } - } break; - default: { - bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); - Assert(!"unexpected LNTC encoding"); - } break; + line_file_out->file_name = dw_interp_string(input, format, str_offsets, form_kind, form); + } break; + case DW_LNCT_DirectoryIndex: { + bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); + line_file_out->dir_idx = dw_interp_const_u64(form_kind, form); + } break; + case DW_LNCT_TimeStamp: { + bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); + line_file_out->modify_time = dw_interp_const_u64(form_kind, form); + } break; + case DW_LNCT_Size: { + bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); + line_file_out->file_size = dw_interp_const_u64(form_kind, form); + } break; + case DW_LNCT_MD5: { + bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); + line_file_out->md5_digest = dw_interp_const_u128(form_kind, form); + } break; + case DW_LNCT_LLVM_Source: { + if (ext & DW_Ext_LLVM) { + bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); + line_file_out->source = dw_interp_string(input, format, str_offsets, form_kind, form); + } else { + Assert(!"extension not supported"); + } + } break; + default: { + bytes_read = dw_read_form(data, cursor, version, format, address_size, form_kind, max_U64, &form); + Assert(!"unexpected LNTC encoding"); + } break; } Assert(bytes_read); cursor += bytes_read; @@ -2382,10 +2382,10 @@ dw_read_line_file_array(Arena *arena, DW_LineVMFileArray *table_out) { Temp temp = temp_begin(arena); - + table_out->count = table_count; table_out->v = push_array(arena, DW_LineFile, table_count); - + U64 i, cursor; for (i = 0, cursor = off; i < table_count; ++i) { U64 bytes_read = dw_read_line_file(data, @@ -2404,7 +2404,7 @@ dw_read_line_file_array(Arena *arena, } cursor += bytes_read; } - + U64 bytes_read = 0; if (i == table_count) { bytes_read = cursor - off; @@ -2413,7 +2413,7 @@ dw_read_line_file_array(Arena *arena, table_out->count = 0; table_out->v = 0; } - + return bytes_read; } @@ -2429,19 +2429,19 @@ dw_read_line_vm_header(Arena *arena, DW_LineVMHeader *header_out) { Temp scratch = scratch_begin(&arena, 1); - + U64 bytes_read = 0; // read unit length U64 unit_length = 0; U64 unit_length_size = str8_deserial_read_dwarf_packed_size(line_data, line_off, &unit_length); - + U64 unit_opl = line_off + unit_length_size + unit_length; Rng1U64 unit_range = rng_1u64(line_off, unit_opl); DW_Format format = DW_FormatFromSize(unit_length); U64 unit_cursor = unit_length_size; String8 unit_data = str8_substr(line_data, unit_range); - + // read unit version DW_Version version = DW_Version_Null; U64 version_size = str8_deserial_read_struct(unit_data, unit_cursor, &version); @@ -2459,7 +2459,7 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += address_size_size; - + U64 segsel_size_size = str8_deserial_read_struct(unit_data, unit_cursor, &segsel_size); if (segsel_size_size == 0) { goto exit; @@ -2476,7 +2476,7 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += header_length_size; - + // read min instruction length U8 min_inst_len = 0; U64 min_inst_len_size = str8_deserial_read_struct(unit_data, unit_cursor, &min_inst_len); @@ -2484,7 +2484,7 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += min_inst_len_size; - + // read max operands for instruction U8 max_ops_for_inst = 1; if (version > DW_Version_3) { @@ -2502,35 +2502,35 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += default_is_stmt_size; - + S8 line_base = 0; U64 line_base_size = str8_deserial_read_struct(unit_data, unit_cursor, &line_base); if (line_base_size == 0) { goto exit; } unit_cursor += line_base_size; - + U8 line_range = 0; U64 line_range_size = str8_deserial_read_struct(unit_data, unit_cursor, &line_range); if (line_range_size == 0) { goto exit; } unit_cursor += line_range_size; - + U8 opcode_base = 0; U64 opcode_base_size = str8_deserial_read_struct(unit_data, unit_cursor, &opcode_base); if (opcode_base_size == 0) { goto exit; } unit_cursor += opcode_base_size; - + U64 num_opcode_lens = opcode_base > 0 ? opcode_base - 1 : 0; U8 *opcode_lens = str8_deserial_get_raw_ptr(unit_data, unit_cursor, num_opcode_lens * sizeof(opcode_lens[0])); if (opcode_lens == 0) { goto exit; } unit_cursor += num_opcode_lens * sizeof(opcode_lens[0]); - + DW_LineVMFileArray dir_table = {0}; DW_LineVMFileArray file_table = {0}; if (version < DW_Version_5) { @@ -2543,7 +2543,7 @@ dw_read_line_vm_header(Arena *arena, SLLQueuePush(dir_list.first, dir_list.last, node); ++dir_list.node_count; } - + // parse additional directories for (; unit_cursor < unit_data.size; ) { String8 dir = {0}; @@ -2551,7 +2551,7 @@ dw_read_line_vm_header(Arena *arena, if (dir.size == 0) { break; } - + DW_LineVMFileNode *node = push_array(scratch.arena, DW_LineVMFileNode, 1); node->file.file_name = dir; SLLQueuePush(dir_list.first, dir_list.last, node); @@ -2575,21 +2575,21 @@ dw_read_line_vm_header(Arena *arena, if (file_name.size == 0) { break; } - + U64 dir_index = 0; U64 dir_index_size = str8_deserial_read_uleb128(unit_data, unit_cursor, &dir_index); if (dir_index_size == 0) { goto exit; } unit_cursor += dir_index_size; - + U64 modify_time = 0; U64 modify_time_size = str8_deserial_read_uleb128(unit_data, unit_cursor, &modify_time); if (modify_time_size == 0) { goto exit; } unit_cursor += modify_time_size; - + U64 file_size = 0; U64 file_size_size = str8_deserial_read_uleb128(unit_data, unit_cursor, &file_size); if (file_size_size == 0) { @@ -2602,12 +2602,12 @@ dw_read_line_vm_header(Arena *arena, node->file.dir_idx = dir_index; node->file.modify_time = modify_time; node->file.file_size = file_size; - + SLLQueuePush(file_list.first, file_list.last, node); ++file_list.node_count; } } - + // list -> array dir_table = dw_line_vm_file_array_from_list(arena, dir_list); file_table = dw_line_vm_file_array_from_list(arena, file_list); @@ -2623,7 +2623,7 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += enc_count_size; - + // read table entry encodings U64 *enc_arr = 0; U64 enc_arr_size = str8_deserial_read_uleb128_array(scratch.arena, unit_data, unit_cursor, enc_count*2, &enc_arr); @@ -2631,7 +2631,7 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += enc_arr_size; - + // read table count U64 table_count = 0; U64 table_count_size = str8_deserial_read_uleb128(unit_data, unit_cursor, &table_count); @@ -2639,7 +2639,7 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += table_count_size; - + // read table U64 table_size = dw_read_line_file_array(arena, unit_data, @@ -2659,7 +2659,7 @@ dw_read_line_vm_header(Arena *arena, } unit_cursor += table_size; } - + // file table { // read table entry encoding count @@ -2669,7 +2669,7 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += enc_count_size; - + // read table entry encodings U64 *enc_arr = 0; U64 enc_arr_size = str8_deserial_read_uleb128_array(scratch.arena, unit_data, unit_cursor, enc_count*2, &enc_arr); @@ -2677,7 +2677,7 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += enc_arr_size; - + // read table count U64 table_count = 0; U64 table_count_size = str8_deserial_read_uleb128(unit_data, unit_cursor, &table_count); @@ -2685,7 +2685,7 @@ dw_read_line_vm_header(Arena *arena, goto exit; } unit_cursor += table_count_size; - + // read table U64 file_table_size = dw_read_line_file_array(arena, unit_data, @@ -2706,7 +2706,7 @@ dw_read_line_vm_header(Arena *arena, unit_cursor += file_table_size; } } - + if (header_out) { header_out->unit_range = unit_range; header_out->version = version; @@ -2724,10 +2724,10 @@ dw_read_line_vm_header(Arena *arena, header_out->dir_table = dir_table; header_out->file_table = file_table; } - + bytes_read = unit_cursor; - -exit:; + + exit:; scratch_end(scratch); return bytes_read; } @@ -2773,13 +2773,13 @@ dw_push_line(Arena *arena, DW_LineTableParseResult *tbl, DW_LineVMState *vm_stat { seq = dw_push_line_seq(arena, tbl); } - + DW_LineNode *n = push_array(arena, DW_LineNode, 1); n->v.file_index = vm_state->file_index; n->v.line = vm_state->line; n->v.column = vm_state->column; n->v.address = vm_state->address; - + SLLQueuePush(seq->first, seq->last, n); seq->count += 1; return n; @@ -2794,23 +2794,23 @@ dw_path_from_file(Arena *arena, DW_LineVMHeader *vm, DW_LineFile *file) if (style == PathStyle_Null || style == PathStyle_Relative) { style = path_style_from_str8(file->file_name); } - + String8List path_list = {0}; - + if (str8_match_lit("..", dir, StringMatchFlag_RightSideSloppy)) { String8List comp_dir_list = str8_split_path(scratch.arena, vm->dir_table.v[0].file_name); str8_list_concat_in_place(&path_list, &comp_dir_list); } - + String8List dir_list = str8_split_path(scratch.arena, dir); str8_list_concat_in_place(&path_list, &dir_list); - + str8_list_push(scratch.arena, &path_list, file->file_name); - + str8_path_list_resolve_dots_in_place(&path_list, style); - + String8 path = str8_path_list_join_by_style(arena, &path_list, style); - + scratch_end(scratch); return path; } @@ -2832,7 +2832,7 @@ dw_parsed_line_table_from_data(Arena *arena, { DW_LineVMHeader vm_header = {0}; U64 vm_header_size = dw_read_line_vm_header(arena, unit_data, 0, input, cu_dir, cu_name, cu_address_size, cu_str_offsets, &vm_header); - + U64 unit_cursor = vm_header_size; //- rjf: prep state for VM @@ -2850,188 +2850,188 @@ dw_parsed_line_table_from_data(Arena *arena, //- rjf: do opcode action switch (opcode) { - default: { - //- rjf: special opcode case - if (opcode >= vm_header.opcode_base) { - U32 adjusted_opcode = (U32)(opcode - vm_header.opcode_base); - U32 op_advance = adjusted_opcode / vm_header.line_range; - S32 line_inc = (S32)vm_header.line_base + ((S32)adjusted_opcode) % (S32)vm_header.line_range; - // TODO: can we just call dw_advance_line_vm_state_pc - U64 addr_inc = vm_header.min_inst_len * ((vm_state.op_index+op_advance) / vm_header.max_ops_for_inst); - - vm_state.address += addr_inc; - vm_state.op_index = (vm_state.op_index + op_advance) % vm_header.max_ops_for_inst; - vm_state.line = (U32)((S32)vm_state.line + line_inc); - vm_state.basic_block = 0; - vm_state.prologue_end = 0; - vm_state.epilogue_begin = 0; - vm_state.discriminator = 0; - + default: { + //- rjf: special opcode case + if (opcode >= vm_header.opcode_base) { + U32 adjusted_opcode = (U32)(opcode - vm_header.opcode_base); + U32 op_advance = adjusted_opcode / vm_header.line_range; + S32 line_inc = (S32)vm_header.line_base + ((S32)adjusted_opcode) % (S32)vm_header.line_range; + // TODO: can we just call dw_advance_line_vm_state_pc + U64 addr_inc = vm_header.min_inst_len * ((vm_state.op_index+op_advance) / vm_header.max_ops_for_inst); + + vm_state.address += addr_inc; + vm_state.op_index = (vm_state.op_index + op_advance) % vm_header.max_ops_for_inst; + vm_state.line = (U32)((S32)vm_state.line + line_inc); + vm_state.basic_block = 0; + vm_state.prologue_end = 0; + vm_state.epilogue_begin = 0; + vm_state.discriminator = 0; + + if(vm_state.is_stmt) + { + dw_push_line(arena, &result, &vm_state, end_of_seq); + } + end_of_seq = 0; + +#if 0 + // NOTE(rjf): DWARF has dummy lines at the end of groups of line ranges, where we'd like + // to break line info into sequences. + if(vm_state.line == 0) + { + end_of_seq = 1; + } +#endif + } + // Skipping unknown opcode. This is a valid case and + // it works because compiler stores operand lengths. + else { + if (0 < opcode && opcode <= vm_header.num_opcode_lens) { + U8 num_operands = vm_header.opcode_lens[opcode - 1]; + for (U8 i = 0; i < num_operands; ++i) { + U64 operand = 0; + unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &operand); + } + } else { + error = 1; + goto exit; + } + } + } break; + + //- Standard opcodes + + case DW_StdOpcode_Copy: { if(vm_state.is_stmt) { dw_push_line(arena, &result, &vm_state, end_of_seq); } end_of_seq = 0; - -#if 0 - // NOTE(rjf): DWARF has dummy lines at the end of groups of line ranges, where we'd like - // to break line info into sequences. - if(vm_state.line == 0) - { - end_of_seq = 1; - } -#endif - } - // Skipping unknown opcode. This is a valid case and - // it works because compiler stores operand lengths. - else { - if (0 < opcode && opcode <= vm_header.num_opcode_lens) { - U8 num_operands = vm_header.opcode_lens[opcode - 1]; - for (U8 i = 0; i < num_operands; ++i) { - U64 operand = 0; - unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &operand); - } - } else { - error = 1; - goto exit; - } - } - } break; - - //- Standard opcodes - - case DW_StdOpcode_Copy: { - if(vm_state.is_stmt) - { - dw_push_line(arena, &result, &vm_state, end_of_seq); - } - end_of_seq = 0; - vm_state.discriminator = 0; - vm_state.basic_block = 0; - vm_state.prologue_end = 0; - vm_state.epilogue_begin = 0; - } break; - - case DW_StdOpcode_AdvancePc: { - U64 advance = 0; - unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &advance); - dw_line_vm_advance(&vm_state, advance, vm_header.min_inst_len, vm_header.max_ops_for_inst); - } break; - - case DW_StdOpcode_AdvanceLine: { - S64 s = 0; - unit_cursor += str8_deserial_read_sleb128(unit_data, unit_cursor, &s); - vm_state.line += s; - } break; - - case DW_StdOpcode_SetFile: { - U64 file_index = 0; - unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &file_index); - vm_state.file_index = file_index; - } break; - - case DW_StdOpcode_SetColumn: { - U64 column = 0; - unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &column); - vm_state.column = column; - } break; - - case DW_StdOpcode_NegateStmt: { - vm_state.is_stmt = !vm_state.is_stmt; - } break; - - case DW_StdOpcode_SetBasicBlock: { - vm_state.basic_block = 1; - } break; - - case DW_StdOpcode_ConstAddPc: { - U64 advance = (0xffu - vm_header.opcode_base) / vm_header.line_range; - dw_line_vm_advance(&vm_state, advance, vm_header.min_inst_len, vm_header.max_ops_for_inst); - } break; - - case DW_StdOpcode_FixedAdvancePc: { - U16 operand = 0; - unit_cursor += str8_deserial_read_struct(unit_data, unit_cursor, &operand); - vm_state.address += operand; - vm_state.op_index = 0; - } break; - - case DW_StdOpcode_SetPrologueEnd: { - vm_state.prologue_end = 1; - } break; - - case DW_StdOpcode_SetEpilogueBegin: { - vm_state.epilogue_begin = 1; - } break; - - case DW_StdOpcode_SetIsa: { - U64 v = 0; - unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &v); - vm_state.isa = v; - } break; - - //- Extended opcodes - case DW_StdOpcode_ExtendedOpcode: { - U64 length = 0; - unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &length); - - U64 extended_opl = unit_cursor + length; - U8 extended_opcode = 0; - unit_cursor += str8_deserial_read_struct(unit_data, unit_cursor, &extended_opcode); - - switch (extended_opcode) { - case DW_ExtOpcode_EndSequence: { - vm_state.end_sequence = 1; - if(vm_state.is_stmt) - { - dw_push_line(arena, &result, &vm_state, 0); - } - dw_line_vm_reset(&vm_state, vm_header.default_is_stmt); - end_of_seq = 1; + vm_state.discriminator = 0; + vm_state.basic_block = 0; + vm_state.prologue_end = 0; + vm_state.epilogue_begin = 0; } break; - case DW_ExtOpcode_SetAddress: { - U64 address = 0; - unit_cursor += str8_deserial_read(unit_data, unit_cursor, &address, vm_header.address_size, vm_header.address_size); - vm_state.address = address; - vm_state.op_index = 0; + case DW_StdOpcode_AdvancePc: { + U64 advance = 0; + unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &advance); + dw_line_vm_advance(&vm_state, advance, vm_header.min_inst_len, vm_header.max_ops_for_inst); } break; - case DW_ExtOpcode_DefineFile: { - String8 file_name = {0}; - U64 dir_index = 0; - U64 modify_time = 0; - U64 file_size = 0; - - unit_cursor += str8_deserial_read_cstr(unit_data, unit_cursor, &file_name); - unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &dir_index); - unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &modify_time); - unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &file_size); - - // TODO(rjf): Not fully implemented. By the DWARF V4 spec, the above is - // all that needs to be parsed, but the rest of the work that needs to - // happen here---allowing this file to be used by further opcodes---is - // not implemented. - // - // See the DWARF V4 spec (June 10, 2010), page 122. - error = 1; - AssertAlways(!"UNHANDLED DEFINE FILE!!!"); + case DW_StdOpcode_AdvanceLine: { + S64 s = 0; + unit_cursor += str8_deserial_read_sleb128(unit_data, unit_cursor, &s); + vm_state.line += s; } break; - case DW_ExtOpcode_SetDiscriminator: { + case DW_StdOpcode_SetFile: { + U64 file_index = 0; + unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &file_index); + vm_state.file_index = file_index; + } break; + + case DW_StdOpcode_SetColumn: { + U64 column = 0; + unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &column); + vm_state.column = column; + } break; + + case DW_StdOpcode_NegateStmt: { + vm_state.is_stmt = !vm_state.is_stmt; + } break; + + case DW_StdOpcode_SetBasicBlock: { + vm_state.basic_block = 1; + } break; + + case DW_StdOpcode_ConstAddPc: { + U64 advance = (0xffu - vm_header.opcode_base) / vm_header.line_range; + dw_line_vm_advance(&vm_state, advance, vm_header.min_inst_len, vm_header.max_ops_for_inst); + } break; + + case DW_StdOpcode_FixedAdvancePc: { + U16 operand = 0; + unit_cursor += str8_deserial_read_struct(unit_data, unit_cursor, &operand); + vm_state.address += operand; + vm_state.op_index = 0; + } break; + + case DW_StdOpcode_SetPrologueEnd: { + vm_state.prologue_end = 1; + } break; + + case DW_StdOpcode_SetEpilogueBegin: { + vm_state.epilogue_begin = 1; + } break; + + case DW_StdOpcode_SetIsa: { U64 v = 0; unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &v); - vm_state.discriminator = v; + vm_state.isa = v; } break; - default: break; - } - - unit_cursor = extended_opl; - } break; + //- Extended opcodes + case DW_StdOpcode_ExtendedOpcode: { + U64 length = 0; + unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &length); + + U64 extended_opl = unit_cursor + length; + U8 extended_opcode = 0; + unit_cursor += str8_deserial_read_struct(unit_data, unit_cursor, &extended_opcode); + + switch (extended_opcode) { + case DW_ExtOpcode_EndSequence: { + vm_state.end_sequence = 1; + if(vm_state.is_stmt) + { + dw_push_line(arena, &result, &vm_state, 0); + } + dw_line_vm_reset(&vm_state, vm_header.default_is_stmt); + end_of_seq = 1; + } break; + + case DW_ExtOpcode_SetAddress: { + U64 address = 0; + unit_cursor += str8_deserial_read(unit_data, unit_cursor, &address, vm_header.address_size, vm_header.address_size); + vm_state.address = address; + vm_state.op_index = 0; + } break; + + case DW_ExtOpcode_DefineFile: { + String8 file_name = {0}; + U64 dir_index = 0; + U64 modify_time = 0; + U64 file_size = 0; + + unit_cursor += str8_deserial_read_cstr(unit_data, unit_cursor, &file_name); + unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &dir_index); + unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &modify_time); + unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &file_size); + + // TODO(rjf): Not fully implemented. By the DWARF V4 spec, the above is + // all that needs to be parsed, but the rest of the work that needs to + // happen here---allowing this file to be used by further opcodes---is + // not implemented. + // + // See the DWARF V4 spec (June 10, 2010), page 122. + error = 1; + AssertAlways(!"UNHANDLED DEFINE FILE!!!"); + } break; + + case DW_ExtOpcode_SetDiscriminator: { + U64 v = 0; + unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &v); + vm_state.discriminator = v; + } break; + + default: break; + } + + unit_cursor = extended_opl; + } break; } } - + exit:; return result; @@ -3041,59 +3041,59 @@ internal DW_PubStringsTable dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Input *input, DW_SectionKind section_kind) { Temp scratch = scratch_begin(&arena, 1); - + DW_PubStringsTable names_table = {0}; names_table.size = 16384; names_table.buckets = push_array(arena, DW_PubStringsBucket*, names_table.size); String8 section_data = input->sec[section_kind].data; for(U64 cursor = 0; cursor < section_data.size; ) { - + U64 unit_length = 0; U64 unit_length_size = str8_deserial_read_dwarf_packed_size(section_data, cursor, &unit_length); if (unit_length_size == 0) { break; } cursor += unit_length_size; - + U64 cursor_opl = Min(cursor + unit_length, section_data.size); if (cursor >= cursor_opl) { break; } - + DW_Version unit_version = 0; cursor += str8_deserial_read_struct(section_data, cursor, &unit_version); if (cursor >= cursor_opl) { break; } - + DW_Format format = DW_FormatFromSize(unit_length); - + U64 debug_info_off = 0; cursor += str8_deserial_read_dwarf_uint(section_data, cursor, format, &debug_info_off); if (cursor >= cursor_opl) { break; } - + U64 debug_info_length = 0; cursor += str8_deserial_read_dwarf_packed_size(section_data, cursor, &debug_info_length); if (cursor >= cursor_opl) { break; } - + U64 off_size = dw_size_from_format(format); for (; (cursor + off_size) <= cursor_opl;) { U64 info_off = 0; U64 info_off_size = str8_deserial_read_dwarf_uint(section_data, cursor, format, &info_off); cursor += info_off_size; - + if (info_off_size == 0 || info_off == 0) { break; } String8 string = {0}; cursor += str8_deserial_read_cstr(section_data, cursor, &string); - + U64 hash = dw_hash_from_string(string); U64 bucket_idx = hash % names_table.size; diff --git a/src/dwarf/dwarf_parse.h b/src/dwarf/dwarf_parse.h index 99a589d6..b89e45be 100644 --- a/src/dwarf/dwarf_parse.h +++ b/src/dwarf/dwarf_parse.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DWARF_PARSE_H diff --git a/src/dwarf/dwarf_unwind.c b/src/dwarf/dwarf_unwind.c index 81cc93de..e3540442 100644 --- a/src/dwarf/dwarf_unwind.c +++ b/src/dwarf/dwarf_unwind.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal U64 dw_based_range_read(void *base, Rng1U64 range, U64 off, U64 size, void *out) { return 0; } @@ -25,9 +25,9 @@ dw_unwind_x64(String8 raw_text, { // TODO: What if ELF has two sections with instructions and pointer is ecnoded relative to .text2? Temp scratch = scratch_begin(0, 0); - + DW_UnwindResult result = {0}; - + dw_unwind_init_x64(); // rebase @@ -46,7 +46,7 @@ dw_unwind_x64(String8 raw_text, //- get frame info range void *frame_base = raw_eh_frame.str; Rng1U64 frame_range = rng_1u64(0, raw_eh_frame.size); - + //- section vaddrs U64 text_base_vaddr = text_vrange.min + rebase_voff_to_vaddr; U64 frame_base_voff = text_vrange.min; @@ -113,7 +113,7 @@ dw_unwind_x64(String8 raw_text, result.is_invalid = 1; } } - + // apply main row to modify the registers if (main_row != 0) { result = dw_unwind_x64__apply_frame_rules(raw_eh_frame, main_row, text_base_vaddr, read_memory, read_memory_ud, stack_pointer, regs); @@ -133,7 +133,7 @@ dw_unwind_x64__apply_frame_rules(String8 raw_eh_frame, DW_RegsX64 *regs) { DW_UnwindResult result = {0}; - + U64 missed_read_addr = 0; //- setup a dwarf expression machine @@ -375,7 +375,7 @@ dw_unwind_parse_pointer_x64(void *frame_base, Rng1U64 frame_range, DW_EhPtrCtx * case DW_EhPtrEnc_SLEB128: { U64 size = dw_based_range_read_sleb128(frame_base, frame_range, pointer_off, - (S64*)&raw_pointer); + (S64*)&raw_pointer); after_pointer_off = pointer_off + size; } break; } @@ -588,7 +588,7 @@ internal DW_CFIRecords dw_unwind_eh_frame_cfi_from_ip_slow_x64(String8 raw_eh_frame, DW_EhPtrCtx *ptr_ctx, U64 ip_voff) { Temp scratch = scratch_begin(0, 0); - + DW_CFIRecords result = {0}; DW_CIEUnpackedNode *cie_first = 0; @@ -622,7 +622,7 @@ dw_unwind_eh_frame_cfi_from_ip_slow_x64(String8 raw_eh_frame, DW_EhPtrCtx *ptr_c Rng1U64 rec_range = rng_1u64(rec_off, rec_opl); String8 raw_rec = str8_substr(raw_eh_frame, rec_range); - + // discriminator U64 discrim_off = after_rec_size_off; U32 discrim = 0; @@ -839,7 +839,7 @@ internal B32 dw_unwind_machine_run_to_ip_x64(void *base, Rng1U64 range, DW_CFIMachine *machine, U64 target_ip, DW_CFIRow *row) { Temp scratch = scratch_begin(0, 0); - + B32 result = 0; // pull out machine's equipment diff --git a/src/dwarf/dwarf_unwind.h b/src/dwarf/dwarf_unwind.h index 8a0018e6..f2e6d2c1 100644 --- a/src/dwarf/dwarf_unwind.h +++ b/src/dwarf/dwarf_unwind.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef DWARF_UNWIND_H diff --git a/src/eval/eval.mdesk b/src/eval/eval.mdesk index f7f382ed..34c570bb 100644 --- a/src/eval/eval.mdesk +++ b/src/eval/eval.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) @table(name) diff --git a/src/eval/eval_core.c b/src/eval/eval_core.c index 60b50054..6a5904af 100644 --- a/src/eval/eval_core.c +++ b/src/eval/eval_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/eval/eval_core.h b/src/eval/eval_core.h index 5789fc19..56ec7378 100644 --- a/src/eval/eval_core.h +++ b/src/eval/eval_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef EVAL_CORE_H diff --git a/src/eval/eval_inc.c b/src/eval/eval_inc.c index cdfed3bd..d768f814 100644 --- a/src/eval/eval_inc.c +++ b/src/eval/eval_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "eval/eval_core.c" diff --git a/src/eval/eval_inc.h b/src/eval/eval_inc.h index bb03829f..26d81e6e 100644 --- a/src/eval/eval_inc.h +++ b/src/eval/eval_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef EVAL_INC_H diff --git a/src/eval/eval_interpret.c b/src/eval/eval_interpret.c index 5af37288..842c6945 100644 --- a/src/eval/eval_interpret.c +++ b/src/eval/eval_interpret.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/eval/eval_interpret.h b/src/eval/eval_interpret.h index 61ac98f0..cca6cd97 100644 --- a/src/eval/eval_interpret.h +++ b/src/eval/eval_interpret.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef EVAL_INTERPRET_H diff --git a/src/eval/eval_ir.c b/src/eval/eval_ir.c index 45005e5c..be21074b 100644 --- a/src/eval/eval_ir.c +++ b/src/eval/eval_ir.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/eval/eval_ir.h b/src/eval/eval_ir.h index 5ba2874d..105250ae 100644 --- a/src/eval/eval_ir.h +++ b/src/eval/eval_ir.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef EVAL_IR_H diff --git a/src/eval/eval_parse.c b/src/eval/eval_parse.c index a82b01db..89789ea9 100644 --- a/src/eval/eval_parse.c +++ b/src/eval/eval_parse.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/eval/eval_parse.h b/src/eval/eval_parse.h index c8e91b4b..d3021dcc 100644 --- a/src/eval/eval_parse.h +++ b/src/eval/eval_parse.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef EVAL_PARSE_H diff --git a/src/eval/eval_types.c b/src/eval/eval_types.c index b88870c4..3f7debc9 100644 --- a/src/eval/eval_types.c +++ b/src/eval/eval_types.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/eval/eval_types.h b/src/eval/eval_types.h index 1e771975..b8274315 100644 --- a/src/eval/eval_types.h +++ b/src/eval/eval_types.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef EVAL_TYPES_H diff --git a/src/eval/generated/eval.meta.c b/src/eval/generated/eval.meta.c index a1305840..c4be0989 100644 --- a/src/eval/generated/eval.meta.c +++ b/src/eval/generated/eval.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/eval/generated/eval.meta.h b/src/eval/generated/eval.meta.h index e85f1b0f..178dec89 100644 --- a/src/eval/generated/eval.meta.h +++ b/src/eval/generated/eval.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/eval_visualization/eval_visualization_core.c b/src/eval_visualization/eval_visualization_core.c index 84778d07..c6bbab59 100644 --- a/src/eval_visualization/eval_visualization_core.c +++ b/src/eval_visualization/eval_visualization_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/eval_visualization/eval_visualization_core.h b/src/eval_visualization/eval_visualization_core.h index 5f5a8d9d..daf46c2e 100644 --- a/src/eval_visualization/eval_visualization_core.h +++ b/src/eval_visualization/eval_visualization_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef EVAL_VISUALIZATION_CORE_H diff --git a/src/eval_visualization/eval_visualization_inc.c b/src/eval_visualization/eval_visualization_inc.c index d944d937..012e8c7b 100644 --- a/src/eval_visualization/eval_visualization_inc.c +++ b/src/eval_visualization/eval_visualization_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "eval_visualization_core.c" diff --git a/src/eval_visualization/eval_visualization_inc.h b/src/eval_visualization/eval_visualization_inc.h index 11c9b212..22d4aa63 100644 --- a/src/eval_visualization/eval_visualization_inc.h +++ b/src/eval_visualization/eval_visualization_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef EVAL_VISUALIZATION_INC_H diff --git a/src/file_stream/file_stream.c b/src/file_stream/file_stream.c index feb6d815..959ce166 100644 --- a/src/file_stream/file_stream.c +++ b/src/file_stream/file_stream.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/file_stream/file_stream.h b/src/file_stream/file_stream.h index a0ede57c..e4c06ba6 100644 --- a/src/file_stream/file_stream.h +++ b/src/file_stream/file_stream.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef FILE_STREAM_H diff --git a/src/font_cache/font_cache.c b/src/font_cache/font_cache.c index 44fea4d1..330e03bc 100644 --- a/src/font_cache/font_cache.c +++ b/src/font_cache/font_cache.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/font_cache/font_cache.h b/src/font_cache/font_cache.h index 4bc6b0b7..647cfaf4 100644 --- a/src/font_cache/font_cache.h +++ b/src/font_cache/font_cache.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef FONT_CACHE_H diff --git a/src/font_provider/dwrite/font_provider_dwrite.c b/src/font_provider/dwrite/font_provider_dwrite.c index 003fd299..66c4a235 100644 --- a/src/font_provider/dwrite/font_provider_dwrite.c +++ b/src/font_provider/dwrite/font_provider_dwrite.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/font_provider/dwrite/font_provider_dwrite.h b/src/font_provider/dwrite/font_provider_dwrite.h index f4533c7a..80c8b32f 100644 --- a/src/font_provider/dwrite/font_provider_dwrite.h +++ b/src/font_provider/dwrite/font_provider_dwrite.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef FONT_PROVIDER_DWRITE_H diff --git a/src/font_provider/font_provider.c b/src/font_provider/font_provider.c index 4b5298a6..cabfda88 100644 --- a/src/font_provider/font_provider.c +++ b/src/font_provider/font_provider.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/font_provider/font_provider.h b/src/font_provider/font_provider.h index f836aa19..80fd608d 100644 --- a/src/font_provider/font_provider.h +++ b/src/font_provider/font_provider.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef FONT_PROVIDER_H diff --git a/src/font_provider/font_provider_inc.c b/src/font_provider/font_provider_inc.c index c589b27a..7b10141b 100644 --- a/src/font_provider/font_provider_inc.c +++ b/src/font_provider/font_provider_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "font_provider.c" diff --git a/src/font_provider/font_provider_inc.h b/src/font_provider/font_provider_inc.h index c3001d25..a2844ac0 100644 --- a/src/font_provider/font_provider_inc.h +++ b/src/font_provider/font_provider_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef FONT_PROVIDER_INC_H diff --git a/src/font_provider/freetype/font_provider_freetype.c b/src/font_provider/freetype/font_provider_freetype.c index b98735b8..338efdbb 100644 --- a/src/font_provider/freetype/font_provider_freetype.c +++ b/src/font_provider/freetype/font_provider_freetype.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/font_provider/freetype/font_provider_freetype.h b/src/font_provider/freetype/font_provider_freetype.h index b1e37c2f..d18f440d 100644 --- a/src/font_provider/freetype/font_provider_freetype.h +++ b/src/font_provider/freetype/font_provider_freetype.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef FONT_PROVIDER_FREETYPE_H diff --git a/src/geo_cache/geo_cache.c b/src/geo_cache/geo_cache.c index dd7fa2e0..298888b7 100644 --- a/src/geo_cache/geo_cache.c +++ b/src/geo_cache/geo_cache.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/geo_cache/geo_cache.h b/src/geo_cache/geo_cache.h index d343be8e..7ba1cc99 100644 --- a/src/geo_cache/geo_cache.h +++ b/src/geo_cache/geo_cache.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef GEO_CACHE_H diff --git a/src/hash_store/hash_store.c b/src/hash_store/hash_store.c index b5a6f574..16b64186 100644 --- a/src/hash_store/hash_store.c +++ b/src/hash_store/hash_store.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/hash_store/hash_store.h b/src/hash_store/hash_store.h index 8141eeb9..f193b3b1 100644 --- a/src/hash_store/hash_store.h +++ b/src/hash_store/hash_store.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef HASH_STORE_H diff --git a/src/lib_raddbg_markup/raddbg_markup.h b/src/lib_raddbg_markup/raddbg_markup.h index e1257cf4..dcff48de 100644 --- a/src/lib_raddbg_markup/raddbg_markup.h +++ b/src/lib_raddbg_markup/raddbg_markup.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADDBG_MARKUP_H diff --git a/src/lib_rdi_format/rdi_format.c b/src/lib_rdi_format/rdi_format.c index 387cbc18..5d301b95 100644 --- a/src/lib_rdi_format/rdi_format.c +++ b/src/lib_rdi_format/rdi_format.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////////////////////////////////////// diff --git a/src/lib_rdi_format/rdi_format.h b/src/lib_rdi_format/rdi_format.h index f430a5cb..4127f15b 100644 --- a/src/lib_rdi_format/rdi_format.h +++ b/src/lib_rdi_format/rdi_format.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////////////////////////////////////// diff --git a/src/lib_rdi_format/rdi_format_parse.c b/src/lib_rdi_format/rdi_format_parse.c index 3439589e..b609dbbe 100644 --- a/src/lib_rdi_format/rdi_format_parse.c +++ b/src/lib_rdi_format/rdi_format_parse.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/lib_rdi_format/rdi_format_parse.h b/src/lib_rdi_format/rdi_format_parse.h index 4d3e40b4..bf768d9e 100644 --- a/src/lib_rdi_format/rdi_format_parse.h +++ b/src/lib_rdi_format/rdi_format_parse.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////////////////////////////////////// diff --git a/src/lib_rdi_make/rdi_make.c b/src/lib_rdi_make/rdi_make.c index ab0bc36e..335344e5 100644 --- a/src/lib_rdi_make/rdi_make.c +++ b/src/lib_rdi_make/rdi_make.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/lib_rdi_make/rdi_make.h b/src/lib_rdi_make/rdi_make.h index e65b2e84..27db8820 100644 --- a/src/lib_rdi_make/rdi_make.h +++ b/src/lib_rdi_make/rdi_make.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////////////////////////////////////// diff --git a/src/mdesk/mdesk.c b/src/mdesk/mdesk.c index 1b6e2f51..efe2a52f 100644 --- a/src/mdesk/mdesk.c +++ b/src/mdesk/mdesk.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/mdesk/mdesk.h b/src/mdesk/mdesk.h index 455cb268..e7a55473 100644 --- a/src/mdesk/mdesk.h +++ b/src/mdesk/mdesk.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef MDESK_H diff --git a/src/metagen/metagen.c b/src/metagen/metagen.c index 33c4daa7..2bce9e88 100644 --- a/src/metagen/metagen.c +++ b/src/metagen/metagen.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/metagen/metagen.h b/src/metagen/metagen.h index 6280cbed..851fc027 100644 --- a/src/metagen/metagen.h +++ b/src/metagen/metagen.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef METAGEN_H diff --git a/src/metagen/metagen_main.c b/src/metagen/metagen_main.c index 24c645b1..1c19ac5d 100644 --- a/src/metagen/metagen_main.c +++ b/src/metagen/metagen_main.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// @@ -536,7 +536,7 @@ entry_point(CmdLine *cmdline) } { FILE *h = fopen((char *)h_path.str, "w"); - fprintf(h, "// Copyright (c) 2024 Epic Games Tools\n"); + fprintf(h, "// Copyright (c) Epic Games Tools\n"); fprintf(h, "// Licensed under the MIT license (https://opensource.org/license/mit/)\n\n"); if(layer->h_header.first == 0) { @@ -592,7 +592,7 @@ entry_point(CmdLine *cmdline) } { FILE *c = fopen((char *)c_path.str, "w"); - fprintf(c, "// Copyright (c) 2024 Epic Games Tools\n"); + fprintf(c, "// Copyright (c) Epic Games Tools\n"); fprintf(c, "// Licensed under the MIT license (https://opensource.org/license/mit/)\n\n"); if(layer->c_header.first == 0) { diff --git a/src/msf/msf.c b/src/msf/msf.c index 116918c8..ad0d59ca 100644 --- a/src/msf/msf.c +++ b/src/msf/msf.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal B32 diff --git a/src/msf/msf.h b/src/msf/msf.h index 34bc9960..46503306 100644 --- a/src/msf/msf.h +++ b/src/msf/msf.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef MSF_H diff --git a/src/msf/msf_parse.c b/src/msf/msf_parse.c index 941f5d40..aa64411f 100644 --- a/src/msf/msf_parse.c +++ b/src/msf/msf_parse.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// @@ -8,7 +8,7 @@ internal MSF_RawStreamTable * msf_raw_stream_table_from_data(Arena *arena, String8 msf_data) { Temp scratch = scratch_begin(&arena, 1); - + MSF_RawStreamTable *result = 0; //- determine msf type @@ -25,7 +25,7 @@ msf_raw_stream_table_from_data(Arena *arena, String8 msf_data) U32 whole_file_page_count_raw = 0; U32 directory_size_raw = 0; U32 directory_super_map_raw = 0; - + if (index_size == 2) { MSF_Header20 *header = (MSF_Header20 *) msf_data.str; page_size_raw = header->page_size; @@ -231,7 +231,7 @@ internal String8 msf_data_from_stream_number(Arena *arena, String8 msf_data, MSF_RawStreamTable *st, MSF_StreamNumber sn) { MSF_RawStream stream = st->streams[sn]; - + U8 *stream_buf = push_array_no_zero(arena, U8, stream.size); U8 *stream_out_ptr = stream_buf; for (U32 i = 0; i < stream.page_count; ++i) { @@ -241,12 +241,12 @@ msf_data_from_stream_number(Arena *arena, String8 msf_data, MSF_RawStreamTable * } else { page_idx = stream.u.page_indices_u16[i]; } - + U64 stream_page_off = (U64)page_idx * st->page_size; if (stream_page_off + st->page_size > msf_data.size) { break; } - + U8 *stream_page_base = msf_data.str + stream_page_off; // clamp copy size by end of stream @@ -258,12 +258,12 @@ msf_data_from_stream_number(Arena *arena, String8 msf_data, MSF_RawStreamTable * MemoryCopy(stream_out_ptr, stream_page_base, copy_size); stream_out_ptr += copy_size; } - + U64 copy_size = (U64)(stream_out_ptr - stream_buf); - + U64 unused_buf_size = stream.size - copy_size; arena_pop(arena, unused_buf_size); - + String8 result = str8(stream_buf, copy_size); return result; } @@ -272,16 +272,16 @@ internal MSF_Parsed * msf_parsed_from_data(Arena *arena, String8 msf_data) { Temp scratch = scratch_begin(&arena, 1); - + MSF_Parsed *result = 0; - + MSF_RawStreamTable *st = msf_raw_stream_table_from_data(scratch.arena, msf_data); if (st) { String8 *streams = push_array_no_zero(arena, String8, st->stream_count); for (MSF_StreamNumber sn = 0; sn < st->stream_count; ++sn) { streams[sn] = msf_data_from_stream_number(arena, msf_data, st, sn); } - + result = push_array_no_zero(arena, MSF_Parsed, 1); result->streams = streams; result->stream_count = st->stream_count; diff --git a/src/msf/msf_parse.h b/src/msf/msf_parse.h index c055df79..df4afb85 100644 --- a/src/msf/msf_parse.h +++ b/src/msf/msf_parse.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef MSF_PARSE_H diff --git a/src/msvc_crt/msvc_crt.c b/src/msvc_crt/msvc_crt.c index fda085a4..6ea33e51 100644 --- a/src/msvc_crt/msvc_crt.c +++ b/src/msvc_crt/msvc_crt.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal U64 @@ -10,37 +10,37 @@ mscrt_parse_func_info(Arena *arena, MSCRT_FuncInfo *func_info) { U64 cursor = off; - + U32 handler_data_voff = 0; cursor += str8_deserial_read_struct(raw_data, cursor, &handler_data_voff); - + // TODO: what is this? padding? U32 unknown = 0; cursor += str8_deserial_read_struct(raw_data, cursor, &unknown); - + // read function info U64 handler_data_foff = coff_foff_from_voff(sections, section_count, handler_data_voff); - + MSCRT_FuncInfo32 func_info32 = {0}; str8_deserial_read_struct(raw_data, handler_data_foff, &func_info32); - + // unwind map MSCRT_UnwindMap32 *unwind_map = push_array(arena, MSCRT_UnwindMap32, func_info32.max_state); U64 unwind_map_foff = coff_foff_from_voff(sections, section_count, func_info32.unwind_map_voff); cursor += str8_deserial_read_array(raw_data, unwind_map_foff, &unwind_map[0], func_info32.max_state); - + // read ip states MSCRT_IPState32 *ip_map = push_array(arena, MSCRT_IPState32, func_info32.ip_map_count); U64 ip_map_foff = coff_foff_from_voff(sections, section_count, func_info32.ip_map_voff); str8_deserial_read_array(raw_data, ip_map_foff, &ip_map[0], func_info32.ip_map_count); - + // read try map MSCRT_TryMapBlock *try_block_map = push_array(arena, MSCRT_TryMapBlock, func_info32.try_block_map_count); U64 try_map_foff = coff_foff_from_voff(sections, section_count, func_info32.try_block_map_voff); for (U32 imap = 0; imap < func_info32.try_block_map_count; ++imap) { MSCRT_TryMapBlock32 map32 = {0}; str8_deserial_read_struct(raw_data, try_map_foff + imap*sizeof(map32), &map32); - + // convert try map to in-memory version MSCRT_TryMapBlock *map = &try_block_map[imap]; map->try_low = map32.try_low; @@ -48,26 +48,26 @@ mscrt_parse_func_info(Arena *arena, map->catch_high = map32.catch_high; map->catch_handlers_count = map32.catch_handlers_count; map->catch_handlers = push_array(arena, MSCRT_EhHandlerType32, map32.catch_handlers_count); - + // read handlers U64 catch_handlers_foff = coff_foff_from_voff(sections, section_count, map32.catch_handlers_voff); str8_deserial_read_array(raw_data, catch_handlers_foff, &map->catch_handlers[0], map->catch_handlers_count); } - + // read exception spec list MSCRT_ExceptionSpecTypeList es_type_list = {0}; if (func_info32.es_type_list_voff) { MSCRT_ExceptionSpecTypeList32 es_list32 = {0}; U64 es_list_foff = coff_foff_from_voff(sections, section_count, func_info32.es_type_list_voff); str8_deserial_read_struct(raw_data, es_list_foff, &es_list32); - + es_type_list.count = es_list32.count; es_type_list.handlers = push_array(arena, MSCRT_EhHandlerType32, es_list32.count); - + U64 handlers_foff = coff_foff_from_voff(sections, section_count, es_list32.handlers_voff); str8_deserial_read_array(raw_data, handlers_foff, &es_type_list.handlers[0], es_type_list.count); } - + // pack result func_info->magic = func_info32.magic; func_info->max_state = func_info32.max_state; @@ -79,7 +79,7 @@ mscrt_parse_func_info(Arena *arena, func_info->frame_offset_unwind_helper = func_info32.frame_offset_unwind_helper; func_info->es_type_list = es_type_list; func_info->eh_flags = func_info32.eh_flags; - + U64 parse_size = (cursor - off); return parse_size; } @@ -90,10 +90,10 @@ internal U64 mscrt_v4_parse_u32(String8 raw_data, U64 offset, U32 *uint_out) { U64 cursor = offset; - + U8 one = 0; cursor += str8_deserial_read_struct(raw_data, cursor, &one); - + if ((one & 0xF) == 15) { U8 two = 0, three = 0, four = 0, five = 0; cursor += str8_deserial_read_struct(raw_data, cursor, &two); @@ -119,7 +119,7 @@ mscrt_v4_parse_u32(String8 raw_data, U64 offset, U32 *uint_out) } else { *uint_out = one >> 1; } - + U64 read_size = cursor - offset; return read_size; } @@ -134,7 +134,7 @@ internal U64 mscrt_parse_handler_type_v4(String8 raw_data, U64 offset, U64 func_voff, MSCRT_EhHandlerTypeV4 *handler) { U64 cursor = offset; - + cursor += str8_deserial_read_struct(raw_data, cursor, &handler->flags); if (handler->flags & MSCRT_EhHandlerV4Flag_Adjectives) { cursor += mscrt_v4_parse_u32(raw_data, cursor, &handler->adjectives); @@ -146,47 +146,47 @@ mscrt_parse_handler_type_v4(String8 raw_data, U64 offset, U64 func_voff, MSCRT_E cursor += mscrt_v4_parse_u32(raw_data, cursor, &handler->catch_obj_voff); } cursor += mscrt_v4_parse_s32(raw_data, cursor, &handler->catch_code_voff); - + U32 cont_type = (handler->flags & MSCRT_EhHandlerV4Flag_ContVOffMask) >> MSCRT_EhHandlerV4Flag_ContVOffShift; if (handler->flags & MSCRT_EhHandlerV4Flag_ContIsVOff) { switch (cont_type) { - case MSCRT_ContV4Type_NoMetadata: break; - case MSCRT_ContV4Type_OneFuncRelAddr: { - S32 v = 0; - cursor += mscrt_v4_parse_s32(raw_data, cursor, &v); - handler->catch_funclet_cont_addr[0] = (U64)v; - handler->catch_funclet_cont_addr_count = 1; - } break; - case MSCRT_ContV4Type_TwoFuncRelAddr: { - S32 v1 = 0, v2 = 0; - cursor += mscrt_v4_parse_s32(raw_data, cursor, &v1); - cursor += mscrt_v4_parse_s32(raw_data, cursor, &v2); - handler->catch_funclet_cont_addr[0] = (U64)v1; - handler->catch_funclet_cont_addr[1] = (U64)v2; - handler->catch_funclet_cont_addr_count = 2; - } break; + case MSCRT_ContV4Type_NoMetadata: break; + case MSCRT_ContV4Type_OneFuncRelAddr: { + S32 v = 0; + cursor += mscrt_v4_parse_s32(raw_data, cursor, &v); + handler->catch_funclet_cont_addr[0] = (U64)v; + handler->catch_funclet_cont_addr_count = 1; + } break; + case MSCRT_ContV4Type_TwoFuncRelAddr: { + S32 v1 = 0, v2 = 0; + cursor += mscrt_v4_parse_s32(raw_data, cursor, &v1); + cursor += mscrt_v4_parse_s32(raw_data, cursor, &v2); + handler->catch_funclet_cont_addr[0] = (U64)v1; + handler->catch_funclet_cont_addr[1] = (U64)v2; + handler->catch_funclet_cont_addr_count = 2; + } break; } } else { switch (cont_type) { - case MSCRT_ContV4Type_NoMetadata: { - } break; - case MSCRT_ContV4Type_OneFuncRelAddr: { - U32 v = 0; - cursor += mscrt_v4_parse_u32(raw_data, cursor, &v); - handler->catch_funclet_cont_addr[0] = func_voff + (U64)v; - handler->catch_funclet_cont_addr_count = 1; - } break; - case MSCRT_ContV4Type_TwoFuncRelAddr: { - U32 v1 = 0, v2 = 0; - cursor += mscrt_v4_parse_u32(raw_data, cursor, &v1); - cursor += mscrt_v4_parse_u32(raw_data, cursor, &v2); - handler->catch_funclet_cont_addr[0] = func_voff + (U64)v1; - handler->catch_funclet_cont_addr[1] = func_voff + (U64)v2; - handler->catch_funclet_cont_addr_count = 2; - } break; + case MSCRT_ContV4Type_NoMetadata: { + } break; + case MSCRT_ContV4Type_OneFuncRelAddr: { + U32 v = 0; + cursor += mscrt_v4_parse_u32(raw_data, cursor, &v); + handler->catch_funclet_cont_addr[0] = func_voff + (U64)v; + handler->catch_funclet_cont_addr_count = 1; + } break; + case MSCRT_ContV4Type_TwoFuncRelAddr: { + U32 v1 = 0, v2 = 0; + cursor += mscrt_v4_parse_u32(raw_data, cursor, &v1); + cursor += mscrt_v4_parse_u32(raw_data, cursor, &v2); + handler->catch_funclet_cont_addr[0] = func_voff + (U64)v1; + handler->catch_funclet_cont_addr[1] = func_voff + (U64)v2; + handler->catch_funclet_cont_addr_count = 2; + } break; } } - + U64 read_size = cursor - offset; return read_size; } @@ -201,7 +201,7 @@ mscrt_parse_handler_type_v4_array(Arena *arena, U64 cursor = offset; U32 count = 0; cursor += mscrt_v4_parse_u32(raw_data, cursor, &count); - + MSCRT_EhHandlerTypeV4 *handlers = 0; if (count) { handlers = push_array(arena, MSCRT_EhHandlerTypeV4, count); @@ -209,10 +209,10 @@ mscrt_parse_handler_type_v4_array(Arena *arena, cursor += mscrt_parse_handler_type_v4(raw_data, cursor, func_voff, &handlers[i]); } } - + array_out->count = count; array_out->v = handlers; - + U64 read_size = cursor - offset; return read_size; } @@ -221,30 +221,30 @@ internal U64 mscrt_parse_unwind_v4_entry(String8 raw_data, U64 offset, MSCRT_UnwindEntryV4 *entry_out) { U64 cursor = offset; - + U32 type_and_next_off = 0; cursor += mscrt_v4_parse_u32(raw_data, cursor, &type_and_next_off); - + entry_out->type = type_and_next_off & 0x3; entry_out->next_off = type_and_next_off >> 2; - + switch (entry_out->type) { - case MSCRT_UnwindMapV4Type_DtorWithObj: - case MSCRT_UnwindMapV4Type_DtorWithPtrToObj: { - cursor += mscrt_v4_parse_s32(raw_data, cursor, &entry_out->action); - cursor += mscrt_v4_parse_u32(raw_data, cursor, &entry_out->object); - } break; - case MSCRT_UnwindMapV4Type_VOFF: { - cursor += mscrt_v4_parse_s32(raw_data, cursor, &entry_out->action); - } break; - case MSCRT_UnwindMapV4Type_NoUW: { - // no action and/or object is associated with this type - } break; - default: { - Assert(!"unknown unwind entry type"); - } break; + case MSCRT_UnwindMapV4Type_DtorWithObj: + case MSCRT_UnwindMapV4Type_DtorWithPtrToObj: { + cursor += mscrt_v4_parse_s32(raw_data, cursor, &entry_out->action); + cursor += mscrt_v4_parse_u32(raw_data, cursor, &entry_out->object); + } break; + case MSCRT_UnwindMapV4Type_VOFF: { + cursor += mscrt_v4_parse_s32(raw_data, cursor, &entry_out->action); + } break; + case MSCRT_UnwindMapV4Type_NoUW: { + // no action and/or object is associated with this type + } break; + default: { + Assert(!"unknown unwind entry type"); + } break; } - + U64 read_size = cursor - offset; return read_size; } @@ -272,27 +272,27 @@ mscrt_parse_try_block_map_array_v4(Arena *arena, MSCRT_TryBlockMapV4Array *map_out) { U64 cursor = off; - + U32 try_block_map_count = 0; cursor += mscrt_v4_parse_u32(raw_data, cursor, &try_block_map_count); - + MSCRT_TryBlockMapV4 *try_block_map = push_array(arena, MSCRT_TryBlockMapV4, try_block_map_count); for (U32 itry = 0; itry < try_block_map_count; ++itry) { MSCRT_TryBlockMapV4 *try_block = &try_block_map[itry]; cursor += mscrt_v4_parse_u32(raw_data, cursor, &try_block->try_low); cursor += mscrt_v4_parse_u32(raw_data, cursor, &try_block->try_high); cursor += mscrt_v4_parse_u32(raw_data, cursor, &try_block->catch_high); - + S32 handler_array_voff = 0; cursor += mscrt_v4_parse_s32(raw_data, cursor, &handler_array_voff); - + U64 handler_array_foff = coff_foff_from_voff(sections, section_count, (U32)handler_array_voff); mscrt_parse_handler_type_v4_array(arena, raw_data, handler_array_foff, func_voff, &try_block->handlers); } - + map_out->count = try_block_map_count; map_out->v = try_block_map; - + U64 read_size = cursor - off; return read_size; } @@ -305,45 +305,45 @@ mscrt_parse_ip2state_map_v4(Arena *arena, MSCRT_IP2State32V4 *ip2state_map_out) { U64 cursor = off; - + U32 count = 0; cursor += mscrt_v4_parse_u32(raw_data, cursor, &count); - + U32 *voffs = push_array(arena, U32, count); S32 *states = push_array(arena, S32, count); - + U32 prev_voff = func_voff; for (U32 i = 0; i < count; ++i) { // virtual offsets are encoded as deltas cursor += mscrt_v4_parse_u32(raw_data, cursor, &voffs[i]); voffs[i] += prev_voff; prev_voff = voffs[i]; - + // states are encoded with +1 to avoid encoding negative integers U32 encoded_state = 0; cursor += mscrt_v4_parse_u32(raw_data, cursor, &encoded_state); states[i] = (S32)encoded_state - 1; } - + ip2state_map_out->count = count; ip2state_map_out->voffs = voffs; ip2state_map_out->states = states; - + U64 read_size = cursor - off; return read_size; } internal U64 mscrt_parse_func_info_v4(Arena *arena, - String8 raw_data, - U64 section_count, - COFF_SectionHeader *sections, - U64 off, - U64 func_voff, - MSCRT_ParsedFuncInfoV4 *func_info_out) + String8 raw_data, + U64 section_count, + COFF_SectionHeader *sections, + U64 off, + U64 func_voff, + MSCRT_ParsedFuncInfoV4 *func_info_out) { U64 cursor = off; - + MSCRT_FuncInfo32V4 func_info = {0}; cursor += str8_deserial_read_struct(raw_data, cursor, &func_info.header); if (func_info.header & MSCRT_FuncInfoV4Flag_IsBBT) { @@ -364,19 +364,19 @@ mscrt_parse_func_info_v4(Arena *arena, if (func_info.header & MSCRT_FuncInfoV4Flag_IsCatch) { cursor += mscrt_v4_parse_s32(raw_data, cursor, &func_info.wrt_frame_establisher_voff); } - + MSCRT_UnwindMapV4 unwind_map = {0}; if (func_info.header & MSCRT_FuncInfoV4Flag_UnwindMap) { U64 unwind_map_foff = coff_foff_from_voff(sections, section_count, func_info.unwind_map_voff); mscrt_parse_unwind_map_v4(arena, raw_data, unwind_map_foff, &unwind_map); } - + MSCRT_TryBlockMapV4Array try_block_map = {0}; if (func_info.header & MSCRT_FuncInfoV4Flag_TryBlockMap) { U64 try_block_map_foff = coff_foff_from_voff(sections, section_count, func_info.try_block_map_voff); mscrt_parse_try_block_map_array_v4(arena, raw_data, try_block_map_foff, section_count, sections, func_voff, &try_block_map); } - + MSCRT_IP2State32V4 ip2state_map = {0}; if (func_info.header & MSCRT_FuncInfoV4Flag_IsSeparated) { Assert(!"TODO: separated ip2state map"); @@ -384,13 +384,13 @@ mscrt_parse_func_info_v4(Arena *arena, U64 ip_to_state_map_foff = coff_foff_from_voff(sections, section_count, func_info.ip_to_state_map_voff); mscrt_parse_ip2state_map_v4(arena, raw_data, ip_to_state_map_foff, func_voff, &ip2state_map); } - + func_info_out->header = func_info.header; func_info_out->bbt_flags = func_info.bbt_flags; func_info_out->try_block_map = try_block_map; func_info_out->unwind_map = unwind_map; func_info_out->ip2state_map = ip2state_map; - + U64 read_size = cursor - off; return read_size; } @@ -405,29 +405,29 @@ mscrt_catch_blocks_from_data_x8664(Arena *arena, Rng1U64 except_frange) { Temp scratch = scratch_begin(&arena, 1); - + Rng1U64List result = {0}; - + String8 raw_pdata = str8_substr(raw_data, except_frange); U64 pdata_count = raw_pdata.size / sizeof(PE_IntelPdata); PE_IntelPdata *src_pdata = (PE_IntelPdata *)raw_pdata.str; PE_IntelPdata *opl_pdata = src_pdata + pdata_count; - + for (PE_IntelPdata *pdata = src_pdata; pdata < opl_pdata; ++pdata) { U64 uwinfo_foff = coff_foff_from_voff(sections, section_count, pdata->voff_unwind_info); PE_UnwindInfo *uwinfo = str8_deserial_get_raw_ptr(raw_data, uwinfo_foff, sizeof(*uwinfo)); - + U8 flags = PE_UNWIND_INFO_FLAGS_FROM_HDR(uwinfo->header); B32 is_chained = !!(flags & PE_UnwindInfoFlag_CHAINED); B32 has_handler_data = !is_chained && ((flags & (PE_UnwindInfoFlag_EHANDLER | PE_UnwindInfoFlag_UHANDLER)) != 0); - + if (has_handler_data) { Temp temp = temp_begin(scratch.arena); - + U32 actual_code_count = PE_UNWIND_INFO_GET_CODE_COUNT(uwinfo->codes_num); U64 handler_data_foff = uwinfo_foff + sizeof(PE_UnwindInfo) + actual_code_count * sizeof(PE_UnwindCode); U32 handler_voff = *(U32 *)str8_deserial_get_raw_ptr(raw_data, handler_data_foff, sizeof(handler_voff)); - + String8 handler_name = str8_zero(); /* TODO: { @@ -437,14 +437,14 @@ mscrt_catch_blocks_from_data_x8664(Arena *arena, handler_name = syms_group_symbol_name_from_sid(temp.arena, group, unit, sid); } */ - + B32 is_handler_v3_or_below = str8_match_lit("__CxxFrameHandler3", handler_name, 0) || - str8_match_lit("__GSHandlerCheck_EH", handler_name, 0); + str8_match_lit("__GSHandlerCheck_EH", handler_name, 0); if (is_handler_v3_or_below) { U64 func_info_foff = handler_data_foff + sizeof(handler_voff); MSCRT_FuncInfo func_info = {0}; mscrt_parse_func_info(temp.arena, raw_data, section_count, sections, func_info_foff, &func_info); - + for (U32 itry = 0; itry < func_info.try_block_map_count; ++itry) { MSCRT_TryMapBlock *try_block = &func_info.try_block_map[itry]; for (U32 icatch = 0; icatch < try_block->catch_handlers_count; ++icatch) { @@ -456,15 +456,15 @@ mscrt_catch_blocks_from_data_x8664(Arena *arena, } goto next; } - + B32 is_handler_v4 = str8_match_lit("__CxxFrameHandler4", handler_name, 0) || - str8_match_lit("__GSHandlerCheck_EH4", handler_name, 0); + str8_match_lit("__GSHandlerCheck_EH4", handler_name, 0); if (is_handler_v4) { U32 func_info_voff = *(U32 *)str8_deserial_get_raw_ptr(raw_data, handler_data_foff + sizeof(handler_voff), sizeof(func_info_voff)); U64 func_info_foff = coff_foff_from_voff(sections, section_count, func_info_voff); MSCRT_ParsedFuncInfoV4 func_info = {0}; mscrt_parse_func_info_v4(temp.arena, raw_data, section_count, sections, func_info_foff, pdata->voff_first, &func_info); - + for (U32 itry = 0; itry < func_info.try_block_map.count; ++itry) { MSCRT_TryBlockMapV4 *try_block = &func_info.try_block_map.v[itry]; for (U32 icatch = 0; icatch < try_block->handlers.count; ++icatch) { @@ -476,12 +476,12 @@ mscrt_catch_blocks_from_data_x8664(Arena *arena, } goto next; } - - next:; + + next:; temp_end(temp); } } - + scratch_end(scratch); return result; } diff --git a/src/msvc_crt/msvc_crt.h b/src/msvc_crt/msvc_crt.h index 21106ee0..93599237 100644 --- a/src/msvc_crt/msvc_crt.h +++ b/src/msvc_crt/msvc_crt.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef MSVC_CRT @@ -56,7 +56,7 @@ enum MSCRT_Magic1 = 0x19930520, MSCRT_Magic2 = 0x19930521, MSCRT_Magic3 = 0x19930522, - + // pure magic indicates that exception cannot be caught in native or managed code. MSCRT_PureMagic1 = 0x1994000, }; @@ -224,7 +224,7 @@ enum MSCRT_EhHandlerV4Flag_DispType = (1 << 1), // set if type descriptors are present MSCRT_EhHandlerV4Flag_DispCatchObj = (1 << 2), // set if catch object object is present MSCRT_EhHandlerV4Flag_ContIsVOff = (1 << 3), // continuantion addresses are VOFF rather than function relative - + MSCRT_EhHandlerV4Flag_ContVOffMask = 0x30, MSCRT_EhHandlerV4Flag_ContVOffShift = 4, }; diff --git a/src/msvc_crt/msvc_crt_enum.c b/src/msvc_crt/msvc_crt_enum.c index e70e4ed0..40052496 100644 --- a/src/msvc_crt/msvc_crt_enum.c +++ b/src/msvc_crt/msvc_crt_enum.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal String8 diff --git a/src/msvc_crt/msvc_crt_enum.h b/src/msvc_crt/msvc_crt_enum.h index ac71508d..8bc3440c 100644 --- a/src/msvc_crt/msvc_crt_enum.h +++ b/src/msvc_crt/msvc_crt_enum.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef MSVC_CRT_ENUM_H diff --git a/src/mule/inline_body.cpp b/src/mule/inline_body.cpp index f20fb7b6..4bb6352f 100644 --- a/src/mule/inline_body.cpp +++ b/src/mule/inline_body.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) bias = (bias^x)&7; diff --git a/src/mule/mule_c.c b/src/mule/mule_c.c index 92492aba..e67e42fd 100644 --- a/src/mule/mule_c.c +++ b/src/mule/mule_c.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) /* diff --git a/src/mule/mule_c.h b/src/mule/mule_c.h index 1bf51721..3a41e4bf 100644 --- a/src/mule/mule_c.h +++ b/src/mule/mule_c.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) /* diff --git a/src/mule/mule_inline.cpp b/src/mule/mule_inline.cpp index bb5d82ae..bfac4bf0 100644 --- a/src/mule/mule_inline.cpp +++ b/src/mule/mule_inline.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) /* diff --git a/src/mule/mule_main.cpp b/src/mule/mule_main.cpp index c81f4f6e..6b9581a1 100644 --- a/src/mule/mule_main.cpp +++ b/src/mule/mule_main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) /* diff --git a/src/mule/mule_module.cpp b/src/mule/mule_module.cpp index f07a2fcb..c47f74fa 100644 --- a/src/mule/mule_module.cpp +++ b/src/mule/mule_module.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #if _WIN32 diff --git a/src/mule/mule_o2.cpp b/src/mule/mule_o2.cpp index b9e86d19..e427e82e 100644 --- a/src/mule/mule_o2.cpp +++ b/src/mule/mule_o2.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) static int important_s32 = 0; diff --git a/src/mutable_text/mutable_text.c b/src/mutable_text/mutable_text.c index 94549be7..f53585c7 100644 --- a/src/mutable_text/mutable_text.c +++ b/src/mutable_text/mutable_text.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/mutable_text/mutable_text.h b/src/mutable_text/mutable_text.h index 1614ae48..bb6826ac 100644 --- a/src/mutable_text/mutable_text.h +++ b/src/mutable_text/mutable_text.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef MUTABLE_TEXT_H diff --git a/src/os/core/linux/os_core_linux.c b/src/os/core/linux/os_core_linux.c index a44072f7..83921594 100644 --- a/src/os/core/linux/os_core_linux.c +++ b/src/os/core/linux/os_core_linux.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/os/core/linux/os_core_linux.h b/src/os/core/linux/os_core_linux.h index e7d2ba5a..1770d239 100644 --- a/src/os/core/linux/os_core_linux.h +++ b/src/os/core/linux/os_core_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef OS_CORE_LINUX_H diff --git a/src/os/core/linux/os_core_linux_old.c b/src/os/core/linux/os_core_linux_old.c index 247a8248..91a457b0 100644 --- a/src/os/core/linux/os_core_linux_old.c +++ b/src/os/core/linux/os_core_linux_old.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include diff --git a/src/os/core/linux/os_core_linux_old.h b/src/os/core/linux/os_core_linux_old.h index 4b6263d3..efec7159 100644 --- a/src/os/core/linux/os_core_linux_old.h +++ b/src/os/core/linux/os_core_linux_old.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef LINUX_H diff --git a/src/os/core/os_core.c b/src/os/core/os_core.c index 21a0a413..6f4b972c 100644 --- a/src/os/core/os_core.c +++ b/src/os/core/os_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/os/core/os_core.h b/src/os/core/os_core.h index 369070e1..b07f511c 100644 --- a/src/os/core/os_core.h +++ b/src/os/core/os_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef OS_CORE_H diff --git a/src/os/core/win32/os_core_win32.c b/src/os/core/win32/os_core_win32.c index ed69e685..cdb2c2e6 100644 --- a/src/os/core/win32/os_core_win32.c +++ b/src/os/core/win32/os_core_win32.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/os/core/win32/os_core_win32.h b/src/os/core/win32/os_core_win32.h index 9a8f0d12..22a21f80 100644 --- a/src/os/core/win32/os_core_win32.h +++ b/src/os/core/win32/os_core_win32.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef OS_CORE_WIN32_H diff --git a/src/os/gfx/generated/os_gfx.meta.c b/src/os/gfx/generated/os_gfx.meta.c index 1debd74b..b44fa317 100644 --- a/src/os/gfx/generated/os_gfx.meta.c +++ b/src/os/gfx/generated/os_gfx.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/os/gfx/generated/os_gfx.meta.h b/src/os/gfx/generated/os_gfx.meta.h index 46b08d2e..72ccea0c 100644 --- a/src/os/gfx/generated/os_gfx.meta.h +++ b/src/os/gfx/generated/os_gfx.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/os/gfx/linux/os_gfx_linux.c b/src/os/gfx/linux/os_gfx_linux.c index f8d43416..12a9aa56 100644 --- a/src/os/gfx/linux/os_gfx_linux.c +++ b/src/os/gfx/linux/os_gfx_linux.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/os/gfx/linux/os_gfx_linux.h b/src/os/gfx/linux/os_gfx_linux.h index b0e23df2..58e51f27 100644 --- a/src/os/gfx/linux/os_gfx_linux.h +++ b/src/os/gfx/linux/os_gfx_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef OS_GFX_LINUX_H diff --git a/src/os/gfx/os_gfx.c b/src/os/gfx/os_gfx.c index 7523984b..ec0ccade 100644 --- a/src/os/gfx/os_gfx.c +++ b/src/os/gfx/os_gfx.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/os/gfx/os_gfx.h b/src/os/gfx/os_gfx.h index 1058c304..d56a71ca 100644 --- a/src/os/gfx/os_gfx.h +++ b/src/os/gfx/os_gfx.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef OS_GFX_H diff --git a/src/os/gfx/os_gfx.mdesk b/src/os/gfx/os_gfx.mdesk index c86bdea0..fc15a5f2 100644 --- a/src/os/gfx/os_gfx.mdesk +++ b/src/os/gfx/os_gfx.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/os/gfx/stub/os_gfx_stub.h b/src/os/gfx/stub/os_gfx_stub.h index e18b6f64..009f9802 100644 --- a/src/os/gfx/stub/os_gfx_stub.h +++ b/src/os/gfx/stub/os_gfx_stub.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef OS_GFX_STUB_H diff --git a/src/os/gfx/win32/os_gfx_win32.c b/src/os/gfx/win32/os_gfx_win32.c index e298c187..93ad7dcf 100644 --- a/src/os/gfx/win32/os_gfx_win32.c +++ b/src/os/gfx/win32/os_gfx_win32.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/os/gfx/win32/os_gfx_win32.h b/src/os/gfx/win32/os_gfx_win32.h index 3ab4de16..8737055d 100644 --- a/src/os/gfx/win32/os_gfx_win32.h +++ b/src/os/gfx/win32/os_gfx_win32.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef OS_GFX_WIN32_H diff --git a/src/os/os_inc.c b/src/os/os_inc.c index d92f9283..37c3e2aa 100644 --- a/src/os/os_inc.c +++ b/src/os/os_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "os/core/os_core.c" diff --git a/src/os/os_inc.h b/src/os/os_inc.h index ce5246a0..d581fe6a 100644 --- a/src/os/os_inc.h +++ b/src/os/os_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef OS_INC_H diff --git a/src/path/path.c b/src/path/path.c index 32c928b7..780fe27b 100644 --- a/src/path/path.c +++ b/src/path/path.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/path/path.h b/src/path/path.h index 0aa18ec2..55b626ff 100644 --- a/src/path/path.h +++ b/src/path/path.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef PATH_H diff --git a/src/pdb/pdb.c b/src/pdb/pdb.c index ad2b1e10..035ca375 100644 --- a/src/pdb/pdb.c +++ b/src/pdb/pdb.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal U32 diff --git a/src/pdb/pdb.h b/src/pdb/pdb.h index 4afe71b7..a2988b8e 100644 --- a/src/pdb/pdb.h +++ b/src/pdb/pdb.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef PDB_H diff --git a/src/pdb/pdb_parse.c b/src/pdb/pdb_parse.c index 8d75a0d2..ddd57975 100644 --- a/src/pdb/pdb_parse.c +++ b/src/pdb/pdb_parse.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// @@ -76,7 +76,7 @@ pdb_info_from_data(Arena *arena, String8 data){ if (epilogue_base_off <= data.size){ U64 record_off = epilogue_base_off; - + // read table if (hash_table_count > 0) { PDB_InfoNode *first = 0; @@ -103,17 +103,17 @@ pdb_info_from_data(Arena *arena, String8 data){ result->last = last; result->auth_guid = *auth_guid; } - - // read PDB features + + // read PDB features PDB_FeatureFlags features = 0; for (; record_off + sizeof(PDB_FeatureSig) <= data.size; ) { PDB_FeatureSig sig = 0; record_off += str8_deserial_read_struct(data, record_off, &sig); switch (sig) { - case PDB_FeatureSig_NULL: break; - case PDB_FeatureSig_VC140: features |= PDB_FeatureFlag_HAS_ID_STREAM; break; - case PDB_FeatureSig_NO_TYPE_MERGE: features |= PDB_FeatureFlag_NO_TYPE_MERGE; break; - case PDB_FeatureSig_MINIMAL_DEBUG_INFO: features |= PDB_FeatureFlag_MINIMAL_DBG_INFO; break; + case PDB_FeatureSig_NULL: break; + case PDB_FeatureSig_VC140: features |= PDB_FeatureFlag_HAS_ID_STREAM; break; + case PDB_FeatureSig_NO_TYPE_MERGE: features |= PDB_FeatureFlag_NO_TYPE_MERGE; break; + case PDB_FeatureSig_MINIMAL_DEBUG_INFO: features |= PDB_FeatureFlag_MINIMAL_DBG_INFO; break; } } result->features = features; @@ -581,18 +581,18 @@ internal U64 pdb_gsi_symbol_from_string(PDB_GsiParsed *gsi, String8 symbol_data, String8 string) { U64 result = max_U64; - + U32 hash = pdb_hash_v1(string); U32 bucket_idx = hash % ArrayCount(gsi->buckets); PDB_GsiBucket bucket = gsi->buckets[bucket_idx]; - + for(U64 i = 0; i < bucket.count; ++i) { U32 off = bucket.offs[i]; if(off + sizeof(CV_RecHeader) <= symbol_data.size) { CV_RecHeader *sym_header = (CV_RecHeader *)(symbol_data.str + off); - + if(sym_header->size >= sizeof(sym_header->kind)) { U64 opl_off = off + sizeof(sym_header->size) + sym_header->size; @@ -605,7 +605,7 @@ pdb_gsi_symbol_from_string(PDB_GsiParsed *gsi, String8 symbol_data, String8 stri Rng1U64 raw_symbol_range = rng_1u64(off + sizeof(*sym_header), off + (sym_header->size - sizeof(sym_header->kind))); String8 raw_symbol = str8_substr(symbol_data, raw_symbol_range); String8 sym_name = cv_name_from_symbol(sym_header->kind, raw_symbol); - + if(str8_match(sym_name, string, 0)) { result = off; @@ -614,8 +614,8 @@ pdb_gsi_symbol_from_string(PDB_GsiParsed *gsi, String8 symbol_data, String8 stri } } } - -exit:; + + exit:; return result; } @@ -1042,28 +1042,28 @@ internal U32 pdb_strtbl_off_from_string(PDB_Strtbl *strtbl, String8 string) { U32 result = max_U32; - + U32 hash = pdb_hash_v1(string); U32 best_bucket_idx = hash % strtbl->bucket_count; U32 bucket_idx = best_bucket_idx; - + do { String8 test_string = pdb_strtbl_string_from_index(strtbl, bucket_idx); - + if(test_string.size == 0) { break; } - + if(str8_match(test_string, string, 0)) { result = bucket_idx; break; } - + bucket_idx = (bucket_idx+1) % strtbl->buckets_max; } while (bucket_idx != best_bucket_idx); - + return result; } diff --git a/src/pdb/pdb_parse.h b/src/pdb/pdb_parse.h index ec827408..6b028ef4 100644 --- a/src/pdb/pdb_parse.h +++ b/src/pdb/pdb_parse.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef PDB_PARSE_H diff --git a/src/pdb/pdb_stringize.c b/src/pdb/pdb_stringize.c index 75716b5e..78ad4bd9 100644 --- a/src/pdb/pdb_stringize.c +++ b/src/pdb/pdb_stringize.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/pdb/pdb_stringize.h b/src/pdb/pdb_stringize.h index 72df9ee2..ec9ca39c 100644 --- a/src/pdb/pdb_stringize.h +++ b/src/pdb/pdb_stringize.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef PDB_STRINGIZE_H diff --git a/src/pe/dos_program.asm b/src/pe/dos_program.asm index 775659d0..3563abed 100644 --- a/src/pe/dos_program.asm +++ b/src/pe/dos_program.asm @@ -1,4 +1,4 @@ -; Copyright (c) 2024 Epic Games Tools +; Copyright (c) Epic Games Tools ; Licensed under the MIT license (https://opensource.org/license/mit/) ; $ c:\devel\projects\bin\win32\nasm src\pe\dos_program.asm -fbin -o dos_program.bin diff --git a/src/pe/pe.c b/src/pe/pe.c index 36c9e423..9046ddb1 100644 --- a/src/pe/pe.c +++ b/src/pe/pe.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// @@ -209,7 +209,7 @@ internal String8 pe_string_from_global_flags(Arena *arena, PE_GlobalFlags flags) { Temp scratch = scratch_begin(&arena, 1); - + String8List l = {0}; if (flags & PE_GlobalFlags_STOP_ON_EXCEPTION) { str8_list_pushf(scratch.arena, &l, "STOP_ON_EXCEPTION"); @@ -304,7 +304,7 @@ pe_string_from_global_flags(Arena *arena, PE_GlobalFlags flags) if (flags & PE_GlobalFlags_DISABLE_PROTDLLS) { str8_list_pushf(scratch.arena, &l, "DISABLE_PROTDLLS"); } - + String8 result = str8_list_join(arena, &l, &(StringJoin){.sep=str8_lit(" ")}); return result; } @@ -345,7 +345,7 @@ pe_string_from_load_config_guard_flags(Arena *arena, PE_LoadConfigGuardFlags fla if (flags & PE_LoadConfigGuardFlags_EH_CONTINUATION_TABLE_PRESENT) { str8_list_pushf(scratch.arena, &l, "EH_CONTINUATION_TABLE_PRESENT"); } - + String8 result = str8_list_join(arena, &l, &(StringJoin){.sep = str8_lit(" ")}); scratch_end(scratch); return result; @@ -615,7 +615,7 @@ pe_bin_info_from_data(Arena *arena, String8 data) info.data_dir_count = data_dir_count; info.tls_header = tls_header; } - + return info; } @@ -623,7 +623,7 @@ internal PE_DebugInfoList pe_parse_debug_directory(Arena *arena, String8 raw_image, String8 raw_debug_dir) { PE_DebugInfoList result = {0}; - + PE_DebugDirectory *debug_entry = str8_deserial_get_raw_ptr(raw_debug_dir, 0, sizeof(*debug_entry)); PE_DebugDirectory *debug_entry_opl = debug_entry + raw_debug_dir.size/sizeof(*debug_entry_opl); for (PE_DebugDirectory *entry = debug_entry; entry < debug_entry_opl; ++entry) { @@ -632,14 +632,14 @@ pe_parse_debug_directory(Arena *arena, String8 raw_image, String8 raw_debug_dir) PE_DebugInfoNode *n = push_array(arena, PE_DebugInfoNode, 1); n->v.header = *entry; n->v.u.raw_data = str8_substr(raw_image, rng_1u64(entry->foff, entry->foff + entry->size)); - + SLLQueuePush(result.first, result.last, n); ++result.count; } break; case PE_DebugDirectoryType_CODEVIEW: { U32 cv_magic = 0; str8_deserial_read_struct(raw_image, entry->foff, &cv_magic); - + switch (cv_magic) { case PE_CODEVIEW_PDB20_MAGIC: { PE_CvHeaderPDB20 cv = {0}; @@ -647,12 +647,12 @@ pe_parse_debug_directory(Arena *arena, String8 raw_image, String8 raw_debug_dir) if (cv_read_size == sizeof(cv)) { String8 path = {0}; str8_deserial_read_cstr(raw_image, entry->foff+sizeof(cv), &path); - + PE_DebugInfoNode *n = push_array(arena, PE_DebugInfoNode, 1); n->v.header = *entry; n->v.u.codeview.pdb20.header = cv; n->v.u.codeview.pdb20.path = path; - + SLLQueuePush(result.first, result.last, n); ++result.count; } else { @@ -665,12 +665,12 @@ pe_parse_debug_directory(Arena *arena, String8 raw_image, String8 raw_debug_dir) if (cv_read_size == sizeof(cv)) { String8 path = {0}; str8_deserial_read_cstr(raw_image, entry->foff+sizeof(cv), &path); - + PE_DebugInfoNode *n = push_array(arena, PE_DebugInfoNode, 1); n->v.header = *entry; n->v.u.codeview.pdb70.header = cv; n->v.u.codeview.pdb70.path = path; - + SLLQueuePush(result.first, result.last, n); ++result.count; } else { @@ -683,12 +683,12 @@ pe_parse_debug_directory(Arena *arena, String8 raw_image, String8 raw_debug_dir) if (cv_read_size == sizeof(cv)) { String8 path = {0}; str8_deserial_read_cstr(raw_image, entry->foff+sizeof(cv), &path); - + PE_DebugInfoNode *n = push_array(arena, PE_DebugInfoNode, 1); n->v.header = *entry; n->v.u.codeview.rdi.header = cv; n->v.u.codeview.rdi.path = path; - + SLLQueuePush(result.first, result.last, n); ++result.count; } else { @@ -700,7 +700,7 @@ pe_parse_debug_directory(Arena *arena, String8 raw_image, String8 raw_debug_dir) } break; } } - + return result; } @@ -711,7 +711,7 @@ internal U64 pe_pdata_off_from_voff__binary_search_x8664(String8 raw_pdata, U64 voff) { U64 result = 0; - + if(raw_pdata.size >= sizeof(PE_IntelPdata)) { U64 pdata_count = raw_pdata.size/sizeof(PE_IntelPdata); @@ -747,7 +747,7 @@ pe_pdata_off_from_voff__binary_search_x8664(String8 raw_pdata, U64 voff) break; } } - + // if we are in range fill result { PE_IntelPdata *pdata = pdata_array + index; @@ -758,7 +758,7 @@ pe_pdata_off_from_voff__binary_search_x8664(String8 raw_pdata, U64 voff) } } } - + return result; } @@ -805,7 +805,7 @@ pe_base_reloc_block_list_from_data(Arena *arena, String8 raw_base_relocs) PE_BaseRelocBlockNode *node = push_array(arena, PE_BaseRelocBlockNode, 1); SLLQueuePush(list.first, list.last, node); list.count += 1; - + U64 entries_size = block_size - (sizeof(block_size) + sizeof(page_virt_off)); // rjf: fill block @@ -815,7 +815,7 @@ pe_base_reloc_block_list_from_data(Arena *arena, String8 raw_base_relocs) block->entries = push_array(arena, U16, block->entry_count); U64 entry_read_size = str8_deserial_read_array(raw_base_relocs, off, &block->entries[0], block->entry_count); Assert(entry_read_size == sizeof(block->entries[0]) * block->entry_count); - + off += entry_read_size; } return list; @@ -920,58 +920,58 @@ pe_get_entry_point_names(COFF_MachineType machine, read_only static String8 dll_entry_point_arr[] = { str8_lit_comp("__DllMainCRTStartup@12"), }; - + entry_point_names.v = &dll_entry_point_arr[0]; entry_point_names.count = ArrayCount(dll_entry_point_arr); } else { read_only static String8 dll_entry_point_arr[] = { str8_lit_comp("_DllMainCRTStartup"), }; - + entry_point_names.v = &dll_entry_point_arr[0]; entry_point_names.count = ArrayCount(dll_entry_point_arr); } } else { switch (subsystem) { - case PE_WindowsSubsystem_UNKNOWN: break; - case PE_WindowsSubsystem_WINDOWS_GUI: { - read_only static String8 gui_entry_point_arr[] = { - str8_lit_comp("WinMain"), - str8_lit_comp("wWinMain"), - str8_lit_comp("WinMainCRTStartup"), - str8_lit_comp("wWinMainCRTStartup"), - }; - - entry_point_names.v = &gui_entry_point_arr[0]; - entry_point_names.count = ArrayCount(gui_entry_point_arr); - } break; - case PE_WindowsSubsystem_WINDOWS_CUI: { - read_only static String8 cui_entry_point_arr[] = { - str8_lit_comp("main"), - str8_lit_comp("wmain"), - str8_lit_comp("mainCRTStartup"), - str8_lit_comp("wmainCRTStartup"), - }; - - entry_point_names.v = &cui_entry_point_arr[0]; - entry_point_names.count = ArrayCount(cui_entry_point_arr); - } break; - case PE_WindowsSubsystem_NATIVE: - case PE_WindowsSubsystem_OS2_CUI: - case PE_WindowsSubsystem_POSIX_CUI: - case PE_WindowsSubsystem_NATIVE_WINDOWS: - case PE_WindowsSubsystem_WINDOWS_CE_GUI: - case PE_WindowsSubsystem_EFI_APPLICATION: - case PE_WindowsSubsystem_EFI_BOOT_SERVICE_DRIVER: - case PE_WindowsSubsystem_EFI_RUNTIME_DRIVER: - case PE_WindowsSubsystem_EFI_ROM: - case PE_WindowsSubsystem_XBOX: - case PE_WindowsSubsystem_WINDOWS_BOOT_APPLICATION: { - // TODO - } break; + case PE_WindowsSubsystem_UNKNOWN: break; + case PE_WindowsSubsystem_WINDOWS_GUI: { + read_only static String8 gui_entry_point_arr[] = { + str8_lit_comp("WinMain"), + str8_lit_comp("wWinMain"), + str8_lit_comp("WinMainCRTStartup"), + str8_lit_comp("wWinMainCRTStartup"), + }; + + entry_point_names.v = &gui_entry_point_arr[0]; + entry_point_names.count = ArrayCount(gui_entry_point_arr); + } break; + case PE_WindowsSubsystem_WINDOWS_CUI: { + read_only static String8 cui_entry_point_arr[] = { + str8_lit_comp("main"), + str8_lit_comp("wmain"), + str8_lit_comp("mainCRTStartup"), + str8_lit_comp("wmainCRTStartup"), + }; + + entry_point_names.v = &cui_entry_point_arr[0]; + entry_point_names.count = ArrayCount(cui_entry_point_arr); + } break; + case PE_WindowsSubsystem_NATIVE: + case PE_WindowsSubsystem_OS2_CUI: + case PE_WindowsSubsystem_POSIX_CUI: + case PE_WindowsSubsystem_NATIVE_WINDOWS: + case PE_WindowsSubsystem_WINDOWS_CE_GUI: + case PE_WindowsSubsystem_EFI_APPLICATION: + case PE_WindowsSubsystem_EFI_BOOT_SERVICE_DRIVER: + case PE_WindowsSubsystem_EFI_RUNTIME_DRIVER: + case PE_WindowsSubsystem_EFI_ROM: + case PE_WindowsSubsystem_XBOX: + case PE_WindowsSubsystem_WINDOWS_BOOT_APPLICATION: { + // TODO + } break; } } - + return entry_point_names; } @@ -988,9 +988,9 @@ pe_parsed_imports_from_data(Arena *arena, { PE_ParsedImport *imports = 0; U64 import_count = 0; - + U64 name_table_off = coff_foff_from_voff(sections, section_count, name_table_voff); - + if (is_pe32) { for (;; ++import_count) { U32 raw_entry = 0; @@ -999,18 +999,18 @@ pe_parsed_imports_from_data(Arena *arena, break; } } - + imports = push_array(arena, PE_ParsedImport, import_count); - + for (U64 imp_idx = 0; imp_idx < import_count; ++imp_idx) { U32 raw_entry = 0; str8_deserial_read_struct(raw_data, name_table_off + imp_idx*sizeof(raw_entry), &raw_entry); - + B32 is_ordinal = raw_entry & (1 << 31); - + PE_ParsedImport *imp = imports+imp_idx; ++imp_idx; - + if (is_ordinal) { // fill out ordinal import imp->type = PE_ParsedImport_Ordinal; @@ -1018,13 +1018,13 @@ pe_parsed_imports_from_data(Arena *arena, } else { // map voff -> foff U64 off = coff_foff_from_voff(sections, section_count, raw_entry); - + // read hint & name U16 hint = 0; String8 name = str8_zero(); str8_deserial_read_struct(raw_data, off, &hint); str8_deserial_read_cstr(raw_data, off+sizeof(hint), &name); - + // fill out named import imp->type = PE_ParsedImport_Name; imp->u.name.hint = hint; @@ -1039,18 +1039,18 @@ pe_parsed_imports_from_data(Arena *arena, break; } } - + imports = push_array(arena, PE_ParsedImport, import_count); - + for (U64 imp_idx = 0; imp_idx < import_count; ++imp_idx) { U64 raw_entry = 0; str8_deserial_read_struct(raw_data, name_table_off + imp_idx*sizeof(raw_entry), &raw_entry); - + B32 is_ordinal = raw_entry & (1ull << 63); - + PE_ParsedImport *imp = imports+imp_idx; ++imp_idx; - + if (is_ordinal) { // fill out ordinal import imp->type = PE_ParsedImport_Ordinal; @@ -1058,13 +1058,13 @@ pe_parsed_imports_from_data(Arena *arena, } else { // map voff -> foff U64 off = coff_foff_from_voff(sections, section_count, raw_entry); - + // read hint & name U16 hint = 0; String8 name = str8_zero(); str8_deserial_read_struct(raw_data, off, &hint); str8_deserial_read_cstr(raw_data, off + sizeof(hint), &name); - + // fill out named import imp->type = PE_ParsedImport_Name; imp->u.name.hint = hint; @@ -1072,7 +1072,7 @@ pe_parsed_imports_from_data(Arena *arena, } } } - + *import_count_out = import_count; return imports; } @@ -1082,11 +1082,11 @@ pe_array_from_null_term_addr(Arena *arena, B32 is_pe32, String8 raw_data, Rng1U6 { U64 *result = 0; *count_out = 0; - + if (is_pe32) { U32 *src = (U32 *)(raw_data.str + range.min); U32 *opl = (U32 *)(raw_data.str + AlignDownPow2(range.max, sizeof(*opl))); - + // count items U32 *ptr; for (ptr = src; ptr < opl && *ptr != 0; ++ptr); @@ -1094,7 +1094,7 @@ pe_array_from_null_term_addr(Arena *arena, B32 is_pe32, String8 raw_data, Rng1U6 // push output array *count_out = (U64)(ptr - src); result = push_array(arena, U64, *count_out); - + // convert & copy for (U64 i = 0; i < *count_out; ++i) { result[i] = (U64)src[i]; @@ -1102,19 +1102,19 @@ pe_array_from_null_term_addr(Arena *arena, B32 is_pe32, String8 raw_data, Rng1U6 } else { U64 *src = (U64 *)(raw_data.str + range.min); U64 *opl = (U64 *)(raw_data.str + AlignDownPow2(range.max, sizeof(*opl))); - + // count items U64 *ptr; for (ptr = src; ptr < opl && *ptr != 0; ++ptr); - + // push output array *count_out = (U64)(ptr - src); result = push_array(arena, U64, *count_out); - + // copy MemoryCopyTyped(result, src, *count_out); } - + return result; } @@ -1136,17 +1136,17 @@ pe_static_imports_from_data(Arena *arena, break; } } - + PE_ParsedStaticDLLImport *dlls = push_array(arena, PE_ParsedStaticDLLImport, dll_count); - + for (U64 dll_idx = 0; dll_idx < dll_count; ++dll_idx) { PE_ImportEntry *raw_dll = str8_deserial_get_raw_ptr(raw_data, dir_file_range.min+(dll_idx*sizeof(*raw_dll)), sizeof(*raw_dll)); - + // get name U64 name_off = coff_foff_from_voff(sections, section_count, raw_dll->name_voff); String8 name = str8_zero(); str8_deserial_read_cstr(raw_data, name_off, &name); - + U64 import_count = 0; PE_ParsedImport *imports = pe_parsed_imports_from_data(arena, is_pe32, @@ -1155,7 +1155,7 @@ pe_static_imports_from_data(Arena *arena, raw_data, raw_dll->lookup_table_voff, &import_count); - + PE_ParsedStaticDLLImport *dll = dlls+dll_idx; dll->name = name; dll->import_address_table_voff = raw_dll->import_addr_table_voff; @@ -1165,11 +1165,11 @@ pe_static_imports_from_data(Arena *arena, dll->import_count = import_count; dll->imports = imports; } - + PE_ParsedStaticImportTable imptab = {0}; imptab.count = dll_count; imptab.v = dlls; - + return imptab; } @@ -1190,16 +1190,16 @@ pe_delay_imports_from_data(Arena *arena, break; } } - + // parse dll imports PE_ParsedDelayDLLImport *dlls = push_array(arena, PE_ParsedDelayDLLImport, dll_count); for (U64 dll_idx = 0; dll_idx < dll_count; ++dll_idx) { PE_DelayedImportEntry *raw_dll = str8_deserial_get_raw_ptr(raw_data, dir_file_range.min+(dll_idx*sizeof(*raw_dll)), sizeof(*raw_dll)); - + U64 name_off = coff_foff_from_voff(sections, section_count, raw_dll->name_voff); String8 name = str8_zero(); str8_deserial_read_cstr(raw_data, name_off, &name); - + // parse import table U64 import_count = 0; PE_ParsedImport *imports = pe_parsed_imports_from_data(arena, @@ -1209,19 +1209,19 @@ pe_delay_imports_from_data(Arena *arena, raw_data, raw_dll->name_table_voff, &import_count); - + // parse bound table U64 bound_table_foff = coff_foff_from_voff(sections, section_count, raw_dll->bound_table_voff); Rng1U64 bound_table_range = rng_1u64(bound_table_foff, raw_data.size); U64 bound_table_count; U64 * bound_table = pe_array_from_null_term_addr(arena, is_pe32, raw_data, bound_table_range, &bound_table_count); - + // parse unload table U64 unload_table_foff = coff_foff_from_voff(sections, section_count, raw_dll->unload_table_voff); Rng1U64 unload_table_range = rng_1u64(unload_table_foff, raw_data.size); U64 unload_table_count; U64 * unload_table = pe_array_from_null_term_addr(arena, is_pe32, raw_data, unload_table_range, &unload_table_count); - + // fill out DLL PE_ParsedDelayDLLImport *dll = dlls+dll_idx; dll->attributes = raw_dll->attributes; @@ -1239,12 +1239,12 @@ pe_delay_imports_from_data(Arena *arena, dll->import_count = import_count; dll->imports = imports; } - + // fill out result PE_ParsedDelayImportTable imptab = {0}; imptab.count = dll_count; imptab.v = dlls; - + return imptab; } @@ -1252,20 +1252,20 @@ internal PE_ParsedExportTable pe_exports_from_data(Arena *arena, U64 section_count, COFF_SectionHeader *sections, String8 raw_data, Rng1U64 dir_file_range, Rng1U64 dir_virt_range) { Temp scratch = scratch_begin(&arena, 1); - + PE_ParsedExportTable exptab = {0}; - + String8 raw_dir = str8_substr(raw_data, dir_file_range); PE_ExportTableHeader *header = str8_deserial_get_raw_ptr(raw_dir, 0, sizeof(*header)); if (header) { U64 name_table_off = coff_foff_from_voff(sections, section_count, header->name_pointer_table_voff); U64 export_table_off = coff_foff_from_voff(sections, section_count, header->export_address_table_voff); U64 ordinal_table_off = coff_foff_from_voff(sections, section_count, header->ordinal_table_voff); - + U32 *name_table = str8_deserial_get_raw_ptr(raw_data, name_table_off, sizeof(*name_table )*header->name_pointer_table_count); U32 *export_table = str8_deserial_get_raw_ptr(raw_data, export_table_off, sizeof(*export_table )*header->export_address_table_count); U16 *ordinal_table = str8_deserial_get_raw_ptr(raw_data, ordinal_table_off, sizeof(*ordinal_table)*header->name_pointer_table_count); - + if (name_table && export_table && ordinal_table) { // Scan export address table to get accruate count of ordinals. // We can't rely on "name_pointer_table_count" becuase it is possible @@ -1276,36 +1276,36 @@ pe_exports_from_data(Arena *arena, U64 section_count, COFF_SectionHeader *sectio ++ordinal_count; } } - + U64 ordinal_max = header->export_address_table_count; B32 *is_ordinal_used = push_array(scratch.arena, B32, ordinal_max); - + PE_ParsedExport *exports = push_array(arena, PE_ParsedExport, ordinal_count); PE_ParsedExport *curr_exp = exports; - + // parse exports with name for (U64 i = 0; i < header->name_pointer_table_count; ++i) { // get name U32 name_voff = name_table[i]; U64 name_foff = coff_foff_from_voff(sections, section_count, name_voff); String8 name = str8_cstring_capped(raw_data.str+name_foff, raw_data.str+raw_data.size); - + // get ordinal U16 ordinal_nb = ordinal_table[i]; - + // mark ordinal Assert(ordinal_nb < ordinal_max); is_ordinal_used[ordinal_nb] = 1; - + // get voff U32 export_voff = 0; if (ordinal_nb < header->export_address_table_count) { export_voff = export_table[ordinal_nb]; } - + // make ordinal U16 ordinal = header->ordinal_base + ordinal_nb; - + String8 forwarder = str8_zero(); { B32 is_forwarder = dir_virt_range.min <= export_voff && export_voff < dir_virt_range.max; @@ -1314,14 +1314,14 @@ pe_exports_from_data(Arena *arena, U64 section_count, COFF_SectionHeader *sectio str8_deserial_read_cstr(raw_data, fwd_name_off, &forwarder); } } - + curr_exp->forwarder = forwarder; curr_exp->name = name; curr_exp->voff = export_voff; curr_exp->ordinal = ordinal; ++curr_exp; } - + // parse exports with ordinal for (U64 ordinal_nb = 0; ordinal_nb < header->export_address_table_count; ++ordinal_nb) { U32 voff = export_table[ordinal_nb]; @@ -1334,7 +1334,7 @@ pe_exports_from_data(Arena *arena, U64 section_count, COFF_SectionHeader *sectio ++curr_exp; } } - + // fill out result exptab.flags = header->flags; exptab.time_stamp = header->time_stamp; @@ -1345,7 +1345,7 @@ pe_exports_from_data(Arena *arena, U64 section_count, COFF_SectionHeader *sectio exptab.exports = exports; } } - + scratch_end(scratch); return exptab; } @@ -1361,32 +1361,32 @@ pe_tls_from_data(Arena *arena, Rng1U64 tls_frange) { String8 raw_tls = str8_substr(raw_data, tls_frange); - + PE_TLSHeader64 header64 = {0}; U64 callback_count = 0; U64 *callback_addrs = 0; - + switch (machine) { case COFF_MachineType_Unknown: break; case COFF_MachineType_X86: { PE_TLSHeader32 header32 = {0}; str8_deserial_read_struct(raw_tls, 0, &header32); - + header64.raw_data_start = header32.raw_data_start; header64.raw_data_end = header32.raw_data_end; header64.index_address = header32.index_address; header64.callbacks_address = header32.callbacks_address; header64.zero_fill_size = header32.zero_fill_size; header64.characteristics = header32.characteristics; - + U64 callbacks_voff = header32.callbacks_address - image_base; U64 callbacks_foff = coff_foff_from_voff(sections, section_count, callbacks_voff); - + U32 *src = (U32 *)(raw_data.str + callbacks_foff); U32 *opl = (U32 *)(raw_data.str + raw_data.size); U32 *ptr = src; for (; ptr < opl && *ptr != 0; ++ptr); - + callback_count = (U64)(ptr-src); callback_addrs = push_array(arena, U64, callback_count); for (U64 i = 0; i < callback_count; ++i) { @@ -1395,27 +1395,27 @@ pe_tls_from_data(Arena *arena, } break; case COFF_MachineType_X64: { str8_deserial_read_struct(raw_tls, 0, &header64); - + U64 callbacks_voff = header64.callbacks_address - image_base; U64 callbacks_foff = coff_foff_from_voff(sections, section_count, callbacks_voff); - + U64 *src = (U64 *)(raw_data.str + callbacks_foff); U64 *opl = (U64 *)(raw_data.str + raw_data.size); U64 *ptr = src; for (; ptr < opl && *ptr != 0; ++ptr); - + callback_count = (U64)(ptr-src); callback_addrs = push_array(arena, U64, callback_count); MemoryCopyTyped(callback_addrs, src, callback_count); } break; default: NotImplemented; } - + PE_ParsedTLS result = {0}; result.header = header64; result.callback_count = callback_count; result.callback_addrs = callback_addrs; - + return result; } @@ -1691,11 +1691,11 @@ pe_make_manifest_resource(Arena *arena, U32 resource_id, String8 manifest_data) COFF_ResourceID type = {0}; type.type = COFF_ResourceIDType_Number; type.u.number = PE_ResourceKind_MANIFEST; - + COFF_ResourceID id = {0}; id.type = COFF_ResourceIDType_Number; id.u.number = resource_id; - + String8 res = coff_write_resource(arena, type, id, 1, 0, 1033, 0, 0, manifest_data); return res; } @@ -1719,7 +1719,7 @@ pe_make_debug_header_pdb70(Arena *arena, Guid guid, U32 age, String8 pdb_path) str8_serial_push_cstr(scratch.arena, &cv_list, pdb_path); String8 cv_data = str8_serial_end(arena, &cv_list); - + scratch_end(scratch); return cv_data; } @@ -1728,18 +1728,18 @@ internal String8 pe_make_debug_header_rdi(Arena *arena, Guid guid, String8 rdi_path) { Temp scratch = scratch_begin(&arena,1); - + PE_CvHeaderRDI header = {0}; header.magic = PE_CODEVIEW_RDI_MAGIC; header.guid = guid; - + String8List list = {0}; str8_serial_begin(scratch.arena, &list); str8_serial_push_struct(scratch.arena, &list, &header); str8_serial_push_cstr(scratch.arena, &list, rdi_path); - + String8 cv_data = str8_serial_end(arena, &list); - + scratch_end(scratch); return cv_data; } diff --git a/src/pe/pe.h b/src/pe/pe.h index 7dadd496..cefd15a4 100644 --- a/src/pe/pe.h +++ b/src/pe/pe.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef PE_H @@ -386,14 +386,14 @@ struct PE_LoadConfig32 U32 security_cookie; U32 seh_handler_table; U32 seh_handler_count; - + // msvc 2015 U32 guard_cf_check_func_ptr; U32 guard_cf_dispatch_func_ptr; U32 guard_cf_func_table; U32 guard_cf_func_count; U32 guard_flags; - + // msvc 2017 PE_LoadConfigCodeIntegrity code_integrity; U32 guard_address_taken_iat_entry_table; @@ -409,7 +409,7 @@ struct PE_LoadConfig32 U16 reserved2; U32 guard_rf_verify_stack_pointer_func_ptr; U32 hot_patch_table_offset; - + // msvc 2019 U32 reserved3; U32 enclave_config_ptr; @@ -445,14 +445,14 @@ struct PE_LoadConfig64 U64 security_cookie; U64 seh_handler_table; U64 seh_handler_count; - + // msvc 2015 U64 guard_cf_check_func_ptr; U64 guard_cf_dispatch_func_ptr; U64 guard_cf_func_table; U64 guard_cf_func_count; U32 guard_flags; - + // msvc 2017 PE_LoadConfigCodeIntegrity code_integrity; U64 guard_address_taken_iat_entry_table; @@ -468,7 +468,7 @@ struct PE_LoadConfig64 U16 reserved2; U64 guard_rf_verify_stack_pointer_func_ptr; U32 hot_patch_table_offset; - + // msvc 2019 U32 reserved3; U64 enclave_config_ptr; diff --git a/src/ptr_graph_cache/ptr_graph_cache.c b/src/ptr_graph_cache/ptr_graph_cache.c index 9ca8d09d..943f563c 100644 --- a/src/ptr_graph_cache/ptr_graph_cache.c +++ b/src/ptr_graph_cache/ptr_graph_cache.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/ptr_graph_cache/ptr_graph_cache.h b/src/ptr_graph_cache/ptr_graph_cache.h index ff707462..96193eae 100644 --- a/src/ptr_graph_cache/ptr_graph_cache.h +++ b/src/ptr_graph_cache/ptr_graph_cache.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef PTR_GRAPH_CACHE_H diff --git a/src/radcon/radcon.h b/src/radcon/radcon.h index 95631068..faebfd3c 100644 --- a/src/radcon/radcon.h +++ b/src/radcon/radcon.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADCON_H @@ -63,4 +63,4 @@ internal String8 rc_rdi_from_cmd_line(Arena *arena, CmdLine *cmdl); internal void rc_main(CmdLine *cmdl); #endif // RADCON_H - + diff --git a/src/radcon/radcon_coff.c b/src/radcon/radcon_coff.c index 08f40a4a..7ce5b4bb 100644 --- a/src/radcon/radcon_coff.c +++ b/src/radcon/radcon_coff.c @@ -1,37 +1,37 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal RDI_Arch c2r_rdi_arch_from_coff_machine(COFF_MachineType machine) { switch (machine) { - case COFF_MachineType_X86: return RDI_Arch_X86; - case COFF_MachineType_X64: return RDI_Arch_X64; - - case COFF_MachineType_Unknown: - case COFF_MachineType_Am33: - case COFF_MachineType_Arm: - case COFF_MachineType_Arm64: - case COFF_MachineType_ArmNt: - case COFF_MachineType_Ebc: - case COFF_MachineType_Ia64: - case COFF_MachineType_M32R: - case COFF_MachineType_Mips16: - case COFF_MachineType_MipsFpu: - case COFF_MachineType_MipsFpu16: - case COFF_MachineType_PowerPc: - case COFF_MachineType_PowerPcFp: - case COFF_MachineType_R4000: - case COFF_MachineType_RiscV32: - case COFF_MachineType_RiscV64: - case COFF_MachineType_Sh3: - case COFF_MachineType_Sh3Dsp: - case COFF_MachineType_Sh4: - case COFF_MachineType_Sh5: - case COFF_MachineType_Thumb: - case COFF_MachineType_WceMipsV2: + case COFF_MachineType_X86: return RDI_Arch_X86; + case COFF_MachineType_X64: return RDI_Arch_X64; + + case COFF_MachineType_Unknown: + case COFF_MachineType_Am33: + case COFF_MachineType_Arm: + case COFF_MachineType_Arm64: + case COFF_MachineType_ArmNt: + case COFF_MachineType_Ebc: + case COFF_MachineType_Ia64: + case COFF_MachineType_M32R: + case COFF_MachineType_Mips16: + case COFF_MachineType_MipsFpu: + case COFF_MachineType_MipsFpu16: + case COFF_MachineType_PowerPc: + case COFF_MachineType_PowerPcFp: + case COFF_MachineType_R4000: + case COFF_MachineType_RiscV32: + case COFF_MachineType_RiscV64: + case COFF_MachineType_Sh3: + case COFF_MachineType_Sh3Dsp: + case COFF_MachineType_Sh4: + case COFF_MachineType_Sh5: + case COFF_MachineType_Thumb: + case COFF_MachineType_WceMipsV2: NotImplemented; - default: + default: return RDI_Arch_NULL; } } @@ -59,13 +59,13 @@ internal RDIM_BinarySectionList c2r_rdi_binary_sections_from_coff_sections(Arena *arena, String8 image_data, String8 string_table, U64 sectab_count, COFF_SectionHeader *sectab) { ProfBeginFunction(); - + RDIM_BinarySectionList binary_sections = {0}; - + for (U64 isec = 0; isec < sectab_count; ++isec) { COFF_SectionHeader *coff_sec = §ab[isec]; RDIM_BinarySection *sec = rdim_binary_section_list_push(arena, &binary_sections); - + sec->name = coff_name_from_section_header(string_table, coff_sec); sec->flags = c2r_rdi_binary_section_flags_from_coff_section_flags(coff_sec->flags); sec->voff_first = coff_sec->voff; @@ -73,7 +73,7 @@ c2r_rdi_binary_sections_from_coff_sections(Arena *arena, String8 image_data, Str sec->foff_first = coff_sec->foff; sec->foff_opl = coff_sec->foff + coff_sec->fsize; } - + ProfEnd(); return binary_sections; } diff --git a/src/radcon/radcon_coff.h b/src/radcon/radcon_coff.h index 252874fd..1b29c820 100644 --- a/src/radcon/radcon_coff.h +++ b/src/radcon/radcon_coff.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADCON_COFF_H diff --git a/src/radcon/radcon_dwarf.c b/src/radcon/radcon_dwarf.c index e2b6af54..c26154e6 100644 --- a/src/radcon/radcon_dwarf.c +++ b/src/radcon/radcon_dwarf.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) // TODO: @@ -35,10 +35,10 @@ internal RDI_RegCode d2r_rdi_reg_from_dw_reg_code(Arch arch, U64 reg_code) { switch (arch) { - case Arch_Null: return 0; - case Arch_x64: return d2r_rdi_reg_from_dw_reg_code_x64(reg_code); - case Arch_x86: return d2r_rdi_reg_from_dw_reg_code_x86(reg_code); - default: InvalidPath; + case Arch_Null: return 0; + case Arch_x64: return d2r_rdi_reg_from_dw_reg_code_x64(reg_code); + case Arch_x86: return d2r_rdi_reg_from_dw_reg_code_x86(reg_code); + default: InvalidPath; } return 0; } @@ -68,21 +68,21 @@ internal RDIM_Type * d2r_type_from_attrib(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { RDIM_Type *type = 0; - + // find attrib DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind); - + // does tag have this attribute? if (attrib->attrib_kind == kind) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); - + if (value_class == DW_AttribClass_Reference) { // resolve reference DW_Reference ref = dw_ref_from_attrib_ptr(input, cu, attrib); - + // TODO: support for external compile unit references AssertAlways(ref.cu == cu); - + // find or create type type = d2r_find_or_create_type_from_offset(arena, type_table, ref.info_off); } else { @@ -91,7 +91,7 @@ d2r_type_from_attrib(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, D } else if (attrib->attrib_kind == DW_Attrib_Null) { type = rdim_builtin_type_from_kind(*type_table->types, RDI_TypeKind_NULL); } - + return type; } @@ -100,7 +100,7 @@ d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 imag { // collect non-contiguous range Rng1U64List ranges = dw_rnglist_from_attrib(arena, input, cu, tag, DW_Attrib_Ranges); - + // debase ranges for (Rng1U64Node *range_n = ranges.first; range_n != 0; range_n = range_n->next) { // TODO: error handling @@ -109,13 +109,13 @@ d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 imag range_n->v.min -= image_base; range_n->v.max -= image_base; } - + // collect contiguous range DW_Attrib *lo_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_Attrib_LowPc); DW_Attrib *hi_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_Attrib_HighPc); if (lo_pc_attrib->attrib_kind != DW_Attrib_Null && hi_pc_attrib->attrib_kind != DW_Attrib_Null) { U64 lo_pc = dw_address_from_attrib_ptr(input, cu, lo_pc_attrib); - + U64 hi_pc; DW_AttribClass hi_pc_class = dw_value_class_from_attrib(cu, hi_pc_attrib); if (hi_pc_class == DW_AttribClass_Address) { @@ -126,17 +126,17 @@ d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 imag } else { AssertAlways(!"undefined attrib encoding"); } - + // TODO: error handling AssertAlways(lo_pc >= image_base); AssertAlways(hi_pc >= image_base); AssertAlways(lo_pc <= hi_pc); - + U64 lo_voff = lo_pc - image_base; U64 hi_voff = hi_pc - image_base; rng1u64_list_push(arena, &ranges, rng_1u64(lo_voff, hi_voff)); } - + return ranges; } @@ -144,7 +144,7 @@ internal RDIM_Type ** d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out) { Temp scratch = scratch_begin(&arena, 1); - + RDIM_TypeList list = {0}; B32 has_vargs = 0; for (DW_TagNode *i = cur_node->first_child; i != 0; i = i->sibling) { @@ -157,18 +157,18 @@ d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input has_vargs = 1; } } - + if (has_vargs) { RDIM_TypeNode *n = push_array(scratch.arena, RDIM_TypeNode, 1); n->v = type_table->varg_type; SLLQueuePush(list.first, list.last, n); ++list.count; } - + // collect params *param_count_out = list.count; RDIM_Type **params = rdim_array_from_type_list(arena, list); - + scratch_end(scratch); return params; } @@ -178,10 +178,10 @@ d2r_unsigned_type_kind_from_size(U64 byte_size) { RDI_TypeKind result = RDI_TypeKind_NULL; switch (byte_size) { - case 1: result = RDI_TypeKind_U8; break; - case 2: result = RDI_TypeKind_U16; break; - case 4: result = RDI_TypeKind_U32; break; - case 8: result = RDI_TypeKind_U64; break; + case 1: result = RDI_TypeKind_U8; break; + case 2: result = RDI_TypeKind_U16; break; + case 4: result = RDI_TypeKind_U32; break; + case 8: result = RDI_TypeKind_U64; break; } return result; } @@ -191,10 +191,10 @@ d2r_signed_type_kind_from_size(U64 byte_size) { RDI_TypeKind result = RDI_TypeKind_NULL; switch (byte_size) { - case 1: result = RDI_TypeKind_S8; break; - case 2: result = RDI_TypeKind_S16; break; - case 4: result = RDI_TypeKind_S32; break; - case 8: result = RDI_TypeKind_S64; break; + case 1: result = RDI_TypeKind_S8; break; + case 2: result = RDI_TypeKind_S16; break; + case 4: result = RDI_TypeKind_S32; break; + case 8: result = RDI_TypeKind_S64; break; } return result; } @@ -203,37 +203,37 @@ internal RDI_EvalTypeGroup d2r_type_group_from_type_kind(RDI_TypeKind x) { switch (x) { - case RDI_TypeKind_NULL: - case RDI_TypeKind_Void: - case RDI_TypeKind_Handle: + case RDI_TypeKind_NULL: + case RDI_TypeKind_Void: + case RDI_TypeKind_Handle: break; - case RDI_TypeKind_UChar8: - case RDI_TypeKind_UChar16: - case RDI_TypeKind_UChar32: - case RDI_TypeKind_U8: - case RDI_TypeKind_U16: - case RDI_TypeKind_U32: - case RDI_TypeKind_U64: - case RDI_TypeKind_U128: - case RDI_TypeKind_U256: - case RDI_TypeKind_U512: + case RDI_TypeKind_UChar8: + case RDI_TypeKind_UChar16: + case RDI_TypeKind_UChar32: + case RDI_TypeKind_U8: + case RDI_TypeKind_U16: + case RDI_TypeKind_U32: + case RDI_TypeKind_U64: + case RDI_TypeKind_U128: + case RDI_TypeKind_U256: + case RDI_TypeKind_U512: return RDI_EvalTypeGroup_U; - case RDI_TypeKind_Char8: - case RDI_TypeKind_Char16: - case RDI_TypeKind_Char32: - case RDI_TypeKind_S8: - case RDI_TypeKind_S16: - case RDI_TypeKind_S32: - case RDI_TypeKind_S64: - case RDI_TypeKind_S128: - case RDI_TypeKind_S256: - case RDI_TypeKind_S512: + case RDI_TypeKind_Char8: + case RDI_TypeKind_Char16: + case RDI_TypeKind_Char32: + case RDI_TypeKind_S8: + case RDI_TypeKind_S16: + case RDI_TypeKind_S32: + case RDI_TypeKind_S64: + case RDI_TypeKind_S128: + case RDI_TypeKind_S256: + case RDI_TypeKind_S512: return RDI_EvalTypeGroup_S; - case RDI_TypeKind_F32: + case RDI_TypeKind_F32: return RDI_EvalTypeGroup_F32; - case RDI_TypeKind_F64: + case RDI_TypeKind_F64: return RDI_EvalTypeGroup_F64; - default: InvalidPath; + default: InvalidPath; } return RDI_EvalTypeGroup_Other; } @@ -250,569 +250,569 @@ d2r_bytecode_from_expression(Arena *arena, B32 *is_addr_out) { Temp scratch = scratch_begin(&arena, 1); - + RDIM_EvalBytecode bc = {0}; - + *is_addr_out = 0; - + struct Frame { struct Frame *next; RDI_EvalTypeGroup value_type; }; struct Frame *stack = 0; #define push_of_type(type) do { \ - struct Frame *f = push_array(scratch.arena, struct Frame, 1); \ - f->value_type = d2r_type_group_from_type_kind(type); \ - SLLStackPush(stack, f); \ +struct Frame *f = push_array(scratch.arena, struct Frame, 1); \ +f->value_type = d2r_type_group_from_type_kind(type); \ +SLLStackPush(stack, f); \ } while (0) #define pop_type() stack->value_type; SLLStackPop(stack) #define peek_type() stack->value_type - - + + RDI_TypeKind addr_type_kind = RDI_TypeKind_NULL; if (address_size == 4) { addr_type_kind = RDI_TypeKind_U32; } else if (address_size == 8) { addr_type_kind = RDI_TypeKind_U64; } - - + + for (U64 cursor = 0; cursor < expr.size; ) { U8 op = 0; cursor += str8_deserial_read_struct(expr, cursor, &op); - + U64 size_param; switch (op) { - case DW_ExprOp_Lit0: case DW_ExprOp_Lit1: case DW_ExprOp_Lit2: - case DW_ExprOp_Lit3: case DW_ExprOp_Lit4: case DW_ExprOp_Lit5: - case DW_ExprOp_Lit6: case DW_ExprOp_Lit7: case DW_ExprOp_Lit8: - case DW_ExprOp_Lit9: case DW_ExprOp_Lit10: case DW_ExprOp_Lit11: - case DW_ExprOp_Lit12: case DW_ExprOp_Lit13: case DW_ExprOp_Lit14: - case DW_ExprOp_Lit15: case DW_ExprOp_Lit16: case DW_ExprOp_Lit17: - case DW_ExprOp_Lit18: case DW_ExprOp_Lit19: case DW_ExprOp_Lit20: - case DW_ExprOp_Lit21: case DW_ExprOp_Lit22: case DW_ExprOp_Lit23: - case DW_ExprOp_Lit24: case DW_ExprOp_Lit25: case DW_ExprOp_Lit26: - case DW_ExprOp_Lit27: case DW_ExprOp_Lit28: case DW_ExprOp_Lit29: - case DW_ExprOp_Lit30: case DW_ExprOp_Lit31: { - U64 lit = op - DW_ExprOp_Lit0; - - rdim_bytecode_push_uconst(arena, &bc, lit); - push_of_type(RDI_TypeKind_U64); - } break; - - case DW_ExprOp_Const1U: { - U8 val = 0; - cursor += str8_deserial_read_struct(expr, cursor, &val); - - rdim_bytecode_push_uconst(arena, &bc, val); - push_of_type(RDI_TypeKind_U8); - } break; - case DW_ExprOp_Const2U: { - U16 val = 0; - cursor += str8_deserial_read_struct(expr, cursor, &val); - - rdim_bytecode_push_uconst(arena, &bc, val); - push_of_type(RDI_TypeKind_U16); - } break; - case DW_ExprOp_Const4U: { - U32 val = 0; - cursor += str8_deserial_read_struct(expr, cursor, &val); - - rdim_bytecode_push_uconst(arena, &bc, val); - push_of_type(RDI_TypeKind_U32); - } break; - case DW_ExprOp_Const8U: { - U64 val = 0; - cursor += str8_deserial_read_struct(expr, cursor, &val); - - rdim_bytecode_push_uconst(arena, &bc, val); - push_of_type(RDI_TypeKind_U64); - } break; - - case DW_ExprOp_Const1S: { - S8 val = 0; - cursor += str8_deserial_read_struct(expr, cursor, &val); - - rdim_bytecode_push_sconst(arena, &bc, val); - push_of_type(RDI_TypeKind_S8); - } break; - case DW_ExprOp_Const2S: { - S16 val = 0; - cursor += str8_deserial_read_struct(expr, cursor, &val); - - rdim_bytecode_push_sconst(arena, &bc, val); - push_of_type(RDI_TypeKind_S16); - } break; - case DW_ExprOp_Const4S: { - S32 val = 0; - cursor += str8_deserial_read_struct(expr, cursor, &val); - - rdim_bytecode_push_sconst(arena, &bc, val); - push_of_type(RDI_TypeKind_S32); - } break; - case DW_ExprOp_Const8S: { - S64 val = 0; - cursor += str8_deserial_read_struct(expr, cursor, &val); - - rdim_bytecode_push_sconst(arena, &bc, val); - push_of_type(RDI_TypeKind_S64); - } break; - - case DW_ExprOp_ConstU: { - U64 val = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &val); - - rdim_bytecode_push_uconst(arena, &bc, val); - push_of_type(RDI_TypeKind_U64); - } break; - - case DW_ExprOp_ConstS: { - S64 val = 0; - cursor += str8_deserial_read_sleb128(expr, cursor, &val); - - rdim_bytecode_push_sconst(arena, &bc, val); - push_of_type(RDI_TypeKind_S64); - } break; - - case DW_ExprOp_Addr: { - U64 addr = 0; - cursor += str8_deserial_read(expr, cursor, &addr, address_size, address_size); - if (addr >= image_base) { - U64 voff = addr - image_base; - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_ModuleOff, voff); - push_of_type(addr_type_kind); - } else { - // TODO: error handling - AssertAlways(!"unable to relocate address"); - } - - *is_addr_out = 1; - } break; - - case DW_ExprOp_Reg0: case DW_ExprOp_Reg1: case DW_ExprOp_Reg2: - case DW_ExprOp_Reg3: case DW_ExprOp_Reg4: case DW_ExprOp_Reg5: - case DW_ExprOp_Reg6: case DW_ExprOp_Reg7: case DW_ExprOp_Reg8: - case DW_ExprOp_Reg9: case DW_ExprOp_Reg10: case DW_ExprOp_Reg11: - case DW_ExprOp_Reg12: case DW_ExprOp_Reg13: case DW_ExprOp_Reg14: - case DW_ExprOp_Reg15: case DW_ExprOp_Reg16: case DW_ExprOp_Reg17: - case DW_ExprOp_Reg18: case DW_ExprOp_Reg19: case DW_ExprOp_Reg20: - case DW_ExprOp_Reg21: case DW_ExprOp_Reg22: case DW_ExprOp_Reg23: - case DW_ExprOp_Reg24: case DW_ExprOp_Reg25: case DW_ExprOp_Reg26: - case DW_ExprOp_Reg27: case DW_ExprOp_Reg28: case DW_ExprOp_Reg29: - case DW_ExprOp_Reg30: case DW_ExprOp_Reg31: { - U64 reg_code_dw = op - DW_ExprOp_Reg0; - U64 reg_size = dw_reg_size_from_code(arch, reg_code_dw); - U64 reg_pos = dw_reg_pos_from_code(arch, reg_code_dw); - - RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); - U32 regread_param = RDI_EncodeRegReadParam(reg_code_rdi, reg_size, reg_pos); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegRead, regread_param); - push_of_type(d2r_unsigned_type_kind_from_size(reg_size)); - } break; - - case DW_ExprOp_RegX: { - U64 reg_code_dw = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, ®_code_dw); - - U64 reg_size = dw_reg_size_from_code(arch, reg_code_dw); - U64 reg_pos = dw_reg_pos_from_code(arch, reg_code_dw); - - RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); - U32 regread_param = RDI_EncodeRegReadParam(reg_code_rdi, reg_size, reg_pos); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegRead, regread_param); - push_of_type(d2r_unsigned_type_kind_from_size(reg_size)); - - *is_addr_out = 1; - } break; - - case DW_ExprOp_ImplicitValue: { - U64 val_size = 0; - String8 val = {0}; - cursor += str8_deserial_read_uleb128(expr, cursor, &val_size); - cursor += str8_deserial_read_block(expr, cursor, val_size, &val); - if (val.size <= sizeof(U64)) { - U64 val64 = 0; - MemoryCopy(&val64, val.str, val.size); - - rdim_bytecode_push_uconst(arena, &bc, val64); - push_of_type(d2r_unsigned_type_kind_from_size(val_size)); - } else { - // TODO: currenlty no way to encode string in RDIM_EvalBytecodeOp - NotImplemented; - } - } break; - - case DW_ExprOp_Piece: { - U64 piece_byte_size = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &piece_byte_size); - - U64 partial_value_size32 = safe_cast_u32(piece_byte_size); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_PartialValue, partial_value_size32); - } break; - - case DW_ExprOp_BitPiece: { - U64 piece_bit_size = 0; - U64 piece_bit_off = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &piece_bit_size); - cursor += str8_deserial_read_uleb128(expr, cursor, &piece_bit_off); - - U32 piece_bit_size32 = safe_cast_u32(piece_bit_size); - U32 piece_bit_off32 = safe_cast_u32(piece_bit_off); - - U64 partial_value = ((U64)piece_bit_size32 << 32) | (U64)piece_bit_off32; - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_PartialValueBit, partial_value); - } break; - - case DW_ExprOp_Pick: { - U8 stack_idx = 0; - cursor += str8_deserial_read_struct(expr, cursor, &stack_idx); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Pick, stack_idx); - } break; - - case DW_ExprOp_PlusUConst: { - U64 addend = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &addend); - rdim_bytecode_push_uconst(arena, &bc, addend); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, RDI_EvalTypeGroup_U); - } break; - - case DW_ExprOp_Skip: { - S16 skip = 0; - cursor += str8_deserial_read_struct(expr, cursor, &skip); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Skip, skip); - } break; - - case DW_ExprOp_Bra: { - NotImplemented; - } break; - - case DW_ExprOp_BReg0: case DW_ExprOp_BReg1: case DW_ExprOp_BReg2: - case DW_ExprOp_BReg3: case DW_ExprOp_BReg4: case DW_ExprOp_BReg5: - case DW_ExprOp_BReg6: case DW_ExprOp_BReg7: case DW_ExprOp_BReg8: - case DW_ExprOp_BReg9: case DW_ExprOp_BReg10: case DW_ExprOp_BReg11: - case DW_ExprOp_BReg12: case DW_ExprOp_BReg13: case DW_ExprOp_BReg14: - case DW_ExprOp_BReg15: case DW_ExprOp_BReg16: case DW_ExprOp_BReg17: - case DW_ExprOp_BReg18: case DW_ExprOp_BReg19: case DW_ExprOp_BReg20: - case DW_ExprOp_BReg21: case DW_ExprOp_BReg22: case DW_ExprOp_BReg23: - case DW_ExprOp_BReg24: case DW_ExprOp_BReg25: case DW_ExprOp_BReg26: - case DW_ExprOp_BReg27: case DW_ExprOp_BReg28: case DW_ExprOp_BReg29: - case DW_ExprOp_BReg30: case DW_ExprOp_BReg31: { - U64 reg_code_dw = op - DW_ExprOp_BReg0; - S64 reg_off = 0; - cursor += str8_deserial_read_sleb128(expr, cursor, ®_off); + case DW_ExprOp_Lit0: case DW_ExprOp_Lit1: case DW_ExprOp_Lit2: + case DW_ExprOp_Lit3: case DW_ExprOp_Lit4: case DW_ExprOp_Lit5: + case DW_ExprOp_Lit6: case DW_ExprOp_Lit7: case DW_ExprOp_Lit8: + case DW_ExprOp_Lit9: case DW_ExprOp_Lit10: case DW_ExprOp_Lit11: + case DW_ExprOp_Lit12: case DW_ExprOp_Lit13: case DW_ExprOp_Lit14: + case DW_ExprOp_Lit15: case DW_ExprOp_Lit16: case DW_ExprOp_Lit17: + case DW_ExprOp_Lit18: case DW_ExprOp_Lit19: case DW_ExprOp_Lit20: + case DW_ExprOp_Lit21: case DW_ExprOp_Lit22: case DW_ExprOp_Lit23: + case DW_ExprOp_Lit24: case DW_ExprOp_Lit25: case DW_ExprOp_Lit26: + case DW_ExprOp_Lit27: case DW_ExprOp_Lit28: case DW_ExprOp_Lit29: + case DW_ExprOp_Lit30: case DW_ExprOp_Lit31: { + U64 lit = op - DW_ExprOp_Lit0; + + rdim_bytecode_push_uconst(arena, &bc, lit); + push_of_type(RDI_TypeKind_U64); + } break; - RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegReadDyn, reg_code_rdi); - if (reg_off > 0) { - rdim_bytecode_push_sconst(arena, &bc, reg_off); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, RDI_EvalTypeGroup_S); - } - push_of_type(RDI_TypeKind_S64); - - *is_addr_out = 1; - } break; - - case DW_ExprOp_BRegX: { - U64 reg_code_dw = 0; - S64 reg_off = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, ®_code_dw); - cursor += str8_deserial_read_sleb128(expr, cursor, ®_off); - - RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegReadDyn, reg_code_rdi); - if (reg_off > 0) { - rdim_bytecode_push_sconst(arena, &bc, reg_off); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, RDI_EvalTypeGroup_S); - } - push_of_type(RDI_TypeKind_S64); - - *is_addr_out = 1; - } break; - - case DW_ExprOp_FBReg: { - S64 frame_off = 0; - cursor += str8_deserial_read_sleb128(expr, cursor, &frame_off); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_FrameOff, frame_off); - - *is_addr_out = 1; - } break; - - case DW_ExprOp_Deref: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_MemRead, address_size); - } break; - - case DW_ExprOp_DerefSize: { - U8 deref_size_in_bytes = 0; - cursor += str8_deserial_read_struct(expr, cursor, &deref_size_in_bytes); - if (0 < deref_size_in_bytes && deref_size_in_bytes <= address_size) { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_MemRead, deref_size_in_bytes); - } else { - // TODO: error handling - AssertAlways(!"ill formed expression"); - } - } break; - - case DW_ExprOp_XDerefSize: { - // TODO: error handling - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Call2: - case DW_ExprOp_Call4: - case DW_ExprOp_CallRef: { - // TODO: error handling - AssertAlways(!"calls are not supported"); - } break; - - case DW_ExprOp_ImplicitPointer: - case DW_ExprOp_GNU_ImplicitPointer: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_Convert: - case DW_ExprOp_GNU_Convert: { - U64 type_info_off = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &type_info_off); - - RDI_EvalTypeGroup in = stack ? d2r_type_group_from_type_kind(stack->value_type) : RDI_EvalTypeGroup_Other; - RDI_EvalTypeGroup out = RDI_EvalTypeGroup_Other; - - if (type_info_off == 0) { - // - // 2.5.1 - // Instead of a base type, elements can have a generic type, - // which is an integral type that has the size of an address - // on the target machine and unspecified signedness. - // - out = d2r_type_group_from_type_kind(addr_type_kind); - } else { - // find ref tag - DW_TagNode *tag_node = dw_tag_node_from_info_off(cu, type_info_off); - DW_Tag tag = tag_node->tag; - if (tag.kind == DW_Tag_BaseType) { - // extract encoding attribute - DW_ATE encoding = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_Encoding); - - // DW_ATE -> RDI_EvalTypeGroup - switch (encoding) { - case DW_ATE_SignedChar: - case DW_ATE_Signed: out = RDI_EvalTypeGroup_S; break; - case DW_ATE_UnsignedChar: - case DW_ATE_Unsigned: out = RDI_EvalTypeGroup_U; break; - case DW_ATE_Float: { - U64 byte_size = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_ByteSize); - switch (byte_size) { - case 4: out = RDI_EvalTypeGroup_F32; break; - case 8: out = RDI_EvalTypeGroup_F64; break; - default: InvalidPath; - } - } break; - default: InvalidPath; - } - } else { - AssertAlways(!"unexpected tag"); // TODO: error handling - } - } - - if (in == RDI_EvalTypeGroup_Other) { - push_of_type(out); - break; - } - - // TODO: error handling - AssertAlways(in != RDI_EvalTypeGroup_Other); - AssertAlways(out != RDI_EvalTypeGroup_Other); - - U16 operand = (U16)in | ((U16)out << 8); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Convert, operand); - } break; - - case DW_ExprOp_GNU_ParameterRef: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_DerefType: - case DW_ExprOp_GNU_DerefType: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_ConstType: - case DW_ExprOp_GNU_ConstType: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_RegvalType: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_EntryValue: - case DW_ExprOp_GNU_EntryValue: { - U64 entry_value_expr_size = 0; - String8 entry_value_expr = {0}; - cursor += str8_deserial_read_uleb128(expr, cursor, &entry_value_expr_size); - cursor += str8_deserial_read_block(expr, cursor, entry_value_expr_size, &entry_value_expr); - - B32 dummy = 0; - RDIM_EvalBytecode call_site_bc = d2r_bytecode_from_expression(arena, input, image_base, address_size, arch, addr_lu, entry_value_expr, cu, &dummy); - - U32 encoded_size32 = safe_cast_u32(call_site_bc.encoded_size); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_CallSiteValue, encoded_size32); - rdim_bytecode_concat_in_place(&bc, &call_site_bc); - } break; - - case DW_ExprOp_Addrx: { - U64 addr_idx = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &addr_idx); - U64 addr = dw_addr_from_list_unit(addr_lu, addr_idx); - if (addr != max_U64) { + case DW_ExprOp_Const1U: { + U8 val = 0; + cursor += str8_deserial_read_struct(expr, cursor, &val); + + rdim_bytecode_push_uconst(arena, &bc, val); + push_of_type(RDI_TypeKind_U8); + } break; + case DW_ExprOp_Const2U: { + U16 val = 0; + cursor += str8_deserial_read_struct(expr, cursor, &val); + + rdim_bytecode_push_uconst(arena, &bc, val); + push_of_type(RDI_TypeKind_U16); + } break; + case DW_ExprOp_Const4U: { + U32 val = 0; + cursor += str8_deserial_read_struct(expr, cursor, &val); + + rdim_bytecode_push_uconst(arena, &bc, val); + push_of_type(RDI_TypeKind_U32); + } break; + case DW_ExprOp_Const8U: { + U64 val = 0; + cursor += str8_deserial_read_struct(expr, cursor, &val); + + rdim_bytecode_push_uconst(arena, &bc, val); + push_of_type(RDI_TypeKind_U64); + } break; + + case DW_ExprOp_Const1S: { + S8 val = 0; + cursor += str8_deserial_read_struct(expr, cursor, &val); + + rdim_bytecode_push_sconst(arena, &bc, val); + push_of_type(RDI_TypeKind_S8); + } break; + case DW_ExprOp_Const2S: { + S16 val = 0; + cursor += str8_deserial_read_struct(expr, cursor, &val); + + rdim_bytecode_push_sconst(arena, &bc, val); + push_of_type(RDI_TypeKind_S16); + } break; + case DW_ExprOp_Const4S: { + S32 val = 0; + cursor += str8_deserial_read_struct(expr, cursor, &val); + + rdim_bytecode_push_sconst(arena, &bc, val); + push_of_type(RDI_TypeKind_S32); + } break; + case DW_ExprOp_Const8S: { + S64 val = 0; + cursor += str8_deserial_read_struct(expr, cursor, &val); + + rdim_bytecode_push_sconst(arena, &bc, val); + push_of_type(RDI_TypeKind_S64); + } break; + + case DW_ExprOp_ConstU: { + U64 val = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &val); + + rdim_bytecode_push_uconst(arena, &bc, val); + push_of_type(RDI_TypeKind_U64); + } break; + + case DW_ExprOp_ConstS: { + S64 val = 0; + cursor += str8_deserial_read_sleb128(expr, cursor, &val); + + rdim_bytecode_push_sconst(arena, &bc, val); + push_of_type(RDI_TypeKind_S64); + } break; + + case DW_ExprOp_Addr: { + U64 addr = 0; + cursor += str8_deserial_read(expr, cursor, &addr, address_size, address_size); if (addr >= image_base) { U64 voff = addr - image_base; rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_ModuleOff, voff); + push_of_type(addr_type_kind); } else { // TODO: error handling AssertAlways(!"unable to relocate address"); } - } else { + + *is_addr_out = 1; + } break; + + case DW_ExprOp_Reg0: case DW_ExprOp_Reg1: case DW_ExprOp_Reg2: + case DW_ExprOp_Reg3: case DW_ExprOp_Reg4: case DW_ExprOp_Reg5: + case DW_ExprOp_Reg6: case DW_ExprOp_Reg7: case DW_ExprOp_Reg8: + case DW_ExprOp_Reg9: case DW_ExprOp_Reg10: case DW_ExprOp_Reg11: + case DW_ExprOp_Reg12: case DW_ExprOp_Reg13: case DW_ExprOp_Reg14: + case DW_ExprOp_Reg15: case DW_ExprOp_Reg16: case DW_ExprOp_Reg17: + case DW_ExprOp_Reg18: case DW_ExprOp_Reg19: case DW_ExprOp_Reg20: + case DW_ExprOp_Reg21: case DW_ExprOp_Reg22: case DW_ExprOp_Reg23: + case DW_ExprOp_Reg24: case DW_ExprOp_Reg25: case DW_ExprOp_Reg26: + case DW_ExprOp_Reg27: case DW_ExprOp_Reg28: case DW_ExprOp_Reg29: + case DW_ExprOp_Reg30: case DW_ExprOp_Reg31: { + U64 reg_code_dw = op - DW_ExprOp_Reg0; + U64 reg_size = dw_reg_size_from_code(arch, reg_code_dw); + U64 reg_pos = dw_reg_pos_from_code(arch, reg_code_dw); + + RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); + U32 regread_param = RDI_EncodeRegReadParam(reg_code_rdi, reg_size, reg_pos); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegRead, regread_param); + push_of_type(d2r_unsigned_type_kind_from_size(reg_size)); + } break; + + case DW_ExprOp_RegX: { + U64 reg_code_dw = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, ®_code_dw); + + U64 reg_size = dw_reg_size_from_code(arch, reg_code_dw); + U64 reg_pos = dw_reg_pos_from_code(arch, reg_code_dw); + + RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); + U32 regread_param = RDI_EncodeRegReadParam(reg_code_rdi, reg_size, reg_pos); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegRead, regread_param); + push_of_type(d2r_unsigned_type_kind_from_size(reg_size)); + + *is_addr_out = 1; + } break; + + case DW_ExprOp_ImplicitValue: { + U64 val_size = 0; + String8 val = {0}; + cursor += str8_deserial_read_uleb128(expr, cursor, &val_size); + cursor += str8_deserial_read_block(expr, cursor, val_size, &val); + if (val.size <= sizeof(U64)) { + U64 val64 = 0; + MemoryCopy(&val64, val.str, val.size); + + rdim_bytecode_push_uconst(arena, &bc, val64); + push_of_type(d2r_unsigned_type_kind_from_size(val_size)); + } else { + // TODO: currenlty no way to encode string in RDIM_EvalBytecodeOp + NotImplemented; + } + } break; + + case DW_ExprOp_Piece: { + U64 piece_byte_size = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &piece_byte_size); + + U64 partial_value_size32 = safe_cast_u32(piece_byte_size); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_PartialValue, partial_value_size32); + } break; + + case DW_ExprOp_BitPiece: { + U64 piece_bit_size = 0; + U64 piece_bit_off = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &piece_bit_size); + cursor += str8_deserial_read_uleb128(expr, cursor, &piece_bit_off); + + U32 piece_bit_size32 = safe_cast_u32(piece_bit_size); + U32 piece_bit_off32 = safe_cast_u32(piece_bit_off); + + U64 partial_value = ((U64)piece_bit_size32 << 32) | (U64)piece_bit_off32; + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_PartialValueBit, partial_value); + } break; + + case DW_ExprOp_Pick: { + U8 stack_idx = 0; + cursor += str8_deserial_read_struct(expr, cursor, &stack_idx); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Pick, stack_idx); + } break; + + case DW_ExprOp_PlusUConst: { + U64 addend = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &addend); + rdim_bytecode_push_uconst(arena, &bc, addend); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, RDI_EvalTypeGroup_U); + } break; + + case DW_ExprOp_Skip: { + S16 skip = 0; + cursor += str8_deserial_read_struct(expr, cursor, &skip); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Skip, skip); + } break; + + case DW_ExprOp_Bra: { + NotImplemented; + } break; + + case DW_ExprOp_BReg0: case DW_ExprOp_BReg1: case DW_ExprOp_BReg2: + case DW_ExprOp_BReg3: case DW_ExprOp_BReg4: case DW_ExprOp_BReg5: + case DW_ExprOp_BReg6: case DW_ExprOp_BReg7: case DW_ExprOp_BReg8: + case DW_ExprOp_BReg9: case DW_ExprOp_BReg10: case DW_ExprOp_BReg11: + case DW_ExprOp_BReg12: case DW_ExprOp_BReg13: case DW_ExprOp_BReg14: + case DW_ExprOp_BReg15: case DW_ExprOp_BReg16: case DW_ExprOp_BReg17: + case DW_ExprOp_BReg18: case DW_ExprOp_BReg19: case DW_ExprOp_BReg20: + case DW_ExprOp_BReg21: case DW_ExprOp_BReg22: case DW_ExprOp_BReg23: + case DW_ExprOp_BReg24: case DW_ExprOp_BReg25: case DW_ExprOp_BReg26: + case DW_ExprOp_BReg27: case DW_ExprOp_BReg28: case DW_ExprOp_BReg29: + case DW_ExprOp_BReg30: case DW_ExprOp_BReg31: { + U64 reg_code_dw = op - DW_ExprOp_BReg0; + S64 reg_off = 0; + cursor += str8_deserial_read_sleb128(expr, cursor, ®_off); + + RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegReadDyn, reg_code_rdi); + if (reg_off > 0) { + rdim_bytecode_push_sconst(arena, &bc, reg_off); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, RDI_EvalTypeGroup_S); + } + push_of_type(RDI_TypeKind_S64); + + *is_addr_out = 1; + } break; + + case DW_ExprOp_BRegX: { + U64 reg_code_dw = 0; + S64 reg_off = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, ®_code_dw); + cursor += str8_deserial_read_sleb128(expr, cursor, ®_off); + + RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegReadDyn, reg_code_rdi); + if (reg_off > 0) { + rdim_bytecode_push_sconst(arena, &bc, reg_off); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, RDI_EvalTypeGroup_S); + } + push_of_type(RDI_TypeKind_S64); + + *is_addr_out = 1; + } break; + + case DW_ExprOp_FBReg: { + S64 frame_off = 0; + cursor += str8_deserial_read_sleb128(expr, cursor, &frame_off); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_FrameOff, frame_off); + + *is_addr_out = 1; + } break; + + case DW_ExprOp_Deref: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_MemRead, address_size); + } break; + + case DW_ExprOp_DerefSize: { + U8 deref_size_in_bytes = 0; + cursor += str8_deserial_read_struct(expr, cursor, &deref_size_in_bytes); + if (0 < deref_size_in_bytes && deref_size_in_bytes <= address_size) { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_MemRead, deref_size_in_bytes); + } else { + // TODO: error handling + AssertAlways(!"ill formed expression"); + } + } break; + + case DW_ExprOp_XDerefSize: { // TODO: error handling - AssertAlways(!"out of bounds index"); - } - } break; - - case DW_ExprOp_CallFrameCfa: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_FrameOff, 0); - } break; - - case DW_ExprOp_FormTlsAddress: { - // TODO: - AssertAlways(!"RDI_EvalOp_TLSOff accepts immediate"); - } break; - - case DW_ExprOp_PushObjectAddress: { - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_Nop: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Noop, 0); - } break; - - case DW_ExprOp_Eq: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_EqEq, peek_type()); - } break; - - case DW_ExprOp_Ge: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_GrEq, peek_type()); - } break; - - case DW_ExprOp_Gt: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Grtr, peek_type()); - } break; - - case DW_ExprOp_Le: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_LsEq, peek_type()); - } break; - - case DW_ExprOp_Lt: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Less, peek_type()); - } break; - - case DW_ExprOp_Ne: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_NtEq, peek_type()); - } break; - - case DW_ExprOp_Shl: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_LShift, peek_type()); - } break; - - case DW_ExprOp_Shr: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RShift, RDI_EvalTypeGroup_U); - } break; - - case DW_ExprOp_Shra: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RShift, RDI_EvalTypeGroup_S); - } break; - - case DW_ExprOp_Xor: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitXor, peek_type()); - } break; - - case DW_ExprOp_XDeref: { - // TODO: error handling - Assert(!"multiple address spaces are not supported"); - } break; - - case DW_ExprOp_Abs: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Abs, peek_type()); - } break; - - case DW_ExprOp_And: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitAnd, peek_type()); - } break; - - case DW_ExprOp_Div: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Div, peek_type()); - } break; - - case DW_ExprOp_Minus: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Sub, peek_type()); - } break; - - case DW_ExprOp_Mod: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Mod, peek_type()); - } break; - - case DW_ExprOp_Mul: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Mul, peek_type()); - } break; - - case DW_ExprOp_Neg: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Neg, peek_type()); - } break; - - case DW_ExprOp_Not: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitNot, peek_type()); - } break; - - case DW_ExprOp_Or: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitOr, peek_type()); - } break; - - case DW_ExprOp_Plus: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, peek_type()); - } break; - - case DW_ExprOp_Rot: { - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Swap: { - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Dup: { - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Drop: { - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Over: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Pick, 1); - } break; - - case DW_ExprOp_StackValue: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Stop, 0); - } break; - - default: InvalidPath; break; + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Call2: + case DW_ExprOp_Call4: + case DW_ExprOp_CallRef: { + // TODO: error handling + AssertAlways(!"calls are not supported"); + } break; + + case DW_ExprOp_ImplicitPointer: + case DW_ExprOp_GNU_ImplicitPointer: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_Convert: + case DW_ExprOp_GNU_Convert: { + U64 type_info_off = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &type_info_off); + + RDI_EvalTypeGroup in = stack ? d2r_type_group_from_type_kind(stack->value_type) : RDI_EvalTypeGroup_Other; + RDI_EvalTypeGroup out = RDI_EvalTypeGroup_Other; + + if (type_info_off == 0) { + // + // 2.5.1 + // Instead of a base type, elements can have a generic type, + // which is an integral type that has the size of an address + // on the target machine and unspecified signedness. + // + out = d2r_type_group_from_type_kind(addr_type_kind); + } else { + // find ref tag + DW_TagNode *tag_node = dw_tag_node_from_info_off(cu, type_info_off); + DW_Tag tag = tag_node->tag; + if (tag.kind == DW_Tag_BaseType) { + // extract encoding attribute + DW_ATE encoding = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_Encoding); + + // DW_ATE -> RDI_EvalTypeGroup + switch (encoding) { + case DW_ATE_SignedChar: + case DW_ATE_Signed: out = RDI_EvalTypeGroup_S; break; + case DW_ATE_UnsignedChar: + case DW_ATE_Unsigned: out = RDI_EvalTypeGroup_U; break; + case DW_ATE_Float: { + U64 byte_size = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_ByteSize); + switch (byte_size) { + case 4: out = RDI_EvalTypeGroup_F32; break; + case 8: out = RDI_EvalTypeGroup_F64; break; + default: InvalidPath; + } + } break; + default: InvalidPath; + } + } else { + AssertAlways(!"unexpected tag"); // TODO: error handling + } + } + + if (in == RDI_EvalTypeGroup_Other) { + push_of_type(out); + break; + } + + // TODO: error handling + AssertAlways(in != RDI_EvalTypeGroup_Other); + AssertAlways(out != RDI_EvalTypeGroup_Other); + + U16 operand = (U16)in | ((U16)out << 8); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Convert, operand); + } break; + + case DW_ExprOp_GNU_ParameterRef: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_DerefType: + case DW_ExprOp_GNU_DerefType: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_ConstType: + case DW_ExprOp_GNU_ConstType: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_RegvalType: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_EntryValue: + case DW_ExprOp_GNU_EntryValue: { + U64 entry_value_expr_size = 0; + String8 entry_value_expr = {0}; + cursor += str8_deserial_read_uleb128(expr, cursor, &entry_value_expr_size); + cursor += str8_deserial_read_block(expr, cursor, entry_value_expr_size, &entry_value_expr); + + B32 dummy = 0; + RDIM_EvalBytecode call_site_bc = d2r_bytecode_from_expression(arena, input, image_base, address_size, arch, addr_lu, entry_value_expr, cu, &dummy); + + U32 encoded_size32 = safe_cast_u32(call_site_bc.encoded_size); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_CallSiteValue, encoded_size32); + rdim_bytecode_concat_in_place(&bc, &call_site_bc); + } break; + + case DW_ExprOp_Addrx: { + U64 addr_idx = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &addr_idx); + U64 addr = dw_addr_from_list_unit(addr_lu, addr_idx); + if (addr != max_U64) { + if (addr >= image_base) { + U64 voff = addr - image_base; + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_ModuleOff, voff); + } else { + // TODO: error handling + AssertAlways(!"unable to relocate address"); + } + } else { + // TODO: error handling + AssertAlways(!"out of bounds index"); + } + } break; + + case DW_ExprOp_CallFrameCfa: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_FrameOff, 0); + } break; + + case DW_ExprOp_FormTlsAddress: { + // TODO: + AssertAlways(!"RDI_EvalOp_TLSOff accepts immediate"); + } break; + + case DW_ExprOp_PushObjectAddress: { + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_Nop: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Noop, 0); + } break; + + case DW_ExprOp_Eq: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_EqEq, peek_type()); + } break; + + case DW_ExprOp_Ge: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_GrEq, peek_type()); + } break; + + case DW_ExprOp_Gt: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Grtr, peek_type()); + } break; + + case DW_ExprOp_Le: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_LsEq, peek_type()); + } break; + + case DW_ExprOp_Lt: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Less, peek_type()); + } break; + + case DW_ExprOp_Ne: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_NtEq, peek_type()); + } break; + + case DW_ExprOp_Shl: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_LShift, peek_type()); + } break; + + case DW_ExprOp_Shr: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RShift, RDI_EvalTypeGroup_U); + } break; + + case DW_ExprOp_Shra: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RShift, RDI_EvalTypeGroup_S); + } break; + + case DW_ExprOp_Xor: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitXor, peek_type()); + } break; + + case DW_ExprOp_XDeref: { + // TODO: error handling + Assert(!"multiple address spaces are not supported"); + } break; + + case DW_ExprOp_Abs: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Abs, peek_type()); + } break; + + case DW_ExprOp_And: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitAnd, peek_type()); + } break; + + case DW_ExprOp_Div: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Div, peek_type()); + } break; + + case DW_ExprOp_Minus: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Sub, peek_type()); + } break; + + case DW_ExprOp_Mod: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Mod, peek_type()); + } break; + + case DW_ExprOp_Mul: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Mul, peek_type()); + } break; + + case DW_ExprOp_Neg: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Neg, peek_type()); + } break; + + case DW_ExprOp_Not: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitNot, peek_type()); + } break; + + case DW_ExprOp_Or: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitOr, peek_type()); + } break; + + case DW_ExprOp_Plus: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, peek_type()); + } break; + + case DW_ExprOp_Rot: { + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Swap: { + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Dup: { + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Drop: { + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Over: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Pick, 1); + } break; + + case DW_ExprOp_StackValue: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Stop, 0); + } break; + + default: InvalidPath; break; } } - + #undef peek_type #undef pop_type #undef push_of_type @@ -827,7 +827,7 @@ d2r_transpile_expression(Arena *arena, DW_Input *input, U64 image_base, U64 addr if (expr.size) { B32 is_addr = 0; RDIM_EvalBytecode bytecode = d2r_bytecode_from_expression(arena, input, image_base, address_size, arch, addr_lu, expr, cu, &is_addr); - + loc = push_array(arena, RDIM_Location, 1); loc->kind = is_addr ? RDI_LocationKind_AddrBytecodeStream : RDI_LocationKind_ValBytecodeStream; loc->bytecode = bytecode; @@ -855,29 +855,29 @@ d2r_locset_from_attrib(Arena *arena, DW_AttribKind kind) { RDIM_LocationSet locset = {0}; - + // extract attrib from tag DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind); DW_AttribClass attrib_class = dw_value_class_from_attrib(cu, attrib); - + if (attrib_class == DW_AttribClass_LocList || attrib_class == DW_AttribClass_LocListPtr) { Temp scratch = scratch_begin(&arena, 1); - + // extract location list from attrib DW_LocList loclist = dw_loclist_from_attrib_ptr(scratch.arena, input, cu, attrib); - + // convert location list to RDIM location set for (DW_LocNode *loc_n = loclist.first; loc_n != 0; loc_n = loc_n->next) { RDIM_Location *location = d2r_transpile_expression(arena, input, image_base, cu->address_size, arch, cu->addr_lu, cu, loc_n->v.expr); RDIM_Rng1U64 voff_range = { .min = loc_n->v.range.min - image_base, .max = loc_n->v.range.max - image_base }; rdim_location_set_push_case(arena, scopes, &locset, voff_range, location); } - + scratch_end(scratch); } else if (attrib_class == DW_AttribClass_ExprLoc) { // extract expression from attrib String8 expr = dw_exprloc_from_attrib_ptr(input, cu, attrib); - + // convert expression and inherit life-time ranges from enclosed scope RDIM_Location *location = d2r_transpile_expression(arena, input, image_base, cu->address_size, arch, cu->addr_lu, cu, expr); for (RDIM_Rng1U64Node *range_n = curr_scope->voff_ranges.first; range_n != 0; range_n = range_n->next) { @@ -886,7 +886,7 @@ d2r_locset_from_attrib(Arena *arena, } else if (attrib_class != DW_AttribClass_Null) { AssertAlways(!"unexpected attrib class"); } - + return locset; } @@ -901,28 +901,28 @@ d2r_var_locset_from_tag(Arena *arena, DW_Tag tag) { RDIM_LocationSet locset = {0}; - + B32 has_const_value = dw_tag_has_attrib(input, cu, tag, DW_Attrib_ConstValue); B32 has_location = dw_tag_has_attrib(input, cu, tag, DW_Attrib_Location); - + if (has_const_value && has_location) { // TODO: error handling AssertAlways(!"unexpected variable encoding"); } - + if (has_const_value) { // extract const value U64 const_value = dw_u64_from_attrib(input, cu, tag, DW_Attrib_ConstValue); - + // make value byte code RDIM_EvalBytecode bc = {0}; rdim_bytecode_push_uconst(arena, &bc, const_value); - + // fill out location RDIM_Location *loc = push_array(arena, RDIM_Location, 1); loc->kind = RDI_LocationKind_ValBytecodeStream; loc->bytecode = bc; - + // push location cases for (RDIM_Rng1U64Node *range_n = curr_scope->voff_ranges.first; range_n != 0; range_n = range_n->next) { rdim_location_set_push_case(arena, scopes, &locset, range_n->v, loc); @@ -930,7 +930,7 @@ d2r_var_locset_from_tag(Arena *arena, } else if (has_location) { locset = d2r_locset_from_attrib(arena, input, cu, scopes, curr_scope, image_base, arch, tag, DW_Attrib_Location); } - + return locset; } @@ -938,38 +938,38 @@ internal D2R_CompUnitContribMap d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) { Temp scratch = scratch_begin(&arena, 1); - + String8 aranges_data = input->sec[DW_Section_ARanges].data; Rng1U64List unit_range_list = dw_unit_ranges_from_data(scratch.arena, aranges_data); - + D2R_CompUnitContribMap cm = {0}; cm.count = 0; cm.info_off_arr = push_array(arena, U64, unit_range_list.count); cm.voff_range_arr = push_array(arena, RDIM_Rng1U64List, unit_range_list.count); - + for (Rng1U64Node *range_n = unit_range_list.first; range_n != 0; range_n = range_n->next) { String8 unit_data = str8_substr(aranges_data, range_n->v); U64 unit_cursor = 0; - + U64 unit_length = 0; U64 unit_length_size = str8_deserial_read_dwarf_packed_size(unit_data, unit_cursor, &unit_length); if (unit_length_size == 0) { continue; } unit_cursor += unit_length_size; - + DW_Version version = 0; U64 version_size = str8_deserial_read_struct(unit_data, unit_cursor, &version); if (version_size == 0) { continue; } unit_cursor += version; - + if (version != DW_Version_2) { AssertAlways(!"unknown .debug_aranges version"); continue; } - + DW_Format unit_format = DW_FormatFromSize(unit_length); U64 cu_info_off = 0; U64 cu_info_off_size = str8_deserial_read_dwarf_uint(unit_data, unit_cursor, unit_format, &cu_info_off); @@ -977,27 +977,27 @@ d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) continue; } unit_cursor += cu_info_off_size; - + U8 address_size = 0; U64 address_size_size = str8_deserial_read_struct(unit_data, unit_cursor, &address_size); if (address_size_size == 0) { continue; } unit_cursor += address_size_size; - + U8 segment_selector_size = 0; U64 segment_selector_size_size = str8_deserial_read_struct(unit_data, unit_cursor, &segment_selector_size); if (segment_selector_size_size == 0) { continue; } unit_cursor += segment_selector_size_size; - + U64 tuple_size = address_size * 2 + segment_selector_size; U64 bytes_too_far_past_boundary = unit_cursor % tuple_size; if (bytes_too_far_past_boundary > 0) { unit_cursor += tuple_size - bytes_too_far_past_boundary; } - + RDIM_Rng1U64List voff_ranges = {0}; if (segment_selector_size == 0) { while (unit_cursor + address_size * 2 <= unit_data.size) { @@ -1005,14 +1005,14 @@ d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) U64 length = 0; unit_cursor += str8_deserial_read(unit_data, unit_cursor, &address, address_size, address_size); unit_cursor += str8_deserial_read(unit_data, unit_cursor, &length, address_size, address_size); - + if (address == 0 && length == 0) { break; } - + // TODO: error handling AssertAlways(address >= image_base); - + U64 min = address - image_base; U64 max = min + length; rdim_rng1u64_list_push(arena, &voff_ranges, (RDIM_Rng1U64){.min = min, .max = max}); @@ -1021,12 +1021,12 @@ d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) // TODO: segment relative addressing NotImplemented; } - + U64 map_idx = cm.count++; cm.info_off_arr[map_idx] = cu_info_off; cm.voff_range_arr[map_idx] = voff_ranges; } - + scratch_end(scratch); return cm; } @@ -1047,29 +1047,29 @@ d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D { // fill out scope RDIM_Scope *scope = rdim_scope_chunk_list_push(arena, scopes, scope_chunk_cap); - + // push ranges for (Rng1U64Node *i = ranges.first; i != 0; i = i->next) { rdim_scope_push_voff_range(arena, scopes, scope, (RDIM_Rng1U64){.min = i->v.min, i->v.max}); } - + // associate scope with tag tag_stack->scope = scope; - + // update scope hierarchy DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine || parent_tag_kind == DW_Tag_LexicalBlock) { RDIM_Scope *parent = tag_stack->next->scope; - + scope->parent_scope = parent; scope->symbol = parent->symbol; - + if (parent->last_child) { parent->last_child->next_sibling = scope; } SLLQueuePush_N(parent->first_child, parent->last_child, scope, next_sibling); } - + return scope; } @@ -1077,71 +1077,71 @@ internal RDIM_BakeParams * d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) { Temp scratch = scratch_begin(&arena, 1); - + //////////////////////////////// - + ProfBegin("compute exe hash"); U64 exe_hash = rdi_hash(in->image_data.str, in->image_data.size); ProfEnd(); - + //////////////////////////////// - + Arch arch = Arch_Null; U64 image_base = 0; RDIM_BinarySectionList binary_sections = {0}; DW_Input input = {0}; - + if (in->image == Image_CoffPe) { PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, in->image_data); - + // get image arch arch = pe.arch; - + // get image base image_base = pe.image_base; - + // get image sections String8 raw_sections = str8_substr(in->image_data, pe.section_table_range); U64 section_count = raw_sections.size / sizeof(COFF_SectionHeader); COFF_SectionHeader *section_table = (COFF_SectionHeader *)raw_sections.str; - + // convert sections String8 string_table = str8_substr(in->image_data, pe.string_table_range); binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, in->image_data, string_table, section_count, section_table); - + // make DWARF input input = dw_input_from_coff_section_table(scratch.arena, in->image_data, string_table, section_count, section_table); } else if (in->image == Image_Elf32 || in->image == Image_Elf64) { ELF_BinInfo elf = elf_bin_from_data(in->debug_data); - + // get image arch arch = arch_from_elf_machine(elf.hdr.e_machine); - + // get image base image_base = elf_base_addr_from_bin(&elf.hdr); - + // get image sections ELF_Shdr64Array shdrs = elf_shdr64_array_from_bin(scratch.arena, in->debug_data, &elf.hdr); - + // convert sections binary_sections = e2r_rdi_binary_sections_from_elf_section_table(arena, shdrs); - + // make DWARF input input = dw_input_from_elf_section_table(scratch.arena, in->debug_data, &elf); } else { InvalidPath; } - + //////////////////////////////// - + RDIM_TopLevelInfo top_level_info = rdim_make_top_level_info(in->image_name, arch, exe_hash, binary_sections); - + //////////////////////////////// - + U64 arch_addr_size = rdi_addr_size_from_arch(arch); - + //////////////////////////////// - + static const U64 UNIT_CHUNK_CAP = 256; static const U64 UDT_CHUNK_CAP = 256; static const U64 TYPE_CHUNK_CAP = 256; @@ -1152,7 +1152,7 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) static const U64 INLINE_SITE_CHUNK_CAP = 256; static const U64 SRC_FILE_CAP = 256; static const U64 LINE_TABLE_CAP = 256; - + RDIM_UnitChunkList units = {0}; RDIM_UDTChunkList udts = {0}; RDIM_TypeChunkList types = rdim_init_type_chunk_list(arena, arch); @@ -1163,13 +1163,13 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) RDIM_InlineSiteChunkList inline_sites = {0}; RDIM_SrcFileChunkList src_files = {0}; RDIM_LineTableChunkList line_tables = {0}; - + //////////////////////////////// - + RDIM_Scope *global_scope = rdim_scope_chunk_list_push(arena, &scopes, SCOPE_CHUNK_CAP); - + //////////////////////////////// - + ProfBegin("Make Unit Contrib Map"); D2R_CompUnitContribMap cu_contrib_map = {0}; if (input.sec[DW_Section_ARanges].data.size > 0) { @@ -1179,15 +1179,15 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) NotImplemented; } ProfEnd(); - + ProfBegin("Parse Comop Unit Ranges"); DW_ListUnitInput lu_input = dw_list_unit_input_from_input(scratch.arena, &input); Rng1U64List cu_range_list = dw_unit_ranges_from_data(scratch.arena, input.sec[DW_Section_Info].data); Rng1U64Array cu_ranges = rng1u64_array_from_list(scratch.arena, &cu_range_list); ProfEnd(); - + //////////////////////////////// - + ProfBegin("Parse Compile Unit Headers"); B32 is_parse_relaxed = !(in->flags & RC_Flag_StrictDwarfParse); DW_CompUnit *cu_arr = push_array(scratch.arena, DW_CompUnit, cu_ranges.count); @@ -1195,9 +1195,9 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) cu_arr[cu_idx] = dw_cu_from_info_off(scratch.arena, &input, lu_input, cu_ranges.v[cu_idx].min, is_parse_relaxed); } ProfEnd(); - + //////////////////////////////// - + ProfBegin("Parse Line Tables"); DW_LineTableParseResult *cu_line_tables = push_array(scratch.arena, DW_LineTableParseResult, cu_ranges.count); for (U64 cu_idx = 0; cu_idx < cu_ranges.count; ++cu_idx) { @@ -1208,17 +1208,17 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) cu_line_tables[cu_idx] = dw_parsed_line_table_from_data(scratch.arena, cu_stmt_list, &input, cu_dir, cu_name, cu->address_size, cu->str_offsets_lu); } ProfEnd(); - + //////////////////////////////// - + ProfBegin("Convert Line Tables"); - + HashTable *source_file_ht = hash_table_init(scratch.arena, 0x4000); RDIM_LineTable **cu_line_tables_rdi = push_array(scratch.arena, RDIM_LineTable *, cu_ranges.count); - + for (U64 cu_idx = 0; cu_idx < cu_ranges.count; ++cu_idx) { cu_line_tables_rdi[cu_idx] = rdim_line_table_chunk_list_push(arena, &line_tables, LINE_TABLE_CAP); - + DW_LineTableParseResult *line_table = &cu_line_tables[cu_idx]; DW_LineVMFileArray *dir_table = &line_table->vm_header.dir_table; DW_LineVMFileArray *file_table = &line_table->vm_header.file_table; @@ -1238,27 +1238,27 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) } src_file_map[file_idx] = src_file; } - + for (DW_LineSeqNode *line_seq = line_table->first_seq; line_seq != 0; line_seq = line_seq->next) { if (line_seq->count == 0) { continue; } - + U64 *voffs = push_array(arena, U64, line_seq->count); U32 *line_nums = push_array(arena, U32, line_seq->count); U16 *col_nums = 0; U64 line_idx = 0; - + DW_LineNode *file_line_n = line_seq->first; U64 file_line_count = 0; - + for (DW_LineNode *line_n = file_line_n; line_n != 0; line_n = line_n->next) { if (file_line_n->v.file_index != line_n->v.file_index || line_n->next == 0) { U64 file_index = file_line_n->v.file_index; U64 *file_voffs = &voffs[line_idx]; U32 *file_line_nums = &line_nums[line_idx]; U16 *file_col_nums = 0; - + U64 lines_written = 0; U64 prev_ln = max_U64; DW_LineNode *sentinel = line_n->v.file_index != file_line_n->v.file_index ? line_n : 0; @@ -1266,82 +1266,82 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) if (file_line_n->v.line != prev_ln) { // TODO: error handling AssertAlways(file_line_n->v.address >= image_base); - + voffs[line_idx] = file_line_n->v.address - image_base; line_nums[line_idx] = file_line_n->v.line; - + ++lines_written; ++line_idx; - + prev_ln = file_line_n->v.line; } } - + RDIM_SrcFile *src_file = src_file_map[file_index]; RDIM_LineSequence *line_seq = rdim_line_table_push_sequence(arena, &line_tables, cu_line_tables_rdi[cu_idx], src_file, file_voffs, file_line_nums, file_col_nums, lines_written); rdim_src_file_push_line_sequence(arena, &src_files, src_file, line_seq); - + file_line_count = 1; } else { ++file_line_count; } } - + // handle last line if (file_line_n) { U64 file_index = file_line_n->v.file_index; U64 *file_voffs = &voffs[line_idx]; U32 *file_line_nums = &line_nums[line_idx]; U16 *file_col_nums = 0; - + for (; file_line_n != 0; file_line_n = file_line_n->next, ++line_idx) { // TODO: error handling AssertAlways(file_line_n->v.address >= image_base); voffs[line_idx] = file_line_n->v.address - image_base; line_nums[line_idx] = file_line_n->v.line; } - + RDIM_SrcFile *src_file = src_file_map[file_index]; RDIM_LineSequence *line_seq = rdim_line_table_push_sequence(arena, &line_tables, cu_line_tables_rdi[cu_idx], src_file, file_voffs, file_line_nums, file_col_nums, file_line_count); rdim_src_file_push_line_sequence(arena, &src_files, src_file, line_seq); } - + //Assert(line_idx == line_seq->count); } } - + ProfEnd(); - + //////////////////////////////// ProfBegin("Convert Units"); - + for (U64 cu_idx = 0; cu_idx < cu_ranges.count; ++cu_idx) { Temp comp_temp = temp_begin(scratch.arena); - + DW_CompUnit *cu = &cu_arr[cu_idx]; - + // parse and build tag tree DW_TagTree tag_tree = dw_tag_tree_from_cu(comp_temp.arena, &input, cu); - + // build tag hash table for abstract origin resolution cu->tag_ht = dw_make_tag_hash_table(comp_temp.arena, tag_tree); - + String8 dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_DwoName); String8 gnu_dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_GNU_DwoName); if (dwo_name.size || gnu_dwo_name.size || cu->dwo_id) { // TODO: report that we dont support DWO continue; } - + // get unit's contribution ranges RDIM_Rng1U64List cu_voff_ranges = d2r_voff_ranges_from_cu_info_off(cu_contrib_map, cu_ranges.v[cu_idx].min); - + String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Name); String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_CompDir); String8 cu_prod = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Producer); DW_Language cu_lang = dw_const_u64_from_attrib(&input, cu, cu->tag, DW_Attrib_Language); - + RDIM_Unit *unit = rdim_unit_chunk_list_push(arena, &units, UNIT_CHUNK_CAP); unit->unit_name = cu_name; unit->compiler_name = cu_prod; @@ -1352,452 +1352,525 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) unit->language = rdi_language_from_dw_language(cu_lang); unit->line_table = cu_line_tables_rdi[cu_idx]; unit->voff_ranges = cu_voff_ranges; - + D2R_TypeTable *type_table = push_array(comp_temp.arena, D2R_TypeTable, 1); type_table->ht = hash_table_init(comp_temp.arena, 0x4000); type_table->types = &types; type_table->type_chunk_cap = TYPE_CHUNK_CAP; type_table->varg_type = d2r_create_type(arena, type_table); type_table->varg_type->kind = RDI_TypeKind_Variadic; - + D2R_TagNode *free_tags = push_array(comp_temp.arena, D2R_TagNode, 1); D2R_TagNode *tag_stack = push_array(comp_temp.arena, D2R_TagNode, 1); tag_stack->cur_node = tag_tree.root; - + while (tag_stack) { while (tag_stack->cur_node) { DW_TagNode *cur_node = tag_stack->cur_node; DW_Tag tag = cur_node->tag; B32 visit_children = 1; - + switch (tag.kind) { - case DW_Tag_Null: { - InvalidPath; - } break; - case DW_Tag_ClassType: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - - B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); - if (is_decl) { - type->kind = RDI_TypeKind_IncompleteClass; - - Assert(!cur_node->first_child); - visit_children = 0; - } else { - RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); - udt->self_type = type; - - type->kind = RDI_TypeKind_Class; - type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); - type->udt = udt; - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - tag_stack->type = type; - } - } break; - case DW_Tag_StructureType: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - - B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); - if (is_decl) { - type->kind = RDI_TypeKind_IncompleteStruct; - - // TODO: error handling - Assert(!cur_node->first_child); - visit_children = 0; - } else { - RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); - udt->self_type = type; - - type->kind = RDI_TypeKind_Struct; - type->udt = udt; - type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + case DW_Tag_Null: { + InvalidPath; + } break; + case DW_Tag_ClassType: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - tag_stack->type = type; - } - } break; - case DW_Tag_UnionType: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - - B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); - if (is_decl) { - type->kind = RDI_TypeKind_IncompleteUnion; - - // TODO: error handling - Assert(!cur_node->first_child); - visit_children = 0; - } else { - RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); - udt->self_type = type; - - type->kind = RDI_TypeKind_Union; - type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); - type->udt = udt; - - tag_stack->type = type; - } - } break; - case DW_Tag_EnumerationType: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - - B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); - if (is_decl) { - type->kind = RDI_TypeKind_IncompleteEnum; - - // TODO: error handling - Assert(!cur_node->first_child); - visit_children = 0; - } else { - RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); - udt->self_type = type; - - type->kind = RDI_TypeKind_Enum; - type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); - type->udt = udt; - - tag_stack->type = type; - } - } break; - case DW_Tag_SubroutineType: { - // collect parameters - RDIM_TypeList param_list = {0}; - for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) { - if (n->tag.kind == DW_Tag_FormalParameter) { - RDIM_Type *param_type = d2r_type_from_attrib(arena, type_table, &input, cu, n->tag, DW_Attrib_Type); - rdim_type_list_push(comp_temp.arena, ¶m_list, param_type); - } else if (n->tag.kind == DW_Tag_UnspecifiedParameters) { - rdim_type_list_push(comp_temp.arena, ¶m_list, type_table->varg_type); + B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); + if (is_decl) { + type->kind = RDI_TypeKind_IncompleteClass; + + Assert(!cur_node->first_child); + visit_children = 0; } else { + RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); + udt->self_type = type; + + type->kind = RDI_TypeKind_Class; + type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + type->udt = udt; + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + + tag_stack->type = type; + } + } break; + case DW_Tag_StructureType: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + + B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); + if (is_decl) { + type->kind = RDI_TypeKind_IncompleteStruct; + // TODO: error handling - AssertAlways(!"unexpected tag"); - } - } - - // init proceudre type - RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Function; - type->byte_size = arch_addr_size; - type->direct_type = ret_type; - type->count = param_list.count; - type->param_types = rdim_array_from_type_list(arena, param_list); - - visit_children = 0; - } break; - case DW_Tag_Typedef: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Alias; - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - } break; - case DW_Tag_BaseType: { - DW_ATE encoding = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Encoding); - U64 byte_size = dw_byte_size_from_tag(&input, cu, tag); - - // convert base type encoding to RDI version - RDI_TypeKind kind = RDI_TypeKind_NULL; - switch (encoding) { - case DW_ATE_Null: kind = RDI_TypeKind_NULL; break; - case DW_ATE_Address: kind = RDI_TypeKind_Void; break; - case DW_ATE_Boolean: kind = RDI_TypeKind_Bool; break; - case DW_ATE_ComplexFloat: { - switch (byte_size) { - case 4: kind = RDI_TypeKind_ComplexF32; break; - case 8: kind = RDI_TypeKind_ComplexF64; break; - case 10: kind = RDI_TypeKind_ComplexF80; break; - case 16: kind = RDI_TypeKind_ComplexF128; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling + Assert(!cur_node->first_child); + visit_children = 0; + } else { + RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); + udt->self_type = type; + + type->kind = RDI_TypeKind_Struct; + type->udt = udt; + type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + + tag_stack->type = type; } } break; - case DW_ATE_Float: { - switch (byte_size) { - case 2: kind = RDI_TypeKind_F16; break; - case 4: kind = RDI_TypeKind_F32; break; - case 6: kind = RDI_TypeKind_F48; break; - case 8: kind = RDI_TypeKind_F64; break; - case 16: kind = RDI_TypeKind_F128; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_Signed: { - switch (byte_size) { - case 1: kind = RDI_TypeKind_S8; break; - case 2: kind = RDI_TypeKind_S16; break; - case 4: kind = RDI_TypeKind_S32; break; - case 8: kind = RDI_TypeKind_S64; break; - case 16: kind = RDI_TypeKind_S128; break; - case 32: kind = RDI_TypeKind_S256; break; - case 64: kind = RDI_TypeKind_S512; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_SignedChar: { - switch (byte_size) { - case 1: kind = RDI_TypeKind_Char8; break; - case 2: kind = RDI_TypeKind_Char16; break; - case 4: kind = RDI_TypeKind_Char32; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_Unsigned: { - switch (byte_size) { - case 1: kind = RDI_TypeKind_U8; break; - case 2: kind = RDI_TypeKind_U16; break; - case 4: kind = RDI_TypeKind_U32; break; - case 8: kind = RDI_TypeKind_U64; break; - case 16: kind = RDI_TypeKind_U128; break; - case 32: kind = RDI_TypeKind_U256; break; - case 64: kind = RDI_TypeKind_U512; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_UnsignedChar: { - switch (byte_size) { - case 1: kind = RDI_TypeKind_UChar8; break; - case 2: kind = RDI_TypeKind_UChar16; break; - case 4: kind = RDI_TypeKind_UChar32; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_ImaginaryFloat: { - NotImplemented; - } break; - case DW_ATE_PackedDecimal: { - NotImplemented; - } break; - case DW_ATE_NumericString: { - NotImplemented; - } break; - case DW_ATE_Edited: { - NotImplemented; - } break; - case DW_ATE_SignedFixed: { - NotImplemented; - } break; - case DW_ATE_UnsignedFixed: { - NotImplemented; - } break; - case DW_ATE_DecimalFloat: { - NotImplemented; - } break; - case DW_ATE_Utf: { - NotImplemented; - } break; - case DW_ATE_Ucs: { - NotImplemented; - } break; - case DW_ATE_Ascii: { - NotImplemented; - } break; - default: AssertAlways(!"unexpected base type encoding"); break; // TODO: error handling - } - - RDIM_Type *base_type = rdim_builtin_type_from_kind(types, kind); - base_type->kind = kind; - base_type->byte_size = byte_size; - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Alias; - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - type->direct_type = base_type; - } break; - case DW_Tag_PointerType: { - RDIM_Type *direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - // TODO: - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Allocated)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Associated)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_AddressClass)); - - U64 byte_size = arch_addr_size; - if (cu->version == DW_Version_5 || cu->relaxed) { - dw_try_byte_size_from_tag(&input, cu, tag, &byte_size); - } - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Ptr; - type->byte_size = byte_size; - type->direct_type = direct_type; - } break; - case DW_Tag_RestrictType: { - // TODO: - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Modifier; - type->byte_size = arch_addr_size; - type->flags = RDI_TypeModifierFlag_Restrict; - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - } break; - case DW_Tag_VolatileType: { - // TODO: - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Modifier; - type->byte_size = arch_addr_size; - type->flags = RDI_TypeModifierFlag_Volatile; - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - } break; - case DW_Tag_ConstType: { - // TODO: - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Modifier; - type->byte_size = arch_addr_size; - type->flags = RDI_TypeModifierFlag_Const; - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - } break; - case DW_Tag_ArrayType: { - // * DWARF vs RDI Array Type Graph * - // - // For example lets take following decl: - // - // int (*foo[2])[3][4]; - // - // This compiles to in DWARF: - // - // foo -> DW_TAG_ArrayType -> (A0) DW_TAG_Subrange [2] - // \ - // -> (B0) DW_TAG_PointerType -> (A1) DW_TAG_ArrayType -> DW_TAG_Subrange [3] -> DW_Tag_Subrange [4] - // \ - // -> (B1) DW_TAG_BaseType (int) - // - // RDI expects: - // - // foo -> Array (2) -> Pointer -> Array (3) -> Array (4) -> int - // - // Note that DWARF forks the graph on DW_TAG_ArrayType to describe array ranges in branch A and - // in branch B describes array type which might be a struct, pointer, base type, or any other type tag. - // However, in RDI we have a simple list of type nodes and to convert we need to append type nodes from - // B to A. - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Array; - type->direct_type = 0; - - U64 subrange_count = 0; - RDIM_Type *t = type; - for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) { - if (n->tag.kind != DW_Tag_SubrangeType) { + case DW_Tag_UnionType: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + + B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); + if (is_decl) { + type->kind = RDI_TypeKind_IncompleteUnion; + // TODO: error handling - AssertAlways(!"unexpected tag"); - continue; - } - - if (subrange_count > 0) { - // init array type node - RDIM_Type *s = d2r_create_type(arena, type_table); - s->kind = RDI_TypeKind_Array; - s->direct_type = 0; - - // append new array type node - t->direct_type = s; - t = s; - } - - // resolve array lower bound - U64 lower_bound = 0; - if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_LowerBound)) { - lower_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_LowerBound); + Assert(!cur_node->first_child); + visit_children = 0; } else { - lower_bound = dw_pick_default_lower_bound(cu_lang); + RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); + udt->self_type = type; + + type->kind = RDI_TypeKind_Union; + type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + type->udt = udt; + + tag_stack->type = type; } - - // resolve array upper bound - U64 upper_bound = 0; - if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_Count)) { - U64 count = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_Count); - upper_bound = lower_bound + count; - } else if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_UpperBound)) { - upper_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_UpperBound); - // turn upper bound into exclusive range - upper_bound += 1; + } break; + case DW_Tag_EnumerationType: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + + B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); + if (is_decl) { + type->kind = RDI_TypeKind_IncompleteEnum; + + // TODO: error handling + Assert(!cur_node->first_child); + visit_children = 0; } else { - // zero size array + RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); + udt->self_type = type; + + type->kind = RDI_TypeKind_Enum; + type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + type->udt = udt; + + tag_stack->type = type; } - - t->count = upper_bound - lower_bound; - ++subrange_count; - } - - Assert(t->direct_type == 0); - t->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - visit_children = 0; - } break; - case DW_Tag_SubrangeType: { - // TODO: error handling - AssertAlways(!"unexpected tag"); - } break; - case DW_Tag_Inheritance: { - DW_TagNode *parent_node = tag_stack->next->cur_node; - if (parent_node->tag.kind != DW_Tag_StructureType && - parent_node->tag.kind != DW_Tag_ClassType) { + } break; + case DW_Tag_SubroutineType: { + // collect parameters + RDIM_TypeList param_list = {0}; + for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) { + if (n->tag.kind == DW_Tag_FormalParameter) { + RDIM_Type *param_type = d2r_type_from_attrib(arena, type_table, &input, cu, n->tag, DW_Attrib_Type); + rdim_type_list_push(comp_temp.arena, ¶m_list, param_type); + } else if (n->tag.kind == DW_Tag_UnspecifiedParameters) { + rdim_type_list_push(comp_temp.arena, ¶m_list, type_table->varg_type); + } else { + // TODO: error handling + AssertAlways(!"unexpected tag"); + } + } + + // init proceudre type + RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Function; + type->byte_size = arch_addr_size; + type->direct_type = ret_type; + type->count = param_list.count; + type->param_types = rdim_array_from_type_list(arena, param_list); + + visit_children = 0; + } break; + case DW_Tag_Typedef: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Alias; + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + } break; + case DW_Tag_BaseType: { + DW_ATE encoding = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Encoding); + U64 byte_size = dw_byte_size_from_tag(&input, cu, tag); + + // convert base type encoding to RDI version + RDI_TypeKind kind = RDI_TypeKind_NULL; + switch (encoding) { + case DW_ATE_Null: kind = RDI_TypeKind_NULL; break; + case DW_ATE_Address: kind = RDI_TypeKind_Void; break; + case DW_ATE_Boolean: kind = RDI_TypeKind_Bool; break; + case DW_ATE_ComplexFloat: { + switch (byte_size) { + case 4: kind = RDI_TypeKind_ComplexF32; break; + case 8: kind = RDI_TypeKind_ComplexF64; break; + case 10: kind = RDI_TypeKind_ComplexF80; break; + case 16: kind = RDI_TypeKind_ComplexF128; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_Float: { + switch (byte_size) { + case 2: kind = RDI_TypeKind_F16; break; + case 4: kind = RDI_TypeKind_F32; break; + case 6: kind = RDI_TypeKind_F48; break; + case 8: kind = RDI_TypeKind_F64; break; + case 16: kind = RDI_TypeKind_F128; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_Signed: { + switch (byte_size) { + case 1: kind = RDI_TypeKind_S8; break; + case 2: kind = RDI_TypeKind_S16; break; + case 4: kind = RDI_TypeKind_S32; break; + case 8: kind = RDI_TypeKind_S64; break; + case 16: kind = RDI_TypeKind_S128; break; + case 32: kind = RDI_TypeKind_S256; break; + case 64: kind = RDI_TypeKind_S512; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_SignedChar: { + switch (byte_size) { + case 1: kind = RDI_TypeKind_Char8; break; + case 2: kind = RDI_TypeKind_Char16; break; + case 4: kind = RDI_TypeKind_Char32; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_Unsigned: { + switch (byte_size) { + case 1: kind = RDI_TypeKind_U8; break; + case 2: kind = RDI_TypeKind_U16; break; + case 4: kind = RDI_TypeKind_U32; break; + case 8: kind = RDI_TypeKind_U64; break; + case 16: kind = RDI_TypeKind_U128; break; + case 32: kind = RDI_TypeKind_U256; break; + case 64: kind = RDI_TypeKind_U512; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_UnsignedChar: { + switch (byte_size) { + case 1: kind = RDI_TypeKind_UChar8; break; + case 2: kind = RDI_TypeKind_UChar16; break; + case 4: kind = RDI_TypeKind_UChar32; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_ImaginaryFloat: { + NotImplemented; + } break; + case DW_ATE_PackedDecimal: { + NotImplemented; + } break; + case DW_ATE_NumericString: { + NotImplemented; + } break; + case DW_ATE_Edited: { + NotImplemented; + } break; + case DW_ATE_SignedFixed: { + NotImplemented; + } break; + case DW_ATE_UnsignedFixed: { + NotImplemented; + } break; + case DW_ATE_DecimalFloat: { + NotImplemented; + } break; + case DW_ATE_Utf: { + NotImplemented; + } break; + case DW_ATE_Ucs: { + NotImplemented; + } break; + case DW_ATE_Ascii: { + NotImplemented; + } break; + default: AssertAlways(!"unexpected base type encoding"); break; // TODO: error handling + } + + RDIM_Type *base_type = rdim_builtin_type_from_kind(types, kind); + base_type->kind = kind; + base_type->byte_size = byte_size; + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Alias; + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + type->direct_type = base_type; + } break; + case DW_Tag_PointerType: { + RDIM_Type *direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + + // TODO: + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Allocated)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Associated)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_AddressClass)); + + U64 byte_size = arch_addr_size; + if (cu->version == DW_Version_5 || cu->relaxed) { + dw_try_byte_size_from_tag(&input, cu, tag, &byte_size); + } + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Ptr; + type->byte_size = byte_size; + type->direct_type = direct_type; + } break; + case DW_Tag_RestrictType: { + // TODO: + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Modifier; + type->byte_size = arch_addr_size; + type->flags = RDI_TypeModifierFlag_Restrict; + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + } break; + case DW_Tag_VolatileType: { + // TODO: + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Modifier; + type->byte_size = arch_addr_size; + type->flags = RDI_TypeModifierFlag_Volatile; + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + } break; + case DW_Tag_ConstType: { + // TODO: + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Modifier; + type->byte_size = arch_addr_size; + type->flags = RDI_TypeModifierFlag_Const; + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + } break; + case DW_Tag_ArrayType: { + // * DWARF vs RDI Array Type Graph * + // + // For example lets take following decl: + // + // int (*foo[2])[3][4]; + // + // This compiles to in DWARF: + // + // foo -> DW_TAG_ArrayType -> (A0) DW_TAG_Subrange [2] + // \ + // -> (B0) DW_TAG_PointerType -> (A1) DW_TAG_ArrayType -> DW_TAG_Subrange [3] -> DW_Tag_Subrange [4] + // \ + // -> (B1) DW_TAG_BaseType (int) + // + // RDI expects: + // + // foo -> Array (2) -> Pointer -> Array (3) -> Array (4) -> int + // + // Note that DWARF forks the graph on DW_TAG_ArrayType to describe array ranges in branch A and + // in branch B describes array type which might be a struct, pointer, base type, or any other type tag. + // However, in RDI we have a simple list of type nodes and to convert we need to append type nodes from + // B to A. + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Array; + type->direct_type = 0; + + U64 subrange_count = 0; + RDIM_Type *t = type; + for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) { + if (n->tag.kind != DW_Tag_SubrangeType) { + // TODO: error handling + AssertAlways(!"unexpected tag"); + continue; + } + + if (subrange_count > 0) { + // init array type node + RDIM_Type *s = d2r_create_type(arena, type_table); + s->kind = RDI_TypeKind_Array; + s->direct_type = 0; + + // append new array type node + t->direct_type = s; + t = s; + } + + // resolve array lower bound + U64 lower_bound = 0; + if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_LowerBound)) { + lower_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_LowerBound); + } else { + lower_bound = dw_pick_default_lower_bound(cu_lang); + } + + // resolve array upper bound + U64 upper_bound = 0; + if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_Count)) { + U64 count = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_Count); + upper_bound = lower_bound + count; + } else if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_UpperBound)) { + upper_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_UpperBound); + // turn upper bound into exclusive range + upper_bound += 1; + } else { + // zero size array + } + + t->count = upper_bound - lower_bound; + ++subrange_count; + } + + Assert(t->direct_type == 0); + t->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + + visit_children = 0; + } break; + case DW_Tag_SubrangeType: { // TODO: error handling - AssertAlways(!"unexpected parent tag"); - } - - RDIM_Type *parent = tag_stack->next->type; - RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, parent->udt); - member->kind = RDI_MemberKind_Base; - member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - member->off = safe_cast_u32(dw_const_u32_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation)); - } break; - case DW_Tag_Enumerator: { - DW_TagNode *parent_node = tag_stack->next->cur_node; - if (parent_node->tag.kind != DW_Tag_EnumerationType) { - // TODO: error handling - AssertAlways(!"unexpected parent tag"); - } - - RDIM_Type *type = tag_stack->next->type; - RDIM_UDTEnumVal *member = rdim_udt_push_enum_val(arena, &udts, type->udt); - member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - member->val = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_ConstValue); - } break; - case DW_Tag_Member: { - DW_TagNode *parent_node = tag_stack->next->cur_node; - if (parent_node->tag.kind != DW_Tag_StructureType && - parent_node->tag.kind != DW_Tag_ClassType && - parent_node->tag.kind != DW_Tag_UnionType && - parent_node->tag.kind != DW_Tag_EnumerationType) { - // TODO: error handling - AssertAlways(!"unexpected parent tag"); - } - - DW_Attrib *data_member_location = dw_attrib_from_tag(&input, cu, tag, DW_Attrib_DataMemberLocation); - DW_AttribClass data_member_location_class = dw_value_class_from_attrib(cu, data_member_location); - if (data_member_location_class == DW_AttribClass_LocList) { - AssertAlways(!"UDT member with multiple locations are not supported"); - } - - RDIM_Type *type = tag_stack->next->type; - RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt); - member->kind = RDI_MemberKind_DataField; - member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - member->off = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation); - } break; - case DW_Tag_SubProgram: { - DW_InlKind inl = dw_u64_from_attrib(&input, cu, tag, DW_Attrib_Inline); - switch (inl) { - case DW_Inl_NotInlined: { + AssertAlways(!"unexpected tag"); + } break; + case DW_Tag_Inheritance: { + DW_TagNode *parent_node = tag_stack->next->cur_node; + if (parent_node->tag.kind != DW_Tag_StructureType && + parent_node->tag.kind != DW_Tag_ClassType) { + // TODO: error handling + AssertAlways(!"unexpected parent tag"); + } + + RDIM_Type *parent = tag_stack->next->type; + RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, parent->udt); + member->kind = RDI_MemberKind_Base; + member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + member->off = safe_cast_u32(dw_const_u32_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation)); + } break; + case DW_Tag_Enumerator: { + DW_TagNode *parent_node = tag_stack->next->cur_node; + if (parent_node->tag.kind != DW_Tag_EnumerationType) { + // TODO: error handling + AssertAlways(!"unexpected parent tag"); + } + + RDIM_Type *type = tag_stack->next->type; + RDIM_UDTEnumVal *member = rdim_udt_push_enum_val(arena, &udts, type->udt); + member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + member->val = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_ConstValue); + } break; + case DW_Tag_Member: { + DW_TagNode *parent_node = tag_stack->next->cur_node; + if (parent_node->tag.kind != DW_Tag_StructureType && + parent_node->tag.kind != DW_Tag_ClassType && + parent_node->tag.kind != DW_Tag_UnionType && + parent_node->tag.kind != DW_Tag_EnumerationType) { + // TODO: error handling + AssertAlways(!"unexpected parent tag"); + } + + DW_Attrib *data_member_location = dw_attrib_from_tag(&input, cu, tag, DW_Attrib_DataMemberLocation); + DW_AttribClass data_member_location_class = dw_value_class_from_attrib(cu, data_member_location); + if (data_member_location_class == DW_AttribClass_LocList) { + AssertAlways(!"UDT member with multiple locations are not supported"); + } + + RDIM_Type *type = tag_stack->next->type; + RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt); + member->kind = RDI_MemberKind_DataField; + member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + member->off = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation); + } break; + case DW_Tag_SubProgram: { + DW_InlKind inl = dw_u64_from_attrib(&input, cu, tag, DW_Attrib_Inline); + switch (inl) { + case DW_Inl_NotInlined: { + U64 param_count = 0; + RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, cur_node, ¶m_count); + + // get return type + RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + + // fill out proc type + RDIM_Type *proc_type = d2r_create_type(arena, type_table); + proc_type->kind = RDI_TypeKind_Function; + proc_type->byte_size = arch_addr_size; + proc_type->direct_type = ret_type; + proc_type->count = param_count; + proc_type->param_types = params; + + // get container type + RDIM_Type *container_type = 0; + if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) { + container_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType); + } + + // get frame base expression + String8 frame_base_expr = dw_exprloc_from_attrib(&input, cu, tag, DW_Attrib_FrameBase); + + // get proc container symbol + RDIM_Symbol *proc = rdim_symbol_chunk_list_push(arena, &procs, PROC_CHUNK_CAP ); + + // make scope + Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); + RDIM_Scope *root_scope = d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); + root_scope->symbol = proc; + + // fill out proc + proc->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External); + proc->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + proc->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName); + proc->type = proc_type; + proc->container_symbol = 0; + proc->container_type = container_type; + proc->root_scope = root_scope; + proc->frame_base = d2r_locset_from_attrib(arena, &input, cu, &scopes, root_scope, image_base, arch, tag, DW_Attrib_FrameBase); + + // sub program with user-defined parent tag is a method + DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; + if (parent_tag_kind == DW_Tag_ClassType || parent_tag_kind == DW_Tag_StructureType) { + RDI_MemberKind member_kind = RDI_MemberKind_NULL; + DW_VirtualityKind virtuality = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Virtuality); + switch (virtuality) { + case DW_VirtualityKind_None: member_kind = RDI_MemberKind_Method; break; + case DW_VirtualityKind_Virtual: member_kind = RDI_MemberKind_VirtualMethod; break; + case DW_VirtualityKind_PureVirtual: member_kind = RDI_MemberKind_VirtualMethod; break; // TODO: create kind for pure virutal + //default: InvalidPath; break; + } + + RDIM_Type *type = tag_stack->next->type; + RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt); + member->kind = member_kind; + member->type = type; + member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + } else if (parent_tag_kind != DW_Tag_CompileUnit) { + //AssertAlways(!"unexpected tag"); + } + + tag_stack->scope = root_scope; + } break; + case DW_Inl_DeclaredNotInlined: + case DW_Inl_DeclaredInlined: + case DW_Inl_Inlined: { + visit_children = 0; + } break; + default: InvalidPath; break; + } + } break; + case DW_Tag_InlinedSubroutine: { U64 param_count = 0; - RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, cur_node, ¶m_count); - + RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, tag_stack->cur_node, ¶m_count); + // get return type RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - + // fill out proc type RDIM_Type *proc_type = d2r_create_type(arena, type_table); proc_type->kind = RDI_TypeKind_Function; @@ -1805,170 +1878,97 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) proc_type->direct_type = ret_type; proc_type->count = param_count; proc_type->param_types = params; - + // get container type - RDIM_Type *container_type = 0; + RDIM_Type *owner = 0; if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) { - container_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType); + owner = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType); } - - // get frame base expression - String8 frame_base_expr = dw_exprloc_from_attrib(&input, cu, tag, DW_Attrib_FrameBase); - - // get proc container symbol - RDIM_Symbol *proc = rdim_symbol_chunk_list_push(arena, &procs, PROC_CHUNK_CAP ); - + + // fill out inline site + RDIM_InlineSite *inline_site = rdim_inline_site_chunk_list_push(arena, &inline_sites, INLINE_SITE_CHUNK_CAP); + inline_site->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + inline_site->type = proc_type; + inline_site->owner = owner; + inline_site->line_table = 0; + // make scope Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); RDIM_Scope *root_scope = d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); - root_scope->symbol = proc; - - // fill out proc - proc->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External); - proc->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - proc->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName); - proc->type = proc_type; - proc->container_symbol = 0; - proc->container_type = container_type; - proc->root_scope = root_scope; - proc->frame_base = d2r_locset_from_attrib(arena, &input, cu, &scopes, root_scope, image_base, arch, tag, DW_Attrib_FrameBase); - - // sub program with user-defined parent tag is a method + root_scope->inline_site = inline_site; + } break; + case DW_Tag_Variable: { + String8 name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + RDIM_Type *type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; - if (parent_tag_kind == DW_Tag_ClassType || parent_tag_kind == DW_Tag_StructureType) { - RDI_MemberKind member_kind = RDI_MemberKind_NULL; - DW_VirtualityKind virtuality = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Virtuality); - switch (virtuality) { - case DW_VirtualityKind_None: member_kind = RDI_MemberKind_Method; break; - case DW_VirtualityKind_Virtual: member_kind = RDI_MemberKind_VirtualMethod; break; - case DW_VirtualityKind_PureVirtual: member_kind = RDI_MemberKind_VirtualMethod; break; // TODO: create kind for pure virutal - //default: InvalidPath; break; + if (parent_tag_kind == DW_Tag_SubProgram || + parent_tag_kind == DW_Tag_InlinedSubroutine || + parent_tag_kind == DW_Tag_LexicalBlock) { + RDIM_Scope *scope = tag_stack->next->scope; + RDIM_Local *local = rdim_scope_push_local(arena, &scopes, tag_stack->next->scope); + local->kind = RDI_LocalKind_Variable; + local->name = name; + local->type = type; + local->locset = d2r_var_locset_from_tag(arena, &input, cu, &scopes, scope, image_base, arch, tag); + } else { + + // NOTE: due to a bug in clang in stb_sprint.h local variables + // are declared in global scope without a name + if (name.size == 0) { + break; } - - RDIM_Type *type = tag_stack->next->type; - RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt); - member->kind = member_kind; - member->type = type; - member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - } else if (parent_tag_kind != DW_Tag_CompileUnit) { - //AssertAlways(!"unexpected tag"); + + RDIM_Symbol *gvar = rdim_symbol_chunk_list_push(arena, &gvars, GVAR_CHUNK_CAP); + gvar->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External); + gvar->name = name; + gvar->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName); + gvar->type = type; + //gvar->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, global_scope, image_base, arch, tag, DW_Attrib_Location); + gvar->container_symbol = 0; + gvar->container_type = 0; // TODO: NotImplemented; } - - tag_stack->scope = root_scope; } break; - case DW_Inl_DeclaredNotInlined: - case DW_Inl_DeclaredInlined: - case DW_Inl_Inlined: { - visit_children = 0; - } break; - default: InvalidPath; break; - } - } break; - case DW_Tag_InlinedSubroutine: { - U64 param_count = 0; - RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, tag_stack->cur_node, ¶m_count); - - // get return type - RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - // fill out proc type - RDIM_Type *proc_type = d2r_create_type(arena, type_table); - proc_type->kind = RDI_TypeKind_Function; - proc_type->byte_size = arch_addr_size; - proc_type->direct_type = ret_type; - proc_type->count = param_count; - proc_type->param_types = params; - - // get container type - RDIM_Type *owner = 0; - if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) { - owner = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType); - } - - // fill out inline site - RDIM_InlineSite *inline_site = rdim_inline_site_chunk_list_push(arena, &inline_sites, INLINE_SITE_CHUNK_CAP); - inline_site->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - inline_site->type = proc_type; - inline_site->owner = owner; - inline_site->line_table = 0; - - // make scope - Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); - RDIM_Scope *root_scope = d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); - root_scope->inline_site = inline_site; - } break; - case DW_Tag_Variable: { - String8 name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - RDIM_Type *type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; - if (parent_tag_kind == DW_Tag_SubProgram || - parent_tag_kind == DW_Tag_InlinedSubroutine || - parent_tag_kind == DW_Tag_LexicalBlock) { - RDIM_Scope *scope = tag_stack->next->scope; - RDIM_Local *local = rdim_scope_push_local(arena, &scopes, tag_stack->next->scope); - local->kind = RDI_LocalKind_Variable; - local->name = name; - local->type = type; - local->locset = d2r_var_locset_from_tag(arena, &input, cu, &scopes, scope, image_base, arch, tag); - } else { - - // NOTE: due to a bug in clang in stb_sprint.h local variables - // are declared in global scope without a name - if (name.size == 0) { - break; + case DW_Tag_FormalParameter: { + DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; + if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine) { + RDIM_Scope *scope = tag_stack->next->scope; + RDIM_Local *param = rdim_scope_push_local(arena, &scopes, scope); + param->kind = RDI_LocalKind_Parameter; + param->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + param->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + param->locset = d2r_var_locset_from_tag(arena, &input, cu, &scopes, scope, image_base, arch, tag); + } else { + // TODO: error handling + AssertAlways(!"this is a local variable"); } - - RDIM_Symbol *gvar = rdim_symbol_chunk_list_push(arena, &gvars, GVAR_CHUNK_CAP); - gvar->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External); - gvar->name = name; - gvar->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName); - gvar->type = type; - //gvar->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, global_scope, image_base, arch, tag, DW_Attrib_Location); - gvar->container_symbol = 0; - gvar->container_type = 0; // TODO: NotImplemented; - } - } break; - case DW_Tag_FormalParameter: { - DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; - if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine) { - RDIM_Scope *scope = tag_stack->next->scope; - RDIM_Local *param = rdim_scope_push_local(arena, &scopes, scope); - param->kind = RDI_LocalKind_Parameter; - param->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - param->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - param->locset = d2r_var_locset_from_tag(arena, &input, cu, &scopes, scope, image_base, arch, tag); - } else { - // TODO: error handling - AssertAlways(!"this is a local variable"); - } - } break; - case DW_Tag_LexicalBlock: { - if (tag_stack->next->cur_node->tag.kind == DW_Tag_SubProgram || - tag_stack->next->cur_node->tag.kind == DW_Tag_InlinedSubroutine || - tag_stack->next->cur_node->tag.kind == DW_Tag_LexicalBlock) { - Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); - d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); - } - } break; - case DW_Tag_CallSite: { - // TODO - } break; - case DW_Tag_CallSiteParameter: { - // TODO - } break; - case DW_Tag_Label: - case DW_Tag_CompileUnit: - case DW_Tag_UnspecifiedParameters: - break; - case DW_Tag_Namespace: break; - case DW_Tag_ImportedDeclaration: break; - case DW_Tag_PtrToMemberType: break; - case DW_Tag_TemplateTypeParameter: break; - case DW_Tag_ReferenceType: break; - default: NotImplemented; break; + } break; + case DW_Tag_LexicalBlock: { + if (tag_stack->next->cur_node->tag.kind == DW_Tag_SubProgram || + tag_stack->next->cur_node->tag.kind == DW_Tag_InlinedSubroutine || + tag_stack->next->cur_node->tag.kind == DW_Tag_LexicalBlock) { + Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); + d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); + } + } break; + case DW_Tag_CallSite: { + // TODO + } break; + case DW_Tag_CallSiteParameter: { + // TODO + } break; + case DW_Tag_Label: + case DW_Tag_CompileUnit: + case DW_Tag_UnspecifiedParameters: + break; + case DW_Tag_Namespace: break; + case DW_Tag_ImportedDeclaration: break; + case DW_Tag_PtrToMemberType: break; + case DW_Tag_TemplateTypeParameter: break; + case DW_Tag_ReferenceType: break; + default: NotImplemented; break; } - + if (tag_stack->cur_node->first_child && visit_children) { D2R_TagNode *frame = free_tags; if (frame) { @@ -1983,22 +1983,22 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) tag_stack->cur_node = tag_stack->cur_node->sibling; } } - + // recycle free frame D2R_TagNode *frame = tag_stack; SLLStackPop(tag_stack); SLLStackPush(free_tags, frame); - + if (tag_stack) { tag_stack->cur_node = tag_stack->cur_node->sibling; } } - + temp_end(comp_temp); } - + ProfEnd(); - + { for (RDIM_TypeChunkNode *chunk_n = types.first; chunk_n != 0; chunk_n = chunk_n->next) { for (U64 i = 0; i < chunk_n->count; ++i) { @@ -2014,18 +2014,18 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) } } } - + { RDIM_TypeNode *type_stack = 0; RDIM_TypeNode *free_types = 0; - + for (RDIM_TypeChunkNode *chunk_n = types.first; chunk_n != 0; chunk_n = chunk_n->next) { for (U64 i = 0; i < chunk_n->count; ++i) { RDIM_Type *type = &chunk_n->v[i]; if (type->kind == RDI_TypeKind_Array) { if (type->byte_size != 0) continue; - + RDIM_Type *t; for (t = type; t != 0 && t->kind == RDI_TypeKind_Array; t = t->direct_type) { RDIM_TypeNode *f = free_types; @@ -2037,12 +2037,12 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) f->v = t; SLLStackPush(type_stack, f); } - + U64 base_type_size = 0; if (t) { base_type_size = t->byte_size; } - + U64 array_size = base_type_size; while (type_stack) { if (type_stack->v->count) { @@ -2052,10 +2052,10 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) } SLLStackPop(type_stack); } - + type->count = 0; type->byte_size = array_size; - + // recycle frames free_types = type_stack; type_stack = 0; @@ -2063,9 +2063,9 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) } } } - + //////////////////////////////// - + RDIM_BakeParams *bake_params = push_array(arena, RDIM_BakeParams, 1); bake_params->top_level_info = top_level_info; bake_params->binary_sections = binary_sections; @@ -2079,7 +2079,7 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) bake_params->procedures = procs; bake_params->scopes = scopes; bake_params->inline_sites = inline_sites; - + scratch_end(scratch); return bake_params; } @@ -2089,23 +2089,23 @@ rdi_language_from_dw_language(DW_Language v) { RDI_Language result = RDI_Language_NULL; switch (v) { - case DW_Language_Null: result = RDI_Language_NULL; break; - - case DW_Language_C89: - case DW_Language_C99: - case DW_Language_C11: - case DW_Language_C: + case DW_Language_Null: result = RDI_Language_NULL; break; + + case DW_Language_C89: + case DW_Language_C99: + case DW_Language_C11: + case DW_Language_C: result = RDI_Language_C; break; - - case DW_Language_CPlusPlus03: - case DW_Language_CPlusPlus11: - case DW_Language_CPlusPlus14: - case DW_Language_CPlusPlus: + + case DW_Language_CPlusPlus03: + case DW_Language_CPlusPlus11: + case DW_Language_CPlusPlus14: + case DW_Language_CPlusPlus: result = RDI_Language_CPlusPlus; break; - - default: NotImplemented; break; + + default: NotImplemented; break; } return result; } @@ -2118,7 +2118,7 @@ rdi_reg_from_dw_reg_x86(DW_RegX86 v) #define X(reg_dw, val_dw, reg_rdi, ...) case DW_RegX86_##reg_dw: result = RDI_RegCodeX86_##reg_rdi; break; DW_Regs_X86_XList(X) #undef X - default: NotImplemented; break; + default: NotImplemented; break; } return result; } @@ -2131,7 +2131,7 @@ rdi_reg_from_dw_reg_x64(DW_RegX64 v, RDI_RegCodeX64 *code_out, U64 *off_out, U64 #define X(reg_dw, val_dw, reg_rdi, off, size) case DW_RegX64_##reg_dw: result = RDI_RegCodeX64_##reg_rdi; *off_out = off; *size_out = size; break; DW_Regs_X64_XList(X) #undef X - default: NotImplemented; break; + default: NotImplemented; break; } return result; } @@ -2141,10 +2141,10 @@ rdi_reg_from_dw_reg(Arch arch, DW_Reg v, RDI_RegCode *code_out, U64 *off_out, U6 { RDI_RegCode result = RDI_RegCode_nil; switch (arch) { - case Arch_Null: break; - case Arch_x86: ; break; - case Arch_x64: return rdi_reg_from_dw_reg_x64(v, code_out, off_out, size_out); - default: NotImplemented; break; + case Arch_Null: break; + case Arch_x86: ; break; + case Arch_x64: return rdi_reg_from_dw_reg_x64(v, code_out, off_out, size_out); + default: NotImplemented; break; } return 0; } diff --git a/src/radcon/radcon_dwarf.h b/src/radcon/radcon_dwarf.h index 3029b314..9ec4e728 100644 --- a/src/radcon/radcon_dwarf.h +++ b/src/radcon/radcon_dwarf.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADCON_DWARF_H diff --git a/src/radcon/radcon_elf.c b/src/radcon/radcon_elf.c index d5ab8333..4ff07e9f 100644 --- a/src/radcon/radcon_elf.c +++ b/src/radcon/radcon_elf.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal RDIM_BinarySectionList diff --git a/src/radcon/radcon_elf.h b/src/radcon/radcon_elf.h index dadb2ae2..9625ff18 100644 --- a/src/radcon/radcon_elf.h +++ b/src/radcon/radcon_elf.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADCON_ELF_H diff --git a/src/radcon/radcon_main.c b/src/radcon/radcon_main.c index 9f3c2b0a..38270579 100644 --- a/src/radcon/radcon_main.c +++ b/src/radcon/radcon_main.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #define BUILD_TITLE "Epic Games Tools (R) RAD Debug Info Converter" diff --git a/src/radcon/radcon_pdb.c b/src/radcon/radcon_pdb.c index 453c5b75..44bd224e 100644 --- a/src/radcon/radcon_pdb.c +++ b/src/radcon/radcon_pdb.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) // TODO(rjf): eliminate redundant null checks, just always allocate @@ -400,12 +400,12 @@ ASYNC_WORK_DEF(p2r_units_convert_work) } // rjf: build line table, fill with parsed binary annotations - + if(inlinee_lines_parsed != 0) { // rjf: grab checksums sub-section CV_C13SubSectionNode *file_chksms = unit_c13->file_chksms_sub_section; - + // rjf: gathered lines typedef struct LineChunk LineChunk; struct LineChunk @@ -423,12 +423,12 @@ ASYNC_WORK_DEF(p2r_units_convert_work) U32 last_file_off = max_U32; U32 curr_file_off = max_U32; RDIM_LineTable* line_table = 0; - + CV_C13InlineSiteDecoder decoder = cv_c13_inline_site_decoder_init(inlinee_lines_parsed->file_off, inlinee_lines_parsed->first_source_ln, base_voff); for(;;) { CV_C13InlineSiteDecoderStep step = cv_c13_inline_site_decoder_step(&decoder, binary_annots); - + if(step.flags & CV_C13InlineSiteDecoderStepFlag_EmitFile) { last_file_off = curr_file_off; @@ -442,7 +442,7 @@ ASYNC_WORK_DEF(p2r_units_convert_work) if((last_file_off != max_U32 && last_file_off != curr_file_off)) { String8 seq_file_name = {0}; - + if(last_file_off + sizeof(CV_C13Checksum) <= file_chksms->size) { CV_C13Checksum *checksum = (CV_C13Checksum*)(unit_c13->data.str + file_chksms->off + last_file_off); @@ -514,7 +514,7 @@ ASYNC_WORK_DEF(p2r_units_convert_work) first_line_chunk = last_line_chunk = 0; total_line_chunk_line_count = 0; } - + if(step.flags & CV_C13InlineSiteDecoderStepFlag_EmitLine) { LineChunk *chunk = last_line_chunk; @@ -532,7 +532,7 @@ ASYNC_WORK_DEF(p2r_units_convert_work) chunk->count += 1; total_line_chunk_line_count += 1; } - + if(step.flags == 0) { break; @@ -1479,7 +1479,7 @@ ASYNC_WORK_DEF(p2r_symbol_stream_convert_work) { container_symbol = top_scope_node->scope->symbol; } - + // form a VOFF location #if 0 RDIM_LocationSet locset = {0}; @@ -1716,7 +1716,7 @@ ASYNC_WORK_DEF(p2r_symbol_stream_convert_work) RDIM_Location *tls_off_loc = rdim_push_location_tls_off(arena, tls_off); rdim_location_set_push_case(arena, &locset, (RDIM_Rng1U64){0,max_U64}, tls_off_loc); #endif - + // rjf: build symbol RDIM_Symbol *tvar = rdim_symbol_chunk_list_push(arena, &sym_thread_variables, sym_thread_variables_chunk_cap); tvar->name = name; @@ -2063,14 +2063,14 @@ ASYNC_WORK_DEF(p2r_symbol_stream_convert_work) for(;;) { CV_C13InlineSiteDecoderStep step = cv_c13_inline_site_decoder_step(&decoder, binary_annots); - + if(step.flags & CV_C13InlineSiteDecoderStepFlag_EmitRange) { // rjf: build new range & add to scope RDIM_Rng1U64 voff_range = { step.range.min, step.range.max }; rdim_scope_push_voff_range(arena, &sym_scopes, scope, voff_range); } - + if(step.flags & CV_C13InlineSiteDecoderStepFlag_ExtendLastRange) { if(scope->voff_ranges.last != 0) @@ -2078,7 +2078,7 @@ ASYNC_WORK_DEF(p2r_symbol_stream_convert_work) scope->voff_ranges.last->v.max = step.range.max; } } - + if(step.flags == 0) { break; @@ -2128,7 +2128,7 @@ internal RDIM_BakeParams * p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) { Temp scratch = scratch_begin(&arena, 1); - + g_p2r_local_state = local_state; ////////////////////////////////////////////////////////////// @@ -2153,7 +2153,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) named_streams = pdb_named_stream_table_from_info(arena, info); MemoryCopyStruct(&auth_guid, &info->auth_guid); scratch_end(scratch); - + if (info->features & PDB_FeatureFlag_MINIMAL_DBG_INFO) { fprintf(stderr, "ERROR: PDB was linked with /DEBUG:FASTLINK (partial debug info is not supported). Please relink using /DEBUG:FULL."); os_abort(1); @@ -2372,7 +2372,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) //- rjf: produce top-level-info // RDIM_TopLevelInfo top_level_info = rdim_make_top_level_info(in->image_name, arch_from_coff_machine(dbi->machine_type), exe_hash, binary_sections); - + ////////////////////////////////////////////////////////////// //- rjf: kick off unit conversion & source file collection // @@ -2450,7 +2450,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) if(in->flags & RC_Flag_Types) ProfScope("types pass 1: construct all root/stub types from TPI") { itype_type_ptrs = push_array(arena, RDIM_Type *, tpi_leaf->itype_opl); - + ////////////////////////// //- build basic types // @@ -2463,7 +2463,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) RDI_TypeKind ulong_type = rdim_unsigned_long_type_from_data_model(data_model); RDI_TypeKind ulong_long_type = rdim_unsigned_long_long_type_from_data_model(data_model); RDI_TypeKind ptr_type = rdim_pointer_size_t_type_from_data_model(data_model); - + struct { char * name; @@ -2518,7 +2518,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) { "char32_t" , RDI_TypeKind_Char32 , CV_BasicType_CHAR32 , 1, 1, 1 }, // always UTF-32 { "__pointer" , ptr_type , CV_BasicType_PTR , 0, 0, 0 } }; - + for(U64 i = 0; i < ArrayCount(table); i += 1) { RDIM_Type *type = rdim_type_chunk_list_push(arena, &all_types, tpi_leaf->itype_opl); @@ -2526,7 +2526,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) type->name = str8_cstring(table[i].name); type->direct_type = rdim_builtin_type_from_kind(all_types, table[i].kind_rdi); itype_type_ptrs[table[i].kind_cv] = type; - + if(table[i].make_pointer_near) { CV_TypeIndex near_ptr_itype = table[i].kind_cv | 0x100; @@ -2556,7 +2556,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) } } } - + ////////////////////////// //- rjf: build complex type // @@ -2566,7 +2566,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) CV_RecRange *range = &tpi_leaf->leaf_ranges.ranges[itype-tpi_leaf->itype_first]; CV_LeafKind kind = range->hdr.kind; U64 header_struct_size = cv_header_struct_size_from_leaf_kind(kind); - + if(range->off+range->hdr.size <= tpi_leaf->data.size && range->off+2+header_struct_size <= tpi_leaf->data.size && range->hdr.size >= 2) @@ -2823,7 +2823,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) { dst_type->kind = (kind == CV_LeafKind_CLASS ? RDI_TypeKind_Class : RDI_TypeKind_Struct); } - + B32 do_unique_name_lookup = (((lf->props & CV_TypeProp_Scoped) != 0) && ((lf->props & CV_TypeProp_HasUniqueName) != 0)); if(do_unique_name_lookup) @@ -2831,7 +2831,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) U8 *unique_name_ptr = name_ptr + name.size + 1; dst_type->link_name = str8_cstring_capped(unique_name_ptr, itype_leaf_opl); } - + dst_type->name = name; dst_type->byte_size = safe_cast_u32(size_u64); }break; @@ -2863,7 +2863,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) dst_type->byte_size = (U32)size_u64; dst_type->name = name; } - + B32 do_unique_name_lookup = (((lf->props & CV_TypeProp_Scoped) != 0) && ((lf->props & CV_TypeProp_HasUniqueName) != 0)); if(do_unique_name_lookup) @@ -2899,7 +2899,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) dst_type->byte_size = (U32)size_u64; dst_type->name = name; } - + B32 do_unique_name_lookup = (((lf->props & CV_TypeProp_Scoped) != 0) && ((lf->props & CV_TypeProp_HasUniqueName) != 0)); if(do_unique_name_lookup) @@ -2934,7 +2934,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in) dst_type->byte_size = direct_type ? direct_type->byte_size : 0; dst_type->name = name; } - + B32 do_unique_name_lookup = (((lf->props & CV_TypeProp_Scoped) != 0) && ((lf->props & CV_TypeProp_HasUniqueName) != 0)); if(do_unique_name_lookup) diff --git a/src/radcon/radcon_pdb.h b/src/radcon/radcon_pdb.h index 7f7aaf72..50323699 100644 --- a/src/radcon/radcon_pdb.h +++ b/src/radcon/radcon_pdb.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADCON_PDB_H diff --git a/src/raddbg/generated/raddbg.meta.c b/src/raddbg/generated/raddbg.meta.c index ee8a5cd5..de5afcd8 100644 --- a/src/raddbg/generated/raddbg.meta.c +++ b/src/raddbg/generated/raddbg.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/raddbg/generated/raddbg.meta.h b/src/raddbg/generated/raddbg.meta.h index 8d48807c..4278aceb 100644 --- a/src/raddbg/generated/raddbg.meta.h +++ b/src/raddbg/generated/raddbg.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/raddbg/raddbg.mdesk b/src/raddbg/raddbg.mdesk index 3ec1fff5..ac64c5f2 100644 --- a/src/raddbg/raddbg.mdesk +++ b/src/raddbg/raddbg.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index 0471bc16..db349a9c 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/raddbg/raddbg_core.h b/src/raddbg/raddbg_core.h index 6468fbc6..523160a7 100644 --- a/src/raddbg/raddbg_core.h +++ b/src/raddbg/raddbg_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADDBG_CORE_H diff --git a/src/raddbg/raddbg_eval.c b/src/raddbg/raddbg_eval.c index 4da6deb4..dd45dcd7 100644 --- a/src/raddbg/raddbg_eval.c +++ b/src/raddbg/raddbg_eval.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/raddbg/raddbg_eval.h b/src/raddbg/raddbg_eval.h index c866f317..b5980a03 100644 --- a/src/raddbg/raddbg_eval.h +++ b/src/raddbg/raddbg_eval.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADDBG_EVAL_H diff --git a/src/raddbg/raddbg_inc.c b/src/raddbg/raddbg_inc.c index ece449df..0a693fae 100644 --- a/src/raddbg/raddbg_inc.c +++ b/src/raddbg/raddbg_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "raddbg_core.c" diff --git a/src/raddbg/raddbg_inc.h b/src/raddbg/raddbg_inc.h index deca7cb0..3109a527 100644 --- a/src/raddbg/raddbg_inc.h +++ b/src/raddbg/raddbg_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADDBG_INC_H diff --git a/src/raddbg/raddbg_legacy_config.c b/src/raddbg/raddbg_legacy_config.c index 119ea215..fb5af05c 100644 --- a/src/raddbg/raddbg_legacy_config.c +++ b/src/raddbg/raddbg_legacy_config.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal RD_CfgList diff --git a/src/raddbg/raddbg_legacy_config.h b/src/raddbg/raddbg_legacy_config.h index 31d2f8da..384d2fc6 100644 --- a/src/raddbg/raddbg_legacy_config.h +++ b/src/raddbg/raddbg_legacy_config.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADDBG_LEGACY_CONFIG_H diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index 3c99d889..78356848 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index 54e16e5f..bf6472e6 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/raddbg/raddbg_views.h b/src/raddbg/raddbg_views.h index 5f8d0869..3b6d5c2a 100644 --- a/src/raddbg/raddbg_views.h +++ b/src/raddbg/raddbg_views.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADDBG_VIEWS_H diff --git a/src/raddbg/raddbg_widgets.c b/src/raddbg/raddbg_widgets.c index 45c2bfd6..baefc83d 100644 --- a/src/raddbg/raddbg_widgets.c +++ b/src/raddbg/raddbg_widgets.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/raddbg/raddbg_widgets.h b/src/raddbg/raddbg_widgets.h index 36014bad..5556ae64 100644 --- a/src/raddbg/raddbg_widgets.h +++ b/src/raddbg/raddbg_widgets.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADDBG_WIDGETS_H diff --git a/src/raddump/raddump.c b/src/raddump/raddump.c index 88ba2992..be54449e 100644 --- a/src/raddump/raddump.c +++ b/src/raddump/raddump.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) // TODO: diff --git a/src/raddump/raddump.h b/src/raddump/raddump.h index fa934579..4c0bab92 100644 --- a/src/raddump/raddump.h +++ b/src/raddump/raddump.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RADDUMP_H diff --git a/src/raddump/raddump_main.c b/src/raddump/raddump_main.c index 69582b8f..958d24ab 100644 --- a/src/raddump/raddump_main.c +++ b/src/raddump/raddump_main.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #define BUILD_CONSOLE_INTERFACE 1 diff --git a/src/rdi_breakpad_from_pdb/rdi_breakpad_from_pdb_main.c b/src/rdi_breakpad_from_pdb/rdi_breakpad_from_pdb_main.c index 6e6b71d0..f0cf50c8 100644 --- a/src/rdi_breakpad_from_pdb/rdi_breakpad_from_pdb_main.c +++ b/src/rdi_breakpad_from_pdb/rdi_breakpad_from_pdb_main.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/rdi_format/rdi_format.mdesk b/src/rdi_format/rdi_format.mdesk index f0ccd388..3310b57f 100644 --- a/src/rdi_format/rdi_format.mdesk +++ b/src/rdi_format/rdi_format.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/rdi_format/rdi_format_local.c b/src/rdi_format/rdi_format_local.c index 5e134430..0cf4656f 100644 --- a/src/rdi_format/rdi_format_local.c +++ b/src/rdi_format/rdi_format_local.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "lib_rdi_format/rdi_format.c" diff --git a/src/rdi_format/rdi_format_local.h b/src/rdi_format/rdi_format_local.h index 5adc29c6..3eca0967 100644 --- a/src/rdi_format/rdi_format_local.h +++ b/src/rdi_format/rdi_format_local.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RDI_FORMAT_LOCAL_H diff --git a/src/rdi_from_dwarf/rdi_from_dwarf.c b/src/rdi_from_dwarf/rdi_from_dwarf.c index 8d600762..ee0c47ed 100644 --- a/src/rdi_from_dwarf/rdi_from_dwarf.c +++ b/src/rdi_from_dwarf/rdi_from_dwarf.c @@ -1,15 +1,15 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal D2R_User2Convert * d2r_user2convert_from_cmdln(Arena *arena, CmdLine *cmdline) { D2R_User2Convert *result = push_array(arena, D2R_User2Convert, 1); - + String8 exe_name = cmd_line_string(cmdline, str8_lit("exe")); String8 debug_name = cmd_line_string(cmdline, str8_lit("debug")); String8 out_name = cmd_line_string(cmdline, str8_lit("out")); - + // error check params if (exe_name.size == 0 && debug_name.size == 0) { str8_list_pushf(arena, &result->errors, "Missing one of the required parameters: '--exe:' or '--debug:'"); @@ -17,7 +17,7 @@ d2r_user2convert_from_cmdln(Arena *arena, CmdLine *cmdline) if (out_name.size == 0) { str8_list_pushf(arena, &result->errors, "Missing required parameter: '--out:'"); } - + // get input EXE or ELF if (exe_name.size > 0) { String8 exe_data = os_data_from_file_path(arena, exe_name); @@ -28,7 +28,7 @@ d2r_user2convert_from_cmdln(Arena *arena, CmdLine *cmdline) result->input_exe_data = exe_data; } } - + // get input DEBUG if (debug_name.size > 0) { String8 debug_data = os_data_from_file_path(arena, debug_name); @@ -39,32 +39,32 @@ d2r_user2convert_from_cmdln(Arena *arena, CmdLine *cmdline) result->input_debug_data = debug_data; } } - + result->output_name = out_name; result->flags = ~0ull; - + String8List only_names = cmd_line_strings(cmdline, str8_lit("only")); String8List omit_names = cmd_line_strings(cmdline, str8_lit("omit")); - + if (only_names.node_count > 0) { result->flags = 0; for (String8Node *i = only_names.first; i != 0; i = i->next) { #define X(t,n,k) if (str8_match_lit(Stringify(n), i->string, StringMatchFlag_CaseInsensitive)) \ - result->flags |= D2R_ConvertFlag_##t; +result->flags |= D2R_ConvertFlag_##t; RDI_SectionKind_XList #undef X } } - + if (omit_names.node_count > 0) { for (String8Node *i = omit_names.first; i != 0; i = i->next) { #define X(t,n,k) if (str8_match_lit(Stringify(n), i->string, StringMatchFlag_CaseInsensitive)) \ - result->flags &= ~D2R_ConvertFlag_##t; +result->flags &= ~D2R_ConvertFlag_##t; RDI_SectionKind_XList #undef X } } - + return result; } @@ -96,9 +96,9 @@ internal RDI_RegCode d2r_rdi_reg_from_dw_reg_code(RDI_Arch arch, U64 reg_code) { switch (arch) { - case RDI_Arch_NULL: return 0; - case RDI_Arch_X64: return d2r_rdi_reg_from_dw_reg_code_x64(reg_code); - case RDI_Arch_X86: return d2r_rdi_reg_from_dw_reg_code_x86(reg_code); + case RDI_Arch_NULL: return 0; + case RDI_Arch_X64: return d2r_rdi_reg_from_dw_reg_code_x64(reg_code); + case RDI_Arch_X86: return d2r_rdi_reg_from_dw_reg_code_x86(reg_code); } InvalidPath; return 0; @@ -129,21 +129,21 @@ internal RDIM_Type * d2r_type_from_attrib(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { RDIM_Type *type = 0; - + // find attrib DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind); - + // does tag have this attribute? if (attrib->attrib_kind == kind) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); - + if (value_class == DW_AttribClass_Reference) { // resolve reference DW_Reference ref = dw_ref_from_attrib_ptr(input, cu, attrib); - + // TODO: support for external compile unit references AssertAlways(ref.cu == cu); - + // find or create type type = d2r_find_or_create_type_from_offset(arena, type_table, ref.info_off); } else { @@ -152,7 +152,7 @@ d2r_type_from_attrib(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, D } else if (attrib->attrib_kind == DW_Attrib_Null) { type = type_table->void_type; } - + return type; } @@ -161,13 +161,13 @@ d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 imag { // collect non-contiguous range Rng1U64List ranges = dw_rnglist_from_attrib(arena, input, cu, tag, DW_Attrib_Ranges); - + // collect contiguous range DW_Attrib *lo_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_Attrib_LowPc); DW_Attrib *hi_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_Attrib_HighPc); if (lo_pc_attrib->attrib_kind != DW_Attrib_Null && hi_pc_attrib->attrib_kind != DW_Attrib_Null) { U64 lo_pc = dw_address_from_attrib_ptr(input, cu, lo_pc_attrib); - + U64 hi_pc; DW_AttribClass hi_pc_class = dw_value_class_from_attrib(cu, hi_pc_attrib); if (hi_pc_class == DW_AttribClass_Address) { @@ -178,17 +178,17 @@ d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 imag } else { AssertAlways(!"undefined attrib encoding"); } - + // TODO: error handling AssertAlways(lo_pc >= image_base); AssertAlways(hi_pc >= image_base); AssertAlways(lo_pc <= hi_pc); - + U64 lo_voff = lo_pc - image_base; U64 hi_voff = hi_pc - image_base; rng1u64_list_push(arena, &ranges, rng_1u64(lo_voff, hi_voff)); } - + return ranges; } @@ -196,7 +196,7 @@ internal RDIM_Type ** d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out) { Temp scratch = scratch_begin(&arena, 1); - + RDIM_TypeList list = {0}; B32 has_vargs = 0; for (DW_TagNode *i = cur_node->first_child; i != 0; i = i->sibling) { @@ -209,18 +209,18 @@ d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input has_vargs = 1; } } - + if (has_vargs) { RDIM_TypeNode *n = push_array(scratch.arena, RDIM_TypeNode, 1); n->v = type_table->varg_type; SLLQueuePush(list.first, list.last, n); ++list.count; } - + // collect params *param_count_out = list.count; RDIM_Type **params = rdim_array_from_type_list(arena, list); - + scratch_end(scratch); return params; } @@ -230,255 +230,64 @@ internal RDIM_EvalBytecode d2r_bytecode_from_expression(Arena *arena, U64 image_base, U64 address_size, RDI_Arch arch, DW_ListUnit *addr_lu, String8 expr) { RDIM_EvalBytecode bc = {0}; - + for (U64 cursor = 0; cursor < expr.size; ) { U8 op = 0; cursor += str8_deserial_read_struct(expr, cursor, &op); - + U64 size_param; switch (op) { - case DW_ExprOp_Lit0: case DW_ExprOp_Lit1: case DW_ExprOp_Lit2: - case DW_ExprOp_Lit3: case DW_ExprOp_Lit4: case DW_ExprOp_Lit5: - case DW_ExprOp_Lit6: case DW_ExprOp_Lit7: case DW_ExprOp_Lit8: - case DW_ExprOp_Lit9: case DW_ExprOp_Lit10: case DW_ExprOp_Lit11: - case DW_ExprOp_Lit12: case DW_ExprOp_Lit13: case DW_ExprOp_Lit14: - case DW_ExprOp_Lit15: case DW_ExprOp_Lit16: case DW_ExprOp_Lit17: - case DW_ExprOp_Lit18: case DW_ExprOp_Lit19: case DW_ExprOp_Lit20: - case DW_ExprOp_Lit21: case DW_ExprOp_Lit22: case DW_ExprOp_Lit23: - case DW_ExprOp_Lit24: case DW_ExprOp_Lit25: case DW_ExprOp_Lit26: - case DW_ExprOp_Lit27: case DW_ExprOp_Lit28: case DW_ExprOp_Lit29: - case DW_ExprOp_Lit30: case DW_ExprOp_Lit31: { - U64 lit = op - DW_ExprOp_Lit0; - rdim_bytecode_push_uconst(arena, &bc, lit); - } break; - - case DW_ExprOp_Const1U: size_param = 1; goto const_unsigned; - case DW_ExprOp_Const2U: size_param = 2; goto const_unsigned; - case DW_ExprOp_Const4U: size_param = 4; goto const_unsigned; - case DW_ExprOp_Const8U: size_param = 8; goto const_unsigned; - const_unsigned: { - U64 val = 0; - cursor += str8_deserial_read(expr, cursor, &val, size_param, size_param); - rdim_bytecode_push_uconst(arena, &bc, val); - } break; - - case DW_ExprOp_Const1S:size_param = 1; goto const_signed; - case DW_ExprOp_Const2S:size_param = 2; goto const_signed; - case DW_ExprOp_Const4S:size_param = 4; goto const_signed; - case DW_ExprOp_Const8S:size_param = 8; goto const_signed; - const_signed: { - S64 val = 0; - cursor += str8_deserial_read(expr, cursor, &val, size_param, size_param); - val = extend_sign64(val, size_param); - rdim_bytecode_push_sconst(arena, &bc, val); - } break; - - case DW_ExprOp_ConstU: { - U64 val = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &val); - rdim_bytecode_push_uconst(arena, &bc, val); - } break; - - case DW_ExprOp_ConstS: { - S64 val = 0; - cursor += str8_deserial_read_sleb128(expr, cursor, &val); - rdim_bytecode_push_sconst(arena, &bc, val); - } break; - - case DW_ExprOp_Addr: { - U64 addr = 0; - cursor += str8_deserial_read(expr, cursor, &addr, address_size, address_size); - if (addr >= image_base) { - U64 voff = addr - image_base; - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_ModuleOff, voff); - } else { - // TODO: error handling - AssertAlways(!"unable to relocate address"); - } - } break; - - case DW_ExprOp_Reg0: case DW_ExprOp_Reg1: case DW_ExprOp_Reg2: - case DW_ExprOp_Reg3: case DW_ExprOp_Reg4: case DW_ExprOp_Reg5: - case DW_ExprOp_Reg6: case DW_ExprOp_Reg7: case DW_ExprOp_Reg8: - case DW_ExprOp_Reg9: case DW_ExprOp_Reg10: case DW_ExprOp_Reg11: - case DW_ExprOp_Reg12: case DW_ExprOp_Reg13: case DW_ExprOp_Reg14: - case DW_ExprOp_Reg15: case DW_ExprOp_Reg16: case DW_ExprOp_Reg17: - case DW_ExprOp_Reg18: case DW_ExprOp_Reg19: case DW_ExprOp_Reg20: - case DW_ExprOp_Reg21: case DW_ExprOp_Reg22: case DW_ExprOp_Reg23: - case DW_ExprOp_Reg24: case DW_ExprOp_Reg25: case DW_ExprOp_Reg26: - case DW_ExprOp_Reg27: case DW_ExprOp_Reg28: case DW_ExprOp_Reg29: - case DW_ExprOp_Reg30: case DW_ExprOp_Reg31: { - U64 reg_code_dw = op - DW_ExprOp_Reg0; - RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); - U32 regread_param = RDI_EncodeRegReadParam(reg_code_rdi, 8, 0); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegRead, regread_param); - } break; - - case DW_ExprOp_RegX: { - U64 reg_code_dw = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, ®_code_dw); - RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); - U32 regread_param = RDI_EncodeRegReadParam(reg_code_rdi, 8, 0); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegRead, regread_param); - } break; - - case DW_ExprOp_ImplicitValue: { - U64 value_size = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &value_size); - - String8 val = str8_substr(expr, rng_1u64(cursor, cursor + value_size)); - if (val.size <= sizeof(U64)) { - U64 val64 = 0; - MemoryCopy(&val64, val.str, val.size); - rdim_bytecode_push_uconst(arena, &bc, val64); - } else { - // TODO: currenlty no way to encode string in RDIM_EvalBytecodeOp - NotImplemented; - } - } break; - - case DW_ExprOp_Piece: { - NotImplemented; - } break; - - case DW_ExprOp_BitPiece: { - NotImplemented; - } break; - - case DW_ExprOp_Pick: { - U8 stack_idx = 0; - cursor += str8_deserial_read_struct(expr, cursor, &stack_idx); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Pick, stack_idx); - } break; - - case DW_ExprOp_PlusUConst: { - U64 addend = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &addend); - rdim_bytecode_push_uconst(arena, &bc, addend); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, 0); - } break; - - case DW_ExprOp_Skip: { - S16 skip = 0; - cursor += str8_deserial_read_struct(expr, cursor, &skip); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Skip, skip); - } break; - - case DW_ExprOp_Bra: { - NotImplemented; - } break; - - case DW_ExprOp_BReg0: case DW_ExprOp_BReg1: case DW_ExprOp_BReg2: - case DW_ExprOp_BReg3: case DW_ExprOp_BReg4: case DW_ExprOp_BReg5: - case DW_ExprOp_BReg6: case DW_ExprOp_BReg7: case DW_ExprOp_BReg8: - case DW_ExprOp_BReg9: case DW_ExprOp_BReg10: case DW_ExprOp_BReg11: - case DW_ExprOp_BReg12: case DW_ExprOp_BReg13: case DW_ExprOp_BReg14: - case DW_ExprOp_BReg15: case DW_ExprOp_BReg16: case DW_ExprOp_BReg17: - case DW_ExprOp_BReg18: case DW_ExprOp_BReg19: case DW_ExprOp_BReg20: - case DW_ExprOp_BReg21: case DW_ExprOp_BReg22: case DW_ExprOp_BReg23: - case DW_ExprOp_BReg24: case DW_ExprOp_BReg25: case DW_ExprOp_BReg26: - case DW_ExprOp_BReg27: case DW_ExprOp_BReg28: case DW_ExprOp_BReg29: - case DW_ExprOp_BReg30: case DW_ExprOp_BReg31: { - U64 reg_code_dw = op - DW_ExprOp_BReg0; - S64 reg_off = 0; - cursor += str8_deserial_read_sleb128(expr, cursor, ®_off); + case DW_ExprOp_Lit0: case DW_ExprOp_Lit1: case DW_ExprOp_Lit2: + case DW_ExprOp_Lit3: case DW_ExprOp_Lit4: case DW_ExprOp_Lit5: + case DW_ExprOp_Lit6: case DW_ExprOp_Lit7: case DW_ExprOp_Lit8: + case DW_ExprOp_Lit9: case DW_ExprOp_Lit10: case DW_ExprOp_Lit11: + case DW_ExprOp_Lit12: case DW_ExprOp_Lit13: case DW_ExprOp_Lit14: + case DW_ExprOp_Lit15: case DW_ExprOp_Lit16: case DW_ExprOp_Lit17: + case DW_ExprOp_Lit18: case DW_ExprOp_Lit19: case DW_ExprOp_Lit20: + case DW_ExprOp_Lit21: case DW_ExprOp_Lit22: case DW_ExprOp_Lit23: + case DW_ExprOp_Lit24: case DW_ExprOp_Lit25: case DW_ExprOp_Lit26: + case DW_ExprOp_Lit27: case DW_ExprOp_Lit28: case DW_ExprOp_Lit29: + case DW_ExprOp_Lit30: case DW_ExprOp_Lit31: { + U64 lit = op - DW_ExprOp_Lit0; + rdim_bytecode_push_uconst(arena, &bc, lit); + } break; - RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegReadDyn, reg_code_rdi); - rdim_bytecode_push_sconst(arena, &bc, reg_off); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, 0); - } break; - - case DW_ExprOp_BRegX: { - U64 reg_code_dw = 0; - S64 reg_off = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, ®_code_dw); - cursor += str8_deserial_read_sleb128(expr, cursor, ®_off); - - RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegReadDyn, reg_code_rdi); - rdim_bytecode_push_sconst(arena, &bc, reg_off); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, 0); - } break; - - case DW_ExprOp_FBReg: { - S64 frame_off = 0; - cursor += str8_deserial_read_sleb128(expr, cursor, &frame_off); - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_FrameOff, frame_off); - } break; - - case DW_ExprOp_Deref: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_MemRead, address_size); - } break; - - case DW_ExprOp_DerefSize: { - U8 deref_size_in_bytes = 0; - cursor += str8_deserial_read_struct(expr, cursor, &deref_size_in_bytes); - if (0 < deref_size_in_bytes && deref_size_in_bytes <= address_size) { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_MemRead, deref_size_in_bytes); - } else { - // TODO: error handling - AssertAlways(!"ill formed expression"); - } - } break; - - case DW_ExprOp_XDerefSize: { - // TODO: error handling - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Call2: - case DW_ExprOp_Call4: - case DW_ExprOp_CallRef: { - // TODO: error handling - AssertAlways(!"calls are not supported"); - } break; - - case DW_ExprOp_ImplicitPointer: - case DW_ExprOp_GNU_ImplicitPointer: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_Convert: - case DW_ExprOp_GNU_Convert: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_GNU_ParameterRef: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_DerefType: - case DW_ExprOp_GNU_DerefType: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_ConstType: - case DW_ExprOp_GNU_ConstType: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_RegvalType: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_EntryValue: - case DW_ExprOp_GNU_EntryValue: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_Addrx: { - U64 addr_idx = 0; - cursor += str8_deserial_read_uleb128(expr, cursor, &addr_idx); - U64 addr = dw_addr_from_list_unit(addr_lu, addr_idx); - if (addr != max_U64) { + case DW_ExprOp_Const1U: size_param = 1; goto const_unsigned; + case DW_ExprOp_Const2U: size_param = 2; goto const_unsigned; + case DW_ExprOp_Const4U: size_param = 4; goto const_unsigned; + case DW_ExprOp_Const8U: size_param = 8; goto const_unsigned; + const_unsigned: { + U64 val = 0; + cursor += str8_deserial_read(expr, cursor, &val, size_param, size_param); + rdim_bytecode_push_uconst(arena, &bc, val); + } break; + + case DW_ExprOp_Const1S:size_param = 1; goto const_signed; + case DW_ExprOp_Const2S:size_param = 2; goto const_signed; + case DW_ExprOp_Const4S:size_param = 4; goto const_signed; + case DW_ExprOp_Const8S:size_param = 8; goto const_signed; + const_signed: { + S64 val = 0; + cursor += str8_deserial_read(expr, cursor, &val, size_param, size_param); + val = extend_sign64(val, size_param); + rdim_bytecode_push_sconst(arena, &bc, val); + } break; + + case DW_ExprOp_ConstU: { + U64 val = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &val); + rdim_bytecode_push_uconst(arena, &bc, val); + } break; + + case DW_ExprOp_ConstS: { + S64 val = 0; + cursor += str8_deserial_read_sleb128(expr, cursor, &val); + rdim_bytecode_push_sconst(arena, &bc, val); + } break; + + case DW_ExprOp_Addr: { + U64 addr = 0; + cursor += str8_deserial_read(expr, cursor, &addr, address_size, address_size); if (addr >= image_base) { U64 voff = addr - image_base; rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_ModuleOff, voff); @@ -486,143 +295,334 @@ d2r_bytecode_from_expression(Arena *arena, U64 image_base, U64 address_size, RDI // TODO: error handling AssertAlways(!"unable to relocate address"); } - } else { + } break; + + case DW_ExprOp_Reg0: case DW_ExprOp_Reg1: case DW_ExprOp_Reg2: + case DW_ExprOp_Reg3: case DW_ExprOp_Reg4: case DW_ExprOp_Reg5: + case DW_ExprOp_Reg6: case DW_ExprOp_Reg7: case DW_ExprOp_Reg8: + case DW_ExprOp_Reg9: case DW_ExprOp_Reg10: case DW_ExprOp_Reg11: + case DW_ExprOp_Reg12: case DW_ExprOp_Reg13: case DW_ExprOp_Reg14: + case DW_ExprOp_Reg15: case DW_ExprOp_Reg16: case DW_ExprOp_Reg17: + case DW_ExprOp_Reg18: case DW_ExprOp_Reg19: case DW_ExprOp_Reg20: + case DW_ExprOp_Reg21: case DW_ExprOp_Reg22: case DW_ExprOp_Reg23: + case DW_ExprOp_Reg24: case DW_ExprOp_Reg25: case DW_ExprOp_Reg26: + case DW_ExprOp_Reg27: case DW_ExprOp_Reg28: case DW_ExprOp_Reg29: + case DW_ExprOp_Reg30: case DW_ExprOp_Reg31: { + U64 reg_code_dw = op - DW_ExprOp_Reg0; + RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); + U32 regread_param = RDI_EncodeRegReadParam(reg_code_rdi, 8, 0); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegRead, regread_param); + } break; + + case DW_ExprOp_RegX: { + U64 reg_code_dw = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, ®_code_dw); + RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); + U32 regread_param = RDI_EncodeRegReadParam(reg_code_rdi, 8, 0); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegRead, regread_param); + } break; + + case DW_ExprOp_ImplicitValue: { + U64 value_size = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &value_size); + + String8 val = str8_substr(expr, rng_1u64(cursor, cursor + value_size)); + if (val.size <= sizeof(U64)) { + U64 val64 = 0; + MemoryCopy(&val64, val.str, val.size); + rdim_bytecode_push_uconst(arena, &bc, val64); + } else { + // TODO: currenlty no way to encode string in RDIM_EvalBytecodeOp + NotImplemented; + } + } break; + + case DW_ExprOp_Piece: { + NotImplemented; + } break; + + case DW_ExprOp_BitPiece: { + NotImplemented; + } break; + + case DW_ExprOp_Pick: { + U8 stack_idx = 0; + cursor += str8_deserial_read_struct(expr, cursor, &stack_idx); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Pick, stack_idx); + } break; + + case DW_ExprOp_PlusUConst: { + U64 addend = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &addend); + rdim_bytecode_push_uconst(arena, &bc, addend); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, 0); + } break; + + case DW_ExprOp_Skip: { + S16 skip = 0; + cursor += str8_deserial_read_struct(expr, cursor, &skip); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Skip, skip); + } break; + + case DW_ExprOp_Bra: { + NotImplemented; + } break; + + case DW_ExprOp_BReg0: case DW_ExprOp_BReg1: case DW_ExprOp_BReg2: + case DW_ExprOp_BReg3: case DW_ExprOp_BReg4: case DW_ExprOp_BReg5: + case DW_ExprOp_BReg6: case DW_ExprOp_BReg7: case DW_ExprOp_BReg8: + case DW_ExprOp_BReg9: case DW_ExprOp_BReg10: case DW_ExprOp_BReg11: + case DW_ExprOp_BReg12: case DW_ExprOp_BReg13: case DW_ExprOp_BReg14: + case DW_ExprOp_BReg15: case DW_ExprOp_BReg16: case DW_ExprOp_BReg17: + case DW_ExprOp_BReg18: case DW_ExprOp_BReg19: case DW_ExprOp_BReg20: + case DW_ExprOp_BReg21: case DW_ExprOp_BReg22: case DW_ExprOp_BReg23: + case DW_ExprOp_BReg24: case DW_ExprOp_BReg25: case DW_ExprOp_BReg26: + case DW_ExprOp_BReg27: case DW_ExprOp_BReg28: case DW_ExprOp_BReg29: + case DW_ExprOp_BReg30: case DW_ExprOp_BReg31: { + U64 reg_code_dw = op - DW_ExprOp_BReg0; + S64 reg_off = 0; + cursor += str8_deserial_read_sleb128(expr, cursor, ®_off); + + RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegReadDyn, reg_code_rdi); + rdim_bytecode_push_sconst(arena, &bc, reg_off); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, 0); + } break; + + case DW_ExprOp_BRegX: { + U64 reg_code_dw = 0; + S64 reg_off = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, ®_code_dw); + cursor += str8_deserial_read_sleb128(expr, cursor, ®_off); + + RDI_RegCode reg_code_rdi = d2r_rdi_reg_from_dw_reg_code(arch, reg_code_dw); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RegReadDyn, reg_code_rdi); + rdim_bytecode_push_sconst(arena, &bc, reg_off); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, 0); + } break; + + case DW_ExprOp_FBReg: { + S64 frame_off = 0; + cursor += str8_deserial_read_sleb128(expr, cursor, &frame_off); + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_FrameOff, frame_off); + } break; + + case DW_ExprOp_Deref: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_MemRead, address_size); + } break; + + case DW_ExprOp_DerefSize: { + U8 deref_size_in_bytes = 0; + cursor += str8_deserial_read_struct(expr, cursor, &deref_size_in_bytes); + if (0 < deref_size_in_bytes && deref_size_in_bytes <= address_size) { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_MemRead, deref_size_in_bytes); + } else { + // TODO: error handling + AssertAlways(!"ill formed expression"); + } + } break; + + case DW_ExprOp_XDerefSize: { // TODO: error handling - AssertAlways(!"out of bounds index"); - } - } break; - - case DW_ExprOp_CallFrameCfa: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_FrameOff, 0); - } break; - - case DW_ExprOp_FormTlsAddress: { - // TODO: - AssertAlways(!"RDI_EvalOp_TLSOff accepts immediate"); - } break; - - case DW_ExprOp_PushObjectAddress: { - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_Nop: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Noop, 0); - } break; - - case DW_ExprOp_Eq: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_EqEq, 0); - } break; - - case DW_ExprOp_Ge: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_GrEq, 0); - } break; - - case DW_ExprOp_Gt: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Grtr, 0); - } break; - - case DW_ExprOp_Le: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_LsEq, 0); - } break; - - case DW_ExprOp_Lt: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Less, 0); - } break; - - case DW_ExprOp_Ne: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_NtEq, 0); - } break; - - case DW_ExprOp_Shl: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_LShift, 0); - } break; - - case DW_ExprOp_Shr: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RShift, 0); - } break; - - case DW_ExprOp_Shra: { - // TODO: - AssertAlways(!"sample"); - } break; - - case DW_ExprOp_Xor: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitXor, 0); - } break; - - case DW_ExprOp_XDeref: { - // TODO: error handling - Assert(!"multiple address spaces are not supported"); - } break; - - case DW_ExprOp_Abs: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Abs, 0); - } break; - - case DW_ExprOp_And: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitAnd, 0); - } break; - - case DW_ExprOp_Div: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Div, 0); - } break; - - case DW_ExprOp_Minus: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Sub, 0); - } break; - - case DW_ExprOp_Mod: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Mod, 0); - } break; - - case DW_ExprOp_Mul: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Mul, 0); - } break; - - case DW_ExprOp_Neg: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Neg, 0); - } break; - - case DW_ExprOp_Not: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitNot, 0); - } break; - - case DW_ExprOp_Or: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitOr, 0); - } break; - - case DW_ExprOp_Plus: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, 0); - } break; - - case DW_ExprOp_Rot: { - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Swap: { - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Dup: { - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Drop: { - AssertAlways(!"no suitable conversion"); - } break; - - case DW_ExprOp_Over: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Pick, 1); - } break; - - case DW_ExprOp_StackValue: { - rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Stop, 0); - } break; - - default: InvalidPath; break; + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Call2: + case DW_ExprOp_Call4: + case DW_ExprOp_CallRef: { + // TODO: error handling + AssertAlways(!"calls are not supported"); + } break; + + case DW_ExprOp_ImplicitPointer: + case DW_ExprOp_GNU_ImplicitPointer: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_Convert: + case DW_ExprOp_GNU_Convert: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_GNU_ParameterRef: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_DerefType: + case DW_ExprOp_GNU_DerefType: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_ConstType: + case DW_ExprOp_GNU_ConstType: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_RegvalType: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_EntryValue: + case DW_ExprOp_GNU_EntryValue: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_Addrx: { + U64 addr_idx = 0; + cursor += str8_deserial_read_uleb128(expr, cursor, &addr_idx); + U64 addr = dw_addr_from_list_unit(addr_lu, addr_idx); + if (addr != max_U64) { + if (addr >= image_base) { + U64 voff = addr - image_base; + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_ModuleOff, voff); + } else { + // TODO: error handling + AssertAlways(!"unable to relocate address"); + } + } else { + // TODO: error handling + AssertAlways(!"out of bounds index"); + } + } break; + + case DW_ExprOp_CallFrameCfa: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_FrameOff, 0); + } break; + + case DW_ExprOp_FormTlsAddress: { + // TODO: + AssertAlways(!"RDI_EvalOp_TLSOff accepts immediate"); + } break; + + case DW_ExprOp_PushObjectAddress: { + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_Nop: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Noop, 0); + } break; + + case DW_ExprOp_Eq: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_EqEq, 0); + } break; + + case DW_ExprOp_Ge: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_GrEq, 0); + } break; + + case DW_ExprOp_Gt: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Grtr, 0); + } break; + + case DW_ExprOp_Le: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_LsEq, 0); + } break; + + case DW_ExprOp_Lt: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Less, 0); + } break; + + case DW_ExprOp_Ne: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_NtEq, 0); + } break; + + case DW_ExprOp_Shl: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_LShift, 0); + } break; + + case DW_ExprOp_Shr: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_RShift, 0); + } break; + + case DW_ExprOp_Shra: { + // TODO: + AssertAlways(!"sample"); + } break; + + case DW_ExprOp_Xor: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitXor, 0); + } break; + + case DW_ExprOp_XDeref: { + // TODO: error handling + Assert(!"multiple address spaces are not supported"); + } break; + + case DW_ExprOp_Abs: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Abs, 0); + } break; + + case DW_ExprOp_And: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitAnd, 0); + } break; + + case DW_ExprOp_Div: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Div, 0); + } break; + + case DW_ExprOp_Minus: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Sub, 0); + } break; + + case DW_ExprOp_Mod: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Mod, 0); + } break; + + case DW_ExprOp_Mul: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Mul, 0); + } break; + + case DW_ExprOp_Neg: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Neg, 0); + } break; + + case DW_ExprOp_Not: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitNot, 0); + } break; + + case DW_ExprOp_Or: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_BitOr, 0); + } break; + + case DW_ExprOp_Plus: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Add, 0); + } break; + + case DW_ExprOp_Rot: { + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Swap: { + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Dup: { + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Drop: { + AssertAlways(!"no suitable conversion"); + } break; + + case DW_ExprOp_Over: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Pick, 1); + } break; + + case DW_ExprOp_StackValue: { + rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_Stop, 0); + } break; + + default: InvalidPath; break; } } - + return bc; } @@ -664,10 +664,10 @@ d2r_locset_from_attrib(Arena *arena, DW_AttribKind kind) { RDIM_LocationSet result = {0}; - + DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind); DW_AttribClass attrib_class = dw_value_class_from_attrib(cu, attrib); - + if (attrib_class == DW_AttribClass_LocList || attrib_class == DW_AttribClass_LocListPtr) { Temp scratch = scratch_begin(&arena, 1); DW_LocList loclist = dw_loclist_from_attrib_ptr(scratch.arena, input, cu, attrib); @@ -681,7 +681,7 @@ d2r_locset_from_attrib(Arena *arena, } else if (attrib_class != DW_AttribClass_Null) { AssertAlways(!"unexpected attrib class"); } - + return result; } @@ -689,38 +689,38 @@ internal D2R_CompUnitContribMap d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) { Temp scratch = scratch_begin(&arena, 1); - + String8 aranges_data = input->sec[DW_Section_ARanges].data; Rng1U64List unit_range_list = dw_unit_ranges_from_data(scratch.arena, aranges_data); - + D2R_CompUnitContribMap cm = {0}; cm.count = 0; cm.info_off_arr = push_array(arena, U64, unit_range_list.count); cm.voff_range_arr = push_array(arena, RDIM_Rng1U64List, unit_range_list.count); - + for (Rng1U64Node *range_n = unit_range_list.first; range_n != 0; range_n = range_n->next) { String8 unit_data = str8_substr(aranges_data, range_n->v); U64 unit_cursor = 0; - + U64 unit_length = 0; U64 unit_length_size = str8_deserial_read_dwarf_packed_size(unit_data, unit_cursor, &unit_length); if (unit_length_size == 0) { continue; } unit_cursor += unit_length_size; - + DW_Version version = 0; U64 version_size = str8_deserial_read_struct(unit_data, unit_cursor, &version); if (version_size == 0) { continue; } unit_cursor += version; - + if (version != DW_Version_2) { AssertAlways(!"unknown .debug_aranges version"); continue; } - + DW_Format unit_format = DW_FormatFromSize(unit_length); U64 cu_info_off = 0; U64 cu_info_off_size = str8_deserial_read_dwarf_uint(unit_data, unit_cursor, unit_format, &cu_info_off); @@ -728,27 +728,27 @@ d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) continue; } unit_cursor += cu_info_off_size; - + U8 address_size = 0; U64 address_size_size = str8_deserial_read_struct(unit_data, unit_cursor, &address_size); if (address_size_size == 0) { continue; } unit_cursor += address_size_size; - + U8 segment_selector_size = 0; U64 segment_selector_size_size = str8_deserial_read_struct(unit_data, unit_cursor, &segment_selector_size); if (segment_selector_size_size == 0) { continue; } unit_cursor += segment_selector_size_size; - + U64 tuple_size = address_size * 2 + segment_selector_size; U64 bytes_too_far_past_boundary = unit_cursor % tuple_size; if (bytes_too_far_past_boundary > 0) { unit_cursor += tuple_size - bytes_too_far_past_boundary; } - + RDIM_Rng1U64List voff_ranges = {0}; if (segment_selector_size == 0) { while (unit_cursor + address_size * 2 <= unit_data.size) { @@ -756,14 +756,14 @@ d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) U64 length = 0; unit_cursor += str8_deserial_read(unit_data, unit_cursor, &address, address_size, address_size); unit_cursor += str8_deserial_read(unit_data, unit_cursor, &length, address_size, address_size); - + if (address == 0 && length == 0) { break; } - + // TODO: error handling AssertAlways(address >= image_base); - + U64 min = address - image_base; U64 max = min + length; rdim_rng1u64_list_push(arena, &voff_ranges, (RDIM_Rng1U64){.min = min, .max = max}); @@ -772,12 +772,12 @@ d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) // TODO: segment relative addressing NotImplemented; } - + U64 map_idx = cm.count++; cm.info_off_arr[map_idx] = cu_info_off; cm.voff_range_arr[map_idx] = voff_ranges; } - + scratch_end(scratch); return cm; } @@ -798,34 +798,34 @@ d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D { // fill out scope RDIM_Scope *scope = rdim_scope_chunk_list_push(arena, scopes, scope_chunk_cap); - + // push ranges for (Rng1U64Node *i = ranges.first; i != 0; i = i->next) { rdim_scope_push_voff_range(arena, scopes, scope, (RDIM_Rng1U64){.min = i->v.min, i->v.max}); } - + // associate scope with tag tag_stack->scope = scope; - + // update scope hierarchy DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine || parent_tag_kind == DW_Tag_LexicalBlock) { RDIM_Scope *parent = tag_stack->next->scope; - + scope->parent_scope = tag_stack->next->scope; - + if (parent->last_child) { parent->last_child->next_sibling = scope; } - + SLLQueuePush_N(parent->first_child, parent->last_child, scope, next_sibling); } - + // propagate scope symbol if (tag_stack->cur_node->tag.kind == DW_Tag_LexicalBlock) { scope->symbol = tag_stack->next->scope->symbol; } - + return scope; } @@ -833,9 +833,9 @@ internal RDIM_BakeParams * d2r_convert(Arena *arena, D2R_User2Convert *in) { Temp scratch = scratch_begin(&arena, 1); - + B32 is_parse_relaxed = !(in->flags & D2R_ConvertFlag_StrictParse); - + RDIM_BinarySectionList binary_sections = {0}; Arch arch = Arch_Null; U64 image_base = 0; @@ -844,27 +844,27 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) DW_ListUnitInput lui = {0}; if (pe_check_magic(in->input_exe_data)) { PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, in->input_exe_data); - + // infer exe info arch = pe.arch; image_base = pe.image_base; - + // get COFF sections String8 raw_sections = str8_substr(in->input_exe_data, rng_1u64(pe.section_array_off, pe.section_array_off+sizeof(COFF_SectionHeader)*pe.section_count)); U64 section_count = raw_sections.size / sizeof(COFF_SectionHeader); COFF_SectionHeader *section_array = (COFF_SectionHeader *)raw_sections.str; - + // loop over section headers and pick max virtual offset for (U64 i = 0; i < section_count; ++i) { U64 sec_voff_max = section_array[i].voff + section_array[i].vsize; voff_max = Max(voff_max, sec_voff_max); } - + ProfBegin("binary sections"); for (U64 i = 0; i < section_count; ++i) { COFF_SectionHeader *coff_sec = §ion_array[i]; RDIM_BinarySection *sec = rdim_binary_section_list_push(arena, &binary_sections); - + sec->name = coff_name_from_section_header(in->input_exe_data, coff_sec, pe.string_table_off); sec->flags = rdi_binary_section_flags_from_coff_section_flags(coff_sec->flags); sec->voff_first = coff_sec->voff; @@ -873,31 +873,31 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) sec->foff_opl = coff_sec->foff + coff_sec->fsize; } ProfEnd(); - + // find DWARF sections input = dw_input_from_coff_section_table(scratch.arena, in->input_exe_data, pe.string_table_off, section_count, section_array); } - + //////////////////////////////// - + RDI_Arch arch_rdi = RDI_Arch_NULL; switch (arch) { - case Arch_Null: arch_rdi = RDI_Arch_NULL; break; - case Arch_x64: arch_rdi = RDI_Arch_X64; break; - case Arch_x86: arch_rdi = RDI_Arch_X86; break; - default: NotImplemented; break; + case Arch_Null: arch_rdi = RDI_Arch_NULL; break; + case Arch_x64: arch_rdi = RDI_Arch_X64; break; + case Arch_x86: arch_rdi = RDI_Arch_X86; break; + default: NotImplemented; break; } - + U64 arch_addr_size = rdi_addr_size_from_arch(arch_rdi); - + //////////////////////////////// - + ProfBegin("compute exe hash"); U64 exe_hash = rdi_hash(in->input_exe_data.str, in->input_exe_data.size); ProfEnd(); - + //////////////////////////////// - + ProfBegin("top level info"); RDIM_TopLevelInfo top_level_info = {0}; top_level_info.arch = arch_rdi; @@ -906,9 +906,9 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) top_level_info.voff_max = voff_max; top_level_info.producer_name = str8_lit(BUILD_TITLE_STRING_LITERAL); ProfEnd(); - + //////////////////////////////// - + static const U64 UNIT_CHUNK_CAP = 256; static const U64 UDT_CHUNK_CAP = 256; static const U64 TYPE_CHUNK_CAP = 256; @@ -919,7 +919,7 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) static const U64 INLINE_SITE_CHUNK_CAP = 256; static const U64 SRC_FILE_CAP = 256; static const U64 LINE_TABLE_CAP = 256; - + RDIM_UnitChunkList units = {0}; RDIM_UDTChunkList udts = {0}; RDIM_TypeChunkList types = {0}; @@ -930,9 +930,9 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) RDIM_InlineSiteChunkList inline_sites = {0}; RDIM_SrcFileChunkList src_files = {0}; RDIM_LineTableChunkList line_tables = {0}; - + //////////////////////////////// - + ProfBegin("Make Unit Contrib Map"); D2R_CompUnitContribMap cu_contrib_map = {0}; if (input.sec[DW_Section_ARanges].data.size > 0) { @@ -942,24 +942,24 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) NotImplemented; } ProfEnd(); - + ProfBegin("Parse Comop Unit Ranges"); DW_ListUnitInput lu_input = dw_list_unit_input_from_input(scratch.arena, &input); Rng1U64List cu_range_list = dw_unit_ranges_from_data(scratch.arena, input.sec[DW_Section_Info].data); Rng1U64Array cu_ranges = rng1u64_array_from_list(scratch.arena, &cu_range_list); ProfEnd(); - + //////////////////////////////// - + ProfBegin("Parse Compile Unit Headers"); DW_CompUnit *cu_arr = push_array(scratch.arena, DW_CompUnit, cu_ranges.count); for (U64 cu_idx = 0; cu_idx < cu_ranges.count; ++cu_idx) { cu_arr[cu_idx] = dw_cu_from_info_off(scratch.arena, &input, lu_input, cu_ranges.v[cu_idx].min, is_parse_relaxed); } ProfEnd(); - + //////////////////////////////// - + ProfBegin("Parse Line Tables"); DW_LineTableParseResult *cu_line_tables = push_array(scratch.arena, DW_LineTableParseResult, cu_ranges.count); for (U64 cu_idx = 0; cu_idx < cu_ranges.count; ++cu_idx) { @@ -970,17 +970,17 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) cu_line_tables[cu_idx] = dw_parsed_line_table_from_data(scratch.arena, cu_stmt_list, &input, cu_dir, cu_name, cu->address_size, cu->str_offsets_lu); } ProfEnd(); - + //////////////////////////////// - + ProfBegin("Convert Line Tables"); - + HashTable *source_file_ht = hash_table_init(scratch.arena, 0x4000); RDIM_LineTable **cu_line_tables_rdi = push_array(scratch.arena, RDIM_LineTable *, cu_ranges.count); - + for (U64 cu_idx = 0; cu_idx < cu_ranges.count; ++cu_idx) { cu_line_tables_rdi[cu_idx] = rdim_line_table_chunk_list_push(arena, &line_tables, LINE_TABLE_CAP); - + DW_LineTableParseResult *line_table = &cu_line_tables[cu_idx]; DW_LineVMFileArray *dir_table = &line_table->vm_header.dir_table; DW_LineVMFileArray *file_table = &line_table->vm_header.file_table; @@ -1000,27 +1000,27 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) } src_file_map[file_idx] = src_file; } - + for (DW_LineSeqNode *line_seq = line_table->first_seq; line_seq != 0; line_seq = line_seq->next) { if (line_seq->count == 0) { continue; } - + U64 *voffs = push_array(arena, U64, line_seq->count); U32 *line_nums = push_array(arena, U32, line_seq->count); U16 *col_nums = 0; U64 line_idx = 0; - + DW_LineNode *file_line_n = line_seq->first; U64 file_line_count = 0; - + for (DW_LineNode *line_n = file_line_n; line_n != 0; line_n = line_n->next) { if (file_line_n->v.file_index != line_n->v.file_index || line_n->next == 0) { U64 file_index = file_line_n->v.file_index; U64 *file_voffs = &voffs[line_idx]; U32 *file_line_nums = &line_nums[line_idx]; U16 *file_col_nums = 0; - + U64 lines_written = 0; U64 prev_ln = max_U64; DW_LineNode *sentinel = line_n->v.file_index != file_line_n->v.file_index ? line_n : 0; @@ -1028,82 +1028,82 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) if (file_line_n->v.line != prev_ln) { // TODO: error handling AssertAlways(file_line_n->v.address >= image_base); - + voffs[line_idx] = file_line_n->v.address - image_base; line_nums[line_idx] = file_line_n->v.line; - + ++lines_written; ++line_idx; - + prev_ln = file_line_n->v.line; } } - + RDIM_SrcFile *src_file = src_file_map[file_index]; RDIM_LineSequence *line_seq = rdim_line_table_push_sequence(arena, &line_tables, cu_line_tables_rdi[cu_idx], src_file, file_voffs, file_line_nums, file_col_nums, lines_written); rdim_src_file_push_line_sequence(arena, &src_files, src_file, line_seq); - + file_line_count = 1; } else { ++file_line_count; } } - + // handle last line if (file_line_n) { U64 file_index = file_line_n->v.file_index; U64 *file_voffs = &voffs[line_idx]; U32 *file_line_nums = &line_nums[line_idx]; U16 *file_col_nums = 0; - + for (; file_line_n != 0; file_line_n = file_line_n->next, ++line_idx) { // TODO: error handling AssertAlways(file_line_n->v.address >= image_base); voffs[line_idx] = file_line_n->v.address - image_base; line_nums[line_idx] = file_line_n->v.line; } - + RDIM_SrcFile *src_file = src_file_map[file_index]; RDIM_LineSequence *line_seq = rdim_line_table_push_sequence(arena, &line_tables, cu_line_tables_rdi[cu_idx], src_file, file_voffs, file_line_nums, file_col_nums, file_line_count); rdim_src_file_push_line_sequence(arena, &src_files, src_file, line_seq); } - + //Assert(line_idx == line_seq->count); } } - + ProfEnd(); - + //////////////////////////////// ProfBegin("Convert Units"); - + for (U64 cu_idx = 0; cu_idx < cu_ranges.count; ++cu_idx) { Temp comp_temp = temp_begin(scratch.arena); - + DW_CompUnit *cu = &cu_arr[cu_idx]; - + // parse and build tag tree DW_TagTree tag_tree = dw_tag_tree_from_cu(comp_temp.arena, &input, cu); - + // build tag hash table for abstract origin resolution cu->tag_ht = dw_make_tag_hash_table(comp_temp.arena, tag_tree); - + String8 dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_DwoName); String8 gnu_dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_GNU_DwoName); if (dwo_name.size || gnu_dwo_name.size || cu->dwo_id) { // TODO: report that we dont support DWO continue; } - + // get unit's contribution ranges RDIM_Rng1U64List cu_voff_ranges = d2r_voff_ranges_from_cu_info_off(cu_contrib_map, cu_ranges.v[cu_idx].min); - + String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Name); String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_CompDir); String8 cu_prod = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Producer); DW_Language cu_lang = dw_const_u64_from_attrib(&input, cu, cu->tag, DW_Attrib_Language); - + RDIM_Unit *unit = rdim_unit_chunk_list_push(arena, &units, UNIT_CHUNK_CAP); unit->unit_name = cu_name; unit->compiler_name = cu_prod; @@ -1114,7 +1114,7 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) unit->language = rdi_language_from_dw_language(cu_lang); unit->line_table = cu_line_tables_rdi[cu_idx]; unit->voff_ranges = cu_voff_ranges; - + D2R_TypeTable *type_table = push_array(comp_temp.arena, D2R_TypeTable, 1); type_table->ht = hash_table_init(comp_temp.arena, 0x4000); type_table->types = &types; @@ -1123,445 +1123,518 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) type_table->void_type->kind = RDI_TypeKind_Void; type_table->varg_type = d2r_create_type(arena, type_table); type_table->varg_type->kind = RDI_TypeKind_Variadic; - + D2R_TagNode *free_tags = push_array(comp_temp.arena, D2R_TagNode, 1); D2R_TagNode *tag_stack = push_array(comp_temp.arena, D2R_TagNode, 1); tag_stack->cur_node = tag_tree.root; - + while (tag_stack) { while (tag_stack->cur_node) { DW_TagNode *cur_node = tag_stack->cur_node; DW_Tag tag = cur_node->tag; B32 visit_children = 1; - + switch (tag.kind) { - case DW_Tag_Null: { - InvalidPath; - } break; - case DW_Tag_ClassType: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - - B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); - if (is_decl) { - type->kind = RDI_TypeKind_IncompleteClass; - - Assert(!cur_node->first_child); - visit_children = 0; - } else { - RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); - udt->self_type = type; - - type->kind = RDI_TypeKind_Class; - type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); - type->udt = udt; - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - tag_stack->type = type; - } - } break; - case DW_Tag_StructureType: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - - B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); - if (is_decl) { - type->kind = RDI_TypeKind_IncompleteStruct; - - // TODO: error handling - Assert(!cur_node->first_child); - visit_children = 0; - } else { - RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); - udt->self_type = type; - - type->kind = RDI_TypeKind_Struct; - type->udt = udt; - type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + case DW_Tag_Null: { + InvalidPath; + } break; + case DW_Tag_ClassType: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - tag_stack->type = type; - } - } break; - case DW_Tag_UnionType: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - - B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); - if (is_decl) { - type->kind = RDI_TypeKind_IncompleteUnion; - - // TODO: error handling - Assert(!cur_node->first_child); - visit_children = 0; - } else { - RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); - udt->self_type = type; - - type->kind = RDI_TypeKind_Union; - type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); - type->udt = udt; - - tag_stack->type = type; - } - } break; - case DW_Tag_EnumerationType: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - - B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); - if (is_decl) { - type->kind = RDI_TypeKind_IncompleteEnum; - - // TODO: error handling - Assert(!cur_node->first_child); - visit_children = 0; - } else { - RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); - udt->self_type = type; - - type->kind = RDI_TypeKind_Enum; - type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); - type->udt = udt; - - tag_stack->type = type; - } - } break; - case DW_Tag_SubroutineType: { - // collect parameters - RDIM_TypeList param_list = {0}; - for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) { - if (n->tag.kind == DW_Tag_FormalParameter) { - RDIM_Type *param_type = d2r_type_from_attrib(arena, type_table, &input, cu, n->tag, DW_Attrib_Type); - rdim_type_list_push(comp_temp.arena, ¶m_list, param_type); - } else if (n->tag.kind == DW_Tag_UnspecifiedParameters) { - rdim_type_list_push(comp_temp.arena, ¶m_list, type_table->varg_type); + B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); + if (is_decl) { + type->kind = RDI_TypeKind_IncompleteClass; + + Assert(!cur_node->first_child); + visit_children = 0; } else { + RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); + udt->self_type = type; + + type->kind = RDI_TypeKind_Class; + type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + type->udt = udt; + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + + tag_stack->type = type; + } + } break; + case DW_Tag_StructureType: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + + B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); + if (is_decl) { + type->kind = RDI_TypeKind_IncompleteStruct; + // TODO: error handling - AssertAlways(!"unexpected tag"); - } - } - - // init proceudre type - RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Function; - type->byte_size = arch_addr_size; - type->direct_type = ret_type; - type->count = param_list.count; - type->param_types = rdim_array_from_type_list(arena, param_list); - - visit_children = 0; - } break; - case DW_Tag_Typedef: { - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Alias; - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - } break; - case DW_Tag_BaseType: { - DW_ATE encoding = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Encoding); - U64 byte_size = dw_byte_size_from_tag(&input, cu, tag); - - // convert base type encoding to RDI version - RDI_TypeKind kind = RDI_TypeKind_NULL; - switch (encoding) { - case DW_ATE_Null: kind = RDI_TypeKind_NULL; break; - case DW_ATE_Address: kind = RDI_TypeKind_Void; break; - case DW_ATE_Boolean: kind = RDI_TypeKind_Bool; break; - case DW_ATE_ComplexFloat: { - switch (byte_size) { - case 4: kind = RDI_TypeKind_ComplexF32; break; - case 8: kind = RDI_TypeKind_ComplexF64; break; - case 10: kind = RDI_TypeKind_ComplexF80; break; - case 16: kind = RDI_TypeKind_ComplexF128; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling + Assert(!cur_node->first_child); + visit_children = 0; + } else { + RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); + udt->self_type = type; + + type->kind = RDI_TypeKind_Struct; + type->udt = udt; + type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + + tag_stack->type = type; } } break; - case DW_ATE_Float: { - switch (byte_size) { - case 2: kind = RDI_TypeKind_F16; break; - case 4: kind = RDI_TypeKind_F32; break; - case 6: kind = RDI_TypeKind_F48; break; - case 8: kind = RDI_TypeKind_F64; break; - case 16: kind = RDI_TypeKind_F128; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_Signed: { - switch (byte_size) { - case 1: kind = RDI_TypeKind_S8; break; - case 2: kind = RDI_TypeKind_S16; break; - case 4: kind = RDI_TypeKind_S32; break; - case 8: kind = RDI_TypeKind_S64; break; - case 16: kind = RDI_TypeKind_S128; break; - case 32: kind = RDI_TypeKind_S256; break; - case 64: kind = RDI_TypeKind_S512; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_SignedChar: { - switch (byte_size) { - case 1: kind = RDI_TypeKind_Char8; break; - case 2: kind = RDI_TypeKind_Char16; break; - case 4: kind = RDI_TypeKind_Char32; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_Unsigned: { - switch (byte_size) { - case 1: kind = RDI_TypeKind_U8; break; - case 2: kind = RDI_TypeKind_U16; break; - case 4: kind = RDI_TypeKind_U32; break; - case 8: kind = RDI_TypeKind_U64; break; - case 16: kind = RDI_TypeKind_U128; break; - case 32: kind = RDI_TypeKind_U256; break; - case 64: kind = RDI_TypeKind_U512; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_UnsignedChar: { - switch (byte_size) { - case 1: kind = RDI_TypeKind_UChar8; break; - case 2: kind = RDI_TypeKind_UChar16; break; - case 4: kind = RDI_TypeKind_UChar32; break; - default: AssertAlways(!"unexpected size"); break; // TODO: error handling - } - } break; - case DW_ATE_ImaginaryFloat: { - NotImplemented; - } break; - case DW_ATE_PackedDecimal: { - NotImplemented; - } break; - case DW_ATE_NumericString: { - NotImplemented; - } break; - case DW_ATE_Edited: { - NotImplemented; - } break; - case DW_ATE_SignedFixed: { - NotImplemented; - } break; - case DW_ATE_UnsignedFixed: { - NotImplemented; - } break; - case DW_ATE_DecimalFloat: { - NotImplemented; - } break; - case DW_ATE_Utf: { - NotImplemented; - } break; - case DW_ATE_Ucs: { - NotImplemented; - } break; - case DW_ATE_Ascii: { - NotImplemented; - } break; - default: AssertAlways(!"unexpected base type encoding"); break; // TODO: error handling - } - - RDIM_Type *base_type = d2r_create_type(arena, type_table); - base_type->kind = kind; - base_type->byte_size = byte_size; - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Alias; - type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - type->direct_type = base_type; - } break; - case DW_Tag_PointerType: { - RDIM_Type *direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - // TODO: - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Allocated)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Associated)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_AddressClass)); - - U64 byte_size = arch_addr_size; - if (cu->version == DW_Version_5 || cu->relaxed) { - dw_try_byte_size_from_tag(&input, cu, tag, &byte_size); - } - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Ptr; - type->byte_size = byte_size; - type->direct_type = direct_type; - } break; - case DW_Tag_RestrictType: { - // TODO: - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Modifier; - type->byte_size = arch_addr_size; - type->flags = RDI_TypeModifierFlag_Restrict; - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - } break; - case DW_Tag_VolatileType: { - // TODO: - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Modifier; - type->byte_size = arch_addr_size; - type->flags = RDI_TypeModifierFlag_Volatile; - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - } break; - case DW_Tag_ConstType: { - // TODO: - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); - Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Modifier; - type->byte_size = arch_addr_size; - type->flags = RDI_TypeModifierFlag_Const; - type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - } break; - case DW_Tag_ArrayType: { - // * DWARF vs RDI Array Type Graph * - // - // For example lets take following decl: - // - // int (*foo[2])[3][4]; - // - // This compiles to in DWARF: - // - // foo -> DW_TAG_ArrayType -> (A0) DW_TAG_Subrange [2] - // \ - // -> (B0) DW_TAG_PointerType -> (A1) DW_TAG_ArrayType -> DW_TAG_Subrange [3] -> DW_Tag_Subrange [4] - // \ - // -> (B1) DW_TAG_BaseType (int) - // - // RDI expects: - // - // foo -> Array (2) -> Pointer -> Array (3) -> Array (4) -> int - // - // Note that DWARF forks the graph on DW_TAG_ArrayType to describe array ranges in branch A and - // in branch B describes array type which might be a struct, pointer, base type, or any other type tag. - // However, in RDI we have a simple list of type nodes and to convert we need to append type nodes from - // B to A. - - RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); - type->kind = RDI_TypeKind_Array; - type->direct_type = 0; - - U64 subrange_count = 0; - RDIM_Type *t = type; - for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) { - if (n->tag.kind != DW_Tag_SubrangeType) { + case DW_Tag_UnionType: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + + B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); + if (is_decl) { + type->kind = RDI_TypeKind_IncompleteUnion; + // TODO: error handling - AssertAlways(!"unexpected tag"); - continue; - } - - if (subrange_count > 0) { - // init array type node - RDIM_Type *s = d2r_create_type(arena, type_table); - s->kind = RDI_TypeKind_Array; - s->direct_type = 0; - - // append new array type node - t->direct_type = s; - t = s; - } - - // resolve array lower bound - U64 lower_bound = 0; - if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_LowerBound)) { - lower_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_LowerBound); + Assert(!cur_node->first_child); + visit_children = 0; } else { - lower_bound = dw_pick_default_lower_bound(cu_lang); + RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); + udt->self_type = type; + + type->kind = RDI_TypeKind_Union; + type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + type->udt = udt; + + tag_stack->type = type; } - - // resolve array upper bound - U64 upper_bound = 0; - if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_Count)) { - U64 count = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_Count); - upper_bound = lower_bound + count; - } else if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_UpperBound)) { - upper_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_UpperBound); - // turn upper bound into exclusive range - upper_bound += 1; + } break; + case DW_Tag_EnumerationType: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + + B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration); + if (is_decl) { + type->kind = RDI_TypeKind_IncompleteEnum; + + // TODO: error handling + Assert(!cur_node->first_child); + visit_children = 0; } else { - // zero size array + RDIM_UDT *udt = rdim_udt_chunk_list_push(arena, &udts, UDT_CHUNK_CAP); + udt->self_type = type; + + type->kind = RDI_TypeKind_Enum; + type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag); + type->udt = udt; + + tag_stack->type = type; } - - t->count = upper_bound - lower_bound; - ++subrange_count; - } - - Assert(t->direct_type == 0); - t->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - visit_children = 0; - } break; - case DW_Tag_SubrangeType: { - // TODO: error handling - AssertAlways(!"unexpected tag"); - } break; - case DW_Tag_Inheritance: { - DW_TagNode *parent_node = tag_stack->next->cur_node; - if (parent_node->tag.kind != DW_Tag_StructureType && - parent_node->tag.kind != DW_Tag_ClassType) { + } break; + case DW_Tag_SubroutineType: { + // collect parameters + RDIM_TypeList param_list = {0}; + for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) { + if (n->tag.kind == DW_Tag_FormalParameter) { + RDIM_Type *param_type = d2r_type_from_attrib(arena, type_table, &input, cu, n->tag, DW_Attrib_Type); + rdim_type_list_push(comp_temp.arena, ¶m_list, param_type); + } else if (n->tag.kind == DW_Tag_UnspecifiedParameters) { + rdim_type_list_push(comp_temp.arena, ¶m_list, type_table->varg_type); + } else { + // TODO: error handling + AssertAlways(!"unexpected tag"); + } + } + + // init proceudre type + RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Function; + type->byte_size = arch_addr_size; + type->direct_type = ret_type; + type->count = param_list.count; + type->param_types = rdim_array_from_type_list(arena, param_list); + + visit_children = 0; + } break; + case DW_Tag_Typedef: { + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Alias; + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + } break; + case DW_Tag_BaseType: { + DW_ATE encoding = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Encoding); + U64 byte_size = dw_byte_size_from_tag(&input, cu, tag); + + // convert base type encoding to RDI version + RDI_TypeKind kind = RDI_TypeKind_NULL; + switch (encoding) { + case DW_ATE_Null: kind = RDI_TypeKind_NULL; break; + case DW_ATE_Address: kind = RDI_TypeKind_Void; break; + case DW_ATE_Boolean: kind = RDI_TypeKind_Bool; break; + case DW_ATE_ComplexFloat: { + switch (byte_size) { + case 4: kind = RDI_TypeKind_ComplexF32; break; + case 8: kind = RDI_TypeKind_ComplexF64; break; + case 10: kind = RDI_TypeKind_ComplexF80; break; + case 16: kind = RDI_TypeKind_ComplexF128; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_Float: { + switch (byte_size) { + case 2: kind = RDI_TypeKind_F16; break; + case 4: kind = RDI_TypeKind_F32; break; + case 6: kind = RDI_TypeKind_F48; break; + case 8: kind = RDI_TypeKind_F64; break; + case 16: kind = RDI_TypeKind_F128; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_Signed: { + switch (byte_size) { + case 1: kind = RDI_TypeKind_S8; break; + case 2: kind = RDI_TypeKind_S16; break; + case 4: kind = RDI_TypeKind_S32; break; + case 8: kind = RDI_TypeKind_S64; break; + case 16: kind = RDI_TypeKind_S128; break; + case 32: kind = RDI_TypeKind_S256; break; + case 64: kind = RDI_TypeKind_S512; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_SignedChar: { + switch (byte_size) { + case 1: kind = RDI_TypeKind_Char8; break; + case 2: kind = RDI_TypeKind_Char16; break; + case 4: kind = RDI_TypeKind_Char32; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_Unsigned: { + switch (byte_size) { + case 1: kind = RDI_TypeKind_U8; break; + case 2: kind = RDI_TypeKind_U16; break; + case 4: kind = RDI_TypeKind_U32; break; + case 8: kind = RDI_TypeKind_U64; break; + case 16: kind = RDI_TypeKind_U128; break; + case 32: kind = RDI_TypeKind_U256; break; + case 64: kind = RDI_TypeKind_U512; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_UnsignedChar: { + switch (byte_size) { + case 1: kind = RDI_TypeKind_UChar8; break; + case 2: kind = RDI_TypeKind_UChar16; break; + case 4: kind = RDI_TypeKind_UChar32; break; + default: AssertAlways(!"unexpected size"); break; // TODO: error handling + } + } break; + case DW_ATE_ImaginaryFloat: { + NotImplemented; + } break; + case DW_ATE_PackedDecimal: { + NotImplemented; + } break; + case DW_ATE_NumericString: { + NotImplemented; + } break; + case DW_ATE_Edited: { + NotImplemented; + } break; + case DW_ATE_SignedFixed: { + NotImplemented; + } break; + case DW_ATE_UnsignedFixed: { + NotImplemented; + } break; + case DW_ATE_DecimalFloat: { + NotImplemented; + } break; + case DW_ATE_Utf: { + NotImplemented; + } break; + case DW_ATE_Ucs: { + NotImplemented; + } break; + case DW_ATE_Ascii: { + NotImplemented; + } break; + default: AssertAlways(!"unexpected base type encoding"); break; // TODO: error handling + } + + RDIM_Type *base_type = d2r_create_type(arena, type_table); + base_type->kind = kind; + base_type->byte_size = byte_size; + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Alias; + type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + type->direct_type = base_type; + } break; + case DW_Tag_PointerType: { + RDIM_Type *direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + + // TODO: + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Allocated)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Associated)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_AddressClass)); + + U64 byte_size = arch_addr_size; + if (cu->version == DW_Version_5 || cu->relaxed) { + dw_try_byte_size_from_tag(&input, cu, tag, &byte_size); + } + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Ptr; + type->byte_size = byte_size; + type->direct_type = direct_type; + } break; + case DW_Tag_RestrictType: { + // TODO: + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Modifier; + type->byte_size = arch_addr_size; + type->flags = RDI_TypeModifierFlag_Restrict; + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + } break; + case DW_Tag_VolatileType: { + // TODO: + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Modifier; + type->byte_size = arch_addr_size; + type->flags = RDI_TypeModifierFlag_Volatile; + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + } break; + case DW_Tag_ConstType: { + // TODO: + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name)); + Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment)); + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Modifier; + type->byte_size = arch_addr_size; + type->flags = RDI_TypeModifierFlag_Const; + type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + } break; + case DW_Tag_ArrayType: { + // * DWARF vs RDI Array Type Graph * + // + // For example lets take following decl: + // + // int (*foo[2])[3][4]; + // + // This compiles to in DWARF: + // + // foo -> DW_TAG_ArrayType -> (A0) DW_TAG_Subrange [2] + // \ + // -> (B0) DW_TAG_PointerType -> (A1) DW_TAG_ArrayType -> DW_TAG_Subrange [3] -> DW_Tag_Subrange [4] + // \ + // -> (B1) DW_TAG_BaseType (int) + // + // RDI expects: + // + // foo -> Array (2) -> Pointer -> Array (3) -> Array (4) -> int + // + // Note that DWARF forks the graph on DW_TAG_ArrayType to describe array ranges in branch A and + // in branch B describes array type which might be a struct, pointer, base type, or any other type tag. + // However, in RDI we have a simple list of type nodes and to convert we need to append type nodes from + // B to A. + + RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off); + type->kind = RDI_TypeKind_Array; + type->direct_type = 0; + + U64 subrange_count = 0; + RDIM_Type *t = type; + for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) { + if (n->tag.kind != DW_Tag_SubrangeType) { + // TODO: error handling + AssertAlways(!"unexpected tag"); + continue; + } + + if (subrange_count > 0) { + // init array type node + RDIM_Type *s = d2r_create_type(arena, type_table); + s->kind = RDI_TypeKind_Array; + s->direct_type = 0; + + // append new array type node + t->direct_type = s; + t = s; + } + + // resolve array lower bound + U64 lower_bound = 0; + if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_LowerBound)) { + lower_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_LowerBound); + } else { + lower_bound = dw_pick_default_lower_bound(cu_lang); + } + + // resolve array upper bound + U64 upper_bound = 0; + if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_Count)) { + U64 count = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_Count); + upper_bound = lower_bound + count; + } else if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_UpperBound)) { + upper_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_UpperBound); + // turn upper bound into exclusive range + upper_bound += 1; + } else { + // zero size array + } + + t->count = upper_bound - lower_bound; + ++subrange_count; + } + + Assert(t->direct_type == 0); + t->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + + visit_children = 0; + } break; + case DW_Tag_SubrangeType: { // TODO: error handling - AssertAlways(!"unexpected parent tag"); - } - - RDIM_Type *parent = tag_stack->next->type; - RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, parent->udt); - member->kind = RDI_MemberKind_Base; - member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - member->off = safe_cast_u32(dw_const_u32_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation)); - } break; - case DW_Tag_Enumerator: { - DW_TagNode *parent_node = tag_stack->next->cur_node; - if (parent_node->tag.kind != DW_Tag_EnumerationType) { - // TODO: error handling - AssertAlways(!"unexpected parent tag"); - } - - RDIM_Type *type = tag_stack->next->type; - RDIM_UDTEnumVal *member = rdim_udt_push_enum_val(arena, &udts, type->udt); - member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - member->val = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_ConstValue); - } break; - case DW_Tag_Member: { - DW_TagNode *parent_node = tag_stack->next->cur_node; - if (parent_node->tag.kind != DW_Tag_StructureType && - parent_node->tag.kind != DW_Tag_ClassType && - parent_node->tag.kind != DW_Tag_UnionType && - parent_node->tag.kind != DW_Tag_EnumerationType) { - // TODO: error handling - AssertAlways(!"unexpected parent tag"); - } - - DW_Attrib *data_member_location = dw_attrib_from_tag(&input, cu, tag, DW_Attrib_DataMemberLocation); - DW_AttribClass data_member_location_class = dw_value_class_from_attrib(cu, data_member_location); - if (data_member_location_class == DW_AttribClass_LocList) { - AssertAlways(!"UDT member with multiple locations are not supported"); - } - - RDIM_Type *type = tag_stack->next->type; - RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt); - member->kind = RDI_MemberKind_DataField; - member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - member->off = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation); - } break; - case DW_Tag_SubProgram: { - DW_InlKind inl = dw_u64_from_attrib(&input, cu, tag, DW_Attrib_Inline); - switch (inl) { - case DW_Inl_NotInlined: { + AssertAlways(!"unexpected tag"); + } break; + case DW_Tag_Inheritance: { + DW_TagNode *parent_node = tag_stack->next->cur_node; + if (parent_node->tag.kind != DW_Tag_StructureType && + parent_node->tag.kind != DW_Tag_ClassType) { + // TODO: error handling + AssertAlways(!"unexpected parent tag"); + } + + RDIM_Type *parent = tag_stack->next->type; + RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, parent->udt); + member->kind = RDI_MemberKind_Base; + member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + member->off = safe_cast_u32(dw_const_u32_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation)); + } break; + case DW_Tag_Enumerator: { + DW_TagNode *parent_node = tag_stack->next->cur_node; + if (parent_node->tag.kind != DW_Tag_EnumerationType) { + // TODO: error handling + AssertAlways(!"unexpected parent tag"); + } + + RDIM_Type *type = tag_stack->next->type; + RDIM_UDTEnumVal *member = rdim_udt_push_enum_val(arena, &udts, type->udt); + member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + member->val = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_ConstValue); + } break; + case DW_Tag_Member: { + DW_TagNode *parent_node = tag_stack->next->cur_node; + if (parent_node->tag.kind != DW_Tag_StructureType && + parent_node->tag.kind != DW_Tag_ClassType && + parent_node->tag.kind != DW_Tag_UnionType && + parent_node->tag.kind != DW_Tag_EnumerationType) { + // TODO: error handling + AssertAlways(!"unexpected parent tag"); + } + + DW_Attrib *data_member_location = dw_attrib_from_tag(&input, cu, tag, DW_Attrib_DataMemberLocation); + DW_AttribClass data_member_location_class = dw_value_class_from_attrib(cu, data_member_location); + if (data_member_location_class == DW_AttribClass_LocList) { + AssertAlways(!"UDT member with multiple locations are not supported"); + } + + RDIM_Type *type = tag_stack->next->type; + RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt); + member->kind = RDI_MemberKind_DataField; + member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + member->off = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation); + } break; + case DW_Tag_SubProgram: { + DW_InlKind inl = dw_u64_from_attrib(&input, cu, tag, DW_Attrib_Inline); + switch (inl) { + case DW_Inl_NotInlined: { + U64 param_count = 0; + RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, cur_node, ¶m_count); + + // get return type + RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + + // fill out proc type + RDIM_Type *proc_type = d2r_create_type(arena, type_table); + proc_type->kind = RDI_TypeKind_Function; + proc_type->byte_size = arch_addr_size; + proc_type->direct_type = ret_type; + proc_type->count = param_count; + proc_type->param_types = params; + + // get container type + RDIM_Type *container_type = 0; + if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) { + container_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType); + } + + // get frame base expression + String8 frame_base_expr = dw_exprloc_from_attrib(&input, cu, tag, DW_Attrib_FrameBase); + + // get proc container symbol + RDIM_Symbol *proc = rdim_symbol_chunk_list_push(arena, &procs, PROC_CHUNK_CAP ); + + // make scope + Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); + RDIM_Scope *root_scope = d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); + root_scope->symbol = proc; + + // fill out proc + proc->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External); + proc->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + proc->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName); + proc->type = proc_type; + proc->container_symbol = 0; + proc->container_type = container_type; + proc->root_scope = root_scope; + proc->frame_base = d2r_locset_from_attrib(arena, &input, cu, &scopes, root_scope, image_base, cu->address_size, arch_rdi, cu->addr_lu, tag, DW_Attrib_FrameBase); + + // sub program with user-defined parent tag is a method + DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; + if (parent_tag_kind == DW_Tag_ClassType || parent_tag_kind == DW_Tag_StructureType) { + RDI_MemberKind member_kind = RDI_MemberKind_NULL; + DW_VirtualityKind virtuality = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Virtuality); + switch (virtuality) { + case DW_VirtualityKind_None: member_kind = RDI_MemberKind_Method; break; + case DW_VirtualityKind_Virtual: member_kind = RDI_MemberKind_VirtualMethod; break; + case DW_VirtualityKind_PureVirtual: member_kind = RDI_MemberKind_VirtualMethod; break; // TODO: create kind for pure virutal + default: InvalidPath; break; + } + + RDIM_Type *type = tag_stack->next->type; + RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt); + member->kind = member_kind; + member->type = type; + member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + } else if (parent_tag_kind != DW_Tag_CompileUnit) { + AssertAlways(!"unexpected tag"); + } + + tag_stack->scope = root_scope; + } break; + case DW_Inl_DeclaredNotInlined: + case DW_Inl_DeclaredInlined: + case DW_Inl_Inlined: { + visit_children = 0; + } break; + default: InvalidPath; break; + } + } break; + case DW_Tag_InlinedSubroutine: { U64 param_count = 0; - RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, cur_node, ¶m_count); - + RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, tag_stack->cur_node, ¶m_count); + // get return type RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - + // fill out proc type RDIM_Type *proc_type = d2r_create_type(arena, type_table); proc_type->kind = RDI_TypeKind_Function; @@ -1569,159 +1642,86 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) proc_type->direct_type = ret_type; proc_type->count = param_count; proc_type->param_types = params; - + // get container type - RDIM_Type *container_type = 0; + RDIM_Type *owner = 0; if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) { - container_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType); + owner = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType); } - - // get frame base expression - String8 frame_base_expr = dw_exprloc_from_attrib(&input, cu, tag, DW_Attrib_FrameBase); - - // get proc container symbol - RDIM_Symbol *proc = rdim_symbol_chunk_list_push(arena, &procs, PROC_CHUNK_CAP ); - + + // fill out inline site + RDIM_InlineSite *inline_site = rdim_inline_site_chunk_list_push(arena, &inline_sites, INLINE_SITE_CHUNK_CAP); + inline_site->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + inline_site->type = proc_type; + inline_site->owner = owner; + inline_site->line_table = 0; + // make scope Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); RDIM_Scope *root_scope = d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); - root_scope->symbol = proc; - - // fill out proc - proc->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External); - proc->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - proc->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName); - proc->type = proc_type; - proc->container_symbol = 0; - proc->container_type = container_type; - proc->root_scope = root_scope; - proc->frame_base = d2r_locset_from_attrib(arena, &input, cu, &scopes, root_scope, image_base, cu->address_size, arch_rdi, cu->addr_lu, tag, DW_Attrib_FrameBase); - - // sub program with user-defined parent tag is a method + root_scope->inline_site = inline_site; + } break; + case DW_Tag_Variable: { + String8 name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + RDIM_Type *type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; - if (parent_tag_kind == DW_Tag_ClassType || parent_tag_kind == DW_Tag_StructureType) { - RDI_MemberKind member_kind = RDI_MemberKind_NULL; - DW_VirtualityKind virtuality = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Virtuality); - switch (virtuality) { - case DW_VirtualityKind_None: member_kind = RDI_MemberKind_Method; break; - case DW_VirtualityKind_Virtual: member_kind = RDI_MemberKind_VirtualMethod; break; - case DW_VirtualityKind_PureVirtual: member_kind = RDI_MemberKind_VirtualMethod; break; // TODO: create kind for pure virutal - default: InvalidPath; break; + if (parent_tag_kind == DW_Tag_SubProgram || + parent_tag_kind == DW_Tag_InlinedSubroutine || + parent_tag_kind == DW_Tag_LexicalBlock) { + RDIM_Scope *scope = tag_stack->next->scope; + RDIM_Local *local = rdim_scope_push_local(arena, &scopes, tag_stack->next->scope); + local->kind = RDI_LocalKind_Variable; + local->name = name; + local->type = type; + local->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, scope, image_base, cu->address_size, arch_rdi, cu->addr_lu, tag, DW_Attrib_Location); + } else { + + // NOTE: due to a bug in clang in stb_sprint.h local variables + // are declared in global scope without a name + if (name.size == 0) { + break; } - - RDIM_Type *type = tag_stack->next->type; - RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt); - member->kind = member_kind; - member->type = type; - member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - } else if (parent_tag_kind != DW_Tag_CompileUnit) { - AssertAlways(!"unexpected tag"); + + RDIM_Symbol *gvar = rdim_symbol_chunk_list_push(arena, &gvars, GVAR_CHUNK_CAP); + gvar->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External); + gvar->name = name; + gvar->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName); + gvar->type = type; + gvar->offset = 0; // TODO: NotImplemented; + gvar->container_symbol = 0; + gvar->container_type = 0; // TODO: NotImplemented; } - - tag_stack->scope = root_scope; } break; - case DW_Inl_DeclaredNotInlined: - case DW_Inl_DeclaredInlined: - case DW_Inl_Inlined: { - visit_children = 0; - } break; - default: InvalidPath; break; - } - } break; - case DW_Tag_InlinedSubroutine: { - U64 param_count = 0; - RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, tag_stack->cur_node, ¶m_count); - - // get return type - RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - // fill out proc type - RDIM_Type *proc_type = d2r_create_type(arena, type_table); - proc_type->kind = RDI_TypeKind_Function; - proc_type->byte_size = arch_addr_size; - proc_type->direct_type = ret_type; - proc_type->count = param_count; - proc_type->param_types = params; - - // get container type - RDIM_Type *owner = 0; - if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) { - owner = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType); - } - - // fill out inline site - RDIM_InlineSite *inline_site = rdim_inline_site_chunk_list_push(arena, &inline_sites, INLINE_SITE_CHUNK_CAP); - inline_site->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - inline_site->type = proc_type; - inline_site->owner = owner; - inline_site->line_table = 0; - - // make scope - Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); - RDIM_Scope *root_scope = d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); - root_scope->inline_site = inline_site; - } break; - case DW_Tag_Variable: { - String8 name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - RDIM_Type *type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - - DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; - if (parent_tag_kind == DW_Tag_SubProgram || - parent_tag_kind == DW_Tag_InlinedSubroutine || - parent_tag_kind == DW_Tag_LexicalBlock) { - RDIM_Scope *scope = tag_stack->next->scope; - RDIM_Local *local = rdim_scope_push_local(arena, &scopes, tag_stack->next->scope); - local->kind = RDI_LocalKind_Variable; - local->name = name; - local->type = type; - local->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, scope, image_base, cu->address_size, arch_rdi, cu->addr_lu, tag, DW_Attrib_Location); - } else { - - // NOTE: due to a bug in clang in stb_sprint.h local variables - // are declared in global scope without a name - if (name.size == 0) { - break; + case DW_Tag_FormalParameter: { + DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; + if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine) { + RDIM_Scope *scope = tag_stack->next->scope; + RDIM_Local *param = rdim_scope_push_local(arena, &scopes, scope); + param->kind = RDI_LocalKind_Parameter; + param->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); + param->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); + param->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, scope, image_base, cu->address_size, arch_rdi, cu->addr_lu, tag, DW_Attrib_Location); + } else { + // TODO: error handling + AssertAlways(!"this is a local variable"); } - - RDIM_Symbol *gvar = rdim_symbol_chunk_list_push(arena, &gvars, GVAR_CHUNK_CAP); - gvar->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External); - gvar->name = name; - gvar->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName); - gvar->type = type; - gvar->offset = 0; // TODO: NotImplemented; - gvar->container_symbol = 0; - gvar->container_type = 0; // TODO: NotImplemented; - } - } break; - case DW_Tag_FormalParameter: { - DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind; - if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine) { - RDIM_Scope *scope = tag_stack->next->scope; - RDIM_Local *param = rdim_scope_push_local(arena, &scopes, scope); - param->kind = RDI_LocalKind_Parameter; - param->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name); - param->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type); - param->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, scope, image_base, cu->address_size, arch_rdi, cu->addr_lu, tag, DW_Attrib_Location); - } else { - // TODO: error handling - AssertAlways(!"this is a local variable"); - } - } break; - case DW_Tag_LexicalBlock: { - if (tag_stack->next->cur_node->tag.kind == DW_Tag_SubProgram || - tag_stack->next->cur_node->tag.kind == DW_Tag_InlinedSubroutine || - tag_stack->next->cur_node->tag.kind == DW_Tag_LexicalBlock) { - Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); - d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); - } - } break; - case DW_Tag_Label: - case DW_Tag_CompileUnit: - case DW_Tag_UnspecifiedParameters: - break; - default: NotImplemented; break; + } break; + case DW_Tag_LexicalBlock: { + if (tag_stack->next->cur_node->tag.kind == DW_Tag_SubProgram || + tag_stack->next->cur_node->tag.kind == DW_Tag_InlinedSubroutine || + tag_stack->next->cur_node->tag.kind == DW_Tag_LexicalBlock) { + Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag); + d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges); + } + } break; + case DW_Tag_Label: + case DW_Tag_CompileUnit: + case DW_Tag_UnspecifiedParameters: + break; + default: NotImplemented; break; } - + if (tag_stack->cur_node->first_child && visit_children) { D2R_TagNode *frame = free_tags; if (frame) { @@ -1736,22 +1736,22 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) tag_stack->cur_node = tag_stack->cur_node->sibling; } } - + // recycle free frame D2R_TagNode *frame = tag_stack; SLLStackPop(tag_stack); SLLStackPush(free_tags, frame); - + if (tag_stack) { tag_stack->cur_node = tag_stack->cur_node->sibling; } } - + temp_end(comp_temp); } - + ProfEnd(); - + { for (RDIM_TypeChunkNode *chunk_n = types.first; chunk_n != 0; chunk_n = chunk_n->next) { for (U64 i = 0; i < chunk_n->count; ++i) { @@ -1767,18 +1767,18 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) } } } - + { RDIM_TypeNode *type_stack = 0; RDIM_TypeNode *free_types = 0; - + for (RDIM_TypeChunkNode *chunk_n = types.first; chunk_n != 0; chunk_n = chunk_n->next) { for (U64 i = 0; i < chunk_n->count; ++i) { RDIM_Type *type = &chunk_n->v[i]; if (type->kind == RDI_TypeKind_Array) { if (type->byte_size != 0) continue; - + RDIM_Type *t; for (t = type; t != 0 && t->kind == RDI_TypeKind_Array; t = t->direct_type) { RDIM_TypeNode *f = free_types; @@ -1790,12 +1790,12 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) f->v = t; SLLStackPush(type_stack, f); } - + U64 base_type_size = 0; if (t) { base_type_size = t->byte_size; } - + U64 array_size = base_type_size; while (type_stack) { if (type_stack->v->count) { @@ -1805,10 +1805,10 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) } SLLStackPop(type_stack); } - + type->count = 0; type->byte_size = array_size; - + // recycle frames free_types = type_stack; type_stack = 0; @@ -1816,9 +1816,9 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) } } } - + //////////////////////////////// - + RDIM_BakeParams *bake_params = push_array(arena, RDIM_BakeParams, 1); bake_params->top_level_info = top_level_info; bake_params->binary_sections = binary_sections; @@ -1832,7 +1832,7 @@ d2r_convert(Arena *arena, D2R_User2Convert *in) bake_params->procedures = procs; bake_params->scopes = scopes; bake_params->inline_sites = inline_sites; - + scratch_end(scratch); return bake_params; } @@ -1841,13 +1841,13 @@ RDI_PROC void rdim_assign_type_index(RDIM_Type *type, U64 *type_indices, U64 *curr_type_idx) { RDI_U64 type_pos = rdim_idx_from_type(type); - + if(type->kind == RDI_TypeKind_NULL) { type_indices[type_pos] = 0; return; } - + if(type_indices[type_pos] == 0) { if(type->param_types) @@ -1857,12 +1857,12 @@ rdim_assign_type_index(RDIM_Type *type, U64 *type_indices, U64 *curr_type_idx) rdim_assign_type_index(type->param_types[param_idx], type_indices, curr_type_idx); } } - + if(type->direct_type) { rdim_assign_type_index(type->direct_type, type_indices, curr_type_idx); } - + type_indices[type_pos] = *curr_type_idx; *curr_type_idx += 1; } @@ -1872,10 +1872,10 @@ RDI_PROC RDI_U64 * rdim_make_type_indices(RDIM_Arena *arena, RDIM_TypeChunkList *types) { ProfBeginFunction(); - + RDI_U64 *type_indices = rdim_push_array(arena, RDI_U64, types->total_count + 1); RDI_U64 type_indices_count = 1; - + for(RDIM_TypeChunkNode *chunk = types->first; chunk != 0; chunk = chunk->next) { for(RDI_U64 i = 0; i < chunk->count; i += 1) @@ -1883,7 +1883,7 @@ rdim_make_type_indices(RDIM_Arena *arena, RDIM_TypeChunkList *types) rdim_assign_type_index(&chunk->v[i], type_indices, &type_indices_count); } } - + ProfEnd(); return type_indices; } @@ -1893,17 +1893,17 @@ d2r_bake(RDIM_LocalState *state, RDIM_BakeParams *in_params) { //////////////////////////////// // resolve incomplete types - + rdim_local_resolve_incomplete_types(&in_params->types, &in_params->udts); - + //////////////////////////////// // compute type indices - + RDI_U64 *type_indices = rdim_make_type_indices(scratch.arena, &in_params->types); - + // using type indices create a correct type array layout NotImplemented; - + return rdim_bake(state, in_params); } @@ -1919,23 +1919,23 @@ rdi_language_from_dw_language(DW_Language v) { RDI_Language result = RDI_Language_NULL; switch (v) { - case DW_Language_Null: result = RDI_Language_NULL; break; - - case DW_Language_C89: - case DW_Language_C99: - case DW_Language_C11: - case DW_Language_C: + case DW_Language_Null: result = RDI_Language_NULL; break; + + case DW_Language_C89: + case DW_Language_C99: + case DW_Language_C11: + case DW_Language_C: result = RDI_Language_C; break; - - case DW_Language_CPlusPlus03: - case DW_Language_CPlusPlus11: - case DW_Language_CPlusPlus14: - case DW_Language_CPlusPlus: + + case DW_Language_CPlusPlus03: + case DW_Language_CPlusPlus11: + case DW_Language_CPlusPlus14: + case DW_Language_CPlusPlus: result = RDI_Language_CPlusPlus; break; - - default: NotImplemented; break; + + default: NotImplemented; break; } return result; } @@ -1948,7 +1948,7 @@ rdi_reg_from_dw_reg_x86(DW_RegX86 v) #define X(reg_dw, val_dw, reg_rdi, ...) case DW_RegX86_##reg_dw: result = RDI_RegCodeX86_##reg_rdi; break; DW_Regs_X86_XList(X) #undef X - default: NotImplemented; break; + default: NotImplemented; break; } return result; } @@ -1961,7 +1961,7 @@ rdi_reg_from_dw_reg_x64(DW_RegX64 v, RDI_RegCodeX64 *code_out, U64 *off_out, U64 #define X(reg_dw, val_dw, reg_rdi, off, size) case DW_RegX64_##reg_dw: result = RDI_RegCodeX64_##reg_rdi; *off_out = off; *size_out = size; break; DW_Regs_X64_XList(X) #undef X - default: NotImplemented; break; + default: NotImplemented; break; } return result; } @@ -1971,10 +1971,10 @@ rdi_reg_from_dw_reg(Arch arch, DW_Reg v, RDI_RegCode *code_out, U64 *off_out, U6 { RDI_RegCode result = RDI_RegCode_nil; switch (arch) { - case Arch_Null: break; - case Arch_x86: ; break; - case Arch_x64: return rdi_reg_from_dw_reg_x64(v, code_out, off_out, size_out); - default: NotImplemented; break; + case Arch_Null: break; + case Arch_x86: ; break; + case Arch_x64: return rdi_reg_from_dw_reg_x64(v, code_out, off_out, size_out); + default: NotImplemented; break; } return 0; } diff --git a/src/rdi_from_dwarf/rdi_from_dwarf.h b/src/rdi_from_dwarf/rdi_from_dwarf.h index 4f59fb27..dbe16860 100644 --- a/src/rdi_from_dwarf/rdi_from_dwarf.h +++ b/src/rdi_from_dwarf/rdi_from_dwarf.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #pragma once diff --git a/src/rdi_from_dwarf/rdi_from_dwarf_main.c b/src/rdi_from_dwarf/rdi_from_dwarf_main.c index a74e3b15..152d943a 100644 --- a/src/rdi_from_dwarf/rdi_from_dwarf_main.c +++ b/src/rdi_from_dwarf/rdi_from_dwarf_main.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #define BUILD_TITLE "Epic Games Tools (R) DWARF Converter" @@ -62,56 +62,56 @@ entry_point(CmdLine *cmdline) B32 do_help = (cmd_line_has_flag(cmdline, str8_lit("help")) || cmd_line_has_flag(cmdline, str8_lit("h")) || cmd_line_has_flag(cmdline, str8_lit("?"))); - + D2R_User2Convert *user2convert = d2r_user2convert_from_cmdln(arena, cmdline); - + // display help if (do_help) { fprintf(stderr, "--- rdi_from_dwarf ------------------------------------------------------------\n\n"); - + fprintf(stderr, "This utility converts debug information from DWARF into the RAD Debug Info\n"); fprintf(stderr, "format. The following arguments are accepted:\n\n"); - + fprintf(stderr, "--exe: [optional] Specifies the path of the executable filefor which the\n"); fprintf(stderr, " debug info was generated.\n"); fprintf(stderr, "--debug: Specifies the path of the .DEBUG debug info file to\n"); fprintf(stderr, " convert.\n"); fprintf(stderr, "--out: Specifies the path at which the output will be written.\n\n"); - + if (!do_help) { for (String8Node *n = user2convert->errors.first; n != 0; n = n->next) { fprintf(stderr, "error(input): %.*s\n", str8_varg(n->string)); } } - + os_abort(0); } RDIM_LocalState *rdim_local_state = rdim_local_init(); - + ProfBegin("convert"); RDIM_BakeParams *convert2bake = d2r_convert(arena, user2convert); ProfEnd(); - + ProfBegin("bake"); RDIM_BakeResults bake2srlz = d2r_bake(rdim_local_state, convert2bake); ProfEnd(); - + ProfBegin("serialize bake"); RDIM_SerializedSectionBundle srlz2file = rdim_serialized_section_bundle_from_bake_results(&bake2srlz); ProfEnd(); - + RDIM_SerializedSectionBundle srlz2file_compressed = srlz2file; if (cmd_line_has_flag(cmdline, str8_lit("compress"))) { ProfBegin("compress"); srlz2file_compressed = d2r_compress(arena, srlz2file); ProfEnd(); } - + ProfBegin("serialize blobs"); String8List blobs = rdim_file_blobs_from_section_bundle(arena, &srlz2file_compressed); ProfEnd(); - + ProfBegin("write"); if (!os_write_data_list_to_file_path(user2convert->output_name, blobs)) { fprintf(stderr, "error(ouptut): unable to write to %.*s\n", str8_varg(user2convert->output_name)); diff --git a/src/rdi_from_pdb/rdi_from_pdb.c b/src/rdi_from_pdb/rdi_from_pdb.c index b0dd17cd..41ba890e 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.c +++ b/src/rdi_from_pdb/rdi_from_pdb.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) // TODO(rjf): eliminate redundant null checks, just always allocate diff --git a/src/rdi_from_pdb/rdi_from_pdb.h b/src/rdi_from_pdb/rdi_from_pdb.h index 9db572df..1994f91f 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.h +++ b/src/rdi_from_pdb/rdi_from_pdb.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RDI_FROM_PDB_H diff --git a/src/rdi_from_pdb/rdi_from_pdb_main.c b/src/rdi_from_pdb/rdi_from_pdb_main.c index a0d02a7d..95470474 100644 --- a/src/rdi_from_pdb/rdi_from_pdb_main.c +++ b/src/rdi_from_pdb/rdi_from_pdb_main.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/rdi_make/rdi_make_help.c b/src/rdi_make/rdi_make_help.c index c3ec28fd..a0ed9407 100644 --- a/src/rdi_make/rdi_make_help.c +++ b/src/rdi_make/rdi_make_help.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/rdi_make/rdi_make_help.h b/src/rdi_make/rdi_make_help.h index 08c64391..59a4320b 100644 --- a/src/rdi_make/rdi_make_help.h +++ b/src/rdi_make/rdi_make_help.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RDIM_MAKE_HELP diff --git a/src/rdi_make/rdi_make_local.c b/src/rdi_make/rdi_make_local.c index af016e81..10635558 100644 --- a/src/rdi_make/rdi_make_local.c +++ b/src/rdi_make/rdi_make_local.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "lib_rdi_make/rdi_make.c" diff --git a/src/rdi_make/rdi_make_local.h b/src/rdi_make/rdi_make_local.h index ac700478..b41ed8fe 100644 --- a/src/rdi_make/rdi_make_local.h +++ b/src/rdi_make/rdi_make_local.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RDI_MAKE_LOCAL_H diff --git a/src/regs/generated/regs.meta.c b/src/regs/generated/regs.meta.c index 1f9f4b10..0805b542 100644 --- a/src/regs/generated/regs.meta.c +++ b/src/regs/generated/regs.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/regs/generated/regs.meta.h b/src/regs/generated/regs.meta.h index f3cdf807..0f6f75a3 100644 --- a/src/regs/generated/regs.meta.h +++ b/src/regs/generated/regs.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/regs/rdi/generated/regs_rdi.meta.c b/src/regs/rdi/generated/regs_rdi.meta.c index 9b0cdf65..de284856 100644 --- a/src/regs/rdi/generated/regs_rdi.meta.c +++ b/src/regs/rdi/generated/regs_rdi.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/regs/rdi/generated/regs_rdi.meta.h b/src/regs/rdi/generated/regs_rdi.meta.h index 6922e280..b5d77852 100644 --- a/src/regs/rdi/generated/regs_rdi.meta.h +++ b/src/regs/rdi/generated/regs_rdi.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/regs/rdi/regs_rdi.c b/src/regs/rdi/regs_rdi.c index b191f5f8..911725c1 100644 --- a/src/regs/rdi/regs_rdi.c +++ b/src/regs/rdi/regs_rdi.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #include "regs/rdi/generated/regs_rdi.meta.c" diff --git a/src/regs/rdi/regs_rdi.h b/src/regs/rdi/regs_rdi.h index 65e210f0..a7fadd80 100644 --- a/src/regs/rdi/regs_rdi.h +++ b/src/regs/rdi/regs_rdi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef REGS_RDI_H diff --git a/src/regs/rdi/regs_rdi.mdesk b/src/regs/rdi/regs_rdi.mdesk index e3961b84..1ef1197c 100644 --- a/src/regs/rdi/regs_rdi.mdesk +++ b/src/regs/rdi/regs_rdi.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/regs/regs.c b/src/regs/regs.c index 1cd17c35..f55d133a 100644 --- a/src/regs/regs.c +++ b/src/regs/regs.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/regs/regs.h b/src/regs/regs.h index 3e6fcbf9..4d781fc9 100644 --- a/src/regs/regs.h +++ b/src/regs/regs.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef REGS_H diff --git a/src/regs/regs.mdesk b/src/regs/regs.mdesk index 5e4ae872..2d7bc1ba 100644 --- a/src/regs/regs.mdesk +++ b/src/regs/regs.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/render/d3d11/generated/render_d3d11.meta.c b/src/render/d3d11/generated/render_d3d11.meta.c index 1431e68e..e6393a68 100644 --- a/src/render/d3d11/generated/render_d3d11.meta.c +++ b/src/render/d3d11/generated/render_d3d11.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/render/d3d11/generated/render_d3d11.meta.h b/src/render/d3d11/generated/render_d3d11.meta.h index 6fd7f833..cc1949a7 100644 --- a/src/render/d3d11/generated/render_d3d11.meta.h +++ b/src/render/d3d11/generated/render_d3d11.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/render/d3d11/render_d3d11.c b/src/render/d3d11/render_d3d11.c index dca4586c..c53dac66 100644 --- a/src/render/d3d11/render_d3d11.c +++ b/src/render/d3d11/render_d3d11.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/render/d3d11/render_d3d11.h b/src/render/d3d11/render_d3d11.h index b1b0d5fd..0344ff74 100644 --- a/src/render/d3d11/render_d3d11.h +++ b/src/render/d3d11/render_d3d11.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RENDER_D3D11_H diff --git a/src/render/d3d11/render_d3d11.mdesk b/src/render/d3d11/render_d3d11.mdesk index 81e2084d..0e001db1 100644 --- a/src/render/d3d11/render_d3d11.mdesk +++ b/src/render/d3d11/render_d3d11.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/render/generated/render.meta.c b/src/render/generated/render.meta.c index 242d8de6..c1897062 100644 --- a/src/render/generated/render.meta.c +++ b/src/render/generated/render.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/render/generated/render.meta.h b/src/render/generated/render.meta.h index 5fad100c..e7b65c2b 100644 --- a/src/render/generated/render.meta.h +++ b/src/render/generated/render.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/render/opengl/generated/render_opengl.meta.c b/src/render/opengl/generated/render_opengl.meta.c index 7084ac1b..228b658d 100644 --- a/src/render/opengl/generated/render_opengl.meta.c +++ b/src/render/opengl/generated/render_opengl.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/render/opengl/generated/render_opengl.meta.h b/src/render/opengl/generated/render_opengl.meta.h index 9f33f24d..dc8709d1 100644 --- a/src/render/opengl/generated/render_opengl.meta.h +++ b/src/render/opengl/generated/render_opengl.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/render/opengl/linux/egl/render_opengl_linux_egl.c b/src/render/opengl/linux/egl/render_opengl_linux_egl.c index 3d3370c6..28505f19 100644 --- a/src/render/opengl/linux/egl/render_opengl_linux_egl.c +++ b/src/render/opengl/linux/egl/render_opengl_linux_egl.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal VoidProc * diff --git a/src/render/opengl/linux/egl/render_opengl_linux_egl.h b/src/render/opengl/linux/egl/render_opengl_linux_egl.h index 54a419d1..77d687d7 100644 --- a/src/render/opengl/linux/egl/render_opengl_linux_egl.h +++ b/src/render/opengl/linux/egl/render_opengl_linux_egl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RENDER_OPENGL_LINUX_EGL_H diff --git a/src/render/opengl/linux/glx/render_opengl_linux_glx.c b/src/render/opengl/linux/glx/render_opengl_linux_glx.c index f8ca0af0..fa7217da 100644 --- a/src/render/opengl/linux/glx/render_opengl_linux_glx.c +++ b/src/render/opengl/linux/glx/render_opengl_linux_glx.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal VoidProc * diff --git a/src/render/opengl/linux/glx/render_opengl_linux_glx.h b/src/render/opengl/linux/glx/render_opengl_linux_glx.h index 995172b0..8b312233 100644 --- a/src/render/opengl/linux/glx/render_opengl_linux_glx.h +++ b/src/render/opengl/linux/glx/render_opengl_linux_glx.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RENDER_OPENGL_LINUX_GLX_H diff --git a/src/render/opengl/linux/render_opengl_linux.c b/src/render/opengl/linux/render_opengl_linux.c index 4e0e2964..47a7f0ce 100644 --- a/src/render/opengl/linux/render_opengl_linux.c +++ b/src/render/opengl/linux/render_opengl_linux.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/render/opengl/linux/render_opengl_linux.h b/src/render/opengl/linux/render_opengl_linux.h index 21069e8d..823e104e 100644 --- a/src/render/opengl/linux/render_opengl_linux.h +++ b/src/render/opengl/linux/render_opengl_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RENDER_OPENGL_LINUX_H diff --git a/src/render/opengl/render_opengl.c b/src/render/opengl/render_opengl.c index 0661e8dc..7f646b36 100644 --- a/src/render/opengl/render_opengl.c +++ b/src/render/opengl/render_opengl.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/render/opengl/render_opengl.h b/src/render/opengl/render_opengl.h index 618298e1..bdbdf051 100644 --- a/src/render/opengl/render_opengl.h +++ b/src/render/opengl/render_opengl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RENDER_OPENGL_H diff --git a/src/render/opengl/render_opengl.mdesk b/src/render/opengl/render_opengl.mdesk index d96874cd..9bfd735c 100644 --- a/src/render/opengl/render_opengl.mdesk +++ b/src/render/opengl/render_opengl.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/render/opengl/win32/render_opengl_win32.c b/src/render/opengl/win32/render_opengl_win32.c index f031758f..e0951e4c 100644 --- a/src/render/opengl/win32/render_opengl_win32.c +++ b/src/render/opengl/win32/render_opengl_win32.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) internal VoidProc * diff --git a/src/render/opengl/win32/render_opengl_win32.h b/src/render/opengl/win32/render_opengl_win32.h index 24e53c14..5cbc0c16 100644 --- a/src/render/opengl/win32/render_opengl_win32.h +++ b/src/render/opengl/win32/render_opengl_win32.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RENDER_OPENGL_WIN32_H diff --git a/src/render/render_core.c b/src/render/render_core.c index 80ca84bf..3e5723c4 100644 --- a/src/render/render_core.c +++ b/src/render/render_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/render/render_core.h b/src/render/render_core.h index 7725c5a3..c23c0503 100644 --- a/src/render/render_core.h +++ b/src/render/render_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RENDER_CORE_H diff --git a/src/render/render_core.mdesk b/src/render/render_core.mdesk index c892a9b0..2be8f472 100644 --- a/src/render/render_core.mdesk +++ b/src/render/render_core.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/render/render_inc.c b/src/render/render_inc.c index bb15be84..ba26df73 100644 --- a/src/render/render_inc.c +++ b/src/render/render_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/render/render_inc.h b/src/render/render_inc.h index d0e87c3c..efe126ef 100644 --- a/src/render/render_inc.h +++ b/src/render/render_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RENDER_INC_H diff --git a/src/render/stub/render_stub.c b/src/render/stub/render_stub.c index 1c8ffbca..702327f3 100644 --- a/src/render/stub/render_stub.c +++ b/src/render/stub/render_stub.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- rjf: top-level layer initialization diff --git a/src/render/stub/render_stub.h b/src/render/stub/render_stub.h index 9142c4f2..51b67de6 100644 --- a/src/render/stub/render_stub.h +++ b/src/render/stub/render_stub.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef RENDER_STUB_H diff --git a/src/scratch/convertperf.c b/src/scratch/convertperf.c index 423f5b79..88375edb 100644 --- a/src/scratch/convertperf.c +++ b/src/scratch/convertperf.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/scratch/eval_scratch.c b/src/scratch/eval_scratch.c index 233a773b..a9cb9a32 100644 --- a/src/scratch/eval_scratch.c +++ b/src/scratch/eval_scratch.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/scratch/ryan_scratch.c b/src/scratch/ryan_scratch.c index 48b3a3fc..219a644e 100644 --- a/src/scratch/ryan_scratch.c +++ b/src/scratch/ryan_scratch.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/scratch/textperf.c b/src/scratch/textperf.c index b252b9e1..3c6c963c 100644 --- a/src/scratch/textperf.c +++ b/src/scratch/textperf.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/tester/tester_main.c b/src/tester/tester_main.c index 45b3e61f..c722b3f0 100644 --- a/src/tester/tester_main.c +++ b/src/tester/tester_main.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/text_cache/text_cache.c b/src/text_cache/text_cache.c index 29200950..920ab6c0 100644 --- a/src/text_cache/text_cache.c +++ b/src/text_cache/text_cache.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/text_cache/text_cache.h b/src/text_cache/text_cache.h index 143a7b75..4a2595a2 100644 --- a/src/text_cache/text_cache.h +++ b/src/text_cache/text_cache.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef TEXT_CACHE_H diff --git a/src/texture_cache/texture_cache.c b/src/texture_cache/texture_cache.c index 8bc7e657..245b69f6 100644 --- a/src/texture_cache/texture_cache.c +++ b/src/texture_cache/texture_cache.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/texture_cache/texture_cache.h b/src/texture_cache/texture_cache.h index 25a00be1..70b53a85 100644 --- a/src/texture_cache/texture_cache.h +++ b/src/texture_cache/texture_cache.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef TEXTURE_CACHE_H diff --git a/src/ui/generated/ui.meta.c b/src/ui/generated/ui.meta.c index f66c6b76..080f373e 100644 --- a/src/ui/generated/ui.meta.c +++ b/src/ui/generated/ui.meta.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/ui/generated/ui.meta.h b/src/ui/generated/ui.meta.h index 2b666b2a..8189edb0 100644 --- a/src/ui/generated/ui.meta.h +++ b/src/ui/generated/ui.meta.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- GENERATED CODE diff --git a/src/ui/ui.mdesk b/src/ui/ui.mdesk index cbe35c8a..a9988bd6 100644 --- a/src/ui/ui.mdesk +++ b/src/ui/ui.mdesk @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //- rjf: stack table diff --git a/src/ui/ui_basic_widgets.c b/src/ui/ui_basic_widgets.c index de24ce72..f4b28a38 100644 --- a/src/ui/ui_basic_widgets.c +++ b/src/ui/ui_basic_widgets.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/ui/ui_basic_widgets.h b/src/ui/ui_basic_widgets.h index 31c592a3..a2ca4159 100644 --- a/src/ui/ui_basic_widgets.h +++ b/src/ui/ui_basic_widgets.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef UI_BASIC_WIDGETS_H diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index 9659939d..3df7eddf 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) //////////////////////////////// diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index 1c915ee5..fce6f281 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef UI_H diff --git a/src/ui/ui_inc.c b/src/ui/ui_inc.c index c9bed64e..72ba4357 100644 --- a/src/ui/ui_inc.c +++ b/src/ui/ui_inc.c @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #undef LAYER_COLOR diff --git a/src/ui/ui_inc.h b/src/ui/ui_inc.h index 2b763f3b..3e95155d 100644 --- a/src/ui/ui_inc.h +++ b/src/ui/ui_inc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Epic Games Tools +// Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) #ifndef UI_INC_H