mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-12 23:31:38 -07:00
eliminate extra type stuff in rdim, organize / reslice dwarf conversion code, start reading through dwarf conversion
This commit is contained in:
+4
-4
@@ -47,10 +47,10 @@ commands =
|
||||
{
|
||||
//- rjf: [raddbg]
|
||||
// .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
// .f1 = { .win = "raddbg_stable --ipc kill_all && build radbin", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
.f1 = { .win = "raddbg_stable --ipc kill_all && build radbin", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
//- rjf: [raddbg wsl]
|
||||
.f1 = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
// .f1 = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
//- rjf: [scratch]
|
||||
.f2 = { .win = "build radbin", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
@@ -65,8 +65,8 @@ commands =
|
||||
// .f1 = { .win = "raddbg_stable --ipc kill_all && build radbin", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
//- rjf: running target
|
||||
// .f3 = { .win = "raddbg_stable --ipc run", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
.f3 = { .win = "wsl ./build/raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
.f3 = { .win = "raddbg_stable --ipc run", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
// .f3 = { .win = "wsl ./build/raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
// .f3 = { .win = "pushd build && raddbg --user:dev.raddbg_user && popd", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
// .f3 = { .win = "C:/devel/raddebugger/build/raddbg.exe --capture --user:C:/devel/raddebugger/build/local_dev.raddbg_user --project:C:/devel/raddebugger/build/local_dev.raddbg_project", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
// .f3 = { .win = "wsl_launch /mnt/c/devel/raddebugger/build/raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
@@ -479,7 +479,7 @@ rdim_rng1u64_chunk_list_push(RDIM_Arena *arena, RDIM_Rng1U64ChunkList *list, RDI
|
||||
//~ Data Model
|
||||
|
||||
RDI_PROC RDI_TypeKind
|
||||
rdim_short_type_from_data_model(RDIM_DataModel data_model)
|
||||
rdim_short_type_kind_from_data_model(RDIM_DataModel data_model)
|
||||
{
|
||||
switch(data_model)
|
||||
{
|
||||
@@ -495,7 +495,7 @@ rdim_short_type_from_data_model(RDIM_DataModel data_model)
|
||||
}
|
||||
|
||||
RDI_PROC RDI_TypeKind
|
||||
rdim_unsigned_short_type_from_data_model(RDIM_DataModel data_model)
|
||||
rdim_unsigned_short_type_kind_from_data_model(RDIM_DataModel data_model)
|
||||
{
|
||||
switch(data_model)
|
||||
{
|
||||
@@ -543,7 +543,7 @@ rdim_unsigned_int_type_from_data_model(RDIM_DataModel data_model)
|
||||
}
|
||||
|
||||
RDI_PROC RDI_TypeKind
|
||||
rdim_long_type_from_data_model(RDIM_DataModel data_model)
|
||||
rdim_long_type_kind_from_data_model(RDIM_DataModel data_model)
|
||||
{
|
||||
switch(data_model)
|
||||
{
|
||||
@@ -559,7 +559,7 @@ rdim_long_type_from_data_model(RDIM_DataModel data_model)
|
||||
}
|
||||
|
||||
RDI_PROC RDI_TypeKind
|
||||
rdim_unsigned_long_type_from_data_model(RDIM_DataModel data_model)
|
||||
rdim_unsigned_long_type_kind_from_data_model(RDIM_DataModel data_model)
|
||||
{
|
||||
switch(data_model)
|
||||
{
|
||||
@@ -575,7 +575,7 @@ rdim_unsigned_long_type_from_data_model(RDIM_DataModel data_model)
|
||||
}
|
||||
|
||||
RDI_PROC RDI_TypeKind
|
||||
rdim_long_long_type_from_data_model(RDIM_DataModel data_model)
|
||||
rdim_long_long_type_kind_from_data_model(RDIM_DataModel data_model)
|
||||
{
|
||||
switch(data_model)
|
||||
{
|
||||
@@ -591,7 +591,7 @@ rdim_long_long_type_from_data_model(RDIM_DataModel data_model)
|
||||
}
|
||||
|
||||
RDI_PROC RDI_TypeKind
|
||||
rdim_unsigned_long_long_type_from_data_model(RDIM_DataModel data_model)
|
||||
rdim_unsigned_long_long_type_kind_from_data_model(RDIM_DataModel data_model)
|
||||
{
|
||||
switch(data_model)
|
||||
{
|
||||
@@ -607,7 +607,7 @@ rdim_unsigned_long_long_type_from_data_model(RDIM_DataModel data_model)
|
||||
}
|
||||
|
||||
RDI_PROC RDI_TypeKind
|
||||
rdim_pointer_size_t_type_from_data_model(RDIM_DataModel data_model)
|
||||
rdim_pointer_size_t_type_kind_from_data_model(RDIM_DataModel data_model)
|
||||
{
|
||||
switch(data_model)
|
||||
{
|
||||
@@ -1346,41 +1346,6 @@ rdim_count_from_location_block_chunk_list(RDIM_String8List *list)
|
||||
return count;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
RDI_PROC RDIM_Type *
|
||||
rdim_builtin_type_from_kind(RDIM_TypeChunkList list, RDI_TypeKind type_kind)
|
||||
{
|
||||
return &list.first->v[type_kind];
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_TypeChunkList
|
||||
rdim_init_type_chunk_list(RDIM_Arena *arena, RDI_Arch arch)
|
||||
{
|
||||
RDIM_TypeChunkList list = {0};
|
||||
|
||||
RDI_U64 type_cap = (RDI_TypeKind_LastBuiltIn - RDI_TypeKind_FirstBuiltIn) + 2;
|
||||
|
||||
// RDI_TypeKind_NULL
|
||||
rdim_type_chunk_list_push(arena, &list, type_cap);
|
||||
|
||||
for(RDI_TypeKind type_kind = RDI_TypeKind_FirstBuiltIn; type_kind <= RDI_TypeKind_LastBuiltIn; type_kind += 1)
|
||||
{
|
||||
RDIM_Type *type = rdim_type_chunk_list_push(arena, &list, type_cap);
|
||||
type->name.str = rdi_string_from_type_kind(type_kind, &type->name.size);
|
||||
type->kind = type_kind;
|
||||
type->byte_size = rdi_size_from_basic_type_kind(type_kind);
|
||||
}
|
||||
|
||||
RDIM_Type *void_type = rdim_builtin_type_from_kind(list, RDI_TypeKind_Void);
|
||||
void_type->byte_size = rdi_addr_size_from_arch(arch);
|
||||
|
||||
RDIM_Type *handle_type = rdim_builtin_type_from_kind(list, RDI_TypeKind_Handle);
|
||||
handle_type->byte_size = rdi_addr_size_from_arch(arch);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Baked VMap Building
|
||||
|
||||
|
||||
@@ -1429,15 +1429,15 @@ RDI_PROC void rdim_rng1u64_chunk_list_push(RDIM_Arena *arena, RDIM_Rng1U64ChunkL
|
||||
////////////////////////////////
|
||||
//~ Data Model
|
||||
|
||||
RDI_PROC RDI_TypeKind rdim_short_type_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_unsigned_short_type_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_short_type_kind_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_unsigned_short_type_kind_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_int_type_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_unsigned_int_type_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_long_type_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_unsigned_long_type_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_long_long_type_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_unsigned_long_long_type_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_pointer_size_t_type_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_long_type_kind_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_unsigned_long_type_kind_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_long_long_type_kind_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_unsigned_long_long_type_kind_from_data_model(RDIM_DataModel data_model);
|
||||
RDI_PROC RDI_TypeKind rdim_pointer_size_t_type_kind_from_data_model(RDIM_DataModel data_model);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Building] Binary Section Info Building
|
||||
@@ -1520,15 +1520,10 @@ RDI_PROC RDIM_Location *rdim_push_location_val_reg(RDIM_Arena *arena, RDI_U8 reg
|
||||
//- rjf: location sets
|
||||
RDI_PROC void rdim_location_set_push_case(RDIM_Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_LocationSet *locset, RDIM_Rng1U64 voff_range, RDIM_Location *location);
|
||||
|
||||
//- rjf:location block chunk list
|
||||
//- rjf: location block chunk list
|
||||
RDI_PROC RDI_LocationBlock *rdim_location_block_chunk_list_push_array(RDIM_Arena *arena, RDIM_String8List *list, RDI_U32 count);
|
||||
RDI_PROC RDI_U32 rdim_count_from_location_block_chunk_list(RDIM_String8List *list);
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
RDI_PROC RDIM_TypeChunkList rdim_init_type_chunk_list(RDIM_Arena *arena, RDI_Arch arch);
|
||||
RDI_PROC RDIM_Type * rdim_builtin_type_from_kind(RDIM_TypeChunkList list, RDI_TypeKind type_kind);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Baked VMap Building
|
||||
|
||||
|
||||
@@ -7,42 +7,81 @@
|
||||
// however it is optional and in case it is missing converter has to generate the ranges from scopes.
|
||||
// [ ] Error handling
|
||||
|
||||
internal RDI_RegCode
|
||||
d2r_rdi_reg_from_dw_reg_code_x64(U64 reg_code)
|
||||
////////////////////////////////
|
||||
//~ rjf: Enum Conversion Helpers
|
||||
|
||||
internal RDI_Language
|
||||
d2r_rdi_language_from_dw_language(DW_Language v)
|
||||
{
|
||||
switch (reg_code) {
|
||||
#define X(reg_name_dw, reg_code_dw, reg_name_rdi, reg_pos, reg_size) case DW_RegX64_##reg_name_dw: return RDI_RegCodeX64_##reg_name_rdi;
|
||||
DW_Regs_X64_XList(X)
|
||||
#undef X
|
||||
RDI_Language result = RDI_Language_NULL;
|
||||
switch(v)
|
||||
{
|
||||
default:{}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:
|
||||
{
|
||||
result = RDI_Language_CPlusPlus;
|
||||
}break;
|
||||
}
|
||||
InvalidPath;
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal RDI_RegCode
|
||||
d2r_rdi_reg_from_dw_reg_code_x86(U64 reg_code)
|
||||
internal RDI_RegCodeX86
|
||||
d2r_rdi_reg_code_from_dw_reg_x86(DW_RegX86 v)
|
||||
{
|
||||
switch (reg_code) {
|
||||
#define X(reg_name_dw, reg_code_dw, reg_name_rdi, reg_pos, reg_size) case DW_RegX86_##reg_name_dw: return RDI_RegCodeX86_##reg_name_rdi;
|
||||
RDI_RegCodeX86 result = RDI_RegCode_nil;
|
||||
switch(v)
|
||||
{
|
||||
default:{}break;
|
||||
#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
|
||||
}
|
||||
InvalidPath;
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal RDI_RegCodeX64
|
||||
d2r_rdi_reg_code_from_dw_reg_x64(DW_RegX64 v)
|
||||
{
|
||||
RDI_RegCodeX64 result = RDI_RegCode_nil;
|
||||
switch(v)
|
||||
{
|
||||
default:{}break;
|
||||
#define X(reg_dw, val_dw, reg_rdi, off, size) case DW_RegX64_##reg_dw:{result = RDI_RegCodeX64_##reg_rdi;}break;
|
||||
DW_Regs_X64_XList(X)
|
||||
#undef X
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal RDI_RegCode
|
||||
d2r_rdi_reg_from_dw_reg_code(Arch arch, U64 reg_code)
|
||||
d2r_rdi_reg_code_from_dw_reg(Arch arch, DW_Reg v)
|
||||
{
|
||||
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;
|
||||
RDI_RegCode result = RDI_RegCode_nil;
|
||||
switch(arch)
|
||||
{
|
||||
default:
|
||||
case Arch_Null:
|
||||
case Arch_x86:{result = d2r_rdi_reg_code_from_dw_reg_x86(v);}break;
|
||||
case Arch_x64:{result = d2r_rdi_reg_code_from_dw_reg_x64(v);}break;
|
||||
}
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Type Conversion Helpers
|
||||
|
||||
internal RDIM_Type *
|
||||
d2r_create_type(Arena *arena, D2R_TypeTable *type_table)
|
||||
{
|
||||
@@ -89,7 +128,8 @@ d2r_type_from_attrib(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, D
|
||||
Assert(!"unexpected attrib class");
|
||||
}
|
||||
} else if (attrib->attrib_kind == DW_AttribKind_Null) {
|
||||
type = rdim_builtin_type_from_kind(*type_table->types, RDI_TypeKind_NULL);
|
||||
// TODO(rjf):
|
||||
// type = rdim_builtin_type_from_kind(*type_table->types, RDI_TypeKind_NULL);
|
||||
}
|
||||
|
||||
return type;
|
||||
@@ -238,6 +278,9 @@ d2r_type_group_from_type_kind(RDI_TypeKind x)
|
||||
return RDI_EvalTypeGroup_Other;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Bytecode Conversion Helpers
|
||||
|
||||
internal RDIM_EvalBytecode
|
||||
d2r_bytecode_from_expression(Arena *arena,
|
||||
DW_Input *input,
|
||||
@@ -404,7 +447,7 @@ SLLStackPush(stack, f); \
|
||||
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);
|
||||
RDI_RegCode reg_code_rdi = d2r_rdi_reg_code_from_dw_reg(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));
|
||||
@@ -417,7 +460,7 @@ SLLStackPush(stack, f); \
|
||||
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);
|
||||
RDI_RegCode reg_code_rdi = d2r_rdi_reg_code_from_dw_reg(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));
|
||||
@@ -501,7 +544,7 @@ SLLStackPush(stack, f); \
|
||||
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);
|
||||
RDI_RegCode reg_code_rdi = d2r_rdi_reg_code_from_dw_reg(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);
|
||||
@@ -518,7 +561,7 @@ SLLStackPush(stack, f); \
|
||||
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);
|
||||
RDI_RegCode reg_code_rdi = d2r_rdi_reg_code_from_dw_reg(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);
|
||||
@@ -1031,6 +1074,9 @@ d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base)
|
||||
return cm;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Compilation Unit / Scope Conversion Helpers
|
||||
|
||||
internal RDIM_Rng1U64ChunkList
|
||||
d2r_voff_ranges_from_cu_info_off(D2R_CompUnitContribMap map, U64 info_off)
|
||||
{
|
||||
@@ -1073,6 +1119,9 @@ d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D
|
||||
return scope;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Main Conversion Entry Point
|
||||
|
||||
internal RDIM_BakeParams
|
||||
d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
{
|
||||
@@ -1140,7 +1189,7 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
|
||||
RDIM_UnitChunkList units = {0};
|
||||
RDIM_UDTChunkList udts = {0};
|
||||
RDIM_TypeChunkList types = rdim_init_type_chunk_list(arena, arch);
|
||||
RDIM_TypeChunkList types = {0};
|
||||
RDIM_SymbolChunkList gvars = {0};
|
||||
RDIM_SymbolChunkList tvars = {0};
|
||||
RDIM_SymbolChunkList procs = {0};
|
||||
@@ -1336,7 +1385,7 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
unit->object_file = str8_zero();
|
||||
unit->archive_file = str8_zero();
|
||||
unit->build_path = cu_dir;
|
||||
unit->language = rdi_language_from_dw_language(cu_lang);
|
||||
unit->language = d2r_rdi_language_from_dw_language(cu_lang);
|
||||
unit->line_table = cu_line_tables_rdi[cu_idx];
|
||||
unit->voff_ranges = cu_voff_ranges;
|
||||
|
||||
@@ -1583,7 +1632,11 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
default: AssertAlways(!"unexpected base type encoding"); break; // TODO: error handling
|
||||
}
|
||||
|
||||
RDIM_Type *base_type = rdim_builtin_type_from_kind(types, kind);
|
||||
// TODO(rjf): this is not good. we can't grab existing type nodes & mutate them here.
|
||||
// to parallelize this properly, we need to *produce* new data only, otherwise threads
|
||||
// will stomp over each other everywhere.
|
||||
//
|
||||
RDIM_Type *base_type = 0; // rdim_builtin_type_from_kind(types, kind);
|
||||
base_type->kind = kind;
|
||||
base_type->byte_size = byte_size;
|
||||
|
||||
@@ -2070,68 +2123,3 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
scratch_end(scratch);
|
||||
return bake_params;
|
||||
}
|
||||
|
||||
internal RDI_Language
|
||||
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:
|
||||
result = RDI_Language_C;
|
||||
break;
|
||||
|
||||
case DW_Language_CPlusPlus03:
|
||||
case DW_Language_CPlusPlus11:
|
||||
case DW_Language_CPlusPlus14:
|
||||
case DW_Language_CPlusPlus:
|
||||
result = RDI_Language_CPlusPlus;
|
||||
break;
|
||||
|
||||
default: NotImplemented; break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal RDI_RegCodeX86
|
||||
rdi_reg_from_dw_reg_x86(DW_RegX86 v)
|
||||
{
|
||||
RDI_RegCodeX86 result = RDI_RegCode_nil;
|
||||
switch (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;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal B32
|
||||
rdi_reg_from_dw_reg_x64(DW_RegX64 v, RDI_RegCodeX64 *code_out, U64 *off_out, U64 *size_out)
|
||||
{
|
||||
RDI_RegCodeX64 result = RDI_RegCode_nil;
|
||||
switch (v) {
|
||||
#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;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal B32
|
||||
rdi_reg_from_dw_reg(Arch arch, DW_Reg v, RDI_RegCode *code_out, U64 *off_out, U64 *size_out)
|
||||
{
|
||||
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;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -39,12 +39,65 @@ typedef struct D2R_CompUnitContribMap
|
||||
} D2R_CompUnitContribMap;
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Enum Conversion Helpers
|
||||
|
||||
internal RDIM_BakeParams d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params);
|
||||
internal RDI_Language d2r_rdi_language_from_dw_language(DW_Language v);
|
||||
internal RDI_RegCodeX86 d2r_rdi_reg_code_from_dw_reg_x86(DW_RegX86 v);
|
||||
internal RDI_RegCodeX64 d2r_rdi_reg_code_from_dw_reg_x64(DW_RegX64 v);
|
||||
internal RDI_RegCode d2r_rdi_reg_code_from_dw_reg(Arch arch, DW_Reg v);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Type Conversion Helpers
|
||||
|
||||
internal RDI_Language rdi_language_from_dw_language(DW_Language v);
|
||||
internal RDI_RegCodeX86 rdi_reg_from_dw_reg_x86(DW_RegX86 v);
|
||||
internal B32 rdi_reg_from_dw_reg_x64(DW_RegX64 v, RDI_RegCodeX64 *code_out, U64 *off_out, U64 *size_out);
|
||||
internal B32 rdi_reg_from_dw_reg(Arch arch, DW_Reg v, RDI_RegCode *code_out, U64 *off_out, U64 *size_out);
|
||||
internal RDIM_Type *d2r_create_type(Arena *arena, D2R_TypeTable *type_table);
|
||||
internal RDIM_Type *d2r_find_or_create_type_from_offset(Arena *arena, D2R_TypeTable *type_table, U64 info_off);
|
||||
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);
|
||||
internal Rng1U64List d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag);
|
||||
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);
|
||||
internal RDI_TypeKind d2r_unsigned_type_kind_from_size(U64 byte_size);
|
||||
internal RDI_TypeKind d2r_signed_type_kind_from_size(U64 byte_size);
|
||||
internal RDI_EvalTypeGroup d2r_type_group_from_type_kind(RDI_TypeKind x);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Bytecode Conversion Helpers
|
||||
|
||||
internal RDIM_EvalBytecode
|
||||
d2r_bytecode_from_expression(Arena *arena,
|
||||
DW_Input *input,
|
||||
U64 image_base,
|
||||
U64 address_size,
|
||||
Arch arch,
|
||||
DW_ListUnit *addr_lu,
|
||||
String8 expr,
|
||||
DW_CompUnit *cu,
|
||||
B32 *is_addr_out);
|
||||
internal RDIM_Location *d2r_transpile_expression(Arena *arena, DW_Input *input, U64 image_base, U64 address_size, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr);
|
||||
internal RDIM_Location *d2r_location_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
|
||||
internal RDIM_LocationSet d2r_locset_from_attrib(Arena *arena,
|
||||
DW_Input *input,
|
||||
DW_CompUnit *cu,
|
||||
RDIM_ScopeChunkList *scopes,
|
||||
RDIM_Scope *curr_scope,
|
||||
U64 image_base,
|
||||
Arch arch,
|
||||
DW_Tag tag,
|
||||
DW_AttribKind kind);
|
||||
internal RDIM_LocationSet d2r_var_locset_from_tag(Arena *arena,
|
||||
DW_Input *input,
|
||||
DW_CompUnit *cu,
|
||||
RDIM_ScopeChunkList *scopes,
|
||||
RDIM_Scope *curr_scope,
|
||||
U64 image_base,
|
||||
Arch arch,
|
||||
DW_Tag tag);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Compilation Unit / Scope Conversion Helpers
|
||||
|
||||
internal D2R_CompUnitContribMap d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base);
|
||||
internal RDIM_Rng1U64ChunkList d2r_voff_ranges_from_cu_info_off(D2R_CompUnitContribMap map, U64 info_off);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Main Conversion Entry Point
|
||||
|
||||
internal RDIM_BakeParams d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params);
|
||||
|
||||
@@ -3708,25 +3708,43 @@ p2r_convert(Arena *arena, ASYNC_Root *async_root, P2R_ConvertParams *in)
|
||||
// from regular type info.
|
||||
//
|
||||
RDIM_Type **itype_type_ptrs = 0;
|
||||
RDIM_TypeChunkList all_types = rdim_init_type_chunk_list(arena, top_level_info.arch);
|
||||
RDIM_Type **basic_type_ptrs = 0;
|
||||
RDIM_TypeChunkList all_types = {0};
|
||||
#define p2r_builtin_type_ptr_from_kind(kind) ((basic_type_ptrs && RDI_TypeKind_FirstBuiltIn <= (kind) && (kind) <= RDI_TypeKind_LastBuiltIn) ? (basic_type_ptrs[(kind) - RDI_TypeKind_FirstBuiltIn]) : 0)
|
||||
#define p2r_type_ptr_from_itype(itype) ((itype_type_ptrs && (itype) < itype_opl) ? (itype_type_ptrs[(itype_fwd_map[(itype)] ? itype_fwd_map[(itype)] : (itype))]) : 0)
|
||||
if(in->subset_flags & RDIM_SubsetFlag_Types) ProfScope("types pass 3: construct all root/stub types from TPI")
|
||||
{
|
||||
itype_type_ptrs = push_array(arena, RDIM_Type *, (U64)(itype_opl));
|
||||
basic_type_ptrs = push_array(arena, RDIM_Type *, (RDI_TypeKind_LastBuiltIn - RDI_TypeKind_FirstBuiltIn + 1));
|
||||
|
||||
//////////////////////////
|
||||
//- basic type aliases
|
||||
////////////////////////////
|
||||
//- rjf: build basic types
|
||||
//
|
||||
{
|
||||
RDIM_DataModel data_model = rdim_infer_data_model(OperatingSystem_Windows, top_level_info.arch);
|
||||
RDI_TypeKind short_type = rdim_short_type_from_data_model(data_model);
|
||||
RDI_TypeKind ushort_type = rdim_unsigned_short_type_from_data_model(data_model);
|
||||
RDI_TypeKind long_type = rdim_long_type_from_data_model(data_model);
|
||||
RDI_TypeKind ulong_type = rdim_unsigned_long_type_from_data_model(data_model);
|
||||
RDI_TypeKind long_long_type = rdim_long_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);
|
||||
|
||||
for(RDI_TypeKind type_kind = RDI_TypeKind_FirstBuiltIn;
|
||||
type_kind <= RDI_TypeKind_LastBuiltIn;
|
||||
type_kind += 1)
|
||||
{
|
||||
RDIM_Type *type = rdim_type_chunk_list_push(arena, &all_types, 512);
|
||||
type->name.str = rdi_string_from_type_kind(type_kind, &type->name.size);
|
||||
type->kind = type_kind;
|
||||
type->byte_size = rdi_size_from_basic_type_kind(type_kind);
|
||||
basic_type_ptrs[type_kind - RDI_TypeKind_FirstBuiltIn] = type;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: build basic type aliases
|
||||
//
|
||||
{
|
||||
RDIM_DataModel data_model = rdim_data_model_from_os_arch(OperatingSystem_Windows, top_level_info.arch);
|
||||
RDI_TypeKind short_type = rdim_short_type_kind_from_data_model(data_model);
|
||||
RDI_TypeKind ushort_type = rdim_unsigned_short_type_kind_from_data_model(data_model);
|
||||
RDI_TypeKind long_type = rdim_long_type_kind_from_data_model(data_model);
|
||||
RDI_TypeKind ulong_type = rdim_unsigned_long_type_kind_from_data_model(data_model);
|
||||
RDI_TypeKind long_long_type = rdim_long_long_type_kind_from_data_model(data_model);
|
||||
RDI_TypeKind ulong_long_type = rdim_unsigned_long_long_type_kind_from_data_model(data_model);
|
||||
RDI_TypeKind ptr_type = rdim_pointer_size_t_type_kind_from_data_model(data_model);
|
||||
struct
|
||||
{
|
||||
char * name;
|
||||
@@ -3776,22 +3794,22 @@ p2r_convert(Arena *arena, ASYNC_Root *async_root, P2R_ConvertParams *in)
|
||||
{ "char32_t" , RDI_TypeKind_Char32 , CV_BasicType_CHAR32 }, // always UTF-32
|
||||
{ "__pointer" , ptr_type , CV_BasicType_PTR }
|
||||
};
|
||||
|
||||
itype_type_ptrs[CV_BasicType_NOTYPE] = rdim_builtin_type_from_kind(all_types, RDI_TypeKind_NULL);
|
||||
itype_type_ptrs[CV_BasicType_HRESULT] = rdim_builtin_type_from_kind(all_types, RDI_TypeKind_HResult);
|
||||
itype_type_ptrs[CV_BasicType_VOID] = rdim_builtin_type_from_kind(all_types, RDI_TypeKind_Void);
|
||||
|
||||
for(U64 i = 0; i < ArrayCount(table); i += 1)
|
||||
for EachElement(idx, table)
|
||||
{
|
||||
RDIM_Type *builtin_alias = rdim_type_chunk_list_push(arena, &all_types, tpi_leaf->itype_opl);
|
||||
builtin_alias->kind = RDI_TypeKind_Alias;
|
||||
builtin_alias->name = str8_cstring(table[i].name);
|
||||
builtin_alias->direct_type = rdim_builtin_type_from_kind(all_types, table[i].kind_rdi);
|
||||
builtin_alias->byte_size = rdi_size_from_basic_type_kind(table[i].kind_rdi);
|
||||
itype_type_ptrs[table[i].kind_cv] = builtin_alias;
|
||||
builtin_alias->name = str8_cstring(table[idx].name);
|
||||
builtin_alias->direct_type = p2r_builtin_type_ptr_from_kind(table[idx].kind_rdi);
|
||||
builtin_alias->byte_size = rdi_size_from_basic_type_kind(table[idx].kind_rdi);
|
||||
itype_type_ptrs[table[idx].kind_cv] = builtin_alias;
|
||||
}
|
||||
itype_type_ptrs[CV_BasicType_HRESULT] = basic_type_ptrs[RDI_TypeKind_HResult - RDI_TypeKind_FirstBuiltIn];
|
||||
itype_type_ptrs[CV_BasicType_VOID] = basic_type_ptrs[RDI_TypeKind_HResult - RDI_TypeKind_Void];
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: build types from TPI
|
||||
//
|
||||
for(CV_TypeId root_itype = 0; root_itype < itype_opl; root_itype += 1)
|
||||
{
|
||||
for(P2R_TypeIdChain *itype_chain = itype_chains[root_itype];
|
||||
@@ -4222,6 +4240,8 @@ p2r_convert(Arena *arena, ASYNC_Root *async_root, P2R_ConvertParams *in)
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef p2r_type_ptr_from_itype
|
||||
#undef p2r_builtin_type_ptr_from_kind
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: types pass 4: kick off UDT build
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
////////////////////////////////
|
||||
|
||||
internal RDIM_DataModel
|
||||
rdim_infer_data_model(OperatingSystem os, RDI_Arch arch)
|
||||
rdim_data_model_from_os_arch(OperatingSystem os, RDI_Arch arch)
|
||||
{
|
||||
RDIM_DataModel data_model = RDIM_DataModel_Null;
|
||||
#define Case(os_name, arch_name, model_name) if(os == OperatingSystem_##os_name && arch == Arch_##arch_name) { data_model = RDIM_DataModel_##model_name; }
|
||||
|
||||
@@ -326,7 +326,7 @@ struct RDIM_BakeIdxRunsIn
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
internal RDIM_DataModel rdim_infer_data_model(OperatingSystem os, RDI_Arch arch);
|
||||
internal RDIM_DataModel rdim_data_model_from_os_arch(OperatingSystem os, RDI_Arch arch);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Baking Stage Tasks
|
||||
@@ -376,7 +376,7 @@ global ASYNC_Root *rdim_local_async_root = 0;
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
internal RDIM_DataModel rdim_infer_data_model(OperatingSystem os, RDI_Arch arch);
|
||||
internal RDIM_DataModel rdim_data_model_from_os_arch(OperatingSystem os, RDI_Arch arch);
|
||||
internal RDIM_TopLevelInfo rdim_make_top_level_info(String8 image_name, Arch arch, U64 exe_hash, RDIM_BinarySectionList sections);
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user