eliminate eval assumption of single architecture; equip each eval module with an architecture; use to correctly specify the debugger process architecture; do initial pass of debugger space evaluation

This commit is contained in:
Ryan Fleury
2024-08-21 12:55:50 -07:00
parent 1ec62b40ae
commit 1848acd47e
14 changed files with 114 additions and 57 deletions
+45 -9
View File
@@ -1411,6 +1411,32 @@ df_parent_expand_key_from_entity(DF_Entity *entity)
return parent_key;
}
//- rjf: entity -> evaluation
internal DF_EntityEval *
df_eval_from_entity(Arena *arena, DF_Entity *entity)
{
DF_EntityEval *eval = push_array(arena, DF_EntityEval, 1);
{
DF_Entity *loc = df_entity_child_from_kind(entity, DF_EntityKind_Location);
String8 label_string = push_str8_copy(arena, entity->name);
String8 loc_string = {0};
if(loc->flags & DF_EntityFlag_HasTextPoint)
{
loc_string = push_str8f(arena, "%S:%I64u:%I64u", loc->name, loc->text_point.line, loc->text_point.column);
}
else if(loc->flags & DF_EntityFlag_HasVAddr)
{
loc_string = push_str8f(arena, "0x%I64x", loc->vaddr);
}
eval->enabled = !entity->disabled;
eval->hit_count = entity->u64;
eval->label_off = (U64)((U8 *)label_string.str - (U8 *)eval);
eval->location_off = (U64)((U8 *)loc_string.str - (U8 *)eval);
}
return eval;
}
////////////////////////////////
//~ rjf: Name Allocation
@@ -3707,10 +3733,21 @@ df_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
DF_Entity *entity = (DF_Entity *)space;
switch(entity->kind)
{
default:{}break;
case DF_EntityKind_Breakpoint:
default:
{
// TODO(rjf)
Temp scratch = scratch_begin(0, 0);
arena_push(scratch.arena, 0, 64);
U64 pos_min = arena_pos(scratch.arena);
DF_EntityEval *eval = df_eval_from_entity(scratch.arena, entity);
U64 pos_opl = arena_pos(scratch.arena);
U64 off_min = 0;
U64 off_opl = pos_opl - pos_min;
if(off_min <= range.min && range.max <= off_opl)
{
result = 1;
MemoryCopy(out, (U8 *)eval + range.min, dim_1u64(range));
}
scratch_end(scratch);
}break;
case DF_EntityKind_Process:
{
@@ -8322,6 +8359,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
{
DF_Entity *m = n->entity;
DI_Key dbgi_key = df_dbgi_key_from_module(m);
eval_modules[eval_module_idx].arch = df_architecture_from_entity(m);
eval_modules[eval_module_idx].rdi = di_rdi_from_key(df_state->frame_di_scope, &dbgi_key, 0);
eval_modules[eval_module_idx].vaddr_range = m->vaddr_rng;
eval_modules[eval_module_idx].space = (U64)df_entity_ancestor_from_kind(m, DF_EntityKind_Process);
@@ -8355,7 +8393,6 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
E_TypeCtx *type_ctx = push_array(arena, E_TypeCtx, 1);
{
E_TypeCtx *ctx = type_ctx;
ctx->arch = arch;
ctx->ip_vaddr = rip_vaddr;
ctx->ip_voff = rip_voff;
ctx->modules = eval_modules;
@@ -8369,14 +8406,13 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
ProfScope("build eval parse context")
{
E_ParseCtx *ctx = parse_ctx;
ctx->arch = arch;
ctx->ip_vaddr = rip_vaddr;
ctx->ip_voff = rip_voff;
ctx->modules = eval_modules;
ctx->modules_count = eval_modules_count;
ctx->primary_module = eval_modules_primary;
ctx->regs_map = ctrl_string2reg_from_arch(ctx->arch);
ctx->reg_alias_map = ctrl_string2alias_from_arch(ctx->arch);
ctx->regs_map = ctrl_string2reg_from_arch(ctx->primary_module->arch);
ctx->reg_alias_map = ctrl_string2alias_from_arch(ctx->primary_module->arch);
ctx->locals_map = df_query_cached_locals_map_from_dbgi_key_voff(&primary_dbgi_key, rip_voff);
ctx->member_map = df_query_cached_member_map_from_dbgi_key_voff(&primary_dbgi_key, rip_voff);
}
@@ -8428,11 +8464,11 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
E_InterpretCtx *interpret_ctx = push_array(arena, E_InterpretCtx, 1);
{
E_InterpretCtx *ctx = interpret_ctx;
ctx->arch = arch;
ctx->space_read_user_data = process;
ctx->space_read = df_eval_space_read;
ctx->primary_space = eval_modules_primary->space;
ctx->reg_size = regs_block_size_from_architecture(ctx->arch);
ctx->reg_arch = eval_modules_primary->arch;
ctx->reg_size = regs_block_size_from_architecture(eval_modules_primary->arch);
ctx->reg_data = push_array(arena, U8, ctx->reg_size);
ctx->module_base = push_array(arena, U64, 1);
ctx->module_base[0]= module->vaddr_rng.min;
+15
View File
@@ -400,6 +400,18 @@ struct DF_EntityRec
S32 pop_count;
};
////////////////////////////////
//~ rjf: Entity Evaluation Types
typedef struct DF_EntityEval DF_EntityEval;
struct DF_EntityEval
{
B64 enabled;
U64 hit_count;
U64 label_off;
U64 location_off;
};
////////////////////////////////
//~ rjf: Entity Fuzzy Listing Types
@@ -1413,6 +1425,9 @@ internal Vec4F32 df_rgba_from_entity(DF_Entity *entity);
internal DF_ExpandKey df_expand_key_from_entity(DF_Entity *entity);
internal DF_ExpandKey df_parent_expand_key_from_entity(DF_Entity *entity);
//- rjf: entity -> evaluation
internal DF_EntityEval *df_eval_from_entity(Arena *arena, DF_Entity *entity);
////////////////////////////////
//~ rjf: Name Allocation
+1 -1
View File
@@ -199,7 +199,7 @@ DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(array)
// rjf: apply array size to type
E_TypeKey pointee = e_type_ptee_from_key(type_key);
E_TypeKey array_type = e_type_key_cons_array(pointee, array_size);
eval.type_key = e_type_key_cons_ptr(array_type);
eval.type_key = e_type_key_cons_ptr(e_type_state->ctx->primary_module->arch, array_type);
}
}
scratch_end(scratch);
+5 -5
View File
@@ -1502,13 +1502,13 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
{
E_MemberList bp_members = {0};
{
e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Disabled"), .off = 0, .type_key = e_type_key_basic(E_TypeKind_S64));
e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Enabled"), .off = 0, .type_key = e_type_key_basic(E_TypeKind_S64));
e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Hit Count"),.off = 0+8, .type_key = e_type_key_basic(E_TypeKind_U64));
e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Label"), .off = 0+8+8, .type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_Char8), 256));
e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Location"), .off = 0+8+8+8, .type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_Char8), 256));
e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Label"), .off = 0+8+8, .type_key = e_type_key_cons_ptr(architecture_from_context(), e_type_key_basic(E_TypeKind_Char8)));
e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Location"), .off = 0+8+8+8, .type_key = e_type_key_cons_ptr(architecture_from_context(), e_type_key_basic(E_TypeKind_Char8)));
}
E_MemberArray bp_members_array = e_member_array_from_list(scratch.arena, &bp_members);
E_TypeKey bp_type = e_type_key_cons(.kind = E_TypeKind_Struct, .name = str8_lit("Breakpoint"), .members = bp_members_array.v, .count = bp_members_array.count);
E_TypeKey bp_type = e_type_key_cons(.arch = architecture_from_context(), .kind = E_TypeKind_Struct, .name = str8_lit("Breakpoint"), .members = bp_members_array.v, .count = bp_members_array.count);
E_Expr *bp_expr = e_push_expr(scratch.arena, E_ExprKind_LeafID, 0);
bp_expr->type_key = bp_type;
bp_expr->mode = E_Mode_Offset;
@@ -1544,7 +1544,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
e_member_list_push_new(scratch.arena, &wp_members, .name = str8_lit("Location"), .off = 0, .type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_Char8), 256));
}
E_MemberArray wp_members_array = e_member_array_from_list(scratch.arena, &wp_members);
E_TypeKey wp_type = e_type_key_cons(.kind = E_TypeKind_Struct, .name = str8_lit("Watch Pin"), .members = wp_members_array.v, .count = wp_members_array.count);
E_TypeKey wp_type = e_type_key_cons(.arch = architecture_from_context(), .kind = E_TypeKind_Struct, .name = str8_lit("Watch Pin"), .members = wp_members_array.v, .count = wp_members_array.count);
E_Expr *wp_expr = e_push_expr(scratch.arena, E_ExprKind_LeafID, 0);
wp_expr->type_key = wp_type;
wp_expr->mode = E_Mode_Offset;