mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-15 21:39:41 -07:00
checkpoint on new local baking
This commit is contained in:
1 parent
d68e19db8b
commit
abb0199936
5 files changed
+117
-32
No files matched your search
@@ -372,6 +372,41 @@ p2r_local_push_location_cases_over_lvar_addr_range(Arena *arena, RDIM_ScopeChunk
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
p2r_location_case_list_push_over_lvar_addr_range(Arena *arena, RDIM_LocationCaseList *loc_cases, RDIM_Location loc, CV_LvarAddrRange *range, COFF_SectionHeader *section, CV_LvarAddrGap *gaps, U64 gap_count)
|
||||
{
|
||||
//- rjf: extract range info
|
||||
U64 voff_first = 0;
|
||||
U64 voff_opl = 0;
|
||||
if(section != 0)
|
||||
{
|
||||
voff_first = section->voff + range->off;
|
||||
voff_opl = voff_first + range->len;
|
||||
}
|
||||
|
||||
//- rjf: emit location for ranges not coverd by gaps
|
||||
CV_LvarAddrGap *gap_ptr = gaps;
|
||||
U64 voff_cursor = voff_first;
|
||||
for(U64 i = 0; i < gap_count; i += 1, gap_ptr += 1)
|
||||
{
|
||||
U64 voff_gap_first = voff_first + gap_ptr->off;
|
||||
U64 voff_gap_opl = voff_gap_first + gap_ptr->len;
|
||||
if(voff_cursor < voff_gap_first)
|
||||
{
|
||||
RDIM_Rng1U64 voff_range = {voff_cursor, voff_gap_first};
|
||||
rdim_location_case_list_push(arena, loc_cases, loc, voff_range);
|
||||
}
|
||||
voff_cursor = voff_gap_opl;
|
||||
}
|
||||
|
||||
//- rjf: emit remaining range
|
||||
if(voff_cursor < voff_opl)
|
||||
{
|
||||
RDIM_Rng1U64 voff_range = {voff_cursor, voff_opl};
|
||||
rdim_location_case_list_push(arena, loc_cases, loc, voff_range);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Top-Level Conversion Entry Point
|
||||
|
||||
@@ -3344,8 +3379,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
//
|
||||
ProfScope("symbols pass 2: construct all symbols, given procedure frame info map")
|
||||
{
|
||||
RDIM_Local *defrange_target = 0;
|
||||
B32 defrange_target_is_param = 0;
|
||||
RDIM_Symbol *defrange_target = 0;
|
||||
U64 procedure_num = 0;
|
||||
U64 procedure_base_voff = 0;
|
||||
CV_ProcFlags proc_flags = 0;
|
||||
@@ -3376,7 +3410,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
SLLStackPush(free_scope_node, n);
|
||||
}
|
||||
defrange_target = 0;
|
||||
defrange_target_is_param = 0;
|
||||
}break;
|
||||
|
||||
//- rjf: BLOCK32
|
||||
@@ -3623,7 +3656,8 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
U32 var_off = regrel32->reg_off;
|
||||
|
||||
// rjf: determine if this is a parameter
|
||||
RDI_LocalKind local_kind = regrel_idx < curr_proc_symbol->type->count ? RDI_LocalKind_Parameter : RDI_LocalKind_Variable;
|
||||
B32 is_param = (regrel_idx < curr_proc_symbol->type->count);
|
||||
RDI_LocalKind local_kind = is_param ? RDI_LocalKind_Parameter : RDI_LocalKind_Variable;
|
||||
|
||||
// rjf: determine if we need an extra indirection to the value
|
||||
B32 extra_indirection_to_value = 0;
|
||||
@@ -3666,6 +3700,30 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: build local
|
||||
{
|
||||
RDIM_Scope *scope = top_scope_node->scope;
|
||||
RDIM_Symbol *local = rdim_symbol_chunk_list_push(arena, &scope->locals, 8);
|
||||
local->is_param = is_param;
|
||||
local->name = name;
|
||||
local->type = type;
|
||||
|
||||
// rjf: equip location info
|
||||
{
|
||||
// rjf: get raddbg register code
|
||||
RDI_RegCode reg_code = p2r_rdi_reg_code_from_cv_reg_code(arch, cv_reg);
|
||||
// TODO(rjf): real byte_size & byte_pos from cv_reg goes here
|
||||
U32 byte_size = 8;
|
||||
U32 byte_pos = 0;
|
||||
|
||||
// rjf: build location
|
||||
RDIM_Location loc = p2r_location_from_addr_reg_off(arena, arch, reg_code, byte_size, byte_pos, (S64)(S32)var_off, extra_indirection_to_value);
|
||||
RDIM_Rng1U64 voff_range = {0, max_U64};
|
||||
rdim_location_case_list_push(arena, &local->location_cases, loc, voff_range);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
// rjf: build local
|
||||
RDIM_Scope *scope = top_scope_node->scope;
|
||||
RDIM_Local *local = rdim_scope_push_local(arena, sym_scopes, scope);
|
||||
@@ -3686,6 +3744,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
RDIM_Rng1U64 voff_range = {0, max_U64};
|
||||
rdim_local_push_location_case(arena, sym_scopes, local, &loc, voff_range);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
regrel_idx += 1;
|
||||
@@ -3760,7 +3819,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
{
|
||||
// TODO(rjf): add global modification symbols
|
||||
defrange_target = 0;
|
||||
defrange_target_is_param = 0;
|
||||
}
|
||||
|
||||
// rjf: is not a global modification -> emit a local variable
|
||||
@@ -3773,16 +3831,26 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
local_kind = RDI_LocalKind_Parameter;
|
||||
}
|
||||
|
||||
// rjf: build local
|
||||
RDIM_Scope *scope = top_scope_node->scope;
|
||||
RDIM_Symbol *local = rdim_symbol_chunk_list_push(arena, &scope->locals, 8);
|
||||
{
|
||||
local->is_param = !!(slocal->flags & CV_LocalFlag_Param);
|
||||
local->name = name;
|
||||
local->type = type;
|
||||
}
|
||||
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
// rjf: build local
|
||||
RDIM_Scope *scope = top_scope_node->scope;
|
||||
RDIM_Local *local = rdim_scope_push_local(arena, sym_scopes, scope);
|
||||
local->kind = local_kind;
|
||||
local->name = name;
|
||||
local->type = type;
|
||||
#endif
|
||||
|
||||
// rjf: save defrange target, for subsequent defrange symbols
|
||||
defrange_target = local;
|
||||
defrange_target_is_param = (local_kind == RDI_LocalKind_Parameter);
|
||||
}
|
||||
}break;
|
||||
|
||||
@@ -3809,7 +3877,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
RDIM_Location loc = {RDI_LocationKind_ValReg, reg_code};
|
||||
|
||||
// rjf: emit locations over ranges
|
||||
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, &loc, range, range_section, gaps, gap_count);
|
||||
p2r_location_case_list_push_over_lvar_addr_range(arena, &defrange_target->location_cases, loc, range, range_section, gaps, gap_count);
|
||||
}break;
|
||||
|
||||
//- rjf: DEFRANGE_FRAMEPOINTER_REL
|
||||
@@ -3844,7 +3912,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
U64 gap_count = ((U8*)iter.opl - (U8*)gaps) / sizeof(*gaps);
|
||||
|
||||
// rjf: select frame pointer register
|
||||
CV_EncodedFramePtrReg encoded_fp_reg = cv_pick_fp_encoding(frameproc, defrange_target_is_param);
|
||||
CV_EncodedFramePtrReg encoded_fp_reg = cv_pick_fp_encoding(frameproc, defrange_target->is_param);
|
||||
RDI_RegCode fp_register_code = p2r_reg_code_from_arch_encoded_fp_reg(arch, encoded_fp_reg);
|
||||
|
||||
// rjf: build location
|
||||
@@ -3855,7 +3923,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
RDIM_Location location = p2r_location_from_addr_reg_off(arena, arch, fp_register_code, byte_size, byte_pos, var_off, extra_indirection);
|
||||
|
||||
// rjf: emit locations over ranges
|
||||
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, &location, range, range_section, gaps, gap_count);
|
||||
p2r_location_case_list_push_over_lvar_addr_range(arena, &defrange_target->location_cases, location, range, range_section, gaps, gap_count);
|
||||
}break;
|
||||
|
||||
//- rjf: DEFRANGE_SUBFIELD_REGISTER
|
||||
@@ -3887,7 +3955,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
RDIM_Location loc = {RDI_LocationKind_ValReg, reg_code};
|
||||
|
||||
// rjf: emit locations over ranges
|
||||
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, &loc, range, range_section, gaps, gap_count);
|
||||
p2r_location_case_list_push_over_lvar_addr_range(arena, &defrange_target->location_cases, loc, range, range_section, gaps, gap_count);
|
||||
}break;
|
||||
|
||||
//- rjf: DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE
|
||||
@@ -3916,7 +3984,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
|
||||
// rjf: unpack sym
|
||||
CV_SymDefrangeFramepointerRelFullScope *defrange_fprel_full_scope = (CV_SymDefrangeFramepointerRelFullScope*)iter.struct_base;
|
||||
CV_EncodedFramePtrReg encoded_fp_reg = cv_pick_fp_encoding(frameproc, defrange_target_is_param);
|
||||
CV_EncodedFramePtrReg encoded_fp_reg = cv_pick_fp_encoding(frameproc, defrange_target->is_param);
|
||||
RDI_RegCode fp_register_code = p2r_reg_code_from_arch_encoded_fp_reg(arch, encoded_fp_reg);
|
||||
|
||||
// rjf: build location
|
||||
@@ -3928,7 +3996,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
|
||||
// rjf: emit location over ranges
|
||||
RDIM_Rng1U64 voff_range = {0, max_U64};
|
||||
rdim_local_push_location_case(arena, sym_scopes, defrange_target, &loc, voff_range);
|
||||
rdim_location_case_list_push(arena, &defrange_target->location_cases, loc, voff_range);
|
||||
}break;
|
||||
|
||||
//- rjf: DEFRANGE_REGISTER_REL
|
||||
@@ -3959,7 +4027,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
RDIM_Location loc = p2r_location_from_addr_reg_off(arena, arch, reg_code, byte_size, byte_pos, var_off, extra_indirection_to_value);
|
||||
|
||||
// rjf: emit locations over ranges
|
||||
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, &loc, range, range_section, gaps, gap_count);
|
||||
p2r_location_case_list_push_over_lvar_addr_range(arena, &defrange_target->location_cases, loc, range, range_section, gaps, gap_count);
|
||||
}break;
|
||||
|
||||
//- rjf: FILESTATIC
|
||||
@@ -3970,7 +4038,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
RDIM_Type *type = p2r_type_ptr_from_itype(file_static->itype);
|
||||
// TODO(rjf): emit a global modifier symbol
|
||||
defrange_target = 0;
|
||||
defrange_target_is_param = 0;
|
||||
}break;
|
||||
|
||||
//- rjf: INLINESITE
|
||||
@@ -4103,7 +4170,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
SLLStackPush(free_scope_node, n);
|
||||
}
|
||||
defrange_target = 0;
|
||||
defrange_target_is_param = 0;
|
||||
}break;
|
||||
|
||||
//- rjf: CONSTANT
|
||||
|
||||
@@ -113,6 +113,7 @@ internal RDI_ChecksumKind p2r_rdi_from_cv_c13_checksum_kind(CV_C13ChecksumKind k
|
||||
internal RDI_RegCode p2r_reg_code_from_arch_encoded_fp_reg(RDI_Arch arch, CV_EncodedFramePtrReg encoded_reg);
|
||||
internal RDIM_Location p2r_location_from_addr_reg_off(Arena *arena, RDI_Arch arch, RDI_RegCode reg_code, U32 reg_byte_size, U32 reg_byte_pos, S64 offset, B32 extra_indirection);
|
||||
internal void p2r_local_push_location_cases_over_lvar_addr_range(Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Local *local, RDIM_Location *loc, CV_LvarAddrRange *range, COFF_SectionHeader *section, CV_LvarAddrGap *gaps, U64 gap_count);
|
||||
internal void p2r_location_case_list_push_over_lvar_addr_range(Arena *arena, RDIM_LocationCaseList *loc_cases, RDIM_Location loc, CV_LvarAddrRange *range, COFF_SectionHeader *section, CV_LvarAddrGap *gaps, U64 gap_count);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Top-Level Conversion Entry Point
|
||||
|
||||
Reference in new issue
Block a user