mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-31 19:30:03 +00:00
split engine from frontend cmd structure; use to begin fixing/hardening engine commands and decoupling them from frontend complications
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include "generated/dbg_frontend.meta.c"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Registers Type Pure Functions
|
||||
//~ rjf: Registers Type Functions
|
||||
|
||||
internal void
|
||||
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;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ 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
|
||||
|
||||
@@ -7518,18 +7531,18 @@ df_cmd_kind_from_string(String8 string)
|
||||
internal void
|
||||
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
|
||||
|
||||
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)
|
||||
{
|
||||
start_node = CastFromMember(D_CmdNode, cmd, cmd[0]);
|
||||
start_node = CastFromMember(DF_CmdNode, cmd, cmd[0]);
|
||||
start_node = start_node->next;
|
||||
}
|
||||
cmd[0] = 0;
|
||||
@@ -8191,7 +8204,7 @@ df_frame(void)
|
||||
//
|
||||
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
|
||||
D_CmdParams *params = &cmd->params;
|
||||
@@ -8216,7 +8229,7 @@ df_frame(void)
|
||||
// rjf: try to run engine command
|
||||
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
|
||||
@@ -8278,7 +8291,7 @@ df_frame(void)
|
||||
processes.count == 1 ? "" : "es");
|
||||
D_CmdParams p = *params;
|
||||
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
|
||||
@@ -8366,7 +8379,7 @@ df_frame(void)
|
||||
{
|
||||
df_state->confirm_active = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -404,6 +404,32 @@ struct DF_MsgKindInfo
|
||||
|
||||
#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
|
||||
|
||||
@@ -670,7 +696,7 @@ struct DF_State
|
||||
|
||||
// rjf: commands
|
||||
Arena *cmds_arena;
|
||||
D_CmdList cmds;
|
||||
DF_CmdList cmds;
|
||||
|
||||
// rjf: frame request state
|
||||
U64 num_frames_requested;
|
||||
@@ -700,7 +726,7 @@ struct DF_State
|
||||
B32 confirm_active;
|
||||
F32 confirm_t;
|
||||
Arena *confirm_arena;
|
||||
D_CmdList confirm_cmds;
|
||||
DF_CmdList confirm_cmds;
|
||||
String8 confirm_title;
|
||||
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};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Registers Type Pure Functions
|
||||
//~ rjf: Registers Type 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: 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
|
||||
|
||||
@@ -1071,7 +1102,7 @@ __VA_ARGS__ \
|
||||
})
|
||||
|
||||
//- rjf: iterating
|
||||
internal B32 df_next_cmd(D_Cmd **cmd);
|
||||
internal B32 df_next_cmd(DF_Cmd **cmd);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Main Layer Top-Level Calls
|
||||
|
||||
@@ -21,7 +21,7 @@ df_code_view_init(DF_CodeViewState *cv, DF_View *view)
|
||||
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)
|
||||
{
|
||||
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);)
|
||||
for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
|
||||
{
|
||||
// rjf: mismatched window/panel => skip
|
||||
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);
|
||||
|
||||
// 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
|
||||
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);
|
||||
|
||||
// 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
|
||||
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_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
|
||||
if(!d_handle_match(d_regs()->window, cmd->params.window) ||
|
||||
@@ -6240,7 +6240,7 @@ typedef struct DF_PendingFileViewState DF_PendingFileViewState;
|
||||
struct DF_PendingFileViewState
|
||||
{
|
||||
Arena *deferred_cmd_arena;
|
||||
D_CmdList deferred_cmds;
|
||||
DF_CmdList deferred_cmds;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
//- 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
|
||||
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_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;
|
||||
}
|
||||
}
|
||||
@@ -6326,9 +6326,9 @@ DF_VIEW_CMD_FUNCTION_DEF(pending_file)
|
||||
//- rjf: if entity is ready, dispatch all deferred commands
|
||||
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);
|
||||
}
|
||||
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());
|
||||
|
||||
//- 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
|
||||
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
|
||||
//
|
||||
for(D_Cmd *cmd = 0; df_next_cmd(&cmd);)
|
||||
for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);)
|
||||
{
|
||||
D_CmdParams params = cmd->params;
|
||||
|
||||
@@ -7022,7 +7022,7 @@ DF_VIEW_SETUP_FUNCTION_DEF(memory)
|
||||
DF_VIEW_CMD_FUNCTION_DEF(memory)
|
||||
{
|
||||
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);
|
||||
D_CmdParams *params = &cmd->params;
|
||||
|
||||
Reference in New Issue
Block a user