mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-02 20:18:12 +00:00
first pass at filesystem evaluation in eval system
This commit is contained in:
+48
-10
@@ -3729,13 +3729,51 @@ df_ctrl_last_stop_event(void)
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Context
|
||||
|
||||
internal DF_Entity *
|
||||
df_entity_from_eval_space(E_Space space)
|
||||
{
|
||||
DF_Entity *entity = &df_g_nil_entity;
|
||||
if(space.u64[0] == 0 && space.u64[1] != 0)
|
||||
{
|
||||
entity = (DF_Entity *)space.u64[1];
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
internal E_Space
|
||||
df_eval_space_from_entity(DF_Entity *entity)
|
||||
{
|
||||
E_Space space = {0};
|
||||
space.u64[1] = (U64)entity;
|
||||
return space;
|
||||
}
|
||||
|
||||
internal B32
|
||||
df_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
|
||||
{
|
||||
B32 result = 0;
|
||||
DF_Entity *entity = (DF_Entity *)space;
|
||||
DF_Entity *entity = df_entity_from_eval_space(space);
|
||||
switch(entity->kind)
|
||||
{
|
||||
//- rjf: nil-space -> fall back to file system
|
||||
case DF_EntityKind_Nil:
|
||||
{
|
||||
U128 key = space;
|
||||
U128 hash = hs_hash_from_key(key, 0);
|
||||
HS_Scope *scope = hs_scope_open();
|
||||
{
|
||||
String8 data = hs_data_from_hash(scope, hash);
|
||||
Rng1U64 legal_range = r1u64(0, data.size);
|
||||
Rng1U64 read_range = intersect_1u64(range, legal_range);
|
||||
if(read_range.min < read_range.max)
|
||||
{
|
||||
result = 1;
|
||||
MemoryCopy(out, data.str + read_range.min, dim_1u64(read_range));
|
||||
}
|
||||
}
|
||||
hs_scope_close(scope);
|
||||
}break;
|
||||
|
||||
//- rjf: default -> evaluating a debugger entity; read from entity POD evaluation
|
||||
default:
|
||||
{
|
||||
@@ -3799,7 +3837,7 @@ internal B32
|
||||
df_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range)
|
||||
{
|
||||
B32 result = 0;
|
||||
DF_Entity *entity = (DF_Entity *)space;
|
||||
DF_Entity *entity = df_entity_from_eval_space(space);
|
||||
switch(entity->kind)
|
||||
{
|
||||
//- rjf: default -> making commits to entity evaluation
|
||||
@@ -4307,8 +4345,8 @@ df_string_from_simple_typed_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
U64 min_digits = (radix == 16) ? type_byte_size*2 : 0;
|
||||
String8 upper64 = str8_from_u64(scratch.arena, eval.value.u128[0], radix, min_digits, digit_group_separator);
|
||||
String8 lower64 = str8_from_u64(scratch.arena, eval.value.u128[1], radix, min_digits, digit_group_separator);
|
||||
String8 upper64 = str8_from_u64(scratch.arena, eval.value.u128.u64[0], radix, min_digits, digit_group_separator);
|
||||
String8 lower64 = str8_from_u64(scratch.arena, eval.value.u128.u64[1], radix, min_digits, digit_group_separator);
|
||||
result = push_str8f(arena, "%S:%S", upper64, lower64);
|
||||
scratch_end(scratch);
|
||||
}break;
|
||||
@@ -5013,7 +5051,7 @@ df_expr_from_eval_viz_block_index(Arena *arena, DF_EvalVizBlock *block, U64 inde
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(module->rdi, Scopes, procedure->root_scope_idx);
|
||||
U64 voff = *rdi_element_from_name_idx(module->rdi, ScopeVOffData, scope->voff_range_first);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, e_value_u64(voff));
|
||||
String8 bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(module->rdi, TypeNodes, type_idx);
|
||||
@@ -5030,7 +5068,7 @@ df_expr_from_eval_viz_block_index(Arena *arena, DF_EvalVizBlock *block, U64 inde
|
||||
RDI_GlobalVariable *gvar = rdi_element_from_name_idx(module->rdi, GlobalVariables, element_idx);
|
||||
U64 voff = gvar->voff;
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, e_value_u64(voff));
|
||||
String8 bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = gvar->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(module->rdi, TypeNodes, type_idx);
|
||||
@@ -5046,7 +5084,7 @@ df_expr_from_eval_viz_block_index(Arena *arena, DF_EvalVizBlock *block, U64 inde
|
||||
{
|
||||
RDI_ThreadVariable *tvar = rdi_element_from_name_idx(module->rdi, ThreadVariables, element_idx);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, tvar->tls_off);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, e_value_u64(tvar->tls_off));
|
||||
String8 bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = tvar->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(module->rdi, TypeNodes, type_idx);
|
||||
@@ -8389,7 +8427,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
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);
|
||||
eval_modules[eval_module_idx].space = df_eval_space_from_entity(df_entity_ancestor_from_kind(m, DF_EntityKind_Process));
|
||||
if(module == m)
|
||||
{
|
||||
eval_modules_primary = &eval_modules[eval_module_idx];
|
||||
@@ -8435,7 +8473,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
E_ParseCtx *ctx = parse_ctx;
|
||||
ctx->ip_vaddr = rip_vaddr;
|
||||
ctx->ip_voff = rip_voff;
|
||||
ctx->ip_thread_space = (E_Space)thread;
|
||||
ctx->ip_thread_space = df_eval_space_from_entity(thread);
|
||||
ctx->modules = eval_modules;
|
||||
ctx->modules_count = eval_modules_count;
|
||||
ctx->primary_module = eval_modules_primary;
|
||||
@@ -8496,7 +8534,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
ctx->space_write = df_eval_space_write;
|
||||
ctx->primary_space = eval_modules_primary->space;
|
||||
ctx->reg_arch = eval_modules_primary->arch;
|
||||
ctx->reg_space = (E_Space)thread;
|
||||
ctx->reg_space = df_eval_space_from_entity(thread);
|
||||
ctx->reg_unwind_count = unwind_count;
|
||||
ctx->module_base = push_array(arena, U64, 1);
|
||||
ctx->module_base[0] = module->vaddr_rng.min;
|
||||
|
||||
@@ -1573,6 +1573,8 @@ internal CTRL_Event df_ctrl_last_stop_event(void);
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Context
|
||||
|
||||
internal DF_Entity *df_entity_from_eval_space(E_Space space);
|
||||
internal E_Space df_eval_space_from_entity(DF_Entity *entity);
|
||||
internal B32 df_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range);
|
||||
internal B32 df_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range);
|
||||
internal E_Eval df_eval_from_eval_cfg_table(Arena *arena, E_Eval eval, DF_CfgTable *cfg);
|
||||
|
||||
+2
-3
@@ -6135,7 +6135,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
DF_ExpandKey parent_key = df_expand_key_make(5381, 1);
|
||||
DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(parent_key), 1);
|
||||
DF_EvalVizBlockList viz_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, &top_level_cfg_table, expr, parent_key, key);
|
||||
DF_Entity *entity = eval.space ? (DF_Entity *)eval.space : &df_g_nil_entity;
|
||||
DF_Entity *entity = df_entity_from_eval_space(eval.space);
|
||||
U32 default_radix = (entity->kind == DF_EntityKind_Thread ? 16 : 10);
|
||||
DF_EvalVizWindowedRowList viz_rows = df_eval_viz_windowed_row_list_from_viz_block_list(scratch.arena, eval_view, r1s64(0, 50), &viz_blocks);
|
||||
|
||||
@@ -6241,9 +6241,8 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
{
|
||||
default:{}break;
|
||||
case E_Mode_Offset:
|
||||
if(row_eval.space >= E_Space_FIXED_COUNT)
|
||||
{
|
||||
DF_Entity *space_entity = (DF_Entity *)row_eval.space;
|
||||
DF_Entity *space_entity = df_entity_from_eval_space(row_eval.space);
|
||||
if(space_entity->kind == DF_EntityKind_Process)
|
||||
{
|
||||
U64 size = e_type_byte_size_from_key(row_eval.type_key);
|
||||
|
||||
@@ -1527,7 +1527,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
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;
|
||||
bp_expr->space = (U64)bp;
|
||||
bp_expr->space = df_eval_space_from_entity(bp);
|
||||
df_append_viz_blocks_for_parent__rec(scratch.arena, eval_view, parent_key, key, title, bp_expr, &top_level_cfg_table, 0, &blocks);
|
||||
}
|
||||
}
|
||||
@@ -1562,7 +1562,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
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;
|
||||
wp_expr->space = (U64)wp;
|
||||
wp_expr->space = df_eval_space_from_entity(wp);
|
||||
df_append_viz_blocks_for_parent__rec(scratch.arena, eval_view, parent_key, key, title, wp_expr, &top_level_cfg_table, 0, &blocks);
|
||||
}
|
||||
}
|
||||
@@ -1625,12 +1625,12 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
}
|
||||
U64 row_vaddr = regs_rip_from_arch_block(arch, row->regs);
|
||||
E_OpList ops = {0};
|
||||
e_oplist_push_op(scratch.arena, &ops, RDI_EvalOp_ConstU64, row_vaddr);
|
||||
e_oplist_push_op(scratch.arena, &ops, RDI_EvalOp_ConstU64, e_value_u64(row_vaddr));
|
||||
String8 bytecode = e_bytecode_from_oplist(scratch.arena, &ops);
|
||||
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafBytecode, 0);
|
||||
expr->bytecode = bytecode;
|
||||
expr->mode = E_Mode_Value;
|
||||
expr->space = (U64)process;
|
||||
expr->space = df_eval_space_from_entity(process);
|
||||
expr->type_key = type_key;
|
||||
block->expr = expr;
|
||||
block->visual_idx_range = r1u64(row_idx, row_idx+1);
|
||||
@@ -2657,9 +2657,8 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
{
|
||||
default:{}break;
|
||||
case E_Mode_Offset:
|
||||
if(row_eval.space >= E_Space_FIXED_COUNT)
|
||||
{
|
||||
DF_Entity *space_entity = (DF_Entity *)row_eval.space;
|
||||
DF_Entity *space_entity = df_entity_from_eval_space(row_eval.space);
|
||||
if(space_entity->kind == DF_EntityKind_Process)
|
||||
{
|
||||
U64 size = e_type_byte_size_from_key(row_eval.type_key);
|
||||
@@ -3215,7 +3214,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
case E_IRExtKind_Bytecode:{ext = str8_lit("[bytecode]");}break;
|
||||
default:
|
||||
{
|
||||
ext = str8_from_u64(scratch.arena, op->u64, 16, 0, 0);
|
||||
ext = str8_from_u64(scratch.arena, op->value.u64, 16, 0, 0);
|
||||
}break;
|
||||
}
|
||||
ui_labelf(" %S%s%S", op_string, ext.size ? " " : "", ext);
|
||||
|
||||
Reference in New Issue
Block a user