From 8492693df2bfa50cf7fcd6d8fd234958797005c9 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Tue, 28 May 2024 21:31:56 -0700 Subject: [PATCH] initial pass of moving rdi definitions to metacode tables --- build.bat | 4 +- project.4coder | 2 +- src/rdi_format/generated/rdi_format.meta.c | 8 + src/rdi_format/generated/rdi_format.meta.h | 253 +++++++ src/rdi_format/rdi_format.mdesk | 766 +++++++++++++++++++++ 5 files changed, 1030 insertions(+), 3 deletions(-) create mode 100644 src/rdi_format/generated/rdi_format.meta.c create mode 100644 src/rdi_format/generated/rdi_format.meta.h create mode 100644 src/rdi_format/rdi_format.mdesk diff --git a/build.bat b/build.bat index 6a59fcd2..89eec163 100644 --- a/build.bat +++ b/build.bat @@ -60,8 +60,8 @@ if "%msvc%"=="1" set EHsc=/EHsc if "%clang%"=="1" set EHsc= if "%msvc%"=="1" set no_aslr=/DYNAMICBASE:NO if "%clang%"=="1" set no_aslr= -if "%msvc%"=="1" set rc=call rc -if "%clang%"=="1" set rc=call llvm-rc +if "%msvc%"=="1" set rc=call rc +if "%clang%"=="1" set rc=call llvm-rc :: --- Choose Compile/Link Lines ---------------------------------------------- if "%msvc%"=="1" set compile_debug=%cl_debug% diff --git a/project.4coder b/project.4coder index 9f070887..7637c9c2 100644 --- a/project.4coder +++ b/project.4coder @@ -47,7 +47,7 @@ commands = { .rjf_f1 = { - .win = "build raddbg telemetry", + .win = "build only_meta", .linux = "", .out = "*compilation*", .footer_panel = true, diff --git a/src/rdi_format/generated/rdi_format.meta.c b/src/rdi_format/generated/rdi_format.meta.c new file mode 100644 index 00000000..32e20884 --- /dev/null +++ b/src/rdi_format/generated/rdi_format.meta.c @@ -0,0 +1,8 @@ +// Copyright (c) 2024 Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//- GENERATED CODE + +C_LINKAGE_BEGIN +C_LINKAGE_END + diff --git a/src/rdi_format/generated/rdi_format.meta.h b/src/rdi_format/generated/rdi_format.meta.h new file mode 100644 index 00000000..e7871be1 --- /dev/null +++ b/src/rdi_format/generated/rdi_format.meta.h @@ -0,0 +1,253 @@ +// Copyright (c) 2024 Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//- GENERATED CODE + +#ifndef RDI_FORMAT_META_H +#define RDI_FORMAT_META_H + +typedef RDI_U32 RDI_DataSectionTag; +typedef enum RDI_DataSectionTagEnum +{ +RDI_DataSectionTag_NULL = 0x0000, +RDI_DataSectionTag_TopLevelInfo = 0x0001, +RDI_DataSectionTag_StringData = 0x0002, +RDI_DataSectionTag_StringTable = 0x0003, +RDI_DataSectionTag_IndexRuns = 0x0004, +RDI_DataSectionTag_BinarySections = 0x0005, +RDI_DataSectionTag_FilePathNodes = 0x0006, +RDI_DataSectionTag_SourceFiles = 0x0007, +RDI_DataSectionTag_Units = 0x0008, +RDI_DataSectionTag_UnitVmap = 0x0009, +RDI_DataSectionTag_TypeNodes = 0x000A, +RDI_DataSectionTag_UDTs = 0x000B, +RDI_DataSectionTag_Members = 0x000C, +RDI_DataSectionTag_EnumMembers = 0x000D, +RDI_DataSectionTag_GlobalVariables = 0x000E, +RDI_DataSectionTag_GlobalVmap = 0x000F, +RDI_DataSectionTag_ThreadVariables = 0x0010, +RDI_DataSectionTag_Procedures = 0x0011, +RDI_DataSectionTag_Scopes = 0x0012, +RDI_DataSectionTag_ScopeVoffData = 0x0013, +RDI_DataSectionTag_ScopeVmap = 0x0014, +RDI_DataSectionTag_Locals = 0x0015, +RDI_DataSectionTag_LocationBlocks = 0x0016, +RDI_DataSectionTag_LocationData = 0x0017, +RDI_DataSectionTag_NameMaps = 0x0018, +RDI_DataSectionTag_PRIMARY_COUNT = 0x0019, +RDI_DataSectionTag_SKIP = RDI_DataSectionTag_SECONDARY|0x0000, +RDI_DataSectionTag_LineInfoVoffs = RDI_DataSectionTag_SECONDARY|0x0001, +RDI_DataSectionTag_LineInfoData = RDI_DataSectionTag_SECONDARY|0x0002, +RDI_DataSectionTag_LineInfoColumns = RDI_DataSectionTag_SECONDARY|0x0003, +RDI_DataSectionTag_LineMapNumbers = RDI_DataSectionTag_SECONDARY|0x0004, +RDI_DataSectionTag_LineMapRanges = RDI_DataSectionTag_SECONDARY|0x0005, +RDI_DataSectionTag_LineMapVoffs = RDI_DataSectionTag_SECONDARY|0x0006, +RDI_DataSectionTag_NameMapBuckets = RDI_DataSectionTag_SECONDARY|0x0007, +RDI_DataSectionTag_NameMapNodes = RDI_DataSectionTag_SECONDARY|0x0008, +} RDI_DataSectionTagEnum; + +typedef RDI_U32 RDI_DataSectionEncoding; +typedef enum RDI_DataSectionEncodingEnum +{ +RDI_DataSectionEncoding_Unpacked = 0, +RDI_DataSectionEncoding_LZB = 1, +} RDI_DataSectionEncodingEnum; + +typedef RDI_U32 RDI_Arch; +typedef enum RDI_ArchEnum +{ +RDI_Arch_NULL = 0, +RDI_Arch_X86 = 1, +RDI_Arch_X64 = 2, +} RDI_ArchEnum; + +typedef enum RDI_RegCodeX86 +{ +RDI_RegCodeX86_nil = 0, +RDI_RegCodeX86_eax = 1, +RDI_RegCodeX86_ecx = 2, +RDI_RegCodeX86_edx = 3, +RDI_RegCodeX86_ebx = 4, +RDI_RegCodeX86_esp = 5, +RDI_RegCodeX86_ebp = 6, +RDI_RegCodeX86_esi = 7, +RDI_RegCodeX86_edi = 8, +RDI_RegCodeX86_fsbase = 9, +RDI_RegCodeX86_gsbase = 10, +RDI_RegCodeX86_eflags = 11, +RDI_RegCodeX86_eip = 12, +RDI_RegCodeX86_dr0 = 13, +RDI_RegCodeX86_dr1 = 14, +RDI_RegCodeX86_dr2 = 15, +RDI_RegCodeX86_dr3 = 16, +RDI_RegCodeX86_dr4 = 17, +RDI_RegCodeX86_dr5 = 18, +RDI_RegCodeX86_dr6 = 19, +RDI_RegCodeX86_dr7 = 20, +RDI_RegCodeX86_fpr0 = 21, +RDI_RegCodeX86_fpr1 = 22, +RDI_RegCodeX86_fpr2 = 23, +RDI_RegCodeX86_fpr3 = 24, +RDI_RegCodeX86_fpr4 = 25, +RDI_RegCodeX86_fpr5 = 26, +RDI_RegCodeX86_fpr6 = 27, +RDI_RegCodeX86_fpr7 = 28, +RDI_RegCodeX86_st0 = 29, +RDI_RegCodeX86_st1 = 30, +RDI_RegCodeX86_st2 = 31, +RDI_RegCodeX86_st3 = 32, +RDI_RegCodeX86_st4 = 33, +RDI_RegCodeX86_st5 = 34, +RDI_RegCodeX86_st6 = 35, +RDI_RegCodeX86_st7 = 36, +RDI_RegCodeX86_fcw = 37, +RDI_RegCodeX86_fsw = 38, +RDI_RegCodeX86_ftw = 39, +RDI_RegCodeX86_fop = 40, +RDI_RegCodeX86_fcs = 41, +RDI_RegCodeX86_fds = 42, +RDI_RegCodeX86_fip = 43, +RDI_RegCodeX86_fdp = 44, +RDI_RegCodeX86_mxcsr = 45, +RDI_RegCodeX86_mxcsr_mask = 46, +RDI_RegCodeX86_ss = 47, +RDI_RegCodeX86_cs = 48, +RDI_RegCodeX86_ds = 49, +RDI_RegCodeX86_es = 50, +RDI_RegCodeX86_fs = 51, +RDI_RegCodeX86_gs = 52, +RDI_RegCodeX86_ymm0 = 53, +RDI_RegCodeX86_ymm1 = 54, +RDI_RegCodeX86_ymm2 = 55, +RDI_RegCodeX86_ymm3 = 56, +RDI_RegCodeX86_ymm4 = 57, +RDI_RegCodeX86_ymm5 = 58, +RDI_RegCodeX86_ymm6 = 59, +RDI_RegCodeX86_ymm7 = 60, +} RDI_RegCodeX86; + +typedef enum RDI_RegCodeX64 +{ +RDI_RegCodeX64_nil = 0, +RDI_RegCodeX64_rax = 1, +RDI_RegCodeX64_rcx = 2, +RDI_RegCodeX64_rdx = 3, +RDI_RegCodeX64_rbx = 4, +RDI_RegCodeX64_rsp = 5, +RDI_RegCodeX64_rbp = 6, +RDI_RegCodeX64_rsi = 7, +RDI_RegCodeX64_rdi = 8, +RDI_RegCodeX64_r8 = 9, +RDI_RegCodeX64_r9 = 10, +RDI_RegCodeX64_r10 = 11, +RDI_RegCodeX64_r11 = 12, +RDI_RegCodeX64_r12 = 13, +RDI_RegCodeX64_r13 = 14, +RDI_RegCodeX64_r14 = 15, +RDI_RegCodeX64_r15 = 16, +RDI_RegCodeX64_es = 17, +RDI_RegCodeX64_cs = 18, +RDI_RegCodeX64_ss = 19, +RDI_RegCodeX64_ds = 20, +RDI_RegCodeX64_fs = 21, +RDI_RegCodeX64_gs = 22, +RDI_RegCodeX64_rip = 23, +RDI_RegCodeX64_rflags = 24, +RDI_RegCodeX64_dr0 = 25, +RDI_RegCodeX64_dr1 = 26, +RDI_RegCodeX64_dr2 = 27, +RDI_RegCodeX64_dr3 = 28, +RDI_RegCodeX64_dr4 = 29, +RDI_RegCodeX64_dr5 = 30, +RDI_RegCodeX64_dr6 = 31, +RDI_RegCodeX64_dr7 = 32, +RDI_RegCodeX64_st0 = 33, +RDI_RegCodeX64_st1 = 34, +RDI_RegCodeX64_st2 = 35, +RDI_RegCodeX64_st3 = 36, +RDI_RegCodeX64_st4 = 37, +RDI_RegCodeX64_st5 = 38, +RDI_RegCodeX64_st6 = 39, +RDI_RegCodeX64_st7 = 40, +RDI_RegCodeX64_fpr0 = 41, +RDI_RegCodeX64_fpr1 = 42, +RDI_RegCodeX64_fpr2 = 43, +RDI_RegCodeX64_fpr3 = 44, +RDI_RegCodeX64_fpr4 = 45, +RDI_RegCodeX64_fpr5 = 46, +RDI_RegCodeX64_fpr6 = 47, +RDI_RegCodeX64_fpr7 = 48, +RDI_RegCodeX64_ymm0 = 49, +RDI_RegCodeX64_ymm1 = 50, +RDI_RegCodeX64_ymm2 = 51, +RDI_RegCodeX64_ymm3 = 52, +RDI_RegCodeX64_ymm4 = 53, +RDI_RegCodeX64_ymm5 = 54, +RDI_RegCodeX64_ymm6 = 55, +RDI_RegCodeX64_ymm7 = 56, +RDI_RegCodeX64_ymm8 = 57, +RDI_RegCodeX64_ymm9 = 58, +RDI_RegCodeX64_ymm10 = 59, +RDI_RegCodeX64_ymm11 = 60, +RDI_RegCodeX64_ymm12 = 61, +RDI_RegCodeX64_ymm13 = 62, +RDI_RegCodeX64_ymm14 = 63, +RDI_RegCodeX64_ymm15 = 64, +RDI_RegCodeX64_mxcsr = 65, +RDI_RegCodeX64_fsbase = 66, +RDI_RegCodeX64_gsbase = 67, +RDI_RegCodeX64_fcw = 68, +RDI_RegCodeX64_fsw = 69, +RDI_RegCodeX64_ftw = 70, +RDI_RegCodeX64_fop = 71, +RDI_RegCodeX64_fcs = 72, +RDI_RegCodeX64_fds = 73, +RDI_RegCodeX64_fip = 74, +RDI_RegCodeX64_fdp = 75, +RDI_RegCodeX64_mxcsr_mask = 76, +} RDI_RegCodeX64; + +typedef RDI_U32 RDI_BinarySectionFlags; +typedef enum RDI_BinarySectionFlagsEnum +{ +RDI_BinarySectionFlags_Read = 1<<0, +RDI_BinarySectionFlags_Write = 1<<1, +RDI_BinarySectionFlags_Execute = 1<<2, +} RDI_BinarySectionFlagsEnum; + +typedef struct RDI_Header RDI_Header; +struct RDI_Header +{ +RDI_U64 magic; +RDI_U32 encoding_version; +RDI_U32 data_section_off; +RDI_U32 data_section_count; +}; + +typedef struct RDI_DataSection RDI_DataSection; +struct RDI_DataSection +{ +RDI_DataSectionTag tag; +RDI_DataSectionEncoding encoding; +}; + +typedef struct RDI_VMapEntry RDI_VMapEntry; +struct RDI_VMapEntry +{ +RDI_U64 voff; +RDI_U64 idx; +}; + +typedef struct RDI_TopLevelInfo RDI_TopLevelInfo; +struct RDI_TopLevelInfo +{ +RDI_Arch arch; +RDI_U32 exe_name_string_idx; +RDI_U64 exe_hash; +RDI_U64 voff_max; +}; + +C_LINKAGE_BEGIN +C_LINKAGE_END + +#endif // RDI_FORMAT_META_H diff --git a/src/rdi_format/rdi_format.mdesk b/src/rdi_format/rdi_format.mdesk new file mode 100644 index 00000000..ce881b2b --- /dev/null +++ b/src/rdi_format/rdi_format.mdesk @@ -0,0 +1,766 @@ +// Copyright (c) 2024 Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//////////////////////////////// +//~ rjf: Format Header Tables + +@table(name type desc) +RDI_HeaderMemberTable: +{ + {magic RDI_U64 ""} + {encoding_version RDI_U32 ""} + {data_section_off RDI_U32 ""} + {data_section_count RDI_U32 ""} +} + +@struct RDI_Header: +{ + @expand(RDI_HeaderMemberTable a) `$(a.type) $(a.name)` +} + +//////////////////////////////// +//~ rjf: Format Data Section Tables + +@constant RDI_DataSectionTag_SECONDARY: 0x80000000 + +@table(name value desc) +RDI_DataSectionTable: +{ + {NULL 0x0000 ""} + {TopLevelInfo 0x0001 ""} + {StringData 0x0002 ""} + {StringTable 0x0003 ""} + {IndexRuns 0x0004 ""} + {BinarySections 0x0005 ""} + {FilePathNodes 0x0006 ""} + {SourceFiles 0x0007 ""} + {Units 0x0008 ""} + {UnitVmap 0x0009 ""} + {TypeNodes 0x000A ""} + {UDTs 0x000B ""} + {Members 0x000C ""} + {EnumMembers 0x000D ""} + {GlobalVariables 0x000E ""} + {GlobalVmap 0x000F ""} + {ThreadVariables 0x0010 ""} + {Procedures 0x0011 ""} + {Scopes 0x0012 ""} + {ScopeVoffData 0x0013 ""} + {ScopeVmap 0x0014 ""} + {Locals 0x0015 ""} + {LocationBlocks 0x0016 ""} + {LocationData 0x0017 ""} + {NameMaps 0x0018 ""} + {PRIMARY_COUNT 0x0019 ""} + {SKIP `RDI_DataSectionTag_SECONDARY|0x0000` ""} + {LineInfoVoffs `RDI_DataSectionTag_SECONDARY|0x0001` ""} + {LineInfoData `RDI_DataSectionTag_SECONDARY|0x0002` ""} + {LineInfoColumns `RDI_DataSectionTag_SECONDARY|0x0003` ""} + {LineMapNumbers `RDI_DataSectionTag_SECONDARY|0x0004` ""} + {LineMapRanges `RDI_DataSectionTag_SECONDARY|0x0005` ""} + {LineMapVoffs `RDI_DataSectionTag_SECONDARY|0x0006` ""} + {NameMapBuckets `RDI_DataSectionTag_SECONDARY|0x0007` ""} + {NameMapNodes `RDI_DataSectionTag_SECONDARY|0x0008` ""} +} + +@table(name value) +RDI_DataSectionEncodingTable: +{ + {Unpacked 0} + {LZB 1} +} + +@table(name type desc) +RDI_DataSectionMemberTable: +{ + {tag RDI_DataSectionTag ""} + {encoding RDI_DataSectionEncoding ""} +} + +@enum(RDI_U32) RDI_DataSectionTag: +{ + @expand(RDI_DataSectionTable a) `$(a.name .. =>20) = $(a.value)`, +} + +@enum(RDI_U32) RDI_DataSectionEncoding: +{ + @expand(RDI_DataSectionEncodingTable a) `$(a.name .. =>10) = $(a.value)`, +} + +@struct RDI_DataSection: +{ + @expand(RDI_DataSectionMemberTable a) `$(a.type) $(a.name)` +} + +//////////////////////////////// +//~ rjf: Common Type Tables + +@table(name type desc) +RDI_VMapEntryMemberTable: +{ + {voff RDI_U64 ""} + {idx RDI_U64 ""} +} + +@struct RDI_VMapEntry: +{ + @expand(RDI_VMapEntryMemberTable a) `$(a.type) $(a.name)` +} + +//////////////////////////////// +//~ rjf: Architecture Info Tables + +@table(name value addr_size) +RDI_ArchTable: +{ + {NULL 0 0} + {X86 1 4} + {X64 2 8} +} + +@table(name value) +RDI_RegCodeX86Table: +{ + {nil 0} + {eax 1} + {ecx 2} + {edx 3} + {ebx 4} + {esp 5} + {ebp 6} + {esi 7} + {edi 8} + {fsbase 9} + {gsbase 10} + {eflags 11} + {eip 12} + {dr0 13} + {dr1 14} + {dr2 15} + {dr3 16} + {dr4 17} + {dr5 18} + {dr6 19} + {dr7 20} + {fpr0 21} + {fpr1 22} + {fpr2 23} + {fpr3 24} + {fpr4 25} + {fpr5 26} + {fpr6 27} + {fpr7 28} + {st0 29} + {st1 30} + {st2 31} + {st3 32} + {st4 33} + {st5 34} + {st6 35} + {st7 36} + {fcw 37} + {fsw 38} + {ftw 39} + {fop 40} + {fcs 41} + {fds 42} + {fip 43} + {fdp 44} + {mxcsr 45} + {mxcsr_mask 46} + {ss 47} + {cs 48} + {ds 49} + {es 50} + {fs 51} + {gs 52} + {ymm0 53} + {ymm1 54} + {ymm2 55} + {ymm3 56} + {ymm4 57} + {ymm5 58} + {ymm6 59} + {ymm7 60} +} + +@table(name value) +RDI_RegCodeX64Table: +{ + {nil 0} + {rax 1} + {rcx 2} + {rdx 3} + {rbx 4} + {rsp 5} + {rbp 6} + {rsi 7} + {rdi 8} + {r8 9} + {r9 10} + {r10 11} + {r11 12} + {r12 13} + {r13 14} + {r14 15} + {r15 16} + {es 17} + {cs 18} + {ss 19} + {ds 20} + {fs 21} + {gs 22} + {rip 23} + {rflags 24} + {dr0 25} + {dr1 26} + {dr2 27} + {dr3 28} + {dr4 29} + {dr5 30} + {dr6 31} + {dr7 32} + {st0 33} + {st1 34} + {st2 35} + {st3 36} + {st4 37} + {st5 38} + {st6 39} + {st7 40} + {fpr0 41} + {fpr1 42} + {fpr2 43} + {fpr3 44} + {fpr4 45} + {fpr5 46} + {fpr6 47} + {fpr7 48} + {ymm0 49} + {ymm1 50} + {ymm2 51} + {ymm3 52} + {ymm4 53} + {ymm5 54} + {ymm6 55} + {ymm7 56} + {ymm8 57} + {ymm9 58} + {ymm10 59} + {ymm11 60} + {ymm12 61} + {ymm13 62} + {ymm14 63} + {ymm15 64} + {mxcsr 65} + {fsbase 66} + {gsbase 67} + {fcw 68} + {fsw 69} + {ftw 70} + {fop 71} + {fcs 72} + {fds 73} + {fip 74} + {fdp 75} + {mxcsr_mask 76} +} + +@enum(RDI_U32) RDI_Arch: +{ + @expand(RDI_ArchTable a) `$(a.name .. =>10) = $(a.value)` +} + +@enum RDI_RegCodeX86: +{ + @expand(RDI_RegCodeX86Table a) `$(a.name .. =>10) = $(a.value)` +} + +@enum RDI_RegCodeX64: +{ + @expand(RDI_RegCodeX64Table a) `$(a.name .. =>10) = $(a.value)` +} + +//////////////////////////////// +//~ rjf: Top-Level Info Type Tables + +@table(name type desc) +RDI_TopLevelInfoMemberTable: +{ + {arch RDI_Arch ""} + {exe_name_string_idx RDI_U32 ""} + {exe_hash RDI_U64 ""} + {voff_max RDI_U64 ""} +} + +@struct RDI_TopLevelInfo: +{ + @expand(RDI_TopLevelInfoMemberTable a) `$(a.type) $(a.name)` +} + +//////////////////////////////// +//~ rjf: Binary Section Info Type Tables + +@table(name value) +RDI_BinarySectionFlagTable: +{ + {Read `1<<0`} + {Write `1<<1`} + {Execute `1<<2`} +} + +@table(name type desc) +RDI_BinarySectionMemberTable: +{ + {name_string_idx RDI_U32 ""} + {flags RDI_BinarySectionFlags ""} + {voff_first RDI_U64 ""} + {voff_opl RDI_U64 ""} + {foff_first RDI_U64 ""} + {foff_opl RDI_U64 ""} +} + +@enum(RDI_U32) RDI_BinarySectionFlags: +{ + @expand(RDI_BinarySectionFlagTable a) `$(a.name .. =>10) = $(a.value)`; +} + +//////////////////////////////// +//~ rjf: File Path Tree Info Type Tables + +@table(name type desc) +RDI_FilePathNodeMemberTable: +{ + {name_string_idx RDI_U32 ""} + {parent_path_node RDI_U32 ""} + {first_child RDI_U32 ""} + {next_sibling RDI_U32 ""} + {source_file_idx RDI_U32 ""} +} + +@table(name type desc) +RDI_SourceFileMemberTable: +{ + {file_path_node_idx RDI_U32 ""} + {normal_full_path_string_idx RDI_U32 ""} + // usage of line map to go from a line number to an array of voffs + // (line_map_nums * line_number) -> (nil | index) + // (line_map_data * index) -> (range) + // (line_map_voff_data * range) -> (array(voff)) + {line_map_count RDI_U32 ""} + {line_map_nums_data_idx RDI_U32 ""} // U32[line_map_count] (sorted - not closed ranges) + {line_map_range_data_idx RDI_U32 ""} // U32[line_map_count + 1] (pairs form ranges) + {line_map_voff_data_idx RDI_U32 ""} // U64[...] (idx by line_map_range_data) +} + +//////////////////////////////// +//~ rjf: Unit Info Type Tables + +@table(name type desc) +RDI_UnitMemberTable: +{ + {unit_name_string_idx RDI_U32 ""} + {compiler_name_string_idx RDI_U32 ""} + {source_file_path_node RDI_U32 ""} + {object_file_path_node RDI_U32 ""} + {archive_file_path_node RDI_U32 ""} + {build_path_node RDI_U32 ""} + {language RDI_Language ""} + // usage of line info to go from voff to file & line number: + // (line_info_voffs * voff) -> (nil + index) + // (line_info_data * index) -> (RDI_Line = (file_idx * line_number)) + {line_info_voffs_data_idx RDI_U32 ""} // U64[line_info_count + 1] (sorted ranges) + {line_info_data_idx RDI_U32 ""} // RDI_Line[line_info_count] + {line_info_col_data_idx RDI_U32 ""} // RDI_Col[line_info_count] + {line_info_count RDI_U32 ""} +} + +//////////////////////////////// +//~ rjf: Line Info Type Tables + +@table(name type desc) +RDI_LineMemberTable: +{ + {file_idx RDI_U32 ""} + {line_num RDI_U32 ""} +} + +@table(name type desc) +RDI_ColumnMemberTable: +{ + {col_first RDI_U16 ""} + {col_opl RDI_U16 ""} +} + +//////////////////////////////// +//~ rjf: Language Info Tables + +@table(name value) +RDI_LanguageTable: +{ + {NULL 0} + {C 1} + {CPlusPlus 2} +} + +//////////////////////////////// +//~ rjf: Type Info Tables + +@table(name value size bookend1 bookend2) +RDI_TypeKindTable: +{ + {NULL 0x0000 0 } + //- + {Void 0x0001 0 FirstBuiltIn } + {Handle 0x0002 0xFFFFFFFF } + {Char8 0x0003 1 } + {Char16 0x0004 2 } + {Char32 0x0005 4 } + {UChar8 0x0006 1 } + {UChar16 0x0007 2 } + {UChar32 0x0008 4 } + {U8 0x0009 1 } + {U16 0x000A 2 } + {U32 0x000B 4 } + {U64 0x000C 8 } + {U128 0x000D 16 } + {U256 0x000E 32 } + {U512 0x000F 64 } + {S8 0x0010 1 } + {S16 0x0011 2 } + {S32 0x0012 4 } + {S64 0x0013 8 } + {S128 0x0014 16 } + {S256 0x0015 32 } + {S512 0x0016 64 } + {Bool 0x0017 1 } + {F16 0x0018 2 } + {F32 0x0019 4 } + {F32PP 0x001A 4 } + {F48 0x001B 6 } + {F64 0x001C 8 } + {F80 0x001D 10 } + {F128 0x001E 16 } + {ComplexF32 0x001F 8 } + {ComplexF64 0x0020 16 } + {ComplexF80 0x0021 20 } + {ComplexF128 0x0022 32 LastBuiltIn } + //- + {Modifier 0x1000 0 FirstConstructed } + {Ptr 0x1001 0 } + {LRef 0x1002 0 } + {RRef 0x1003 0 } + {Array 0x1004 0 } + {Function 0x1005 0 } + {Method 0x1006 0 } + {MemberPtr 0x1007 0 LastConstructed } + //- + {Struct 0x2000 0 FirstUserDefined FirstRecord } + {Class 0x2001 0 } + {Union 0x2002 0 LastRecord } + {Enum 0x2003 0 } + {Alias 0x2004 0 } + {IncompleteStruct 0x2005 0 FirstIncomplete } + {IncompleteUnion 0x2006 0 } + {IncompleteClass 0x2007 0 } + {IncompleteEnum 0x2008 0 LastIncomplete LastUserDefined} + //- + {Bitfield 0xF000 0 } + {Variadic 0xF001 0 } +} + +@table(name val) +RDI_TypeModifierFlagTable: +{ + {Const `1<<0`} + {Volatile `1<<1`} +} + +@table(name type desc) +RDI_TypeNodeMemberTable: +{ + {kind RDI_TypeKind ""} + {byte_size RDI_U32 ""} + {kind_info `RDI_U32[3]` ""} +} + +@table(name val) +RDI_UDTFlagTable: +{ + {EnumMembers `1<<0`} +} + +@table(name type desc) +RDI_UDTMemberTable: +{ + {self_type_idx RDI_U32 ""} + {flags RDI_UDTFlags ""} + {member_first RDI_U32 ""} + {member_count RDI_U32 ""} + {file_idx RDI_U32 ""} + {line RDI_U32 ""} + {col RDI_U32 ""} +} + +@table(name val) +RDI_MemberKindTable: +{ + {NULL 0x0000} + {DataField 0x0001} + {StaticData 0x0002} + {Method 0x0100} + {StaticMethod 0x0101} + {VirtualMethod 0x0102} + {VTablePtr 0x0200} + {Base 0x0201} + {VirtualBase 0x0202} + {NestedType 0x0300} +} + +@table(name type desc) +RDI_MemberMemberTable: +{ + {kind RDI_MemberKind ""} + {pad RDI_U16 ""} + {name_string_idx RDI_U32 ""} + {type_idx RDI_U32 ""} + {off RDI_U32 ""} +} + +@table(name type desc) +RDI_EnumMemberTable: +{ + {name_string_idx RDI_U32 ""} + {pad RDI_U32 ""} + {val RDI_U64 ""} +} + +//////////////////////////////// +//~ rjf: Symbol Info Tables + +@table(name val) +RDI_LinkFlagTable: +{ + {External `1<<0`} + {TypeScoped `1<<1`} + {ProcScoped `1<<2`} +} + +@table(name val) +RDI_LocalKindTable: +{ + {NULL 0x0} + {Parameter 0x1} + {Variable 0x2} +} + +@table(name val) +RDI_LocationKindTable: +{ + {NULL 0x0} + {AddrBytecodeStream 0x1} + {ValBytecodeStream 0x2} + {AddrRegisterPlusU16 0x3} + {AddrAddrRegisterPlusU16 0x4} + {ValRegister 0x5} +} + +@table(name type desc) +RDI_GlobalVariableMemberTable: +{ + {name_string_idx RDI_U32 ""} + {link_flags RDI_LinkFlags ""} + {voff RDI_U64 ""} + {type_idx RDI_U32 ""} + {container_idx RDI_U32 ""} +} + +@table(name type desc) +RDI_ThreadVariableMemberTable: +{ + {name_string_idx RDI_U32 ""} + {link_flags RDI_LinkFlags ""} + {tls_off RDI_U32 ""} + {type_idx RDI_U32 ""} + {container_idx RDI_U32 ""} +} + +@table(name type desc) +RDI_ProcedureMemberTable: +{ + {name_string_idx RDI_U32 ""} + {link_name_string_idx RDI_U32 ""} + {link_flags RDI_LinkFlags ""} + {type_idx RDI_U32 ""} + {root_scope_idx RDI_U32 ""} + {container_idx RDI_U32 ""} +} + +@table(name type desc) +RDI_ScopeMemberTable: +{ + {proc_idx RDI_U32 ""} + {parent_scope_idx RDI_U32 ""} + {first_child_scope_idx RDI_U32 ""} + {next_sibling_scope_idx RDI_U32 ""} + {voff_range_first RDI_U32 ""} + {voff_range_opl RDI_U32 ""} + {local_first RDI_U32 ""} + {local_count RDI_U32 ""} + {static_local_idx_run_first RDI_U32 ""} + {static_local_count RDI_U32 ""} +} + +@table(name type desc) +RDI_LocalMemberTable: +{ + {kind RDI_LocalKind ""} + {name_string_idx RDI_U32 ""} + {type_idx RDI_U32 ""} + {pad RDI_U32 ""} + {location_first RDI_U32 ""} + {location_opl RDI_U32 ""} +} + +@table(name type desc) +RDI_LocationBlockMemberTable: +{ + {scope_off_first RDI_U32} + {scope_off_opl RDI_U32} + {location_data_off RDI_U32} +} + +@table(name type desc) +RDI_LocationBytecodeStreamMemberTable: +{ + {kind RDI_LocationKind ""} + // [... 0] null terminated byte sequence RDI_EvalBytecodeStream +} + +@table(name type desc) +RDI_LocationRegisterPlusU16MemberTable: +{ + {kind RDI_LocationKind } + {register_code RDI_RegisterCode } + {offset RDI_U16 } +} + +@table(name type desc) +RDI_LocationRegister: +{ + {kind RDI_LocationKind } + {register_code RDI_RegisterCode } +} + +//////////////////////////////// +//~ rjf: Evaluation Bytecode Tables + +@table(name num_decodes num_pops num_pushes) +RDI_EvalOpTable: +{ + {Stop 0 0 0} + {Noop 0 0 0} + {Cond 1 1 0} + {Skip 1 0 0} + {MemRead 1 1 1} + {RegRead 4 0 1} + {RegReadDyn 0 1 1} + {FrameOff 1 0 1} + {ModuleOff 4 0 1} + {TLSOff 4 0 1} + {ObjectOff 0 0 0} + {CFA 0 0 0} + {ConstU8 1 0 1} + {ConstU16 2 0 1} + {ConstU32 4 0 1} + {ConstU64 8 0 1} + {Abs 1 1 1} + {Neg 1 1 1} + {Add 1 2 1} + {Sub 1 2 1} + {Mul 1 2 1} + {Div 1 2 1} + {Mod 1 2 1} + {LShift 1 2 1} + {RShift 1 2 1} + {BitAnd 1 2 1} + {BitOr 1 2 1} + {BitXor 1 2 1} + {BitNot 1 1 1} + {LogAnd 1 2 1} + {LogOr 1 2 1} + {LogNot 1 1 1} + {EqEq 1 2 1} + {NtEq 1 2 1} + {LsEq 1 2 1} + {GrEq 1 2 1} + {Less 1 2 1} + {Grtr 1 2 1} + {Trunc 1 1 1} + {TruncSigned 1 1 1} + {Convert 2 1 1} + {Pick 1 0 1} + {Pop 0 1 0} + {Insert 1 0 0} +} + +@table(name val) +RDI_EvalTypeGroupTable: +{ + {Other 0} + {U 1} + {S 2} + {F32 3} + {F64 4} +} + +@table(name val error_string) +RDI_EvalConversionKindTable: +{ + {Noop 0 "" } + {Legal 1 "" } + {OtherToOther 2 "Cannot convert between these types."} + {ToOther 3 "Cannot convert to this type." } + {FromOther 4 "Cannot convert this type." } +} + +//////////////////////////////// +//~ rjf: Name Map Tables + +@table(name val) +RDI_NameMapKindTable: +{ + {NULL 0} + {GlobalVariables 1} + {ThreadVariables 2} + {Procedures 3} + {Types 4} + {LinkNameProcedures 5} + {NormalSourcePaths 6} +} + +@table(name type desc) +RDI_NameMapMemberTable: +{ + {kind RDI_NameMapKind ""} + {bucket_data_idx RDI_U32 ""} + {node_data_idx RDI_U32 ""} +} + +@table(name type desc) +RDI_NameMapBucketMemberTable: +{ + {first_node RDI_U32 ""} + {node_count RDI_U32 ""} +} + +@table(name type desc) +RDI_NameMapNodeMemberTable: +{ + {string_idx RDI_U32 ""} + {match_count RDI_U32 ""} + // NOTE: if (match_count == 1) then this is the index of the matching item + // if (match_count > 1) then this is the first for an index run of all the matches + {match_idx_or_idx_run_first RDI_U32 ""} +} +