mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-14 12:59:41 -07:00
get debugger onto new location info & symbol format
This commit is contained in:
1 parent
6764e1281e
commit
881e19c842
29 files changed
+352
-1653
No files matched your search
@@ -2753,216 +2753,6 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: @rdim_bake_stage compute lane location block layout
|
||||
//
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
typedef struct LocLayout LocLayout;
|
||||
struct LocLayout
|
||||
{
|
||||
RDI_U64 *location_case_chunk_lane_counts; // [lane_count * (scope_chunk_count + procedure_chunk_count)
|
||||
RDI_U64 *location_case_chunk_lane_offs; // [lane_count * (scope_chunk_count + procedure_chunk_count)
|
||||
RDI_U64 total_location_case_count;
|
||||
};
|
||||
LocLayout *loc_layout = 0;
|
||||
U64 total_location_case_chunk_count = (all_scopes->chunk_count + params->procedures.chunk_count);
|
||||
ProfScope("compute lane location block layout")
|
||||
{
|
||||
// rjf: set up
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
loc_layout = push_array(scratch.arena, LocLayout, 1);
|
||||
loc_layout->location_case_chunk_lane_counts = push_array(arena, RDI_U64, lane_count() * total_location_case_chunk_count);
|
||||
loc_layout->location_case_chunk_lane_offs = push_array(arena, RDI_U64, lane_count() * total_location_case_chunk_count);
|
||||
}
|
||||
lane_sync_u64(&loc_layout, 0);
|
||||
|
||||
// rjf: per-chunk-lane count of location cases
|
||||
{
|
||||
// rjf: count location cases in scopes
|
||||
U64 chunk_idx = 0;
|
||||
for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first)
|
||||
{
|
||||
U64 slot_idx = lane_idx() * total_location_case_chunk_count + chunk_idx;
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(idx, range)
|
||||
{
|
||||
for EachNode(local, RDIM_Local, n->v[idx].first_local)
|
||||
{
|
||||
loc_layout->location_case_chunk_lane_counts[slot_idx] += local->location_cases.count;
|
||||
}
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
|
||||
// rjf: count location cases in procedures
|
||||
for EachNode(n, RDIM_SymbolChunkNode, params->procedures.first)
|
||||
{
|
||||
U64 slot_idx = lane_idx() * total_location_case_chunk_count + chunk_idx;
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(idx, range)
|
||||
{
|
||||
loc_layout->location_case_chunk_lane_counts[slot_idx] += n->v[idx].location_cases.count;
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
// rjf: lay out location case offsets
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
U64 chunk_idx = 0;
|
||||
U64 location_case_layout_off = 1;
|
||||
for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first)
|
||||
{
|
||||
for EachIndex(l_idx, lane_count())
|
||||
{
|
||||
U64 slot_idx = l_idx * total_location_case_chunk_count + chunk_idx;
|
||||
loc_layout->location_case_chunk_lane_offs[slot_idx] = location_case_layout_off;
|
||||
location_case_layout_off += loc_layout->location_case_chunk_lane_counts[slot_idx];
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
for EachNode(n, RDIM_SymbolChunkNode, params->procedures.first)
|
||||
{
|
||||
for EachIndex(l_idx, lane_count())
|
||||
{
|
||||
U64 slot_idx = l_idx * total_location_case_chunk_count + chunk_idx;
|
||||
loc_layout->location_case_chunk_lane_offs[slot_idx] = location_case_layout_off;
|
||||
location_case_layout_off += loc_layout->location_case_chunk_lane_counts[slot_idx];
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
loc_layout->total_location_case_count = location_case_layout_off;
|
||||
}
|
||||
}
|
||||
lane_sync();
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: @rdim_bake_stage bake location blocks
|
||||
//
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
RDIM_LocationBlockBakeResult *baked_location_blocks = 0;
|
||||
ProfScope("bake location blocks")
|
||||
{
|
||||
// rjf: set up
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
baked_location_blocks = push_array(scratch.arena, RDIM_LocationBlockBakeResult, 1);
|
||||
baked_location_blocks->location_blocks_count = loc_layout->total_location_case_count;
|
||||
baked_location_blocks->location_blocks = push_array(arena, RDI_LocationBlock, baked_location_blocks->location_blocks_count);
|
||||
}
|
||||
lane_sync_u64(&baked_location_blocks, 0);
|
||||
|
||||
// rjf: wide fill from scopes
|
||||
U64 chunk_idx = 0;
|
||||
ProfScope("wide fill from scopes")
|
||||
{
|
||||
for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first)
|
||||
{
|
||||
U64 layout_slot_idx = lane_idx() * total_location_case_chunk_count + chunk_idx;
|
||||
U64 layout_off = loc_layout->location_case_chunk_lane_offs[layout_slot_idx];
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(idx, range)
|
||||
{
|
||||
for EachNode(local, RDIM_Local, n->v[idx].first_local)
|
||||
{
|
||||
for EachNode(src, RDIM_LocationCase, local->location_cases.first)
|
||||
{
|
||||
RDI_LocationBlock *dst = &baked_location_blocks->location_blocks[layout_off];
|
||||
dst->scope_off_first = (RDI_U32)src->voff_range.min; // TODO(rjf): @u64_to_u32
|
||||
dst->scope_off_opl = (RDI_U32)src->voff_range.max; // TODO(rjf): @u64_to_u32
|
||||
dst->location_data_off = (RDI_U32)rdim_off_from_location(src->location); // TODO(rjf): @u64_to_u32
|
||||
layout_off += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: wide fill from procedures
|
||||
ProfScope("wide fill from procedures")
|
||||
{
|
||||
for EachNode(n, RDIM_SymbolChunkNode, params->procedures.first)
|
||||
{
|
||||
U64 layout_slot_idx = lane_idx() * total_location_case_chunk_count + chunk_idx;
|
||||
U64 layout_off = loc_layout->location_case_chunk_lane_offs[layout_slot_idx];
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(idx, range)
|
||||
{
|
||||
for EachNode(src, RDIM_LocationCase, n->v[idx].location_cases.first)
|
||||
{
|
||||
RDI_LocationBlock *dst = &baked_location_blocks->location_blocks[layout_off];
|
||||
dst->scope_off_first = (RDI_U32)src->voff_range.min; // TODO(rjf): @u64_to_u32
|
||||
dst->scope_off_opl = (RDI_U32)src->voff_range.max; // TODO(rjf): @u64_to_u32
|
||||
dst->location_data_off = (RDI_U32)rdim_off_from_location(src->location); // TODO(rjf): @u64_to_u32
|
||||
layout_off += 1;
|
||||
}
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: @rdim_bake_stage bake locations (OLD)
|
||||
//
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
RDIM_LocationBakeResult *baked_locations = 0;
|
||||
ProfScope("bake locations")
|
||||
{
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
baked_locations = push_array(scratch.arena, RDIM_LocationBakeResult, 1);
|
||||
baked_locations->location_data_size = params->locations.total_encoded_size+1;
|
||||
baked_locations->location_data = push_array(arena, RDI_U8, baked_locations->location_data_size);
|
||||
}
|
||||
lane_sync_u64(&baked_locations, 0);
|
||||
for EachNode(n, RDIM_LocationChunkNode, params->locations.first)
|
||||
{
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(n_idx, range)
|
||||
{
|
||||
RDIM_Location *loc = &n->v[n_idx];
|
||||
RDI_U8 *dst = &baked_locations->location_data[n->base_encoding_off + loc->relative_encoding_off + 1];
|
||||
switch((RDI_LocationKindEnum)loc->info.kind)
|
||||
{
|
||||
case RDI_LocationKind_NULL:{}break;
|
||||
case RDI_LocationKind_AddrBytecodeStream:
|
||||
case RDI_LocationKind_ValBytecodeStream:
|
||||
{
|
||||
MemoryCopy(dst+0, &loc->info.kind, sizeof(loc->info.kind));
|
||||
RDI_U64 write_off = sizeof(loc->info.kind);
|
||||
for EachNode(op_node, RDIM_EvalBytecodeOp, loc->info.bytecode.first_op)
|
||||
{
|
||||
MemoryCopy(dst + write_off, &op_node->op, 1);
|
||||
write_off += 1;
|
||||
MemoryCopy(dst + write_off, &op_node->p, op_node->p_size);
|
||||
write_off += op_node->p_size;
|
||||
}
|
||||
dst[write_off] = 0;
|
||||
}break;
|
||||
case RDI_LocationKind_AddrRegPlusU16:
|
||||
case RDI_LocationKind_AddrAddrRegPlusU16:
|
||||
{
|
||||
RDI_LocationRegPlusU16 baked = {loc->info.kind, loc->info.reg_code, loc->info.offset};
|
||||
MemoryCopy(dst, &baked, sizeof(baked));
|
||||
}break;
|
||||
case RDI_LocationKind_ValReg:
|
||||
{
|
||||
RDI_LocationReg baked = {loc->info.kind, loc->info.reg_code};
|
||||
MemoryCopy(dst, &baked, sizeof(baked));
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: @rdim_bake_stage compute layout for scope sub-lists (locals / voffs)
|
||||
//
|
||||
@@ -3150,178 +2940,6 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
||||
}
|
||||
lane_sync_u64(&all_locals, 0);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: @rdim_bake_stage bake procedures
|
||||
//
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
RDIM_ProcedureBakeResult *baked_procedures = 0;
|
||||
ProfScope("bake procedures")
|
||||
{
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
baked_procedures = push_array(scratch.arena, RDIM_ProcedureBakeResult, 1);
|
||||
baked_procedures->procedures_count = params->procedures.total_count+1;
|
||||
baked_procedures->procedures = push_array(arena, RDI_Procedure, baked_procedures->procedures_count);
|
||||
}
|
||||
lane_sync_u64(&baked_procedures, 0);
|
||||
{
|
||||
U64 chunk_idx = 0;
|
||||
for EachNode(n, RDIM_SymbolChunkNode, params->procedures.first)
|
||||
{
|
||||
U64 location_block_layout_slot_idx = lane_idx()*total_location_case_chunk_count + all_scopes->chunk_count + chunk_idx;
|
||||
U64 location_block_off = loc_layout->location_case_chunk_lane_offs[location_block_layout_slot_idx];
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(n_idx, range)
|
||||
{
|
||||
RDIM_Symbol *src = &n->v[n_idx];
|
||||
RDI_Procedure *dst = &baked_procedures->procedures[n->base_idx + n_idx + 1];
|
||||
dst->name_string_idx = rdim_bake_idx_from_string(bake_strings, src->name);
|
||||
dst->link_name_string_idx = rdim_bake_idx_from_string(bake_strings, src->link_name);
|
||||
if(src->is_extern)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_External;
|
||||
}
|
||||
if(src->container_type != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_TypeScoped;
|
||||
dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
else if(src->container_scope != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_ProcScoped;
|
||||
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_scope->symbol); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
|
||||
dst->root_scope_idx = (RDI_U32)rdim_idx_from_scope(src->root_scope); // TODO(rjf): @u64_to_u32
|
||||
if(src->location_cases.count != 0)
|
||||
{
|
||||
dst->frame_base_location_first = location_block_off;
|
||||
dst->frame_base_location_opl = location_block_off + src->location_cases.count;
|
||||
location_block_off += src->location_cases.count;
|
||||
}
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: @rdim_bake_stage compute layout for constant data
|
||||
//
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
typedef struct ConstantLayout ConstantLayout;
|
||||
struct ConstantLayout
|
||||
{
|
||||
RDI_U64 *constant_data_chunk_lane_counts; // [lane_count * constant_chunk_count]
|
||||
RDI_U64 *constant_data_chunk_lane_offs; // [lane_count * constant_chunk_count]
|
||||
};
|
||||
ConstantLayout *constant_layout = 0;
|
||||
ProfScope("compute layout for constant data")
|
||||
{
|
||||
// rjf: set up
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
constant_layout = push_array(scratch.arena, ConstantLayout, 1);
|
||||
constant_layout->constant_data_chunk_lane_counts = push_array(arena, U64, lane_count() * params->constants.chunk_count);
|
||||
constant_layout->constant_data_chunk_lane_offs = push_array(arena, U64, lane_count() * params->constants.chunk_count);
|
||||
}
|
||||
lane_sync_u64(&constant_layout, 0);
|
||||
|
||||
// rjf: count
|
||||
{
|
||||
U64 chunk_idx = 0;
|
||||
for EachNode(n, RDIM_SymbolChunkNode, params->constants.first)
|
||||
{
|
||||
U64 slot_idx = lane_idx()*params->constants.chunk_count + chunk_idx;
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(idx, range)
|
||||
{
|
||||
constant_layout->constant_data_chunk_lane_counts[slot_idx] += n->v[idx].value_data.size;
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
// rjf: layout
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
U64 chunk_idx = 0;
|
||||
U64 layout_off = 0;
|
||||
for EachNode(n, RDIM_SymbolChunkNode, params->constants.first)
|
||||
{
|
||||
for EachIndex(l_idx, lane_count())
|
||||
{
|
||||
U64 slot_idx = l_idx*params->constants.chunk_count + chunk_idx;
|
||||
constant_layout->constant_data_chunk_lane_offs[slot_idx] = layout_off;
|
||||
layout_off += constant_layout->constant_data_chunk_lane_counts[slot_idx];
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
lane_sync();
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: @rdim_bake_stage bake constants
|
||||
//
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
RDIM_ConstantsBakeResult *baked_constants = 0;
|
||||
ProfScope("bake constants")
|
||||
{
|
||||
// rjf: set up
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
baked_constants = push_array(scratch.arena, RDIM_ConstantsBakeResult, 1);
|
||||
}
|
||||
lane_sync_u64(&baked_constants, 0);
|
||||
if(lane_idx() == lane_from_task_idx(0))
|
||||
{
|
||||
baked_constants->constant_values_count = params->constants.total_count+1;
|
||||
baked_constants->constant_values = push_array(arena, RDI_U32, baked_constants->constant_values_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(1))
|
||||
{
|
||||
baked_constants->constant_value_data_size = params->constants.total_value_data_size;
|
||||
baked_constants->constant_value_data = push_array(arena, RDI_U8, baked_constants->constant_value_data_size);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(2))
|
||||
{
|
||||
baked_constants->constants_count = params->constants.total_count+1;
|
||||
baked_constants->constants = push_array(arena, RDI_Constant, baked_constants->constants_count);
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
// rjf: wide bake
|
||||
{
|
||||
U64 chunk_idx = 0;
|
||||
for EachNode(n, RDIM_SymbolChunkNode, params->constants.first)
|
||||
{
|
||||
U64 slot_idx = lane_idx()*params->constants.chunk_count + chunk_idx;
|
||||
U64 value_data_off = constant_layout->constant_data_chunk_lane_offs[slot_idx];
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(n_idx, range)
|
||||
{
|
||||
RDIM_Symbol *src = &n->v[n_idx];
|
||||
RDI_Constant *dst = &baked_constants->constants[1 + n->base_idx + n_idx];
|
||||
RDI_U32 *dst_value_off = &baked_constants->constant_values[1 + n->base_idx + n_idx];
|
||||
RDI_U8 *dst_value_data = baked_constants->constant_value_data + value_data_off;
|
||||
dst->name_string_idx = rdim_bake_idx_from_string(bake_strings, src->name);
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
|
||||
dst->constant_value_idx = 1 + n->base_idx + n_idx;
|
||||
dst_value_off[0] = (RDI_U32)value_data_off; // TODO(rjf): @u64_to_u32
|
||||
rdim_memcpy(dst_value_data, src->value_data.str, src->value_data.size);
|
||||
value_data_off += src->value_data.size;
|
||||
}
|
||||
chunk_idx += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
lane_sync();
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: @rdim_bake_stage bake units, types, inline sites
|
||||
//
|
||||
@@ -3463,72 +3081,6 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: bake global variables
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
ProfScope("bake global variables")
|
||||
{
|
||||
for EachNode(n, RDIM_SymbolChunkNode, params->global_variables.first)
|
||||
{
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(n_idx, range)
|
||||
{
|
||||
RDIM_Symbol *src = &n->v[n_idx];
|
||||
RDI_GlobalVariable *dst = &baked_global_variables->global_variables[n->base_idx + n_idx + 1];
|
||||
dst->name_string_idx = rdim_bake_idx_from_string(bake_strings, src->name);
|
||||
dst->voff = src->offset;
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
|
||||
if(src->is_extern)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_External;
|
||||
}
|
||||
if(src->container_type != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_TypeScoped;
|
||||
dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
else if(src->container_scope != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_ProcScoped;
|
||||
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_scope->symbol); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//- rjf: bake thread variables
|
||||
#if 0 // TODO(rjf): @locpass
|
||||
ProfScope("bake thread variables")
|
||||
{
|
||||
for EachNode(n, RDIM_SymbolChunkNode, params->thread_variables.first)
|
||||
{
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
for EachInRange(n_idx, range)
|
||||
{
|
||||
RDIM_Symbol *src = &n->v[n_idx];
|
||||
RDI_ThreadVariable *dst = &baked_thread_variables->thread_variables[n->base_idx + n_idx + 1];
|
||||
dst->name_string_idx = rdim_bake_idx_from_string(bake_strings, src->name);
|
||||
dst->tls_off = (RDI_U32)src->offset; // TODO(rjf): @u64_to_u32
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type);
|
||||
if(src->is_extern)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_External;
|
||||
}
|
||||
if(src->container_type != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_TypeScoped;
|
||||
dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
else if(src->container_scope != 0)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_ProcScoped;
|
||||
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_scope->symbol); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//- rjf: bake inline sites
|
||||
ProfScope("bake inline sites")
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user