mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
sketch out more locals baking stuff, + notes for unit-arrangement pass
This commit is contained in:
+4
-3
@@ -387,9 +387,10 @@ RDI_MemberKind_NestedType = 0x0300,
|
|||||||
typedef RDI_U8 RDI_ContainerKind;
|
typedef RDI_U8 RDI_ContainerKind;
|
||||||
typedef enum RDI_ContainerKindEnum
|
typedef enum RDI_ContainerKindEnum
|
||||||
{
|
{
|
||||||
RDI_ContainerKind_Type = 0x0,
|
RDI_ContainerKind_Unit = 0x0,
|
||||||
RDI_ContainerKind_Scope = 0x1,
|
RDI_ContainerKind_Type = 0x1,
|
||||||
RDI_ContainerKind_Namespace = 0x2,
|
RDI_ContainerKind_Scope = 0x2,
|
||||||
|
RDI_ContainerKind_Namespace = 0x3,
|
||||||
} RDI_ContainerKindEnum;
|
} RDI_ContainerKindEnum;
|
||||||
|
|
||||||
typedef RDI_U8 RDI_ContainerFlags;
|
typedef RDI_U8 RDI_ContainerFlags;
|
||||||
|
|||||||
@@ -25,15 +25,19 @@
|
|||||||
// [ ] single-line viz for pointers w/ bad (unmapped) addresses
|
// [ ] single-line viz for pointers w/ bad (unmapped) addresses
|
||||||
//
|
//
|
||||||
//- namespace/locations/variables RDI pass
|
//- namespace/locations/variables RDI pass
|
||||||
// [ ] RDI_Local, RDI_GlobalVariable, RDI_ThreadVariable -> RDI_Variable
|
// [x] RDI_Local, RDI_GlobalVariable, RDI_ThreadVariable -> RDI_Variable
|
||||||
// [ ] RDI_Variable gets RDI_ContainerFlags, and a container_idx
|
// [x] RDI_Variable gets RDI_ContainerFlags, and a container_idx
|
||||||
// [ ] RDI_Namespace can be a container, same as types/procedures
|
// [x] RDI_Namespace can be a container, same as types/procedures
|
||||||
// [ ] If procedure-contained, then index goes to scope now, not procedure
|
// [x] If procedure-contained, then index goes to scope now, not procedure
|
||||||
// [ ] Location sections -> split by location kind, fixed tables for simple locations, one catch-all table for bytecode.
|
// [x] Location sections -> split by location kind, fixed tables for simple locations, one catch-all table for bytecode.
|
||||||
// [ ] Location kind -> can be thread-local offset, or module virtual offset, to enclose globals/tlocals cases
|
// [x] Location kind -> can be thread-local offset, or module virtual offset, to enclose globals/tlocals cases
|
||||||
// [ ] Referring to one location -> kind * index
|
// [x] Referring to one location -> kind * index
|
||||||
// [ ] Referring to many locations, based on scope offsets -> kind = BlockList; BlockList encodes a first/opl pair into Block table, each Block has scope_off_first/opl, location_kind, location_idx - but a block's location kind CANNOT BE BlockList
|
// [x] Referring to many locations, based on scope offsets -> kind = BlockList; BlockList encodes a first/opl pair into Block table, each Block has scope_off_first/opl, location_kind, location_idx - but a block's location kind CANNOT BE BlockList
|
||||||
// [ ] RDI_Variable has location_kind, location_idx
|
// [x] RDI_Variable has location_kind, location_idx
|
||||||
|
//
|
||||||
|
// [ ] we keep flat tables of symbols, *but*, "sort" by containing unit. unit -> [f, opl) of procedures, globals, threadvars, constants, etc.
|
||||||
|
// [ ] container can also be a unit, so you can also go from procedure/global/tvar -> unit
|
||||||
|
//
|
||||||
// [ ] symbols only store their *partly-qualified name*, e.g. `x` for A::B::C::x
|
// [ ] symbols only store their *partly-qualified name*, e.g. `x` for A::B::C::x
|
||||||
// [ ] default name maps look up *partly-qualified names*
|
// [ ] default name maps look up *partly-qualified names*
|
||||||
// [ ] to match a *fully qualified name*, there needs to be a second kind of different lookup - instead of string-matching, we need to match against the *fully qualified names*. the maps must be built by hashing the *fully qualified name*, but redirecting to the symbol with the *partially qualified name*. this is to allow fully-qualified lookups, but avoid storing fully-qualified names.
|
// [ ] to match a *fully qualified name*, there needs to be a second kind of different lookup - instead of string-matching, we need to match against the *fully qualified names*. the maps must be built by hashing the *fully qualified name*, but redirecting to the symbol with the *partially qualified name*. this is to allow fully-qualified lookups, but avoid storing fully-qualified names.
|
||||||
|
|||||||
+4
-3
@@ -992,9 +992,10 @@ RDI_EnumMemberTable:
|
|||||||
@table(name value)
|
@table(name value)
|
||||||
RDI_ContainerKindTable:
|
RDI_ContainerKindTable:
|
||||||
{
|
{
|
||||||
{Type 0x0}
|
{Unit 0x0}
|
||||||
{Scope 0x1}
|
{Type 0x1}
|
||||||
{Namespace 0x2}
|
{Scope 0x2}
|
||||||
|
{Namespace 0x3}
|
||||||
}
|
}
|
||||||
|
|
||||||
@table(name value)
|
@table(name value)
|
||||||
|
|||||||
@@ -1359,7 +1359,7 @@ d2r_locset_from_attrib(Arena *arena,
|
|||||||
for EachNode(loc_n, DW_LocNode, loclist.first) {
|
for EachNode(loc_n, DW_LocNode, loclist.first) {
|
||||||
RDIM_Location location = d2r_transpile_expression(arena, input, image_base, arch, cu->addr_lu, cu, loc_n->v.expr);
|
RDIM_Location location = d2r_transpile_expression(arena, input, image_base, 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_Rng1U64 voff_range = { .min = loc_n->v.range.min - image_base, .max = loc_n->v.range.max - image_base };
|
||||||
rdim_push_location_case(arena, scopes, &locset, &location, voff_range);
|
rdim_location_case_list_push(arena, &locset, location, voff_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
@@ -1370,7 +1370,7 @@ d2r_locset_from_attrib(Arena *arena,
|
|||||||
// convert expression and inherit life-time ranges from enclosed scope
|
// convert expression and inherit life-time ranges from enclosed scope
|
||||||
RDIM_Location location = d2r_transpile_expression(arena, input, image_base, arch, cu->addr_lu, cu, expr);
|
RDIM_Location location = d2r_transpile_expression(arena, input, image_base, arch, cu->addr_lu, cu, expr);
|
||||||
for EachNode(range_n, RDIM_Rng1U64Node, curr_scope->voff_ranges.first) {
|
for EachNode(range_n, RDIM_Rng1U64Node, curr_scope->voff_ranges.first) {
|
||||||
rdim_push_location_case(arena, scopes, &locset, &location, range_n->v);
|
rdim_location_case_list_push(arena, &locset, location, range_n->v);
|
||||||
}
|
}
|
||||||
} else if (attrib_class != DW_AttribClass_Null) {
|
} else if (attrib_class != DW_AttribClass_Null) {
|
||||||
log_user_errorf("unexpected attrib class @ .debug_info+%llx", tag.info_off);
|
log_user_errorf("unexpected attrib class @ .debug_info+%llx", tag.info_off);
|
||||||
@@ -1414,7 +1414,7 @@ d2r_var_locset_from_tag(Arena *arena,
|
|||||||
|
|
||||||
// push location cases
|
// push location cases
|
||||||
for EachNode(range_n, RDIM_Rng1U64Node, curr_scope->voff_ranges.first) {
|
for EachNode(range_n, RDIM_Rng1U64Node, curr_scope->voff_ranges.first) {
|
||||||
rdim_push_location_case(arena, scopes, &locset, &loc, range_n->v);
|
rdim_location_case_list_push(arena, &locset, loc, range_n->v);
|
||||||
}
|
}
|
||||||
} else if (has_location) {
|
} else if (has_location) {
|
||||||
locset = d2r_locset_from_attrib(arena, scopes, curr_scope, input, cu, image_base, arch, tag, DW_AttribKind_Location);
|
locset = d2r_locset_from_attrib(arena, scopes, curr_scope, input, cu, image_base, arch, tag, DW_AttribKind_Location);
|
||||||
@@ -2468,8 +2468,7 @@ d2r_convert_symbols(Arena *arena,
|
|||||||
parent_tag.kind == DW_TagKind_InlinedSubroutine ||
|
parent_tag.kind == DW_TagKind_InlinedSubroutine ||
|
||||||
parent_tag.kind == DW_TagKind_LexicalBlock) {
|
parent_tag.kind == DW_TagKind_LexicalBlock) {
|
||||||
RDIM_Scope *scope = it->stack->next->scope;
|
RDIM_Scope *scope = it->stack->next->scope;
|
||||||
RDIM_Local *local = rdim_scope_push_local(arena, &g_d2r_shared.scopes, scope);
|
RDIM_Symbol *local = rdim_symbol_chunk_list_push(arena, &scope->locals, 8);
|
||||||
local->kind = RDI_LocalKind_Variable;
|
|
||||||
local->name = name;
|
local->name = name;
|
||||||
local->type = type;
|
local->type = type;
|
||||||
local->location_cases = d2r_var_locset_from_tag(arena, &g_d2r_shared.scopes, scope, input, cu, image_base, arch, tag);
|
local->location_cases = d2r_var_locset_from_tag(arena, &g_d2r_shared.scopes, scope, input, cu, image_base, arch, tag);
|
||||||
@@ -2531,8 +2530,8 @@ d2r_convert_symbols(Arena *arena,
|
|||||||
DW_Tag parent_tag = d2r_tag_iterator_parent_tag(it);
|
DW_Tag parent_tag = d2r_tag_iterator_parent_tag(it);
|
||||||
if (parent_tag.kind == DW_TagKind_SubProgram || parent_tag.kind == DW_TagKind_InlinedSubroutine) {
|
if (parent_tag.kind == DW_TagKind_SubProgram || parent_tag.kind == DW_TagKind_InlinedSubroutine) {
|
||||||
RDIM_Scope *scope = it->stack->next->scope;
|
RDIM_Scope *scope = it->stack->next->scope;
|
||||||
RDIM_Local *param = rdim_scope_push_local(arena, &g_d2r_shared.scopes, scope);
|
RDIM_Symbol *param = rdim_symbol_chunk_list_push(arena, &scope->locals, 4);
|
||||||
param->kind = RDI_LocalKind_Parameter;
|
param->is_param = 1;
|
||||||
param->name = dw_string_from_tag_attrib_kind(input, cu, tag, DW_AttribKind_Name);
|
param->name = dw_string_from_tag_attrib_kind(input, cu, tag, DW_AttribKind_Name);
|
||||||
param->type = d2r_type_from_attrib(type_table, input, cu, tag, DW_AttribKind_Type);
|
param->type = d2r_type_from_attrib(type_table, input, cu, tag, DW_AttribKind_Type);
|
||||||
param->location_cases = d2r_var_locset_from_tag(arena, &g_d2r_shared.scopes, scope, input, cu, image_base, arch, tag);
|
param->location_cases = d2r_var_locset_from_tag(arena, &g_d2r_shared.scopes, scope, input, cu, image_base, arch, tag);
|
||||||
|
|||||||
@@ -2980,7 +2980,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
|||||||
lane_sync();
|
lane_sync();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
//- rjf: @rdim_bake_stage bake scopes
|
//- rjf: @rdim_bake_stage bake scopes, gather locals
|
||||||
//
|
//
|
||||||
typedef struct BakedScopes BakedScopes;
|
typedef struct BakedScopes BakedScopes;
|
||||||
struct BakedScopes
|
struct BakedScopes
|
||||||
@@ -2989,8 +2989,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
|||||||
RDI_U64 scopes_count;
|
RDI_U64 scopes_count;
|
||||||
RDI_U64 *scope_voffs;
|
RDI_U64 *scope_voffs;
|
||||||
RDI_U64 scope_voffs_count;
|
RDI_U64 scope_voffs_count;
|
||||||
RDI_Symbol *locals;
|
RDIM_SymbolChunkList arranged_locals;
|
||||||
RDI_U64 locals_count;
|
|
||||||
};
|
};
|
||||||
BakedScopes *baked_scopes = 0;
|
BakedScopes *baked_scopes = 0;
|
||||||
ProfScope("bake scopes")
|
ProfScope("bake scopes")
|
||||||
@@ -3011,11 +3010,6 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
|||||||
baked_scopes->scope_voffs_count = params->scopes.scope_voff_count+1;
|
baked_scopes->scope_voffs_count = params->scopes.scope_voff_count+1;
|
||||||
baked_scopes->scope_voffs = push_array(arena, RDI_U64, baked_scopes->scope_voffs_count);
|
baked_scopes->scope_voffs = push_array(arena, RDI_U64, baked_scopes->scope_voffs_count);
|
||||||
}
|
}
|
||||||
if(lane_idx() == lane_from_task_idx(2))
|
|
||||||
{
|
|
||||||
baked_scopes->locals_count = params->scopes.local_count+1;
|
|
||||||
baked_scopes->locals = push_array(arena, RDI_Symbol, baked_scopes->locals_count);
|
|
||||||
}
|
|
||||||
lane_sync();
|
lane_sync();
|
||||||
|
|
||||||
//- rjf: wide fill
|
//- rjf: wide fill
|
||||||
@@ -3050,8 +3044,8 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
|||||||
for EachIndex(src_local_idx, src_local_n->count)
|
for EachIndex(src_local_idx, src_local_n->count)
|
||||||
{
|
{
|
||||||
RDIM_Symbol *src_local = &src_local_n->v[src_local_idx];
|
RDIM_Symbol *src_local = &src_local_n->v[src_local_idx];
|
||||||
RDI_Symbol *dst_local = &baked_scopes->locals[chunk_local_off];
|
|
||||||
#if 0
|
#if 0
|
||||||
|
RDI_Symbol *dst_local = &baked_scopes->locals[chunk_local_off];
|
||||||
dst_local->kind = src_local->kind;
|
dst_local->kind = src_local->kind;
|
||||||
dst_local->name_string_idx = rdim_bake_idx_from_string(bake_strings, src_local->name);
|
dst_local->name_string_idx = rdim_bake_idx_from_string(bake_strings, src_local->name);
|
||||||
dst_local->type_idx = (RDI_U32)rdim_idx_from_type(src_local->type); // TODO(rjf): @u64_to_u32
|
dst_local->type_idx = (RDI_U32)rdim_idx_from_type(src_local->type); // TODO(rjf): @u64_to_u32
|
||||||
@@ -3481,6 +3475,8 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
|||||||
U64 baked_procedures_count = 0;
|
U64 baked_procedures_count = 0;
|
||||||
RDI_Symbol *baked_constants = 0;
|
RDI_Symbol *baked_constants = 0;
|
||||||
U64 baked_constants_count = 0;
|
U64 baked_constants_count = 0;
|
||||||
|
RDI_Symbol *baked_locals = 0;
|
||||||
|
U64 baked_locals_count = 0;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
RDIM_SymbolChunkList *symbols;
|
RDIM_SymbolChunkList *symbols;
|
||||||
@@ -3493,6 +3489,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
|||||||
{¶ms->thread_variables, &baked_thread_variables, &baked_thread_variables_count},
|
{¶ms->thread_variables, &baked_thread_variables, &baked_thread_variables_count},
|
||||||
{¶ms->procedures, &baked_procedures, &baked_procedures_count},
|
{¶ms->procedures, &baked_procedures, &baked_procedures_count},
|
||||||
{¶ms->constants, &baked_constants, &baked_constants_count},
|
{¶ms->constants, &baked_constants, &baked_constants_count},
|
||||||
|
{&baked_scopes->arranged_locals, &baked_locals, &baked_locals_count},
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
@@ -3908,7 +3905,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
|||||||
Map(ThreadVariableSymbols, baked_thread_variables, baked_thread_variables_count);
|
Map(ThreadVariableSymbols, baked_thread_variables, baked_thread_variables_count);
|
||||||
Map(ConstantSymbols, baked_constants, baked_constants_count);
|
Map(ConstantSymbols, baked_constants, baked_constants_count);
|
||||||
Map(ProcedureSymbols, baked_procedures, baked_procedures_count);
|
Map(ProcedureSymbols, baked_procedures, baked_procedures_count);
|
||||||
// Map(LocalVariableSymbols, );
|
Map(LocalVariableSymbols, baked_locals, baked_locals_count);
|
||||||
Map(LocationsBytecodeData, baked_location_bytecode_data, baked_location_bytecode_data_size);
|
Map(LocationsBytecodeData, baked_location_bytecode_data, baked_location_bytecode_data_size);
|
||||||
Map(LocationsConstantData, baked_location_constant_data, baked_location_constant_data_size);
|
Map(LocationsConstantData, baked_location_constant_data, baked_location_constant_data_size);
|
||||||
Map(LocationsSetElements, baked_location_set_elements, baked_location_set_elements_count);
|
Map(LocationsSetElements, baked_location_set_elements, baked_location_set_elements_count);
|
||||||
|
|||||||
Reference in New Issue
Block a user