mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-26 01:13:44 +00:00
dead code elimination
This commit is contained in:
@@ -14533,96 +14533,6 @@ rd_frame(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0 // TODO(rjf): @msgs
|
||||
RD_Entity *file = &d_nil_entity;
|
||||
if(name_resolved == 0)
|
||||
{
|
||||
RD_Entity *src_entity = rd_entity_from_handle(rd_regs()->entity);
|
||||
String8 file_part_of_name = name;
|
||||
U64 quote_pos = str8_find_needle(name, 0, str8_lit("\""), 0);
|
||||
if(quote_pos < name.size)
|
||||
{
|
||||
file_part_of_name = str8_skip(name, quote_pos+1);
|
||||
U64 ender_quote_pos = str8_find_needle(file_part_of_name, 0, str8_lit("\""), 0);
|
||||
file_part_of_name = str8_prefix(file_part_of_name, ender_quote_pos);
|
||||
}
|
||||
if(file_part_of_name.size != 0)
|
||||
{
|
||||
String8 folder_path = str8_chop_last_slash(file_part_of_name);
|
||||
String8 file_name = str8_skip_last_slash(file_part_of_name);
|
||||
String8List folders = str8_split_path(scratch.arena, folder_path);
|
||||
|
||||
// rjf: some folders are specified
|
||||
if(folders.node_count != 0)
|
||||
{
|
||||
String8 first_folder_name = folders.first->string;
|
||||
RD_Entity *root_folder = &d_nil_entity;
|
||||
|
||||
// rjf: try to find root folder as if it's an absolute path
|
||||
if(rd_entity_is_nil(root_folder))
|
||||
{
|
||||
root_folder = d_entity_from_path(first_folder_name, D_EntityFromPathFlag_OpenAsNeeded);
|
||||
}
|
||||
|
||||
// rjf: try to find root folder as if it's a path we've already loaded
|
||||
if(rd_entity_is_nil(root_folder))
|
||||
{
|
||||
root_folder = rd_entity_from_name_and_kind(first_folder_name, RD_EntityKind_File);
|
||||
}
|
||||
|
||||
// rjf: try to find root folder as if it's inside of a path we've already loaded
|
||||
if(rd_entity_is_nil(root_folder))
|
||||
{
|
||||
RD_EntityList all_files = rd_query_cached_entity_list_with_kind(RD_EntityKind_File);
|
||||
for(RD_EntityNode *n = all_files.first; n != 0; n = n->next)
|
||||
{
|
||||
if(n->entity->flags & RD_EntityFlag_IsFolder)
|
||||
{
|
||||
String8 n_entity_path = rd_full_path_from_entity(scratch.arena, n->entity);
|
||||
String8 estimated_full_path = push_str8f(scratch.arena, "%S/%S", n_entity_path, first_folder_name);
|
||||
root_folder = d_entity_from_path(estimated_full_path, D_EntityFromPathFlag_OpenAsNeeded);
|
||||
if(!rd_entity_is_nil(root_folder))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: has root folder -> descend downwards
|
||||
if(!rd_entity_is_nil(root_folder))
|
||||
{
|
||||
String8 root_folder_path = rd_full_path_from_entity(scratch.arena, root_folder);
|
||||
String8List full_file_path_parts = {0};
|
||||
str8_list_push(scratch.arena, &full_file_path_parts, root_folder_path);
|
||||
for(String8Node *n = folders.first->next; n != 0; n = n->next)
|
||||
{
|
||||
str8_list_push(scratch.arena, &full_file_path_parts, n->string);
|
||||
}
|
||||
str8_list_push(scratch.arena, &full_file_path_parts, file_name);
|
||||
StringJoin join = {0};
|
||||
join.sep = str8_lit("/");
|
||||
String8 full_file_path = str8_list_join(scratch.arena, &full_file_path_parts, &join);
|
||||
file = d_entity_from_path(full_file_path, D_EntityFromPathFlag_AllowOverrides|D_EntityFromPathFlag_OpenAsNeeded|D_EntityFromPathFlag_OpenMissing);
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: no folders specified => just try the local folder, then try globally
|
||||
else if(src_entity->kind == RD_EntityKind_File)
|
||||
{
|
||||
file = rd_entity_from_name_and_kind(file_name, RD_EntityKind_File);
|
||||
if(rd_entity_is_nil(file))
|
||||
{
|
||||
String8 src_entity_full_path = rd_full_path_from_entity(scratch.arena, src_entity);
|
||||
String8 src_entity_folder = str8_chop_last_slash(src_entity_full_path);
|
||||
String8 estimated_full_path = push_str8f(scratch.arena, "%S/%S", src_entity_folder, file_name);
|
||||
file = d_entity_from_path(estimated_full_path, D_EntityFromPathFlag_All);
|
||||
}
|
||||
}
|
||||
}
|
||||
name_resolved = !rd_entity_is_nil(file) && !(file->flags & RD_EntityFlag_IsMissing) && !(file->flags & RD_EntityFlag_IsFolder);
|
||||
}
|
||||
#endif
|
||||
|
||||
// rjf: process resolved info
|
||||
if(!name_resolved)
|
||||
|
||||
@@ -5231,229 +5231,6 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(scheduler)
|
||||
ProfEnd();
|
||||
}
|
||||
|
||||
#if 0
|
||||
RD_VIEW_RULE_UI_FUNCTION_DEF(scheduler)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
UI_ScrollPt2 scroll_pos = rd_view_scroll_pos();
|
||||
String8 query = string;
|
||||
|
||||
//- rjf: get state
|
||||
typedef struct RD_SchedulerViewState RD_SchedulerViewState;
|
||||
struct RD_SchedulerViewState
|
||||
{
|
||||
RD_Handle selected_entity;
|
||||
S64 selected_column;
|
||||
};
|
||||
RD_SchedulerViewState *sv = rd_view_state(RD_SchedulerViewState);
|
||||
|
||||
//- rjf: get entities
|
||||
RD_EntityList machines = rd_query_cached_entity_list_with_kind(RD_EntityKind_Machine);
|
||||
RD_EntityList processes = rd_query_cached_entity_list_with_kind(RD_EntityKind_Process);
|
||||
RD_EntityList threads = rd_query_cached_entity_list_with_kind(RD_EntityKind_Thread);
|
||||
|
||||
//- rjf: produce list of items; no query -> all entities, in tree; query -> only show threads
|
||||
RD_EntityFuzzyItemArray items = {0};
|
||||
ProfScope("query -> entities")
|
||||
{
|
||||
if(query.size == 0)
|
||||
{
|
||||
//- rjf: build flat array of entities, arranged into row order
|
||||
RD_EntityArray entities = {0};
|
||||
{
|
||||
entities.count = machines.count+processes.count+threads.count;
|
||||
entities.v = push_array_no_zero(scratch.arena, RD_Entity *, entities.count);
|
||||
U64 idx = 0;
|
||||
for(RD_EntityNode *machine_n = machines.first; machine_n != 0; machine_n = machine_n->next)
|
||||
{
|
||||
RD_Entity *machine = machine_n->entity;
|
||||
entities.v[idx] = machine;
|
||||
idx += 1;
|
||||
for(RD_EntityNode *process_n = processes.first; process_n != 0; process_n = process_n->next)
|
||||
{
|
||||
RD_Entity *process = process_n->entity;
|
||||
if(rd_entity_ancestor_from_kind(process, RD_EntityKind_Machine) != machine)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entities.v[idx] = process;
|
||||
idx += 1;
|
||||
for(RD_EntityNode *thread_n = threads.first; thread_n != 0; thread_n = thread_n->next)
|
||||
{
|
||||
RD_Entity *thread = thread_n->entity;
|
||||
if(rd_entity_ancestor_from_kind(thread, RD_EntityKind_Process) != process)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entities.v[idx] = thread;
|
||||
idx += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: entities -> fuzzy-filtered entities
|
||||
items = rd_entity_fuzzy_item_array_from_entity_array_needle(scratch.arena, &entities, query);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = rd_entity_fuzzy_item_array_from_entity_list_needle(scratch.arena, &threads, query);
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: selected column/entity -> selected cursor
|
||||
Vec2S64 cursor = {sv->selected_column};
|
||||
for(U64 idx = 0; idx < items.count; idx += 1)
|
||||
{
|
||||
if(items.v[idx].entity == rd_entity_from_handle(sv->selected_entity))
|
||||
{
|
||||
cursor.y = (S64)(idx+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: build table
|
||||
Rng1S64 visible_row_range = {0};
|
||||
UI_ScrollListParams scroll_list_params = {0};
|
||||
{
|
||||
scroll_list_params.flags = UI_ScrollListFlag_All;
|
||||
scroll_list_params.row_height_px = floor_f32(ui_top_font_size()*2.5f);
|
||||
scroll_list_params.dim_px = dim_2f32(rect);
|
||||
scroll_list_params.cursor_range = r2s64(v2s64(0, 0), v2s64(4, items.count));
|
||||
scroll_list_params.item_range = r1s64(0, items.count);
|
||||
scroll_list_params.cursor_min_is_empty_selection[Axis2_Y] = 1;
|
||||
}
|
||||
UI_ScrollListSignal scroll_list_sig = {0};
|
||||
UI_Focus(UI_FocusKind_On)
|
||||
UI_ScrollList(&scroll_list_params,
|
||||
&scroll_pos.y,
|
||||
&cursor,
|
||||
0,
|
||||
&visible_row_range,
|
||||
&scroll_list_sig)
|
||||
UI_Focus(UI_FocusKind_Null)
|
||||
UI_TableF(0, 0, "scheduler_table")
|
||||
{
|
||||
Vec2S64 next_cursor = cursor;
|
||||
for(U64 idx = visible_row_range.min;
|
||||
idx <= visible_row_range.max && idx < items.count;
|
||||
idx += 1)
|
||||
{
|
||||
RD_Entity *entity = items.v[idx].entity;
|
||||
CTRL_Entity *entity_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, entity->ctrl_handle);
|
||||
B32 row_is_selected = (cursor.y == (S64)(idx+1));
|
||||
F32 depth = 0.f;
|
||||
if(query.size == 0) switch(entity->kind)
|
||||
{
|
||||
default:{}break;
|
||||
case RD_EntityKind_Machine:{depth = 0.f;}break;
|
||||
case RD_EntityKind_Process:{depth = 1.f;}break;
|
||||
case RD_EntityKind_Thread: {depth = 2.f;}break;
|
||||
}
|
||||
Rng1S64 desc_col_rng = r1s64(1, 1);
|
||||
switch(entity->kind)
|
||||
{
|
||||
default:{}break;
|
||||
case RD_EntityKind_Machine:{desc_col_rng = r1s64(1, 4);}break;
|
||||
case RD_EntityKind_Process:{desc_col_rng = r1s64(1, 1);}break;
|
||||
case RD_EntityKind_Thread: {desc_col_rng = r1s64(1, 1);}break;
|
||||
}
|
||||
UI_NamedTableVectorF("entity_row_%p", entity)
|
||||
{
|
||||
UI_TableCellSized(ui_em(1.5f*depth, 1.f)) {}
|
||||
UI_TableCellSized(ui_em(2.25f, 1.f)) UI_FocusHot((row_is_selected && cursor.x == 0) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
B32 frozen = ctrl_entity_tree_is_frozen(entity_ctrl);
|
||||
UI_Palette *palette = ui_top_palette();
|
||||
if(frozen)
|
||||
{
|
||||
palette = rd_palette_from_code(RD_PaletteCode_NegativePopButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
palette = rd_palette_from_code(RD_PaletteCode_PositivePopButton);
|
||||
}
|
||||
UI_Signal sig = {0};
|
||||
UI_Palette(palette) sig = rd_icon_buttonf(frozen ? RD_IconKind_Locked : RD_IconKind_Unlocked, 0, "###lock_%p", entity);
|
||||
if(ui_clicked(sig))
|
||||
{
|
||||
D_CmdKind cmd_kind = frozen ? D_CmdKind_ThawEntity : D_CmdKind_FreezeEntity;
|
||||
rd_cmd(cmd_kind, .entity = rd_handle_from_entity(entity));
|
||||
}
|
||||
}
|
||||
UI_TableCellSized(ui_pct(1, 0))
|
||||
UI_FocusHot((row_is_selected && desc_col_rng.min <= cursor.x && cursor.x <= desc_col_rng.max) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
rd_entity_desc_button(entity, &items.v[idx].matches, query, 0);
|
||||
}
|
||||
switch(entity->kind)
|
||||
{
|
||||
default:{}break;
|
||||
case RD_EntityKind_Machine:
|
||||
{
|
||||
|
||||
}break;
|
||||
case RD_EntityKind_Process:
|
||||
{
|
||||
UI_TableCellSized(ui_children_sum(1.f)) UI_FocusHot((row_is_selected && cursor.x == 2) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
UI_PrefWidth(ui_text_dim(10, 1))
|
||||
UI_TextAlignment(UI_TextAlign_Center)
|
||||
if(ui_clicked(ui_buttonf("Detach")))
|
||||
{
|
||||
rd_cmd(D_CmdKind_Detach, .entity = rd_handle_from_entity(entity));
|
||||
}
|
||||
}
|
||||
UI_TableCellSized(ui_em(2.25f, 1.f)) UI_FocusHot((row_is_selected && cursor.x == 3) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
if(ui_clicked(rd_icon_buttonf(RD_IconKind_Redo, 0, "###retry")))
|
||||
{
|
||||
rd_cmd(D_CmdKind_Restart, .entity = rd_handle_from_entity(entity));
|
||||
}
|
||||
}
|
||||
UI_TableCellSized(ui_em(2.25f, 1.f)) UI_FocusHot((row_is_selected && cursor.x == 4) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
RD_Palette(RD_PaletteCode_NegativePopButton)
|
||||
if(ui_clicked(rd_icon_buttonf(RD_IconKind_X, 0, "###kill")))
|
||||
{
|
||||
rd_cmd(D_CmdKind_Kill, .entity = rd_handle_from_entity(entity));
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case RD_EntityKind_Thread:
|
||||
{
|
||||
UI_TableCellSized(ui_children_sum(1.f)) UI_FocusHot((row_is_selected && cursor.x >= 2) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
CTRL_Entity *entity_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, entity->ctrl_handle);
|
||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity_ctrl, RD_EntityKind_Process);
|
||||
U64 rip_vaddr = d_query_cached_rip_from_thread(entity_ctrl);
|
||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
|
||||
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr);
|
||||
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
||||
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff);
|
||||
if(lines.first != 0)
|
||||
{
|
||||
UI_PrefWidth(ui_children_sum(0)) rd_src_loc_button(lines.first->v.file_path, lines.first->v.pt);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor = next_cursor;
|
||||
}
|
||||
|
||||
//- rjf: selected num -> selected entity
|
||||
sv->selected_column = cursor.x;
|
||||
sv->selected_entity = (1 <= cursor.y && cursor.y <= items.count) ? rd_handle_from_entity(items.v[cursor.y-1].entity) : rd_handle_zero();
|
||||
|
||||
rd_store_view_scroll_pos(scroll_pos);
|
||||
scratch_end(scratch);
|
||||
ProfEnd();
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: call_stack @view_hook_impl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user