ctrl -> d type pass

This commit is contained in:
Ryan Fleury
2026-04-22 13:37:00 -07:00
parent a90fbc844b
commit 0d8a6a4d3a
21 changed files with 1996 additions and 2132 deletions
+118 -118
View File
@@ -57,10 +57,10 @@ D_RunKind;
typedef struct D_CmdParams D_CmdParams;
struct D_CmdParams
{
CTRL_Handle machine;
CTRL_Handle process;
CTRL_Handle thread;
CTRL_Handle entity;
D_Handle machine;
D_Handle process;
D_Handle thread;
D_Handle entity;
String8 string;
String8 file_path;
TxtPt cursor;
@@ -104,7 +104,7 @@ typedef struct D_RunTLSBaseCacheNode D_RunTLSBaseCacheNode;
struct D_RunTLSBaseCacheNode
{
D_RunTLSBaseCacheNode *hash_next;
CTRL_Handle process;
D_Handle process;
U64 root_vaddr;
U64 rip_vaddr;
U64 tls_base_vaddr;
@@ -154,43 +154,43 @@ struct D_RunLocalsCache
////////////////////////////////
//~ rjf: User -> Ctrl Message Types
typedef enum CTRL_MsgKind
typedef enum D_MsgKind
{
CTRL_MsgKind_Null,
CTRL_MsgKind_Launch,
CTRL_MsgKind_Attach,
CTRL_MsgKind_Kill,
CTRL_MsgKind_KillAll,
CTRL_MsgKind_Detach,
CTRL_MsgKind_Run,
CTRL_MsgKind_SingleStep,
CTRL_MsgKind_SetUserEntryPoints,
CTRL_MsgKind_SetModuleDebugInfoPath,
CTRL_MsgKind_FreezeThread,
CTRL_MsgKind_ThawThread,
CTRL_MsgKind_COUNT,
D_MsgKind_Null,
D_MsgKind_Launch,
D_MsgKind_Attach,
D_MsgKind_Kill,
D_MsgKind_KillAll,
D_MsgKind_Detach,
D_MsgKind_Run,
D_MsgKind_SingleStep,
D_MsgKind_SetUserEntryPoints,
D_MsgKind_SetModuleDebugInfoPath,
D_MsgKind_FreezeThread,
D_MsgKind_ThawThread,
D_MsgKind_COUNT,
}
CTRL_MsgKind;
D_MsgKind;
typedef U32 CTRL_RunFlags;
typedef U32 D_RunFlags;
enum
{
CTRL_RunFlag_StopOnEntryPoint = (1<<0),
D_RunFlag_StopOnEntryPoint = (1<<0),
};
typedef struct CTRL_Msg CTRL_Msg;
struct CTRL_Msg
typedef struct D_Msg D_Msg;
struct D_Msg
{
CTRL_MsgKind kind;
CTRL_RunFlags run_flags;
CTRL_MsgID msg_id;
CTRL_Handle entity;
CTRL_Handle parent;
D_MsgKind kind;
D_RunFlags run_flags;
D_MsgID msg_id;
D_Handle entity;
D_Handle parent;
U32 entity_id;
U32 exit_code;
B32 env_inherit;
B32 debug_subprocesses;
U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64];
U64 exception_code_filters[(D_ExceptionCodeKind_COUNT+63)/64];
String8 path;
String8List entry_points;
String8List cmd_line_string_list;
@@ -198,104 +198,104 @@ struct CTRL_Msg
String8 stdout_path;
String8 stderr_path;
String8 stdin_path;
CTRL_TrapList traps;
D_TrapList traps;
CTRL_UserBreakpointList user_bps;
};
typedef struct CTRL_MsgNode CTRL_MsgNode;
struct CTRL_MsgNode
typedef struct D_MsgNode D_MsgNode;
struct D_MsgNode
{
CTRL_MsgNode *next;
CTRL_Msg v;
D_MsgNode *next;
D_Msg v;
};
typedef struct CTRL_MsgList CTRL_MsgList;
struct CTRL_MsgList
typedef struct D_MsgList D_MsgList;
struct D_MsgList
{
CTRL_MsgNode *first;
CTRL_MsgNode *last;
D_MsgNode *first;
D_MsgNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: Ctrl -> User Event Types
typedef enum CTRL_EventKind
typedef enum D_EventKind
{
CTRL_EventKind_Null,
CTRL_EventKind_Error,
D_EventKind_Null,
D_EventKind_Error,
//- rjf: starts/stops
CTRL_EventKind_Started,
CTRL_EventKind_Stopped,
D_EventKind_Started,
D_EventKind_Stopped,
//- rjf: entity creation/deletion
CTRL_EventKind_NewProc,
CTRL_EventKind_NewThread,
CTRL_EventKind_NewModule,
CTRL_EventKind_EndProc,
CTRL_EventKind_EndThread,
CTRL_EventKind_EndModule,
D_EventKind_NewProc,
D_EventKind_NewThread,
D_EventKind_NewModule,
D_EventKind_EndProc,
D_EventKind_EndThread,
D_EventKind_EndModule,
//- rjf: thread freeze state changes
CTRL_EventKind_ThreadFrozen,
CTRL_EventKind_ThreadThawed,
D_EventKind_ThreadFrozen,
D_EventKind_ThreadThawed,
//- rjf: debug info changes
CTRL_EventKind_ModuleDebugInfoPathChange,
D_EventKind_ModuleDebugInfoPathChange,
//- rjf: debug strings / decorations / markup
CTRL_EventKind_DebugString,
CTRL_EventKind_ThreadName,
CTRL_EventKind_ThreadColor,
CTRL_EventKind_SetBreakpoint,
CTRL_EventKind_UnsetBreakpoint,
CTRL_EventKind_SetVAddrRangeNote,
D_EventKind_DebugString,
D_EventKind_ThreadName,
D_EventKind_ThreadColor,
D_EventKind_SetBreakpoint,
D_EventKind_UnsetBreakpoint,
D_EventKind_SetVAddrRangeNote,
//- rjf: memory
CTRL_EventKind_MemReserve,
CTRL_EventKind_MemCommit,
CTRL_EventKind_MemDecommit,
CTRL_EventKind_MemRelease,
D_EventKind_MemReserve,
D_EventKind_MemCommit,
D_EventKind_MemDecommit,
D_EventKind_MemRelease,
CTRL_EventKind_COUNT
D_EventKind_COUNT
}
CTRL_EventKind;
D_EventKind;
typedef enum CTRL_EventCause
typedef enum D_EventCause
{
CTRL_EventCause_Null,
CTRL_EventCause_Error,
CTRL_EventCause_Finished,
CTRL_EventCause_EntryPoint,
CTRL_EventCause_UserBreakpoint,
CTRL_EventCause_InterruptedByTrap,
CTRL_EventCause_InterruptedByException,
CTRL_EventCause_InterruptedByHalt,
CTRL_EventCause_COUNT
D_EventCause_Null,
D_EventCause_Error,
D_EventCause_Finished,
D_EventCause_EntryPoint,
D_EventCause_UserBreakpoint,
D_EventCause_InterruptedByTrap,
D_EventCause_InterruptedByException,
D_EventCause_InterruptedByHalt,
D_EventCause_COUNT
}
CTRL_EventCause;
D_EventCause;
typedef enum CTRL_ExceptionKind
typedef enum D_ExceptionKind
{
CTRL_ExceptionKind_Null,
CTRL_ExceptionKind_MemoryRead,
CTRL_ExceptionKind_MemoryWrite,
CTRL_ExceptionKind_MemoryExecute,
CTRL_ExceptionKind_CppThrow,
CTRL_ExceptionKind_COUNT
D_ExceptionKind_Null,
D_ExceptionKind_MemoryRead,
D_ExceptionKind_MemoryWrite,
D_ExceptionKind_MemoryExecute,
D_ExceptionKind_CppThrow,
D_ExceptionKind_COUNT
}
CTRL_ExceptionKind;
D_ExceptionKind;
typedef struct CTRL_Event CTRL_Event;
struct CTRL_Event
typedef struct D_Event D_Event;
struct D_Event
{
CTRL_EventKind kind;
CTRL_EventCause cause;
CTRL_ExceptionKind exception_kind;
CTRL_MsgID msg_id;
CTRL_Handle entity;
CTRL_Handle parent;
D_EventKind kind;
D_EventCause cause;
D_ExceptionKind exception_kind;
D_MsgID msg_id;
D_Handle entity;
D_Handle parent;
Arch arch;
U64 u64_code;
U32 entity_id;
@@ -308,24 +308,24 @@ struct CTRL_Event
U64 timestamp;
U32 exception_code;
U32 rgba;
CTRL_UserBreakpointFlags bp_flags;
D_BreakpointFlags bp_flags;
String8 string;
OperatingSystem target_os;
CTRL_TlsModel tls_model;
D_TlsModel tls_model;
};
typedef struct CTRL_EventNode CTRL_EventNode;
struct CTRL_EventNode
typedef struct D_EventNode D_EventNode;
struct D_EventNode
{
CTRL_EventNode *next;
CTRL_Event v;
D_EventNode *next;
D_Event v;
};
typedef struct CTRL_EventList CTRL_EventList;
struct CTRL_EventList
typedef struct D_EventList D_EventList;
struct D_EventList
{
CTRL_EventNode *first;
CTRL_EventNode *last;
D_EventNode *first;
D_EventNode *last;
U64 count;
};
@@ -362,21 +362,21 @@ struct D_UserState
Arena *ctrl_last_run_arena;
D_RunKind ctrl_last_run_kind;
U64 ctrl_last_run_frame_idx;
CTRL_Handle ctrl_last_run_thread_handle;
CTRL_RunFlags ctrl_last_run_flags;
CTRL_TrapList ctrl_last_run_traps;
D_Handle ctrl_last_run_thread_handle;
D_RunFlags ctrl_last_run_flags;
D_TrapList ctrl_last_run_traps;
D_BreakpointArray ctrl_last_run_extra_bps;
U128 ctrl_last_run_param_state_hash;
B32 ctrl_is_running;
B32 ctrl_thread_run_state;
B32 ctrl_soft_halt_issued;
Arena *ctrl_msg_arena;
CTRL_MsgList ctrl_msgs;
D_MsgList ctrl_msgs;
// rjf: ctrl -> user reading state
CTRL_EntityCtxRWStore *ctrl_entity_store;
D_EntityCtxRWStore *ctrl_entity_store;
Arena *ctrl_stop_arena;
CTRL_Event ctrl_last_stop_event;
D_Event ctrl_last_stop_event;
};
////////////////////////////////
@@ -419,9 +419,9 @@ internal void d_cmd_list_push_new(Arena *arena, D_CmdList *cmds, D_CmdKind kind,
////////////////////////////////
//~ rjf: Stepping "Trap Net" Builders
internal D_TrapNet d_trap_net_from_thread__step_over_inst(Arena *arena, CTRL_Entity *thread);
internal D_TrapNet d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread);
internal D_TrapNet d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread);
internal D_TrapNet d_trap_net_from_thread__step_over_inst(Arena *arena, D_Entity *thread);
internal D_TrapNet d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread);
internal D_TrapNet d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread);
////////////////////////////////
//~ rjf: Debug Info Lookups
@@ -440,13 +440,13 @@ internal D_LineList d_lines_from_file_path_line_num(Arena *arena, String8 file_p
////////////////////////////////
//~ rjf: Process/Thread/Module Info Lookups
internal U64 d_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64 rip_vaddr);
internal U64 d_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 rip_vaddr);
////////////////////////////////
//~ rjf: Target Controls
//- rjf: stopped info from the control thread
internal CTRL_Event d_ctrl_last_stop_event(void);
internal D_Event d_ctrl_last_stop_event(void);
////////////////////////////////
//~ rjf: Main State Accessors/Mutators
@@ -463,10 +463,10 @@ internal B32 d_ctrl_targets_running(void);
internal DI_KeyList d_push_active_dbgi_key_list(Arena *arena);
//- rjf: per-run caches
internal U64 d_query_cached_rip_from_thread(CTRL_Entity *thread);
internal U64 d_query_cached_rip_from_thread_unwind(CTRL_Entity *thread, U64 unwind_count);
internal U64 d_query_cached_cfa_from_thread_unwind(CTRL_Entity *thread, U64 unwind_count);
internal U64 d_query_cached_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64 rip_vaddr);
internal U64 d_query_cached_rip_from_thread(D_Entity *thread);
internal U64 d_query_cached_rip_from_thread_unwind(D_Entity *thread, U64 unwind_count);
internal U64 d_query_cached_cfa_from_thread_unwind(D_Entity *thread, U64 unwind_count);
internal U64 d_query_cached_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 rip_vaddr);
internal E_String2NumMap *d_query_cached_locals_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);
@@ -480,6 +480,6 @@ internal B32 d_next_cmd(D_Cmd **cmd);
////////////////////////////////
//~ rjf: Main Layer Top-Level Calls
internal D_EventList d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64]);
internal D_EventList d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(D_ExceptionCodeKind_COUNT+63)/64]);
#endif // DBG_ENGINE_USER_H