set up scaffolding for dbg engine/frontendm sgs

This commit is contained in:
Ryan Fleury
2024-08-30 15:24:35 -07:00
parent 533fd0041f
commit 8770a43678
9 changed files with 609 additions and 0 deletions
+122
View File
@@ -144,6 +144,128 @@ D_RegTable:
@expand(D_RegTable a) `{OffsetOf(D_Regs, $(a.name_lower)), OffsetOf(D_Regs, $(a.name_lower)) + sizeof($(a.c_type))}`
}
@gen
{
`#define d_regs_lit_init_top \\`
@expand(D_RegTable a) `.$(a.name_lower) = d_regs()->$(a.name_lower),\\`
``;
}
////////////////////////////////
//~ rjf: Message Tables
@table(name name_lower show_in_ui show_in_ipc_docs q_slot q_ent_kind q_allow_files q_allow_folders q_keep_oi q_select_oi q_is_code q_required canonical_icon desc)
D_MsgKindTable:
{
{Null null 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: low level target operations
{LaunchAndRun launch_and_run 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{LaunchAndInit launch_and_init 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{Kill kill 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{KillAll kill_all 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{Attach attach 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{Detach detach 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{Continue continue 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{StepIntoInst step_into_inst 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{StepOverInst step_over_inst 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{StepIntoLine step_into_line 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{StepOverLine step_over_line 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{StepOut step_out 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{Halt halt 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{SoftHaltRefresh soft_halt_refresh 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{SetThreadIP set_thread_ip 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: high level target operations
{RunToLine run_to_line 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{RunToAddress run_to_address 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{Run run 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{Restart restart 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{StepInto step_into 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{StepOver step_over 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: thread / frame selection
{SelectThread select_thread 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{SelectUnwind select_unwind 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{UpOneFrame up_one_frame 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{DownOneFrame down_one_frame 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: thread freezing/thawing
{FreezeThread freeze_thread 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{ThawThread thaw_thread 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{FreezeProcess freeze_process 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{ThawProcess thaw_process 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{FreezeMachine freeze_machine 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{ThawMachine thaw_machine 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{FreezeLocalMachine freeze_local_machine 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{ThawLocalMachine thaw_local_machine 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: path overrides
{SetFileOverrideLinkSrc set_file_override_link_src 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{SetFileOverrideLinkDst set_file_override_link_dst 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{SetFileReplacementPath set_file_replacement_path 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: auto view rules
{SetAutoViewRuleType set_auto_view_rule_type 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{SetAutoViewRuleViewRule set_auto_view_rule_view_rule 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: general entity operations
{EnableEntity enable_entity 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{EnableBreakpoint enable_breakpoint 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{EnableTarget enable_target 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{DisableEntity disable_entity 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{DisableBreakpoint disable_breakpoint 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{DisableTarget disable_target 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{FreezeEntity freeze_entity 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{ThawEntity thaw_entity 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{RemoveEntity remove_entity 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{RemoveBreakpoint remove_breakpoint 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{RemoveTarget remove_target 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{NameEntity name_entity 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{DuplicateEntity duplicate_entity 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{RelocateEntity relocate_entity 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: breakpoints
{AddBreakpoint add_breakpoint 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{ToggleBreakpoint toggle_breakpoint 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{AddAddressBreakpoint add_address_breakpoint 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{AddFunctionBreakpoint add_function_breakpoint 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: watch pins
{AddWatchPin add_watch_pin 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{ToggleWatchPin toggle_watch_pin 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: watch expressions
{ToggleWatchExpression toggle_watch_expression 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: at-cursor operations
{ToggleBreakpointAtCursor toggle_breakpoint_at_cursor 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{ToggleWatchPinAtCursor toggle_watch_pin_at_cursor 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{ToggleWatchExpressionAtCursor toggle_watch_expression_at_cursor 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{GoToNameAtCursor go_to_name_at_cursor 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{RunToCursor run_to_cursor 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{SetNextStatement set_next_statement 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: targets
{AddTarget add_target 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{SelectTarget select_target 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{RetryEndedProcess retry_ended_process 0 0 Null Nil 0 0 0 0 0 0 Null ""}
//- rjf: meta
{RegisterAsJITDebugger register_as_jit_debugger 0 0 Null Nil 0 0 0 0 0 0 Null ""}
{LogMarker log_marker 0 0 Null Nil 0 0 0 0 0 0 Null ""}
}
@enum D_MsgKind:
{
@expand(D_MsgKindTable a) `$(a.name)`
}
@data(String8) d_msg_kind_name_lower_table:
{
@expand(D_MsgKindTable a) `str8_lit_comp("$(a.name_lower)")`
}
////////////////////////////////
//~ rjf: Built-In Command Tables
+13
View File
@@ -6215,6 +6215,19 @@ d_errorf(char *fmt, ...)
scratch_end(scratch);
}
////////////////////////////////
//~ rjf: Message Functions
internal void
d_msg_(D_MsgKind kind, D_Regs *regs)
{
D_MsgNode *n = push_array(d_state->msgs_arena, D_MsgNode, 1);
SLLQueuePush(d_state->msgs.first, d_state->msgs.last, n);
d_state->msgs.count += 1;
n->v.kind = kind;
n->v.regs = d_regs_copy(d_state->msgs_arena, regs);
}
////////////////////////////////
//~ rjf: Main Layer Top-Level Calls
+40
View File
@@ -657,6 +657,31 @@ struct D_EvalVizWindowedRowList
U64 count_before_semantic;
};
////////////////////////////////
//~ rjf: Message Types
typedef struct D_Msg D_Msg;
struct D_Msg
{
D_MsgKind kind;
D_Regs *regs;
};
typedef struct D_MsgNode D_MsgNode;
struct D_MsgNode
{
D_MsgNode *next;
D_Msg v;
};
typedef struct D_MsgList D_MsgList;
struct D_MsgList
{
D_MsgNode *first;
D_MsgNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: Command Specification Types
@@ -957,6 +982,10 @@ struct D_State
D_RegsNode base_regs;
D_RegsNode *top_regs;
// rjf: messages
Arena *msgs_arena;
D_MsgList msgs;
// rjf: top-level command batch
Arena *root_cmd_arena;
D_CmdList root_cmds;
@@ -1529,6 +1558,17 @@ internal void d_errorf(char *fmt, ...);
__VA_ARGS__ \
})
////////////////////////////////
//~ rjf: Message Functions
internal void d_msg_(D_MsgKind kind, D_Regs *regs);
#define d_msg(kind, ...) d_msg_((kind),\
&(D_Regs)\
{\
d_regs_lit_init_top\
__VA_ARGS__\
})
////////////////////////////////
//~ rjf: Main Layer Top-Level Calls
@@ -34,6 +34,81 @@ Rng1U64 d_reg_slot_range_table[26] =
{OffsetOf(D_Regs, params_tree), OffsetOf(D_Regs, params_tree) + sizeof(MD_Node *)},
};
String8 d_msg_kind_name_lower_table[71] =
{
str8_lit_comp("null"),
str8_lit_comp("launch_and_run"),
str8_lit_comp("launch_and_init"),
str8_lit_comp("kill"),
str8_lit_comp("kill_all"),
str8_lit_comp("attach"),
str8_lit_comp("detach"),
str8_lit_comp("continue"),
str8_lit_comp("step_into_inst"),
str8_lit_comp("step_over_inst"),
str8_lit_comp("step_into_line"),
str8_lit_comp("step_over_line"),
str8_lit_comp("step_out"),
str8_lit_comp("halt"),
str8_lit_comp("soft_halt_refresh"),
str8_lit_comp("set_thread_ip"),
str8_lit_comp("run_to_line"),
str8_lit_comp("run_to_address"),
str8_lit_comp("run"),
str8_lit_comp("restart"),
str8_lit_comp("step_into"),
str8_lit_comp("step_over"),
str8_lit_comp("select_thread"),
str8_lit_comp("select_unwind"),
str8_lit_comp("up_one_frame"),
str8_lit_comp("down_one_frame"),
str8_lit_comp("freeze_thread"),
str8_lit_comp("thaw_thread"),
str8_lit_comp("freeze_process"),
str8_lit_comp("thaw_process"),
str8_lit_comp("freeze_machine"),
str8_lit_comp("thaw_machine"),
str8_lit_comp("freeze_local_machine"),
str8_lit_comp("thaw_local_machine"),
str8_lit_comp("set_file_override_link_src"),
str8_lit_comp("set_file_override_link_dst"),
str8_lit_comp("set_file_replacement_path"),
str8_lit_comp("set_auto_view_rule_type"),
str8_lit_comp("set_auto_view_rule_view_rule"),
str8_lit_comp("enable_entity"),
str8_lit_comp("enable_breakpoint"),
str8_lit_comp("enable_target"),
str8_lit_comp("disable_entity"),
str8_lit_comp("disable_breakpoint"),
str8_lit_comp("disable_target"),
str8_lit_comp("freeze_entity"),
str8_lit_comp("thaw_entity"),
str8_lit_comp("remove_entity"),
str8_lit_comp("remove_breakpoint"),
str8_lit_comp("remove_target"),
str8_lit_comp("name_entity"),
str8_lit_comp("duplicate_entity"),
str8_lit_comp("relocate_entity"),
str8_lit_comp("add_breakpoint"),
str8_lit_comp("toggle_breakpoint"),
str8_lit_comp("add_address_breakpoint"),
str8_lit_comp("add_function_breakpoint"),
str8_lit_comp("add_watch_pin"),
str8_lit_comp("toggle_watch_pin"),
str8_lit_comp("toggle_watch_expression"),
str8_lit_comp("toggle_breakpoint_at_cursor"),
str8_lit_comp("toggle_watch_pin_at_cursor"),
str8_lit_comp("toggle_watch_expression_at_cursor"),
str8_lit_comp("go_to_name_at_cursor"),
str8_lit_comp("run_to_cursor"),
str8_lit_comp("set_next_statement"),
str8_lit_comp("add_target"),
str8_lit_comp("select_target"),
str8_lit_comp("retry_ended_process"),
str8_lit_comp("register_as_jit_debugger"),
str8_lit_comp("log_marker"),
};
Rng1U64 d_cmd_param_slot_range_table[23] =
{
{OffsetOf(D_CmdParams, window), OffsetOf(D_CmdParams, window) + sizeof(D_Handle)},
+104
View File
@@ -36,6 +36,81 @@ D_RegSlot_String,
D_RegSlot_ParamsTree,
} D_RegSlot;
typedef enum D_MsgKind
{
D_MsgKind_Null,
D_MsgKind_LaunchAndRun,
D_MsgKind_LaunchAndInit,
D_MsgKind_Kill,
D_MsgKind_KillAll,
D_MsgKind_Attach,
D_MsgKind_Detach,
D_MsgKind_Continue,
D_MsgKind_StepIntoInst,
D_MsgKind_StepOverInst,
D_MsgKind_StepIntoLine,
D_MsgKind_StepOverLine,
D_MsgKind_StepOut,
D_MsgKind_Halt,
D_MsgKind_SoftHaltRefresh,
D_MsgKind_SetThreadIP,
D_MsgKind_RunToLine,
D_MsgKind_RunToAddress,
D_MsgKind_Run,
D_MsgKind_Restart,
D_MsgKind_StepInto,
D_MsgKind_StepOver,
D_MsgKind_SelectThread,
D_MsgKind_SelectUnwind,
D_MsgKind_UpOneFrame,
D_MsgKind_DownOneFrame,
D_MsgKind_FreezeThread,
D_MsgKind_ThawThread,
D_MsgKind_FreezeProcess,
D_MsgKind_ThawProcess,
D_MsgKind_FreezeMachine,
D_MsgKind_ThawMachine,
D_MsgKind_FreezeLocalMachine,
D_MsgKind_ThawLocalMachine,
D_MsgKind_SetFileOverrideLinkSrc,
D_MsgKind_SetFileOverrideLinkDst,
D_MsgKind_SetFileReplacementPath,
D_MsgKind_SetAutoViewRuleType,
D_MsgKind_SetAutoViewRuleViewRule,
D_MsgKind_EnableEntity,
D_MsgKind_EnableBreakpoint,
D_MsgKind_EnableTarget,
D_MsgKind_DisableEntity,
D_MsgKind_DisableBreakpoint,
D_MsgKind_DisableTarget,
D_MsgKind_FreezeEntity,
D_MsgKind_ThawEntity,
D_MsgKind_RemoveEntity,
D_MsgKind_RemoveBreakpoint,
D_MsgKind_RemoveTarget,
D_MsgKind_NameEntity,
D_MsgKind_DuplicateEntity,
D_MsgKind_RelocateEntity,
D_MsgKind_AddBreakpoint,
D_MsgKind_ToggleBreakpoint,
D_MsgKind_AddAddressBreakpoint,
D_MsgKind_AddFunctionBreakpoint,
D_MsgKind_AddWatchPin,
D_MsgKind_ToggleWatchPin,
D_MsgKind_ToggleWatchExpression,
D_MsgKind_ToggleBreakpointAtCursor,
D_MsgKind_ToggleWatchPinAtCursor,
D_MsgKind_ToggleWatchExpressionAtCursor,
D_MsgKind_GoToNameAtCursor,
D_MsgKind_RunToCursor,
D_MsgKind_SetNextStatement,
D_MsgKind_AddTarget,
D_MsgKind_SelectTarget,
D_MsgKind_RetryEndedProcess,
D_MsgKind_RegisterAsJITDebugger,
D_MsgKind_LogMarker,
} D_MsgKind;
typedef enum D_CfgSrc
{
D_CfgSrc_User,
@@ -421,6 +496,34 @@ U64 unwind_index;
U64 inline_depth;
};
#define d_regs_lit_init_top \
.module = d_regs()->module,\
.process = d_regs()->process,\
.thread = d_regs()->thread,\
.window = d_regs()->window,\
.panel = d_regs()->panel,\
.view = d_regs()->view,\
.prev_view = d_regs()->prev_view,\
.dst_panel = d_regs()->dst_panel,\
.entity = d_regs()->entity,\
.entity_list = d_regs()->entity_list,\
.unwind_count = d_regs()->unwind_count,\
.inline_depth = d_regs()->inline_depth,\
.file_path = d_regs()->file_path,\
.cursor = d_regs()->cursor,\
.mark = d_regs()->mark,\
.text_key = d_regs()->text_key,\
.lang_kind = d_regs()->lang_kind,\
.lines = d_regs()->lines,\
.dbgi_key = d_regs()->dbgi_key,\
.vaddr_range = d_regs()->vaddr_range,\
.voff_range = d_regs()->voff_range,\
.force_confirm = d_regs()->force_confirm,\
.prefer_disasm = d_regs()->prefer_disasm,\
.dir2 = d_regs()->dir2,\
.string = d_regs()->string,\
.params_tree = d_regs()->params_tree,\
D_VIEW_RULE_EXPR_RESOLUTION_FUNCTION_DEF(array);
D_VIEW_RULE_EXPR_RESOLUTION_FUNCTION_DEF(slice);
D_VIEW_RULE_EXPR_RESOLUTION_FUNCTION_DEF(bswap);
@@ -461,6 +564,7 @@ struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] =
};
C_LINKAGE_BEGIN
extern Rng1U64 d_reg_slot_range_table[26];
extern String8 d_msg_kind_name_lower_table[71];
extern Rng1U64 d_cmd_param_slot_range_table[23];
extern String8 d_entity_kind_display_string_table[31];
extern String8 d_entity_kind_name_lower_table[31];