mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 05:18:40 +00:00
further work on convergence, dead code elimination, and lens (view rule) calls
This commit is contained in:
+31
-23
@@ -9619,10 +9619,18 @@ rd_value_string_from_eval_NEW(Arena *arena, String8 filter, EV_StringParams *par
|
||||
{
|
||||
EV_StringIter *iter = ev_string_iter_begin(scratch.arena, eval, params);
|
||||
F32 space_taken_px = 0;
|
||||
for(String8 string = {0}; ev_string_iter_next(scratch.arena, iter, &string) && space_taken_px < max_size;)
|
||||
for(String8 string = {0}; ev_string_iter_next(scratch.arena, iter, &string);)
|
||||
{
|
||||
str8_list_push(scratch.arena, &strs, string);
|
||||
space_taken_px += fnt_dim_from_tag_size_string(font, font_size, 0, 0, string).x;
|
||||
if(space_taken_px > max_size)
|
||||
{
|
||||
str8_list_push(scratch.arena, &strs, str8_lit("..."));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
str8_list_push(scratch.arena, &strs, string);
|
||||
space_taken_px += fnt_dim_from_tag_size_string(font, font_size, 0, 0, string).x;
|
||||
}
|
||||
}
|
||||
}
|
||||
String8 result = str8_list_join(arena, &strs, 0);
|
||||
@@ -12272,12 +12280,6 @@ rd_frame(void)
|
||||
ctx->member_map = d_query_cached_member_map_from_dbgi_key_voff(&primary_dbgi_key, rip_voff);
|
||||
ctx->macro_map = push_array(scratch.arena, E_String2ExprMap, 1);
|
||||
ctx->macro_map[0] = e_string2expr_map_make(scratch.arena, 512);
|
||||
#if 0 // TODO(rjf): @eval
|
||||
ctx->lookup_rule_map = push_array(scratch.arena, E_LookupRuleMap, 1);
|
||||
ctx->lookup_rule_map[0] = e_lookup_rule_map_make(scratch.arena, 512);
|
||||
ctx->irgen_rule_map = push_array(scratch.arena, E_IRGenRuleMap, 1);
|
||||
ctx->irgen_rule_map[0] = e_irgen_rule_map_make(scratch.arena, 512);
|
||||
#endif
|
||||
ctx->auto_hook_map = push_array(scratch.arena, E_AutoHookMap, 1);
|
||||
ctx->auto_hook_map[0] = e_auto_hook_map_make(scratch.arena, 512);
|
||||
|
||||
@@ -12433,19 +12435,19 @@ rd_frame(void)
|
||||
|
||||
//- rjf: add types for queries
|
||||
{
|
||||
#if 0 // TODO(rjf): @eval
|
||||
e_string2typekey_map_insert(rd_frame_arena(), rd_state->meta_name2type_map, str8_lit("environment"),
|
||||
e_type_key_cons(.kind = E_TypeKind_Set,
|
||||
.name = str8_lit("environment"),
|
||||
.flags = E_TypeFlag_EditableChildren,
|
||||
.irgen = E_TYPE_IRGEN_FUNCTION_NAME(environment),
|
||||
.access = E_TYPE_ACCESS_FUNCTION_NAME(environment),
|
||||
.expand =
|
||||
{
|
||||
.info = E_LOOKUP_INFO_FUNCTION_NAME(environment),
|
||||
.range = E_LOOKUP_RANGE_FUNCTION_NAME(environment),
|
||||
.id_from_num = E_LOOKUP_ID_FROM_NUM_FUNCTION_NAME(environment),
|
||||
.num_from_id = E_LOOKUP_NUM_FROM_ID_FUNCTION_NAME(environment),
|
||||
.info = E_TYPE_EXPAND_INFO_FUNCTION_NAME(environment),
|
||||
.range = E_TYPE_EXPAND_RANGE_FUNCTION_NAME(environment),
|
||||
.id_from_num = E_TYPE_EXPAND_ID_FROM_NUM_FUNCTION_NAME(environment),
|
||||
.num_from_id = E_TYPE_EXPAND_NUM_FROM_ID_FUNCTION_NAME(environment),
|
||||
}));
|
||||
#endif
|
||||
e_string2typekey_map_insert(rd_frame_arena(),
|
||||
rd_state->meta_name2type_map,
|
||||
str8_lit("call_stack"),
|
||||
@@ -12555,20 +12557,21 @@ rd_frame(void)
|
||||
e_string2expr_map_insert(scratch.arena, ctx->macro_map, collection_name, expr);
|
||||
}
|
||||
|
||||
#if 0 // TODO(rjf): @eval
|
||||
//- rjf: add macro / lookup rules for unattached processes
|
||||
{
|
||||
String8 collection_name = str8_lit("unattached_processes");
|
||||
E_TypeKey collection_type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = collection_name);
|
||||
E_TypeKey collection_type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = collection_name,
|
||||
.expand =
|
||||
{
|
||||
.info = E_TYPE_EXPAND_INFO_FUNCTION_NAME(unattached_processes),
|
||||
.range = E_TYPE_EXPAND_RANGE_FUNCTION_NAME(unattached_processes)
|
||||
});
|
||||
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0);
|
||||
expr->type_key = collection_type_key;
|
||||
expr->space = e_space_make(RD_EvalSpaceKind_MetaCtrlEntity);
|
||||
e_string2expr_map_insert(scratch.arena, ctx->macro_map, collection_name, expr);
|
||||
e_lookup_rule_map_insert_new(scratch.arena, ctx->lookup_rule_map, str8_lit("unattached_processes"),
|
||||
.info = E_LOOKUP_INFO_FUNCTION_NAME(unattached_processes),
|
||||
.range = E_LOOKUP_RANGE_FUNCTION_NAME(unattached_processes));
|
||||
e_string2typekey_map_insert(rd_frame_arena(), rd_state->meta_name2type_map, collection_name, collection_type_key);
|
||||
}
|
||||
#endif
|
||||
|
||||
//- rjf: add macro for commands
|
||||
{
|
||||
@@ -12665,10 +12668,10 @@ rd_frame(void)
|
||||
e_select_ir_ctx(ir_ctx);
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: generate macros for all view ui rules
|
||||
//- rjf: generate macros for all view rules
|
||||
//
|
||||
{
|
||||
//- rjf: choose set of view ui rules
|
||||
//- rjf: choose set of view rules
|
||||
// TODO(rjf): generate via metaprogram
|
||||
struct
|
||||
{
|
||||
@@ -12678,6 +12681,11 @@ rd_frame(void)
|
||||
}
|
||||
view_ui_rule_table[] =
|
||||
{
|
||||
{str8_lit("bin")},
|
||||
{str8_lit("oct")},
|
||||
{str8_lit("dec")},
|
||||
{str8_lit("hex")},
|
||||
{str8_lit("digits")},
|
||||
{str8_lit("text"), RD_VIEW_UI_FUNCTION_NAME(text), EV_EXPAND_RULE_INFO_FUNCTION_NAME(text)},
|
||||
{str8_lit("disasm"), RD_VIEW_UI_FUNCTION_NAME(disasm), EV_EXPAND_RULE_INFO_FUNCTION_NAME(disasm)},
|
||||
{str8_lit("memory"), RD_VIEW_UI_FUNCTION_NAME(memory), EV_EXPAND_RULE_INFO_FUNCTION_NAME(memory)},
|
||||
|
||||
+63
-58
@@ -765,44 +765,26 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(call_stack)
|
||||
return result;
|
||||
}
|
||||
|
||||
#if 0 // TODO(rjf): @eval
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: `environment` Type Hooks
|
||||
|
||||
E_TYPE_ACCESS_FUNCTION_DEF(environment)
|
||||
typedef struct RD_EnvironmentAccel RD_EnvironmentAccel;
|
||||
struct RD_EnvironmentAccel
|
||||
{
|
||||
E_LookupAccess result = {{&e_irnode_nil}};
|
||||
if(kind == E_ExprKind_ArrayIndex)
|
||||
RD_CfgArray cfgs;
|
||||
};
|
||||
|
||||
E_TYPE_IRGEN_FUNCTION_DEF(environment)
|
||||
{
|
||||
E_IRTreeAndType result = *irtree;
|
||||
RD_EnvironmentAccel *accel = push_array(arena, RD_EnvironmentAccel, 1);
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
RD_CfgArray *cfgs = (RD_CfgArray *)user_data;
|
||||
E_IRTreeAndType rhs_irtree = e_irtree_and_type_from_expr(scratch.arena, rhs);
|
||||
E_OpList rhs_oplist = e_oplist_from_irtree(scratch.arena, rhs_irtree.root);
|
||||
String8 rhs_bytecode = e_bytecode_from_oplist(scratch.arena, &rhs_oplist);
|
||||
E_Interpretation rhs_interp = e_interpret(rhs_bytecode);
|
||||
E_Value rhs_value = rhs_interp.value;
|
||||
if(0 <= rhs_value.u64 && rhs_value.u64 < cfgs->count)
|
||||
{
|
||||
RD_Cfg *cfg = cfgs->v[rhs_value.u64];
|
||||
result.irtree_and_type.root = e_irtree_set_space(arena, rd_eval_space_from_cfg(cfg), e_irtree_const_u(arena, 0));
|
||||
result.irtree_and_type.type_key = e_type_key_cons_ptr(arch_from_context(), e_type_key_basic(E_TypeKind_U8), 1, E_TypeFlag_IsCodeText);
|
||||
result.irtree_and_type.mode = E_Mode_Offset;
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_INFO_FUNCTION_DEF(environment)
|
||||
{
|
||||
E_TypeExpandInfo result = {0};
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
{
|
||||
E_OpList oplist = e_oplist_from_irtree(scratch.arena, lhs->root);
|
||||
E_OpList oplist = e_oplist_from_irtree(scratch.arena, irtree->root);
|
||||
String8 bytecode = e_bytecode_from_oplist(scratch.arena, &oplist);
|
||||
E_Interpretation interpret = e_interpret(bytecode);
|
||||
RD_Cfg *target = rd_cfg_from_eval_space(interpret.space);
|
||||
E_Space space = interpret.space;
|
||||
RD_Cfg *target = rd_cfg_from_eval_space(space);
|
||||
RD_CfgList env_strings = {0};
|
||||
for(RD_Cfg *child = target->first; child != &rd_nil_cfg; child = child->next)
|
||||
{
|
||||
@@ -811,57 +793,80 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(environment)
|
||||
rd_cfg_list_push(scratch.arena, &env_strings, child);
|
||||
}
|
||||
}
|
||||
RD_CfgArray *accel = push_array(arena, RD_CfgArray, 1);
|
||||
*accel = rd_cfg_array_from_list(arena, &env_strings);
|
||||
result.user_data = accel;
|
||||
result.idxed_expr_count = accel->count + 1;
|
||||
accel->cfgs = rd_cfg_array_from_list(arena, &env_strings);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
scratch_end(scratch);
|
||||
result.user_data = accel;
|
||||
return result;
|
||||
}
|
||||
|
||||
E_TYPE_ACCESS_FUNCTION_DEF(environment)
|
||||
{
|
||||
E_IRTreeAndType result = {&e_irnode_nil};
|
||||
if(expr->kind == E_ExprKind_ArrayIndex)
|
||||
{
|
||||
RD_EnvironmentAccel *accel = (RD_EnvironmentAccel *)lhs_irtree->user_data;
|
||||
RD_CfgArray *cfgs = &accel->cfgs;
|
||||
E_Value rhs_value = e_value_from_expr(expr->first->next);
|
||||
if(0 <= rhs_value.u64 && rhs_value.u64 < cfgs->count)
|
||||
{
|
||||
RD_Cfg *cfg = cfgs->v[rhs_value.u64];
|
||||
result.root = e_irtree_set_space(arena, rd_eval_space_from_cfg(cfg), e_irtree_const_u(arena, 0));
|
||||
result.type_key = e_type_key_cons_ptr(arch_from_context(), e_type_key_basic(E_TypeKind_U8), 1, E_TypeFlag_IsCodeText);
|
||||
result.mode = E_Mode_Offset;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_INFO_FUNCTION_DEF(environment)
|
||||
{
|
||||
RD_EnvironmentAccel *accel = (RD_EnvironmentAccel *)irtree->user_data;
|
||||
E_TypeExpandInfo result = {accel, accel->cfgs.count + 1};
|
||||
return result;
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_RANGE_FUNCTION_DEF(environment)
|
||||
{
|
||||
RD_CfgArray *cfgs = (RD_CfgArray *)user_data;
|
||||
E_IRTreeAndType lhs_irtree = e_irtree_and_type_from_expr(arena, lhs);
|
||||
Rng1U64 legal_idx_range = r1u64(0, cfgs->count);
|
||||
RD_EnvironmentAccel *accel = (RD_EnvironmentAccel *)user_data;
|
||||
Rng1U64 legal_idx_range = r1u64(0, accel->cfgs.count);
|
||||
Rng1U64 read_range = intersect_1u64(idx_range, legal_idx_range);
|
||||
U64 read_range_count = dim_1u64(read_range);
|
||||
for(U64 idx = 0; idx < read_range_count; idx += 1)
|
||||
{
|
||||
U64 cfg_idx = read_range.min + idx;
|
||||
if(cfg_idx < cfgs->count)
|
||||
if(cfg_idx < accel->cfgs.count)
|
||||
{
|
||||
exprs[idx] = e_expr_irext_array_index(arena, lhs, &lhs_irtree, cfg_idx);
|
||||
exprs_out[idx] = e_expr_irext_array_index(arena, expr, irtree, cfg_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
E_LOOKUP_ID_FROM_NUM_FUNCTION_DEF(environment)
|
||||
E_TYPE_EXPAND_ID_FROM_NUM_FUNCTION_DEF(environment)
|
||||
{
|
||||
U64 id = 0;
|
||||
RD_CfgArray *cfgs = (RD_CfgArray *)user_data;
|
||||
if(1 <= num && num <= cfgs->count)
|
||||
RD_EnvironmentAccel *accel = (RD_EnvironmentAccel *)user_data;
|
||||
if(1 <= num && num <= accel->cfgs.count)
|
||||
{
|
||||
U64 idx = (num-1);
|
||||
id = cfgs->v[idx]->id;
|
||||
id = accel->cfgs.v[idx]->id;
|
||||
}
|
||||
else if(num == cfgs->count+1)
|
||||
else if(num == accel->cfgs.count+1)
|
||||
{
|
||||
id = max_U64;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(environment)
|
||||
E_TYPE_EXPAND_NUM_FROM_ID_FUNCTION_DEF(environment)
|
||||
{
|
||||
U64 num = 0;
|
||||
RD_CfgArray *cfgs = (RD_CfgArray *)user_data;
|
||||
RD_EnvironmentAccel *accel = (RD_EnvironmentAccel *)user_data;
|
||||
if(id != 0 && id != max_U64)
|
||||
{
|
||||
for EachIndex(idx, cfgs->count)
|
||||
for EachIndex(idx, accel->cfgs.count)
|
||||
{
|
||||
if(cfgs->v[idx]->id == id)
|
||||
if(accel->cfgs.v[idx]->id == id)
|
||||
{
|
||||
num = idx+1;
|
||||
break;
|
||||
@@ -870,7 +875,7 @@ E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(environment)
|
||||
}
|
||||
else if(id == max_U64)
|
||||
{
|
||||
num = cfgs->count + 1;
|
||||
num = accel->cfgs.count + 1;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
@@ -893,20 +898,21 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(unattached_processes)
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
//- rjf: evaluate lhs machine, if we have one
|
||||
E_OpList lhs_oplist = e_oplist_from_irtree(scratch.arena, lhs->root);
|
||||
E_OpList lhs_oplist = e_oplist_from_irtree(scratch.arena, irtree->root);
|
||||
String8 lhs_bytecode = e_bytecode_from_oplist(scratch.arena, &lhs_oplist);
|
||||
E_Interpretation lhs_interp = e_interpret(lhs_bytecode);
|
||||
CTRL_Entity *lhs_entity = rd_ctrl_entity_from_eval_space(lhs_interp.space);
|
||||
|
||||
//- rjf: gather all machines we're searching through
|
||||
CTRL_EntityList machines = {0};
|
||||
CTRL_EntityArray machines = {0};
|
||||
if(lhs_entity->kind == CTRL_EntityKind_Machine)
|
||||
{
|
||||
ctrl_entity_list_push(scratch.arena, &machines, lhs_entity);
|
||||
machines.v = &lhs_entity;
|
||||
machines.count = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
machines = ctrl_entity_list_from_kind(d_state->ctrl_entity_store, CTRL_EntityKind_Machine);
|
||||
machines = ctrl_entity_array_from_kind(d_state->ctrl_entity_store, CTRL_EntityKind_Machine);
|
||||
}
|
||||
|
||||
//- rjf: gather system processes from this machine
|
||||
@@ -920,9 +926,9 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(unattached_processes)
|
||||
Node *first = 0;
|
||||
Node *last = 0;
|
||||
U64 count = 0;
|
||||
for(CTRL_EntityNode *n = machines.first; n != 0; n = n->next)
|
||||
for EachIndex(idx, machines.count)
|
||||
{
|
||||
CTRL_Entity *machine = n->v;
|
||||
CTRL_Entity *machine = machines.v[idx];
|
||||
DMN_ProcessIter iter = {0};
|
||||
dmn_process_iter_begin(&iter);
|
||||
for(DMN_ProcessInfo info = {0}; dmn_process_iter_next(scratch.arena, &iter, &info);)
|
||||
@@ -970,7 +976,7 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(unattached_processes)
|
||||
accel->infos_count = infos_count;
|
||||
accel->machines = infos_machines;
|
||||
info.user_data = accel;
|
||||
info.idxed_expr_count = infos_count;
|
||||
info.expr_count = infos_count;
|
||||
scratch_end(scratch);
|
||||
}
|
||||
return info;
|
||||
@@ -991,7 +997,6 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(unattached_processes)
|
||||
exprs_out[out_idx] = expr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Control Entity List Type Hooks (`processes`, `threads`, etc.)
|
||||
|
||||
@@ -56,22 +56,21 @@ E_TYPE_IRGEN_FUNCTION_DEF(call_stack);
|
||||
E_TYPE_ACCESS_FUNCTION_DEF(call_stack);
|
||||
E_TYPE_EXPAND_INFO_FUNCTION_DEF(call_stack);
|
||||
|
||||
#if 0 // TODO(rjf): @eval
|
||||
////////////////////////////////
|
||||
//~ rjf: `environment` Type Hooks
|
||||
|
||||
E_TYPE_IRGEN_FUNCTION_DEF(environment);
|
||||
E_TYPE_ACCESS_FUNCTION_DEF(environment);
|
||||
E_TYPE_EXPAND_INFO_FUNCTION_DEF(environment);
|
||||
E_TYPE_EXPAND_RANGE_FUNCTION_DEF(environment);
|
||||
E_LOOKUP_ID_FROM_NUM_FUNCTION_DEF(environment);
|
||||
E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(environment);
|
||||
E_TYPE_EXPAND_ID_FROM_NUM_FUNCTION_DEF(environment);
|
||||
E_TYPE_EXPAND_NUM_FROM_ID_FUNCTION_DEF(environment);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: `unattached_processes` Type Hooks
|
||||
|
||||
E_TYPE_EXPAND_INFO_FUNCTION_DEF(unattached_processes);
|
||||
E_TYPE_EXPAND_RANGE_FUNCTION_DEF(unattached_processes);
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Control Entity List Type Hooks (`processes`, `threads`, etc.)
|
||||
|
||||
@@ -1289,7 +1289,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
F32 next_pct = 0;
|
||||
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .default_pct = 0.65f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .string = str8_lit("(U64)($expr) => hex"), .default_pct = 0.20f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .string = str8_lit("hex((U64)($expr))"), .default_pct = 0.20f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Tag, .default_pct = 0.15f, .pct = take_pct());
|
||||
#undef take_pct
|
||||
}
|
||||
@@ -1313,7 +1313,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_CallStackFrame, .default_pct = 0.05f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .default_pct = 0.55f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .string = str8_lit("(U64)($expr) => hex"), .default_pct = 0.20f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .string = str8_lit("hex((U64)($expr))"), .default_pct = 0.20f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .eval = module_eval, .default_pct = 0.20f, .pct = take_pct());
|
||||
#undef take_pct
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user