split engine from frontend cmd structure; use to begin fixing/hardening engine commands and decoupling them from frontend complications

This commit is contained in:
Ryan Fleury
2024-09-11 17:42:34 -07:00
parent deef05d0d2
commit c8efacf707
5 changed files with 104 additions and 86 deletions
+31 -57
View File
@@ -390,10 +390,10 @@ d_cmd_params_apply_spec_query(Arena *arena, D_CmdParams *params, D_CmdSpec *spec
//- rjf: command lists //- rjf: command lists
internal void internal void
d_cmd_list_push(Arena *arena, D_CmdList *cmds, D_CmdParams *params, D_CmdSpec *spec) d_cmd_list_push_new(Arena *arena, D_CmdList *cmds, D_CmdKind kind, D_CmdParams *params)
{ {
D_CmdNode *n = push_array(arena, D_CmdNode, 1); D_CmdNode *n = push_array(arena, D_CmdNode, 1);
n->cmd.spec = spec; n->cmd.kind = kind;
n->cmd.params = df_cmd_params_copy(arena, params); n->cmd.params = df_cmd_params_copy(arena, params);
DLLPushBack(cmds->first, cmds->last, n); DLLPushBack(cmds->first, cmds->last, n);
cmds->count += 1; cmds->count += 1;
@@ -3823,9 +3823,9 @@ d_query_cached_member_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
//- rjf: top-level command dispatch //- rjf: top-level command dispatch
internal void internal void
d_push_cmd(D_CmdSpec *spec, D_CmdParams *params) d_push_cmd(D_CmdKind kind, D_CmdParams *params)
{ {
d_cmd_list_push(d_state->cmds_arena, &d_state->cmds, params, spec); d_cmd_list_push_new(d_state->cmds_arena, &d_state->cmds, kind, params);
} }
//- rjf: command iteration //- rjf: command iteration
@@ -3998,9 +3998,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
if(should_snap && stop_thread->kind == D_EntityKind_Thread) if(should_snap && stop_thread->kind == D_EntityKind_Thread)
{ {
log_infof("stop_thread: \"%S\"\n", d_display_string_from_entity(scratch.arena, stop_thread)); log_infof("stop_thread: \"%S\"\n", d_display_string_from_entity(scratch.arena, stop_thread));
D_CmdParams params = d_cmd_params_zero(); d_cmd(D_CmdKind_SelectThread, .entity = d_handle_from_entity(stop_thread));
params.entity = d_handle_from_entity(stop_thread);
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_SelectThread), &params);
} }
// rjf: if no stop-causing thread, and if selected thread, snap to selected // rjf: if no stop-causing thread, and if selected thread, snap to selected
@@ -4181,9 +4179,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
B32 do_initial_snap = (already_existing_processes.count == 1 && thread_idx_in_process == 0); B32 do_initial_snap = (already_existing_processes.count == 1 && thread_idx_in_process == 0);
if(do_initial_snap) if(do_initial_snap)
{ {
D_CmdParams params = d_cmd_params_zero(); d_cmd(D_CmdKind_SelectThread, .entity = d_handle_from_entity(entity));
params.entity = d_handle_from_entity(entity);
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_SelectThread), &params);
} }
}break; }break;
@@ -4489,8 +4485,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
{ {
// rjf: unpack command // rjf: unpack command
D_CmdParams params = cmd->params; D_CmdParams params = cmd->params;
D_CmdKind core_cmd_kind = d_cmd_kind_from_string(cmd->spec->info.string);
d_cmd_spec_counter_inc(cmd->spec);
// rjf: prep ctrl running arguments // rjf: prep ctrl running arguments
B32 need_run = 0; B32 need_run = 0;
@@ -4500,7 +4494,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
CTRL_TrapList run_traps = {0}; CTRL_TrapList run_traps = {0};
// rjf: process command // rjf: process command
switch(core_cmd_kind) switch(cmd->kind)
{ {
default:{}break; default:{}break;
@@ -4581,7 +4575,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
need_run = 1; need_run = 1;
run_kind = D_RunKind_Run; run_kind = D_RunKind_Run;
run_thread = &ctrl_entity_nil; run_thread = &ctrl_entity_nil;
run_flags = (core_cmd_kind == D_CmdKind_LaunchAndInit) ? CTRL_RunFlag_StopOnEntryPoint : 0; run_flags = (cmd->kind == D_CmdKind_LaunchAndInit) ? CTRL_RunFlag_StopOnEntryPoint : 0;
} }
// rjf: no targets -> error // rjf: no targets -> error
@@ -4700,7 +4694,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
{ {
B32 good = 1; B32 good = 1;
CTRL_TrapList traps = {0}; CTRL_TrapList traps = {0};
switch(core_cmd_kind) switch(cmd->kind)
{ {
default: break; default: break;
case D_CmdKind_StepIntoInst: {}break; case D_CmdKind_StepIntoInst: {}break;
@@ -4804,8 +4798,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
D_Entity *loc = d_entity_alloc(bp, D_EntityKind_Location); D_Entity *loc = d_entity_alloc(bp, D_EntityKind_Location);
d_entity_equip_name(loc, file_path); d_entity_equip_name(loc, file_path);
d_entity_equip_txt_pt(loc, point); d_entity_equip_txt_pt(loc, point);
D_CmdParams p = d_cmd_params_zero(); d_cmd(D_CmdKind_Run);
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_Run), &p);
}break; }break;
case D_CmdKind_RunToAddress: case D_CmdKind_RunToAddress:
{ {
@@ -4814,8 +4807,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
bp->flags |= D_EntityFlag_DiesOnRunStop; bp->flags |= D_EntityFlag_DiesOnRunStop;
D_Entity *loc = d_entity_alloc(bp, D_EntityKind_Location); D_Entity *loc = d_entity_alloc(bp, D_EntityKind_Location);
d_entity_equip_vaddr(loc, params.vaddr); d_entity_equip_vaddr(loc, params.vaddr);
D_CmdParams p = d_cmd_params_zero(); d_cmd(D_CmdKind_Run);
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_Run), &p);
}break; }break;
case D_CmdKind_Run: case D_CmdKind_Run:
{ {
@@ -4823,21 +4815,17 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
D_EntityList processes = d_query_cached_entity_list_with_kind(D_EntityKind_Process); D_EntityList processes = d_query_cached_entity_list_with_kind(D_EntityKind_Process);
if(processes.count != 0) if(processes.count != 0)
{ {
D_CmdParams params = d_cmd_params_zero(); d_cmd(D_CmdKind_Continue);
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_Continue), &params);
} }
else if(!d_ctrl_targets_running()) else if(!d_ctrl_targets_running())
{ {
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_LaunchAndRun), &params); d_cmd(D_CmdKind_LaunchAndRun);
} }
}break; }break;
case D_CmdKind_Restart: case D_CmdKind_Restart:
{ {
// rjf: kill all // rjf: kill all
{ d_cmd(D_CmdKind_KillAll);
D_CmdParams params = d_cmd_params_zero();
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_KillAll), &params);
}
// rjf: gather targets corresponding to all launched processes // rjf: gather targets corresponding to all launched processes
D_EntityList targets = {0}; D_EntityList targets = {0};
@@ -4855,11 +4843,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
} }
// rjf: re-launch targets // rjf: re-launch targets
{ d_cmd(D_CmdKind_LaunchAndRun, .entity_list = d_handle_list_from_entity_list(scratch.arena, targets));
D_CmdParams params = d_cmd_params_zero();
params.entity_list = d_handle_list_from_entity_list(scratch.arena, targets);
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_LaunchAndRun), &params);
}
}break; }break;
case D_CmdKind_StepInto: case D_CmdKind_StepInto:
case D_CmdKind_StepOver: case D_CmdKind_StepOver:
@@ -4867,24 +4851,22 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
D_EntityList processes = d_query_cached_entity_list_with_kind(D_EntityKind_Process); D_EntityList processes = d_query_cached_entity_list_with_kind(D_EntityKind_Process);
if(processes.count != 0) if(processes.count != 0)
{ {
D_CmdKind step_cmd_kind = (core_cmd_kind == D_CmdKind_StepInto D_CmdKind step_cmd_kind = (cmd->kind == D_CmdKind_StepInto
? D_CmdKind_StepIntoLine ? D_CmdKind_StepIntoLine
: D_CmdKind_StepOverLine); : D_CmdKind_StepOverLine);
B32 prefer_dasm = params.prefer_dasm; B32 prefer_dasm = params.prefer_dasm;
if(prefer_dasm) if(prefer_dasm)
{ {
step_cmd_kind = (core_cmd_kind == D_CmdKind_StepInto step_cmd_kind = (cmd->kind == D_CmdKind_StepInto
? D_CmdKind_StepIntoInst ? D_CmdKind_StepIntoInst
: D_CmdKind_StepOverInst); : D_CmdKind_StepOverInst);
} }
d_push_cmd(d_cmd_spec_from_kind(step_cmd_kind), &params); d_cmd(step_cmd_kind);
} }
else if(!d_ctrl_targets_running()) else if(!d_ctrl_targets_running())
{ {
D_EntityList targets = d_push_active_target_list(scratch.arena); D_EntityList targets = d_push_active_target_list(scratch.arena);
D_CmdParams p = params; d_cmd(D_CmdKind_LaunchAndInit, .entity_list = d_handle_list_from_entity_list(scratch.arena, targets));
p.entity_list = d_handle_list_from_entity_list(scratch.arena, targets);
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_LaunchAndInit), &p);
} }
}break; }break;
case D_CmdKind_RunToCursor: case D_CmdKind_RunToCursor:
@@ -4918,10 +4900,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
} }
} }
} }
D_CmdParams p = d_cmd_params_zero(); d_cmd(D_CmdKind_SetThreadIP, .entity = d_handle_from_entity(thread), .vaddr = new_rip_vaddr);
p.entity = d_handle_from_entity(thread);
p.vaddr = new_rip_vaddr;
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_SetThreadIP), &p);
}break; }break;
@@ -4973,7 +4952,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
if(crnt_unwind_idx < rich_unwind.frames.concrete_frame_count) if(crnt_unwind_idx < rich_unwind.frames.concrete_frame_count)
{ {
D_UnwindFrame *f = &rich_unwind.frames.v[crnt_unwind_idx]; D_UnwindFrame *f = &rich_unwind.frames.v[crnt_unwind_idx];
switch(core_cmd_kind) switch(cmd->kind)
{ {
default:{}break; default:{}break;
case D_CmdKind_UpOneFrame: case D_CmdKind_UpOneFrame:
@@ -5002,10 +4981,9 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
}break; }break;
} }
} }
D_CmdParams p = params; d_cmd(D_CmdKind_SelectUnwind,
p.unwind_index = next_unwind_idx; .unwind_index = next_unwind_idx,
p.inline_depth = next_inline_dpt; .inline_depth = next_inline_dpt);
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_SelectUnwind), &p);
di_scope_close(di_scope); di_scope_close(di_scope);
}break; }break;
case D_CmdKind_FreezeThread: case D_CmdKind_FreezeThread:
@@ -5015,31 +4993,27 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints)
case D_CmdKind_FreezeMachine: case D_CmdKind_FreezeMachine:
case D_CmdKind_ThawMachine: case D_CmdKind_ThawMachine:
{ {
D_CmdKind disptch_kind = ((core_cmd_kind == D_CmdKind_FreezeThread || D_CmdKind disptch_kind = ((cmd->kind == D_CmdKind_FreezeThread ||
core_cmd_kind == D_CmdKind_FreezeProcess || cmd->kind == D_CmdKind_FreezeProcess ||
core_cmd_kind == D_CmdKind_FreezeMachine) cmd->kind == D_CmdKind_FreezeMachine)
? D_CmdKind_FreezeEntity ? D_CmdKind_FreezeEntity
: D_CmdKind_ThawEntity); : D_CmdKind_ThawEntity);
d_push_cmd(d_cmd_spec_from_kind(disptch_kind), &params); d_push_cmd(disptch_kind, &params);
}break; }break;
case D_CmdKind_FreezeLocalMachine: case D_CmdKind_FreezeLocalMachine:
{ {
CTRL_MachineID machine_id = CTRL_MachineID_Local; CTRL_MachineID machine_id = CTRL_MachineID_Local;
D_CmdParams params = d_cmd_params_zero(); d_cmd(D_CmdKind_FreezeMachine, .entity = d_handle_from_entity(d_machine_entity_from_machine_id(machine_id)));
params.entity = d_handle_from_entity(d_machine_entity_from_machine_id(machine_id));
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_FreezeMachine), &params);
}break; }break;
case D_CmdKind_ThawLocalMachine: case D_CmdKind_ThawLocalMachine:
{ {
CTRL_MachineID machine_id = CTRL_MachineID_Local; CTRL_MachineID machine_id = CTRL_MachineID_Local;
D_CmdParams params = d_cmd_params_zero(); d_cmd(D_CmdKind_ThawMachine, .entity = d_handle_from_entity(d_machine_entity_from_machine_id(machine_id)));
params.entity = d_handle_from_entity(d_machine_entity_from_machine_id(machine_id));
d_push_cmd(d_cmd_spec_from_kind(D_CmdKind_ThawMachine), &params);
}break; }break;
case D_CmdKind_FreezeEntity: case D_CmdKind_FreezeEntity:
case D_CmdKind_ThawEntity: case D_CmdKind_ThawEntity:
{ {
B32 should_freeze = (core_cmd_kind == D_CmdKind_FreezeEntity); B32 should_freeze = (cmd->kind == D_CmdKind_FreezeEntity);
D_Entity *root = d_entity_from_handle(params.entity); D_Entity *root = d_entity_from_handle(params.entity);
for(D_Entity *e = root; !d_entity_is_nil(e); e = d_entity_rec_depth_first_pre(e, root).next) for(D_Entity *e = root; !d_entity_is_nil(e); e = d_entity_rec_depth_first_pre(e, root).next)
{ {
+4 -4
View File
@@ -497,8 +497,8 @@ struct D_CmdSpecInfoArray
typedef struct D_Cmd D_Cmd; typedef struct D_Cmd D_Cmd;
struct D_Cmd struct D_Cmd
{ {
D_CmdKind kind;
D_CmdParams params; D_CmdParams params;
D_CmdSpec *spec;
}; };
typedef struct D_CmdNode D_CmdNode; typedef struct D_CmdNode D_CmdNode;
@@ -776,7 +776,7 @@ internal D_CmdParams d_cmd_params_zero(void);
internal String8 d_cmd_params_apply_spec_query(Arena *arena, D_CmdParams *params, D_CmdSpec *spec, String8 query); internal String8 d_cmd_params_apply_spec_query(Arena *arena, D_CmdParams *params, D_CmdSpec *spec, String8 query);
//- rjf: command lists //- rjf: command lists
internal void d_cmd_list_push(Arena *arena, D_CmdList *cmds, D_CmdParams *params, D_CmdSpec *spec); internal void d_cmd_list_push_new(Arena *arena, D_CmdList *cmds, D_CmdKind kind, D_CmdParams *params);
//- rjf: string -> core layer command kind //- rjf: string -> core layer command kind
internal D_CmdKind d_cmd_kind_from_string(String8 string); internal D_CmdKind d_cmd_kind_from_string(String8 string);
@@ -1040,8 +1040,8 @@ internal E_String2NumMap *d_query_cached_locals_map_from_dbgi_key_voff(DI_Key *d
internal E_String2NumMap *d_query_cached_member_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff); internal E_String2NumMap *d_query_cached_member_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff);
//- rjf: top-level command dispatch //- rjf: top-level command dispatch
internal void d_push_cmd(D_CmdSpec *spec, D_CmdParams *params); internal void d_push_cmd(D_CmdKind kind, D_CmdParams *params);
#define d_cmd(kind, ...) d_push_cmd(d_cmd_spec_from_kind(kind), \ #define d_cmd(kind, ...) d_push_cmd((kind), \
&(D_CmdParams) \ &(D_CmdParams) \
{ \ { \
.window = d_regs()->window, \ .window = d_regs()->window, \
+22 -9
View File
@@ -10,7 +10,7 @@
#include "generated/dbg_frontend.meta.c" #include "generated/dbg_frontend.meta.c"
//////////////////////////////// ////////////////////////////////
//~ rjf: Registers Type Pure Functions //~ rjf: Registers Type Functions
internal void internal void
df_regs_copy_contents(Arena *arena, DF_Regs *dst, DF_Regs *src) df_regs_copy_contents(Arena *arena, DF_Regs *dst, DF_Regs *src)
@@ -36,6 +36,19 @@ df_regs_copy(Arena *arena, DF_Regs *src)
return dst; return dst;
} }
////////////////////////////////
//~ rjf: Commands Type Functions
internal void
df_cmd_list_push_new(Arena *arena, DF_CmdList *cmds, D_CmdSpec *spec, D_CmdParams *params)
{
DF_CmdNode *n = push_array(arena, DF_CmdNode, 1);
n->cmd.spec = spec;
n->cmd.params = df_cmd_params_copy(arena, params);
DLLPushBack(cmds->first, cmds->last, n);
cmds->count += 1;
}
//////////////////////////////// ////////////////////////////////
//~ rjf: View Type Functions //~ rjf: View Type Functions
@@ -7518,18 +7531,18 @@ df_cmd_kind_from_string(String8 string)
internal void internal void
df_push_cmd(D_CmdSpec *spec, D_CmdParams *params) df_push_cmd(D_CmdSpec *spec, D_CmdParams *params)
{ {
d_cmd_list_push(df_state->cmds_arena, &df_state->cmds, params, spec); df_cmd_list_push_new(df_state->cmds_arena, &df_state->cmds, spec, params);
} }
//- rjf: iterating //- rjf: iterating
internal B32 internal B32
df_next_cmd(D_Cmd **cmd) df_next_cmd(DF_Cmd **cmd)
{ {
D_CmdNode *start_node = df_state->cmds.first; DF_CmdNode *start_node = df_state->cmds.first;
if(cmd[0] != 0) if(cmd[0] != 0)
{ {
start_node = CastFromMember(D_CmdNode, cmd, cmd[0]); start_node = CastFromMember(DF_CmdNode, cmd, cmd[0]);
start_node = start_node->next; start_node = start_node->next;
} }
cmd[0] = 0; cmd[0] = 0;
@@ -8191,7 +8204,7 @@ df_frame(void)
// //
B32 panel_reset_done = 0; B32 panel_reset_done = 0;
{ {
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
{ {
// rjf: unpack command // rjf: unpack command
D_CmdParams *params = &cmd->params; D_CmdParams *params = &cmd->params;
@@ -8216,7 +8229,7 @@ df_frame(void)
// rjf: try to run engine command // rjf: try to run engine command
if(D_CmdKind_Null < (D_CmdKind)kind && (D_CmdKind)kind < D_CmdKind_COUNT) if(D_CmdKind_Null < (D_CmdKind)kind && (D_CmdKind)kind < D_CmdKind_COUNT)
{ {
d_push_cmd(cmd->spec, params); d_push_cmd((D_CmdKind)kind, params);
} }
// rjf: try to open tabs for "view driver" commands // rjf: try to open tabs for "view driver" commands
@@ -8278,7 +8291,7 @@ df_frame(void)
processes.count == 1 ? "" : "es"); processes.count == 1 ? "" : "es");
D_CmdParams p = *params; D_CmdParams p = *params;
p.force_confirm = 1; p.force_confirm = 1;
d_cmd_list_push(df_state->confirm_arena, &df_state->confirm_cmds, &p, df_cmd_spec_from_kind(DF_CmdKind_Exit)); df_cmd_list_push_new(df_state->confirm_arena, &df_state->confirm_cmds, df_cmd_spec_from_kind(DF_CmdKind_Exit), &p);
} }
// rjf: otherwise, actually exit // rjf: otherwise, actually exit
@@ -8366,7 +8379,7 @@ df_frame(void)
{ {
df_state->confirm_active = 0; df_state->confirm_active = 0;
df_state->confirm_key = ui_key_zero(); df_state->confirm_key = ui_key_zero();
for(D_CmdNode *n = df_state->confirm_cmds.first; n != 0; n = n->next) for(DF_CmdNode *n = df_state->confirm_cmds.first; n != 0; n = n->next)
{ {
df_push_cmd(n->cmd.spec, &n->cmd.params); df_push_cmd(n->cmd.spec, &n->cmd.params);
} }
+35 -4
View File
@@ -404,6 +404,32 @@ struct DF_MsgKindInfo
#include "generated/dbg_frontend.meta.h" #include "generated/dbg_frontend.meta.h"
////////////////////////////////
//~ rjf: Command Types
typedef struct DF_Cmd DF_Cmd;
struct DF_Cmd
{
D_CmdSpec *spec;
D_CmdParams params;
};
typedef struct DF_CmdNode DF_CmdNode;
struct DF_CmdNode
{
DF_CmdNode *next;
DF_CmdNode *prev;
DF_Cmd cmd;
};
typedef struct DF_CmdList DF_CmdList;
struct DF_CmdList
{
DF_CmdNode *first;
DF_CmdNode *last;
U64 count;
};
//////////////////////////////// ////////////////////////////////
//~ rjf: Context Register Types //~ rjf: Context Register Types
@@ -670,7 +696,7 @@ struct DF_State
// rjf: commands // rjf: commands
Arena *cmds_arena; Arena *cmds_arena;
D_CmdList cmds; DF_CmdList cmds;
// rjf: frame request state // rjf: frame request state
U64 num_frames_requested; U64 num_frames_requested;
@@ -700,7 +726,7 @@ struct DF_State
B32 confirm_active; B32 confirm_active;
F32 confirm_t; F32 confirm_t;
Arena *confirm_arena; Arena *confirm_arena;
D_CmdList confirm_cmds; DF_CmdList confirm_cmds;
String8 confirm_title; String8 confirm_title;
String8 confirm_desc; String8 confirm_desc;
@@ -823,11 +849,16 @@ global D_Handle df_last_drag_drop_panel = {0};
global D_Handle df_last_drag_drop_prev_tab = {0}; global D_Handle df_last_drag_drop_prev_tab = {0};
//////////////////////////////// ////////////////////////////////
//~ rjf: Registers Type Pure Functions //~ rjf: Registers Type Functions
internal void df_regs_copy_contents(Arena *arena, DF_Regs *dst, DF_Regs *src); 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); internal DF_Regs *df_regs_copy(Arena *arena, DF_Regs *src);
////////////////////////////////
//~ rjf: Commands Type Functions
internal void df_cmd_list_push_new(Arena *arena, DF_CmdList *cmds, D_CmdSpec *spec, D_CmdParams *params);
//////////////////////////////// ////////////////////////////////
//~ rjf: View Type Functions //~ rjf: View Type Functions
@@ -1071,7 +1102,7 @@ __VA_ARGS__ \
}) })
//- rjf: iterating //- rjf: iterating
internal B32 df_next_cmd(D_Cmd **cmd); internal B32 df_next_cmd(DF_Cmd **cmd);
//////////////////////////////// ////////////////////////////////
//~ rjf: Main Layer Top-Level Calls //~ rjf: Main Layer Top-Level Calls
+12 -12
View File
@@ -21,7 +21,7 @@ df_code_view_init(DF_CodeViewState *cv, DF_View *view)
internal void internal void
df_code_view_cmds(DF_View *view, DF_CodeViewState *cv, String8 text_data, TXT_TextInfo *text_info, DASM_LineArray *dasm_lines, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key) df_code_view_cmds(DF_View *view, DF_CodeViewState *cv, String8 text_data, TXT_TextInfo *text_info, DASM_LineArray *dasm_lines, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key)
{ {
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
{ {
// rjf: mismatched window/panel => skip // rjf: mismatched window/panel => skip
if(!d_handle_match(d_regs()->window, cmd->params.window) || if(!d_handle_match(d_regs()->window, cmd->params.window) ||
@@ -4670,7 +4670,7 @@ DF_VIEW_CMD_FUNCTION_DEF(target)
D_Entity *entity = d_entity_from_eval_string(string); D_Entity *entity = d_entity_from_eval_string(string);
// rjf: process commands // rjf: process commands
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
{ {
// rjf: mismatched window/panel => skip // rjf: mismatched window/panel => skip
if(!d_handle_match(d_regs()->window, cmd->params.window) || if(!d_handle_match(d_regs()->window, cmd->params.window) ||
@@ -5155,7 +5155,7 @@ DF_VIEW_CMD_FUNCTION_DEF(file_path_map)
DF_FilePathMapViewState *fpms = df_view_user_state(view, DF_FilePathMapViewState); DF_FilePathMapViewState *fpms = df_view_user_state(view, DF_FilePathMapViewState);
// rjf: process commands // rjf: process commands
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
{ {
// rjf: mismatched window/panel => skip // rjf: mismatched window/panel => skip
if(!d_handle_match(d_regs()->window, cmd->params.window) || if(!d_handle_match(d_regs()->window, cmd->params.window) ||
@@ -5788,7 +5788,7 @@ DF_VIEW_SETUP_FUNCTION_DEF(modules)
DF_VIEW_CMD_FUNCTION_DEF(modules) DF_VIEW_CMD_FUNCTION_DEF(modules)
{ {
DF_ModulesViewState *mv = df_view_user_state(view, DF_ModulesViewState); DF_ModulesViewState *mv = df_view_user_state(view, DF_ModulesViewState);
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
{ {
// rjf: mismatched window/panel => skip // rjf: mismatched window/panel => skip
if(!d_handle_match(d_regs()->window, cmd->params.window) || if(!d_handle_match(d_regs()->window, cmd->params.window) ||
@@ -6240,7 +6240,7 @@ typedef struct DF_PendingFileViewState DF_PendingFileViewState;
struct DF_PendingFileViewState struct DF_PendingFileViewState
{ {
Arena *deferred_cmd_arena; Arena *deferred_cmd_arena;
D_CmdList deferred_cmds; DF_CmdList deferred_cmds;
}; };
DF_VIEW_SETUP_FUNCTION_DEF(pending_file) DF_VIEW_SETUP_FUNCTION_DEF(pending_file)
@@ -6255,7 +6255,7 @@ DF_VIEW_CMD_FUNCTION_DEF(pending_file)
DF_PendingFileViewState *pves = df_view_user_state(view, DF_PendingFileViewState); DF_PendingFileViewState *pves = df_view_user_state(view, DF_PendingFileViewState);
//- rjf: process commands //- rjf: process commands
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
{ {
// rjf: mismatched window/panel => skip // rjf: mismatched window/panel => skip
if(!d_handle_match(d_regs()->window, cmd->params.window) || if(!d_handle_match(d_regs()->window, cmd->params.window) ||
@@ -6276,7 +6276,7 @@ DF_VIEW_CMD_FUNCTION_DEF(pending_file)
case DF_CmdKind_CenterCursor: case DF_CmdKind_CenterCursor:
case DF_CmdKind_ContainCursor: case DF_CmdKind_ContainCursor:
{ {
d_cmd_list_push(pves->deferred_cmd_arena, &pves->deferred_cmds, &cmd->params, cmd->spec); df_cmd_list_push_new(pves->deferred_cmd_arena, &pves->deferred_cmds, cmd->spec, &cmd->params);
}break; }break;
} }
} }
@@ -6326,9 +6326,9 @@ DF_VIEW_CMD_FUNCTION_DEF(pending_file)
//- rjf: if entity is ready, dispatch all deferred commands //- rjf: if entity is ready, dispatch all deferred commands
if(file_is_ready) if(file_is_ready)
{ {
for(D_CmdNode *cmd_node = pves->deferred_cmds.first; cmd_node != 0; cmd_node = cmd_node->next) for(DF_CmdNode *cmd_node = pves->deferred_cmds.first; cmd_node != 0; cmd_node = cmd_node->next)
{ {
D_Cmd *cmd = &cmd_node->cmd; DF_Cmd *cmd = &cmd_node->cmd;
df_push_cmd(cmd->spec, &cmd->params); df_push_cmd(cmd->spec, &cmd->params);
} }
arena_clear(pves->deferred_cmd_arena); arena_clear(pves->deferred_cmd_arena);
@@ -6398,7 +6398,7 @@ DF_VIEW_CMD_FUNCTION_DEF(text)
df_code_view_cmds(view, cv, data, &info, 0, r1u64(0, 0), di_key_zero()); df_code_view_cmds(view, cv, data, &info, 0, r1u64(0, 0), di_key_zero());
//- rjf: process code-file commands //- rjf: process code-file commands
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
{ {
// rjf: mismatched window/panel => skip // rjf: mismatched window/panel => skip
if(!d_handle_match(d_regs()->window, cmd->params.window) || if(!d_handle_match(d_regs()->window, cmd->params.window) ||
@@ -6717,7 +6717,7 @@ DF_VIEW_CMD_FUNCTION_DEF(disasm)
////////////////////////////// //////////////////////////////
//- rjf: process disassembly-specific commands //- rjf: process disassembly-specific commands
// //
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
{ {
D_CmdParams params = cmd->params; D_CmdParams params = cmd->params;
@@ -7022,7 +7022,7 @@ DF_VIEW_SETUP_FUNCTION_DEF(memory)
DF_VIEW_CMD_FUNCTION_DEF(memory) DF_VIEW_CMD_FUNCTION_DEF(memory)
{ {
DF_MemoryViewState *mv = df_view_user_state(view, DF_MemoryViewState); DF_MemoryViewState *mv = df_view_user_state(view, DF_MemoryViewState);
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
{ {
DF_CmdKind kind = df_cmd_kind_from_string(cmd->spec->info.string); DF_CmdKind kind = df_cmd_kind_from_string(cmd->spec->info.string);
D_CmdParams *params = &cmd->params; D_CmdParams *params = &cmd->params;