Skip to content

Commit

Permalink
delete raddbg layer duplicative ctrl entity kinds / related code; we …
Browse files Browse the repository at this point in the history
…are now fully moved onto the ctrl system for ctrl entities
  • Loading branch information
ryanfleury committed Dec 6, 2024
1 parent 7516264 commit 87a1dd8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 297 deletions.
174 changes: 0 additions & 174 deletions src/dbg_engine/dbg_engine_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1756,133 +1756,10 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
MTX_Op op = {r1u64(0, 0xffffffffffffffffull), str8_lit("[new session]\n")};
mtx_push_op(d_state->output_log_key, op);
}

// rjf: create entity
RD_Entity *machine = rd_machine_entity_from_machine_id(event->entity.machine_id);
RD_Entity *entity = rd_entity_alloc(machine, RD_EntityKind_Process);
rd_entity_equip_u64(entity, event->msg_id);
rd_entity_equip_ctrl_handle(entity, event->entity);
rd_entity_equip_ctrl_id(entity, event->entity_id);
rd_entity_equip_arch(entity, event->arch);
}break;

case CTRL_EventKind_NewThread:
{
// rjf: create entity
RD_Entity *parent = rd_entity_from_ctrl_handle(event->parent);
RD_Entity *entity = rd_entity_alloc(parent, RD_EntityKind_Thread);
rd_entity_equip_ctrl_handle(entity, event->entity);
rd_entity_equip_arch(entity, event->arch);
rd_entity_equip_ctrl_id(entity, event->entity_id);
rd_entity_equip_stack_base(entity, event->stack_base);
rd_entity_equip_vaddr(entity, event->rip_vaddr);
if(event->string.size != 0)
{
rd_entity_equip_name(entity, event->string);
}

// rjf: find any pending thread names correllating with this TID -> equip name if found match
{
RD_EntityList pending_thread_names = rd_query_cached_entity_list_with_kind(RD_EntityKind_PendingThreadName);
for(RD_EntityNode *n = pending_thread_names.first; n != 0; n = n->next)
{
RD_Entity *pending_thread_name = n->entity;
if(event->entity.machine_id == pending_thread_name->ctrl_handle.machine_id && event->entity_id == pending_thread_name->ctrl_id)
{
rd_entity_mark_for_deletion(pending_thread_name);
rd_entity_equip_name(entity, pending_thread_name->string);
break;
}
}
}

// rjf: determine index in process
U64 thread_idx_in_process = 0;
for(RD_Entity *child = parent->first; !rd_entity_is_nil(child); child = child->next)
{
if(child == entity)
{
break;
}
if(child->kind == RD_EntityKind_Thread)
{
thread_idx_in_process += 1;
}
}

// rjf: build default thread color table
Vec4F32 thread_colors[] =
{
rd_rgba_from_theme_color(RD_ThemeColor_Thread0),
rd_rgba_from_theme_color(RD_ThemeColor_Thread1),
rd_rgba_from_theme_color(RD_ThemeColor_Thread2),
rd_rgba_from_theme_color(RD_ThemeColor_Thread3),
rd_rgba_from_theme_color(RD_ThemeColor_Thread4),
rd_rgba_from_theme_color(RD_ThemeColor_Thread5),
rd_rgba_from_theme_color(RD_ThemeColor_Thread6),
rd_rgba_from_theme_color(RD_ThemeColor_Thread7),
};

// rjf: pick color
Vec4F32 thread_color = thread_colors[thread_idx_in_process % ArrayCount(thread_colors)];

// rjf: equip color
rd_entity_equip_color_rgba(entity, thread_color);
}break;

