diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index c4ede06b..fcefa45d 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -214,6 +214,35 @@ ctrl_msg_list_push(Arena *arena, CTRL_MsgList *list) return msg; } +internal CTRL_MsgList +ctrl_msg_list_deep_copy(Arena *arena, CTRL_MsgList *src) +{ + CTRL_MsgList dst = {0}; + for(CTRL_MsgNode *n = src->first; n != 0; n = n->next) + { + CTRL_Msg *src_msg = &n->v; + CTRL_Msg *dst_msg = ctrl_msg_list_push(arena, &dst); + ctrl_msg_deep_copy(arena, dst_msg, src_msg); + } + return dst; +} + +internal void +ctrl_msg_list_concat_in_place(CTRL_MsgList *dst, CTRL_MsgList *src) +{ + if(dst->last && src->first) + { + dst->last->next = src->first; + dst->last = src->last; + dst->count += src->count; + } + else if(src->first) + { + MemoryCopyStruct(dst, src); + } + MemoryZeroStruct(src); +} + //- rjf: serialization internal String8 diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index 6d83033f..03f8ea17 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -696,6 +696,8 @@ internal void ctrl_msg_deep_copy(Arena *arena, CTRL_Msg *dst, CTRL_Msg *src); //- rjf: list building internal CTRL_Msg *ctrl_msg_list_push(Arena *arena, CTRL_MsgList *list); +internal CTRL_MsgList ctrl_msg_list_deep_copy(Arena *arena, CTRL_MsgList *src); +internal void ctrl_msg_list_concat_in_place(CTRL_MsgList *dst, CTRL_MsgList *src); //- rjf: serialization internal String8 ctrl_serialized_string_from_msg_list(Arena *arena, CTRL_MsgList *msgs); diff --git a/src/dbg_engine/dbg_engine_core.c b/src/dbg_engine/dbg_engine_core.c index 73790ed4..f5a325f7 100644 --- a/src/dbg_engine/dbg_engine_core.c +++ b/src/dbg_engine/dbg_engine_core.c @@ -77,28 +77,6 @@ d_handle_list_push(Arena *arena, D_HandleList *list, D_Handle handle) d_handle_list_push_node(list, n); } -internal void -d_handle_list_remove(D_HandleList *list, D_HandleNode *node) -{ - DLLRemove(list->first, list->last, node); - list->count -= 1; -} - -internal D_HandleNode * -d_handle_list_find(D_HandleList *list, D_Handle handle) -{ - D_HandleNode *result = 0; - for(D_HandleNode *n = list->first; n != 0; n = n->next) - { - if(d_handle_match(n->handle, handle)) - { - result = n; - break; - } - } - return result; -} - internal D_HandleList d_handle_list_copy(Arena *arena, D_HandleList list) { @@ -2925,20 +2903,6 @@ d_unwind_from_ctrl_unwind(Arena *arena, DI_Scope *di_scope, D_Entity *process, C //////////////////////////////// //~ rjf: Target Controls -//- rjf: control message dispatching - -internal void -d_push_ctrl_msg(CTRL_Msg *msg) -{ - CTRL_Msg *dst = ctrl_msg_list_push(d_state->ctrl_msg_arena, &d_state->ctrl_msgs); - ctrl_msg_deep_copy(d_state->ctrl_msg_arena, dst, msg); - if(d_state->ctrl_soft_halt_issued == 0 && d_ctrl_targets_running()) - { - d_state->ctrl_soft_halt_issued = 1; - ctrl_halt(); - } -} - //- rjf: stopped info from the control thread internal CTRL_Event @@ -3764,14 +3728,6 @@ d_cfg_strings_from_core(Arena *arena, String8 root_path, D_CfgSrc source) return strs; } -//- rjf: current path - -internal String8 -d_current_path(void) -{ - return d_state->current_path; -} - //- rjf: entity kind cache internal D_EntityList @@ -4141,7 +4097,6 @@ d_init(void) d_state->entities_root = &d_nil_entity; d_state->entities_base = push_array(d_state->entities_arena, D_Entity, 0); d_state->entities_count = 0; - d_state->ctrl_msg_arena = arena_alloc(); d_state->ctrl_entity_store = ctrl_entity_store_alloc(); d_state->ctrl_stop_arena = arena_alloc(); d_state->entities_root = d_entity_alloc(&d_nil_entity, D_EntityKind_Root); @@ -4150,6 +4105,7 @@ d_init(void) d_state->view_rule_spec_table_size = 1024; d_state->view_rule_spec_table = push_array(arena, D_ViewRuleSpec *, d_state->view_rule_spec_table_size); d_state->top_regs = &d_state->base_regs; + d_state->ctrl_msg_arena = arena_alloc(); // rjf: set up initial exception filtering rules for(CTRL_ExceptionCodeKind k = (CTRL_ExceptionCodeKind)0; k < CTRL_ExceptionCodeKind_COUNT; k = (CTRL_ExceptionCodeKind)(k+1)) @@ -4201,22 +4157,13 @@ d_init(void) // rjf: set up run state d_state->ctrl_last_run_arena = arena_alloc(); - - // rjf: set up initial browse path - { - Temp scratch = scratch_begin(0, 0); - String8 current_path = os_get_current_path(scratch.arena); - String8 current_path_with_slash = push_str8f(scratch.arena, "%S/", current_path); - d_state->current_path_arena = arena_alloc(); - d_state->current_path = push_str8_copy(d_state->current_path_arena, current_path_with_slash); - scratch_end(scratch); - } } internal CTRL_EventList d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_Scope *di_scope, F32 dt) { ProfBeginFunction(); + Temp scratch = scratch_begin(&arena, 1); CTRL_EventList result = {0}; d_state->frame_index += 1; arena_clear(d_frame_arena()); @@ -4231,8 +4178,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ // ProfScope("sync with ctrl thread") { - Temp scratch = scratch_begin(&arena, 1); - //- rjf: grab next reggen/memgen U64 new_mem_gen = ctrl_mem_gen(); U64 new_reg_gen = ctrl_reg_gen(); @@ -4632,8 +4577,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ cache->table = 0; d_state->member_cache_reggen_idx = new_reg_gen; } - - scratch_end(scratch); } ////////////////////////////// @@ -4641,8 +4584,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ // U128 ctrl_param_state_hash = {0}; { - Temp scratch = scratch_begin(0, 0); - // rjf: build data strings of all param data String8List strings = {0}; { @@ -4666,8 +4607,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ // rjf: join & hash to produce result String8 string = str8_list_join(scratch.arena, &strings, 0); blake2b((U8 *)&ctrl_param_state_hash.u64[0], sizeof(ctrl_param_state_hash), string.str, string.size, 0, 0); - - scratch_end(scratch); } ////////////////////////////// @@ -4732,7 +4671,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ // ProfScope("sync with di parsers") { - Temp scratch = scratch_begin(&arena, 1); DI_EventList events = di_p2u_pop_events(scratch.arena, 0); for(DI_EventNode *n = events.first; n != 0; n = n->next) { @@ -4755,7 +4693,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ }break; } } - scratch_end(scratch); } ////////////////////////////// @@ -4776,13 +4713,11 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ ////////////////////////////// //- rjf: process top-level commands // + CTRL_MsgList ctrl_msgs = {0}; ProfScope("process top-level commands") { - Temp scratch = scratch_begin(&arena, 1); for(D_Cmd *cmd = 0; d_next_cmd(&cmd);) { - temp_end(scratch); - // rjf: unpack command D_CmdParams params = cmd->params; D_CmdKind core_cmd_kind = d_cmd_kind_from_string(cmd->spec->info.string); @@ -4863,13 +4798,13 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ // rjf: push message to launch { - CTRL_Msg msg = {CTRL_MsgKind_Launch}; - msg.path = path; - msg.cmd_line_string_list = cmdln_strings; - msg.env_inherit = 1; - MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters); - str8_list_push(scratch.arena, &msg.entry_points, entry); - d_push_ctrl_msg(&msg); + CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); + msg->kind = CTRL_MsgKind_Launch; + msg->path = path; + msg->cmd_line_string_list = cmdln_strings; + msg->env_inherit = 1; + MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); + str8_list_push(scratch.arena, &msg->entry_points, entry); } } @@ -4902,13 +4837,11 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ for(D_EntityNode *n = processes.first; n != 0; n = n->next) { D_Entity *process = n->entity; - CTRL_Msg msg = {CTRL_MsgKind_Kill}; - { - msg.exit_code = 1; - msg.entity = process->ctrl_handle; - MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters); - } - d_push_ctrl_msg(&msg); + CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); + msg->kind = CTRL_MsgKind_Kill; + msg->exit_code = 1; + msg->entity = process->ctrl_handle; + MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); } } @@ -4926,13 +4859,11 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ for(D_EntityNode *n = processes.first; n != 0; n = n->next) { D_Entity *process = n->entity; - CTRL_Msg msg = {CTRL_MsgKind_Kill}; - { - msg.exit_code = 1; - msg.entity = process->ctrl_handle; - MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters); - } - d_push_ctrl_msg(&msg); + CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); + msg->kind = CTRL_MsgKind_Kill; + msg->exit_code = 1; + msg->entity = process->ctrl_handle; + MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); } } if(processes.count == 0) @@ -4947,10 +4878,10 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ D_Entity *entity = d_entity_from_handle(n->handle); if(entity->kind == D_EntityKind_Process) { - CTRL_Msg msg = {CTRL_MsgKind_Detach}; - msg.entity = entity->ctrl_handle; - MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters); - d_push_ctrl_msg(&msg); + CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); + msg->kind = CTRL_MsgKind_Detach; + msg->entity = entity->ctrl_handle; + MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); } } }break; @@ -5090,8 +5021,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ } } } - - scratch_end(scratch); } }break; @@ -5349,9 +5278,9 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ { CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, e->ctrl_handle); thread->is_frozen = should_freeze; - CTRL_Msg msg = {should_freeze ? CTRL_MsgKind_FreezeThread : CTRL_MsgKind_ThawThread}; - msg.entity = thread->handle; - d_push_ctrl_msg(&msg); + CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); + msg->kind = (should_freeze ? CTRL_MsgKind_FreezeThread : CTRL_MsgKind_ThawThread); + msg->entity = thread->handle; } } }break; @@ -5362,10 +5291,10 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ U64 pid = params.id; if(pid != 0) { - CTRL_Msg msg = {CTRL_MsgKind_Attach}; - msg.entity_id = (U32)pid; - MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters); - d_push_ctrl_msg(&msg); + CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); + msg->kind = CTRL_MsgKind_Attach; + msg->entity_id = (U32)pid; + MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); } }break; } @@ -5378,15 +5307,16 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ d_state->ctrl_last_run_param_state_hash = ctrl_param_state_hash; } - // rjf: build run message - CTRL_Msg msg = {(run_kind == D_RunKind_Run || run_kind == D_RunKind_Step) ? CTRL_MsgKind_Run : CTRL_MsgKind_SingleStep}; + // rjf: push & fill run message + CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); { CTRL_Entity *process = ctrl_entity_ancestor_from_kind(run_thread, CTRL_EntityKind_Process); - msg.run_flags = run_flags; - msg.entity = run_thread->handle; - msg.parent = process->handle; - MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters); - MemoryCopyStruct(&msg.traps, &run_traps); + msg->kind = (run_kind == D_RunKind_Run || run_kind == D_RunKind_Step) ? CTRL_MsgKind_Run : CTRL_MsgKind_SingleStep; + msg->run_flags = run_flags; + msg->entity = run_thread->handle; + msg->parent = process->handle; + MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); + MemoryCopyStruct(&msg->traps, &run_traps); for(U64 idx = 0; idx < breakpoints->count; idx += 1) { // rjf: unpack user breakpoint entity @@ -5402,7 +5332,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ ctrl_user_bp.string = n->string; ctrl_user_bp.pt = bp->pt; ctrl_user_bp.condition = bp->condition; - ctrl_user_breakpoint_list_push(scratch.arena, &msg.user_bps, &ctrl_user_bp); + ctrl_user_breakpoint_list_push(scratch.arena, &msg->user_bps, &ctrl_user_bp); } } @@ -5412,7 +5342,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ CTRL_UserBreakpoint ctrl_user_bp = {CTRL_UserBreakpointKind_VirtualAddress}; ctrl_user_bp.u64 = bp->vaddr; ctrl_user_bp.condition = bp->condition; - ctrl_user_breakpoint_list_push(scratch.arena, &msg.user_bps, &ctrl_user_bp); + ctrl_user_breakpoint_list_push(scratch.arena, &msg->user_bps, &ctrl_user_bp); } // rjf: symbol name location -> add breakpoint for symbol name @@ -5421,14 +5351,11 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ CTRL_UserBreakpoint ctrl_user_bp = {CTRL_UserBreakpointKind_SymbolNameAndOffset}; ctrl_user_bp.string = bp->symbol_name; ctrl_user_bp.condition = bp->condition; - ctrl_user_breakpoint_list_push(scratch.arena, &msg.user_bps, &ctrl_user_bp); + ctrl_user_breakpoint_list_push(scratch.arena, &msg->user_bps, &ctrl_user_bp); } } } - // rjf: push msg - d_push_ctrl_msg(&msg); - // rjf: copy run traps to scratch (needed, if run_traps can be `d_state->ctrl_last_run_traps`) CTRL_TrapList run_traps_copy = ctrl_trap_list_copy(scratch.arena, &run_traps); @@ -5446,7 +5373,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ d_state->base_regs.v.inline_depth = 0; } } - scratch_end(scratch); } ////////////////////////////// @@ -5458,17 +5384,24 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_ } ////////////////////////////// - //- rjf: send messages to control + //- rjf: push new control messages to queue - try to send queue to control, + // clear queue if successful (if not, we'll just keep them around until + // the next tick) // - if(d_state->ctrl_msgs.count != 0) { - if(ctrl_u2c_push_msgs(&d_state->ctrl_msgs, os_now_microseconds()+100)) + CTRL_MsgList msgs_copy = ctrl_msg_list_deep_copy(d_state->ctrl_msg_arena, &ctrl_msgs); + ctrl_msg_list_concat_in_place(&d_state->ctrl_msgs, &msgs_copy); + if(d_state->ctrl_msgs.count != 0) { - MemoryZeroStruct(&d_state->ctrl_msgs); - arena_clear(d_state->ctrl_msg_arena); + if(ctrl_u2c_push_msgs(&d_state->ctrl_msgs, os_now_microseconds()+100)) + { + MemoryZeroStruct(&d_state->ctrl_msgs); + arena_clear(d_state->ctrl_msg_arena); + } } } ProfEnd(); + scratch_end(scratch); return result; } diff --git a/src/dbg_engine/dbg_engine_core.h b/src/dbg_engine/dbg_engine_core.h index 6db86b92..4d795f2d 100644 --- a/src/dbg_engine/dbg_engine_core.h +++ b/src/dbg_engine/dbg_engine_core.h @@ -808,31 +808,6 @@ struct D_EntityListCache D_EntityList list; }; -//- rjf: auto view rules hash table cache - -typedef struct D_AutoViewRuleNode D_AutoViewRuleNode; -struct D_AutoViewRuleNode -{ - D_AutoViewRuleNode *next; - String8 type; - String8 view_rule; -}; - -typedef struct D_AutoViewRuleSlot D_AutoViewRuleSlot; -struct D_AutoViewRuleSlot -{ - D_AutoViewRuleNode *first; - D_AutoViewRuleNode *last; -}; - -typedef struct D_AutoViewRuleMapCache D_AutoViewRuleMapCache; -struct D_AutoViewRuleMapCache -{ - Arena *arena; - U64 slots_count; - D_AutoViewRuleSlot *slots; -}; - //- rjf: per-thread unwind cache typedef struct D_UnwindCacheNode D_UnwindCacheNode; @@ -969,7 +944,6 @@ struct D_State // rjf: entity query caches U64 kind_alloc_gens[D_EntityKind_COUNT]; D_EntityListCache kind_caches[D_EntityKind_COUNT]; - D_AutoViewRuleMapCache auto_view_rule_cache; // rjf: per-run caches D_UnwindCache unwind_cache; @@ -1006,9 +980,9 @@ struct D_State U128 ctrl_last_run_param_state_hash; B32 ctrl_is_running; B32 ctrl_soft_halt_issued; + U64 ctrl_exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64]; Arena *ctrl_msg_arena; CTRL_MsgList ctrl_msgs; - U64 ctrl_exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64]; // rjf: control thread ctrl -> user reading state CTRL_EntityStore *ctrl_entity_store; @@ -1021,10 +995,6 @@ struct D_State U64 cfg_cached_timestamp[D_CfgSrc_COUNT]; Arena *cfg_arena; D_CfgTable cfg_table; - - // rjf: current path - Arena *current_path_arena; - String8 current_path; }; //////////////////////////////// @@ -1062,8 +1032,6 @@ internal D_Handle d_handle_zero(void); internal B32 d_handle_match(D_Handle a, D_Handle b); internal void d_handle_list_push_node(D_HandleList *list, D_HandleNode *node); internal void d_handle_list_push(Arena *arena, D_HandleList *list, D_Handle handle); -internal void d_handle_list_remove(D_HandleList *list, D_HandleNode *node); -internal D_HandleNode *d_handle_list_find(D_HandleList *list, D_Handle handle); internal D_HandleList d_handle_list_copy(Arena *arena, D_HandleList list); //////////////////////////////// @@ -1285,9 +1253,6 @@ internal D_Unwind d_unwind_from_ctrl_unwind(Arena *arena, DI_Scope *di_scope, D_ //////////////////////////////// //~ rjf: Target Controls -//- rjf: control message dispatching -internal void d_push_ctrl_msg(CTRL_Msg *msg); - //- rjf: stopped info from the control thread internal CTRL_Event d_ctrl_last_stop_event(void); @@ -1363,9 +1328,6 @@ internal String8 d_cfg_escaped_from_raw_string(Arena *arena, String8 string); internal String8 d_cfg_raw_from_escaped_string(Arena *arena, String8 string); internal String8List d_cfg_strings_from_core(Arena *arena, String8 root_path, D_CfgSrc source); -//- rjf: current path -internal String8 d_current_path(void); - //- rjf: entity kind cache internal D_EntityList d_query_cached_entity_list_with_kind(D_EntityKind kind); diff --git a/src/dbg_frontend/dbg_frontend_core.c b/src/dbg_frontend/dbg_frontend_core.c index d0dd887d..e92c11d3 100644 --- a/src/dbg_frontend/dbg_frontend_core.c +++ b/src/dbg_frontend/dbg_frontend_core.c @@ -9,6 +9,33 @@ #include "generated/dbg_frontend.meta.c" +//////////////////////////////// +//~ rjf: Registers Type Pure Functions + +internal void +df_regs_copy_contents(Arena *arena, DF_Regs *dst, DF_Regs *src) +{ + MemoryCopyStruct(dst, src); + dst->entity_list = d_handle_list_copy(arena, src->entity_list); + dst->file_path = push_str8_copy(arena, src->file_path); + dst->lines = d_line_list_copy(arena, &src->lines); + dst->dbgi_key = di_key_copy(arena, &src->dbgi_key); + dst->string = push_str8_copy(arena, src->string); + dst->params_tree = md_tree_copy(arena, src->params_tree); + if(dst->entity_list.count == 0 && !d_handle_match(d_handle_zero(), dst->entity)) + { + d_handle_list_push(arena, &dst->entity_list, dst->entity); + } +} + +internal DF_Regs * +df_regs_copy(Arena *arena, DF_Regs *src) +{ + DF_Regs *dst = push_array(arena, DF_Regs, 1); + df_regs_copy_contents(arena, dst, src); + return dst; +} + //////////////////////////////// //~ rjf: View Type Functions @@ -3615,7 +3642,7 @@ df_window_frame(DF_Window *ws) }break; case D_CmdParamSlot_FilePath: { - default_query = path_normalized_from_string(scratch.arena, d_current_path()); + default_query = path_normalized_from_string(scratch.arena, df_state->current_path); default_query = push_str8f(scratch.arena, "%S/", default_query); }break; } @@ -7676,6 +7703,16 @@ df_init(CmdLine *cmdln) scratch_end(scratch); } + // rjf: set up initial browse path + { + Temp scratch = scratch_begin(0, 0); + String8 current_path = os_get_current_path(scratch.arena); + String8 current_path_with_slash = push_str8f(scratch.arena, "%S/", current_path); + df_state->current_path_arena = arena_alloc(); + df_state->current_path = push_str8_copy(df_state->current_path_arena, current_path_with_slash); + scratch_end(scratch); + } + ProfEnd(); } @@ -9656,32 +9693,25 @@ df_frame(void) }break; //- rjf: undo/redo - case DF_CmdKind_Undo: - { - }break; - case DF_CmdKind_Redo: - { - }break; + case DF_CmdKind_Undo:{}break; + case DF_CmdKind_Redo:{}break; //- rjf: focus history - case DF_CmdKind_GoBack: - { - }break; - case DF_CmdKind_GoForward: - { - }break; + case DF_CmdKind_GoBack:{}break; + case DF_CmdKind_GoForward:{}break; //- rjf: files case DF_CmdKind_SetCurrentPath: { - arena_clear(d_state->current_path_arena); - d_state->current_path = push_str8_copy(d_state->current_path_arena, params->file_path); + arena_clear(df_state->current_path_arena); + df_state->current_path = push_str8_copy(df_state->current_path_arena, params->file_path); }break; //- rjf: override file links case DF_CmdKind_SetFileOverrideLinkSrc: case DF_CmdKind_SetFileOverrideLinkDst: { +#if 0 // TODO(rjf): @msgs // rjf: unpack args D_Entity *map = d_entity_from_handle(params->entity); String8 path = path_normalized_from_string(scratch.arena, params->file_path); @@ -9725,6 +9755,7 @@ df_frame(void) { d_entity_mark_for_deletion(map); } +#endif }break; case DF_CmdKind_SetFileReplacementPath: { @@ -9745,8 +9776,7 @@ df_frame(void) //- rjf: unpack String8 src_path = params->string; String8 dst_path = params->file_path; -#if 0 - // TODO(rjf): +#if 0 // TODO(rjf): @msgs //- rjf: grab src file & chosen replacement D_Entity *file = d_entity_from_handle(params.entity); @@ -9787,57 +9817,6 @@ df_frame(void) case DF_CmdKind_SetAutoViewRuleType: case DF_CmdKind_SetAutoViewRuleViewRule: { - D_Entity *map = d_entity_from_handle(params->entity); - if(d_entity_is_nil(map)) - { - map = d_entity_alloc(d_entity_root(), D_EntityKind_AutoViewRule); - d_entity_equip_cfg_src(map, D_CfgSrc_Project); - } - D_Entity *src = d_entity_child_from_kind(map, D_EntityKind_Source); - if(d_entity_is_nil(src)) - { - src = d_entity_alloc(map, D_EntityKind_Source); - } - D_Entity *dst = d_entity_child_from_kind(map, D_EntityKind_Dest); - if(d_entity_is_nil(dst)) - { - dst = d_entity_alloc(map, D_EntityKind_Dest); - } - if(map->kind == D_EntityKind_AutoViewRule) - { - D_Entity *edit_child = (kind == DF_CmdKind_SetAutoViewRuleType ? src : dst); - d_entity_equip_name(edit_child, params->string); - } - if(src->string.size == 0 && dst->string.size == 0) - { - d_entity_mark_for_deletion(map); - } - { - D_AutoViewRuleMapCache *cache = &d_state->auto_view_rule_cache; - if(cache->arena == 0) - { - cache->arena = arena_alloc(); - } - arena_clear(cache->arena); - cache->slots_count = 1024; - cache->slots = push_array(cache->arena, D_AutoViewRuleSlot, cache->slots_count); - D_EntityList maps = d_query_cached_entity_list_with_kind(D_EntityKind_AutoViewRule); - for(D_EntityNode *n = maps.first; n != 0; n = n->next) - { - D_Entity *map = n->entity; - D_Entity *src = d_entity_child_from_kind(map, D_EntityKind_Source); - D_Entity *dst = d_entity_child_from_kind(map, D_EntityKind_Dest); - String8 type = src->string; - String8 view_rule = dst->string; - U64 hash = d_hash_from_string(type); - U64 slot_idx = hash%cache->slots_count; - D_AutoViewRuleSlot *slot = &cache->slots[slot_idx]; - D_AutoViewRuleNode *node = push_array(cache->arena, D_AutoViewRuleNode, 1); - node->type = push_str8_copy(cache->arena, type); - node->view_rule = push_str8_copy(cache->arena, view_rule); - SLLQueuePush(slot->first, slot->last, node); - } - } }break; //- rjf: panel removal diff --git a/src/dbg_frontend/dbg_frontend_core.h b/src/dbg_frontend/dbg_frontend_core.h index 2f16f1e5..5dd120a1 100644 --- a/src/dbg_frontend/dbg_frontend_core.h +++ b/src/dbg_frontend/dbg_frontend_core.h @@ -760,6 +760,10 @@ struct DF_State // rjf: icon texture R_Handle icon_texture; + + // rjf: current path + Arena *current_path_arena; + String8 current_path; }; //////////////////////////////// @@ -809,6 +813,12 @@ global DF_DragDropPayload df_drag_drop_payload = {0}; global D_Handle df_last_drag_drop_panel = {0}; global D_Handle df_last_drag_drop_prev_tab = {0}; +//////////////////////////////// +//~ rjf: Registers Type Pure Functions + +internal void df_regs_copy_contents(Arena *arena, DF_Regs *dst, DF_Regs *src); +internal DF_Regs *df_regs_copy(Arena *arena, DF_Regs *src); + //////////////////////////////// //~ rjf: View Type Functions