case CTRL_EventKind_NewModule:
{
// rjf: grab process
RD_Entity *parent = rd_entity_from_ctrl_handle(event->parent);

// rjf: determine if this is the first module
B32 is_first = 0;
if(rd_entity_is_nil(rd_entity_child_from_kind(parent, RD_EntityKind_Module)))
{
is_first = 1;
}

// rjf: create module entity
RD_Entity *module = rd_entity_alloc(parent, RD_EntityKind_Module);
rd_entity_equip_ctrl_handle(module, event->entity);
rd_entity_equip_arch(module, event->arch);
rd_entity_equip_name(module, event->string);
rd_entity_equip_vaddr_rng(module, event->vaddr_rng);
rd_entity_equip_vaddr(module, event->rip_vaddr);
rd_entity_equip_timestamp(module, event->timestamp);

// rjf: is first -> find target, equip process & module & first thread with target color
if(is_first)
{
RD_EntityList targets = rd_query_cached_entity_list_with_kind(RD_EntityKind_Target);
for(RD_EntityNode *n = targets.first; n != 0; n = n->next)
{
RD_Entity *target = n->entity;
RD_Entity *exe = rd_entity_child_from_kind(target, RD_EntityKind_Executable);
String8 exe_name = exe->string;
String8 exe_name_normalized = path_normalized_from_string(scratch.arena, exe_name);
String8 module_name_normalized = path_normalized_from_string(scratch.arena, module->string);
if(str8_match(exe_name_normalized, module_name_normalized, StringMatchFlag_CaseInsensitive) &&
target->flags & RD_EntityFlag_HasColor)
{
RD_Entity *first_thread = rd_entity_child_from_kind(parent, RD_EntityKind_Thread);
Vec4F32 rgba = rd_rgba_from_entity(target);
rd_entity_equip_color_rgba(parent, rgba);
rd_entity_equip_color_rgba(first_thread, rgba);
rd_entity_equip_color_rgba(module, rgba);
break;
}
}
}
}break;

case CTRL_EventKind_EndProc:
{
U32 pid = event->entity_id;
RD_Entity *process = rd_entity_from_ctrl_handle(event->entity);
rd_entity_mark_for_deletion(process);

// rjf: report
D_EventNode *n = push_array(arena, D_EventNode, 1);
SLLQueuePush(result.first, result.last, n);
result.count += 1;
Expand All @@ -1891,32 +1768,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
evt->code = event->u64_code;
}break;

case CTRL_EventKind_EndThread:
{
RD_Entity *thread = rd_entity_from_ctrl_handle(event->entity);
rd_entity_mark_for_deletion(thread);
}break;

case CTRL_EventKind_EndModule:
{
RD_Entity *module = rd_entity_from_ctrl_handle(event->entity);
rd_entity_mark_for_deletion(module);
}break;

//- rjf: debug info changes

case CTRL_EventKind_ModuleDebugInfoPathChange:
{
RD_Entity *module = rd_entity_from_ctrl_handle(event->entity);
RD_Entity *debug_info = rd_entity_child_from_kind(module, RD_EntityKind_DebugInfoPath);
if(rd_entity_is_nil(debug_info))
{
debug_info = rd_entity_alloc(module, RD_EntityKind_DebugInfoPath);
}
rd_entity_equip_name(debug_info, event->string);
rd_entity_equip_timestamp(debug_info, event->timestamp);
}break;

//- rjf: debug strings

case CTRL_EventKind_DebugString:
Expand All @@ -1925,31 +1776,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
mtx_push_op(d_state->output_log_key, op);
}break;

case CTRL_EventKind_ThreadName:
{
String8 string = event->string;
RD_Entity *entity = rd_entity_from_ctrl_handle(event->entity);
if(event->entity_id != 0)
{
entity = rd_entity_from_ctrl_id(event->entity.machine_id, event->entity_id);
}
if(rd_entity_is_nil(entity))
{
RD_Entity *process = rd_entity_from_ctrl_handle(event->parent);
if(!rd_entity_is_nil(process))
{
entity = rd_entity_alloc(process, RD_EntityKind_PendingThreadName);
rd_entity_equip_name(entity, string);
rd_entity_equip_ctrl_handle(entity, ctrl_handle_make(event->entity.machine_id, dmn_handle_zero()));
rd_entity_equip_ctrl_id(entity, event->entity_id);
}
}
if(!rd_entity_is_nil(entity))
{
rd_entity_equip_name(entity, string);
}
}break;

//- rjf: memory

case CTRL_EventKind_MemReserve:{}break;
Expand Down
42 changes: 6 additions & 36 deletions src/raddbg/generated/raddbg.meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RD_CmdKind_Null,
RD_CmdKind_Null,
};

String8 d_entity_kind_display_string_table[34] =
String8 d_entity_kind_display_string_table[29] =
{
str8_lit_comp("Nil"),
str8_lit_comp("Root"),
Expand Down Expand Up @@ -65,16 +65,11 @@ str8_lit_comp("Recent Project"),
str8_lit_comp("Recent File"),
str8_lit_comp("Source"),
str8_lit_comp("Destination"),
str8_lit_comp("Process"),
str8_lit_comp("Thread"),
str8_lit_comp("Module"),
str8_lit_comp("Pending Thread Name"),
str8_lit_comp("Debug Info Path"),
str8_lit_comp("Conversion Task"),
str8_lit_comp("Conversion Failure"),
};

String8 d_entity_kind_name_lower_table[34] =
String8 d_entity_kind_name_lower_table[29] =
{
str8_lit_comp("nil"),
str8_lit_comp("root"),
Expand Down Expand Up @@ -103,16 +98,11 @@ str8_lit_comp("recent_project"),
str8_lit_comp("recent_file"),
str8_lit_comp("source"),
str8_lit_comp("dest"),
str8_lit_comp("process"),
str8_lit_comp("thread"),
str8_lit_comp("module"),
str8_lit_comp("pending_thread_name"),
str8_lit_comp("debug_info_path"),
str8_lit_comp("conversion_task"),
str8_lit_comp("conversion_fail"),
};

String8 d_entity_kind_name_lower_plural_table[34] =
String8 d_entity_kind_name_lower_plural_table[29] =
{
str8_lit_comp("nils"),
str8_lit_comp("roots"),
Expand Down Expand Up @@ -141,16 +131,11 @@ str8_lit_comp("recent_projects"),
str8_lit_comp("recent_files"),
str8_lit_comp("sources"),
str8_lit_comp("dests"),
str8_lit_comp("processes"),
str8_lit_comp("threads"),
str8_lit_comp("modules"),
str8_lit_comp("pending_thread_names"),
str8_lit_comp("debug_info_paths"),
str8_lit_comp("conversion_tasks"),
str8_lit_comp("conversion_fails"),
};

String8 d_entity_kind_name_label_table[34] =
String8 d_entity_kind_name_label_table[29] =
{
str8_lit_comp("Label"),
str8_lit_comp("Label"),
Expand Down Expand Up @@ -181,14 +166,9 @@ str8_lit_comp("Path"),
str8_lit_comp("Path"),
str8_lit_comp("Label"),
str8_lit_comp("Label"),
str8_lit_comp("Label"),
str8_lit_comp("Label"),
str8_lit_comp("Label"),
str8_lit_comp("Label"),
str8_lit_comp("Label"),
};

RD_EntityKindFlags rd_entity_kind_flags_table[34] =
RD_EntityKindFlags rd_entity_kind_flags_table[29] =
{
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (0*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (0*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
Expand Down Expand Up @@ -217,11 +197,6 @@ RD_EntityKindFlags rd_entity_kind_flags_table[34] =
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (0*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (1*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (1*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (0*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (0*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (1*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (1*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (1*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (1*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (0*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (0*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (0*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (1*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
(0*RD_EntityKindFlag_CanDelete) | (0*RD_EntityKindFlag_CanFreeze) | (0*RD_EntityKindFlag_CanEdit) | (1*RD_EntityKindFlag_CanRename) | (0*RD_EntityKindFlag_CanEnable) | (0*RD_EntityKindFlag_CanCondition) | (0*RD_EntityKindFlag_CanDuplicate) | (0*RD_EntityKindFlag_NameIsCode) | (0*RD_EntityKindFlag_NameIsPath) | (0*RD_EntityKindFlag_UserDefinedLifetime) | (0*RD_EntityKindFlag_IsSerializedToConfig),
};
Expand Down Expand Up @@ -885,7 +860,7 @@ RD_ViewRuleInfo rd_view_rule_kind_info_table[35] =
{str8_lit_comp("geo3d"), str8_lit_comp("Visualizes memory as 3D geometry."), str8_lit_comp("Geometry (3D)"), str8_lit_comp("x:{'count':expr, 'vtx':expr, 'vtx_size':expr}"), RD_IconKind_Binoculars, (RD_ViewRuleInfoFlag_ShowInDocs*1|RD_ViewRuleInfoFlag_CanFilter*0|RD_ViewRuleInfoFlag_FilterIsCode*0|RD_ViewRuleInfoFlag_TypingAutomaticallyFilters*0|RD_ViewRuleInfoFlag_CanUseInWatchTable*1|RD_ViewRuleInfoFlag_CanFillValueCell*0|RD_ViewRuleInfoFlag_CanExpand*1), EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_NAME(geo3d) , RD_VIEW_RULE_UI_FUNCTION_NAME(geo3d)},
};

RD_IconKind rd_entity_kind_icon_kind_table[34] =
RD_IconKind rd_entity_kind_icon_kind_table[29] =
{
RD_IconKind_Null,
RD_IconKind_Null,
Expand Down Expand Up @@ -914,11 +889,6 @@ RD_IconKind_Briefcase,
RD_IconKind_FileOutline,
RD_IconKind_Null,
RD_IconKind_Null,
RD_IconKind_Threads,
RD_IconKind_Thread,
RD_IconKind_Module,
RD_IconKind_Threads,
RD_IconKind_Module,
RD_IconKind_Null,
RD_IconKind_Null,
};
Expand Down
17 changes: 6 additions & 11 deletions src/raddbg/generated/raddbg.meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ RD_EntityKind_RecentProject,
RD_EntityKind_RecentFile,
RD_EntityKind_Source,
RD_EntityKind_Dest,
RD_EntityKind_Process,
RD_EntityKind_Thread,
RD_EntityKind_Module,
RD_EntityKind_PendingThreadName,
RD_EntityKind_DebugInfoPath,
RD_EntityKind_ConversionTask,
RD_EntityKind_ConversionFail,
RD_EntityKind_COUNT,
Expand Down Expand Up @@ -766,11 +761,11 @@ extern String8 rd_cfg_src_string_table[4];
extern RD_CmdKind rd_cfg_src_load_cmd_kind_table[4];
extern RD_CmdKind rd_cfg_src_write_cmd_kind_table[4];
extern RD_CmdKind rd_cfg_src_apply_cmd_kind_table[4];
extern String8 d_entity_kind_display_string_table[34];
extern String8 d_entity_kind_name_lower_table[34];
extern String8 d_entity_kind_name_lower_plural_table[34];
extern String8 d_entity_kind_name_label_table[34];
extern RD_EntityKindFlags rd_entity_kind_flags_table[34];
extern String8 d_entity_kind_display_string_table[29];
extern String8 d_entity_kind_name_lower_table[29];
extern String8 d_entity_kind_name_lower_plural_table[29];
extern String8 d_entity_kind_name_label_table[29];
extern RD_EntityKindFlags rd_entity_kind_flags_table[29];
extern Rng1U64 rd_reg_slot_range_table[34];
extern RD_StringBindingPair rd_default_binding_table[110];
extern String8 rd_binding_version_remap_old_name_table[8];
Expand All @@ -784,7 +779,7 @@ extern EV_ViewRuleExprExpandRangeInfoHookFunctionType * rd_collection_expr_expan
extern EV_ViewRuleExprExpandIDFromNumHookFunctionType * rd_collection_expr_expand_id_from_num_hook_function_table[18];
extern EV_ViewRuleExprExpandIDFromNumHookFunctionType * rd_collection_expr_expand_num_from_id_hook_function_table[18];
extern RD_ViewRuleInfo rd_view_rule_kind_info_table[35];
extern RD_IconKind rd_entity_kind_icon_kind_table[34];
extern RD_IconKind rd_entity_kind_icon_kind_table[29];
extern String8 rd_theme_preset_display_string_table[9];
extern String8 rd_theme_preset_code_string_table[9];
extern String8 rd_theme_color_version_remap_old_name_table[22];
Expand Down
Loading

0 comments on commit 87a1dd8

Please sign in to comment.