deduplicate debug string event generation; log ctrl messages

This commit is contained in:
Ryan Fleury
2024-05-31 11:17:59 -07:00
parent ed8731c093
commit d3adfdeced
3 changed files with 24 additions and 8 deletions
+22
View File
@@ -43,6 +43,25 @@ ctrl_event_cause_from_dmn_event_kind(DMN_EventKind event_kind)
return cause;
}
internal String8
ctrl_string_from_msg_kind(CTRL_MsgKind kind)
{
String8 result = {0};
switch(kind)
{
default:{}break;
case CTRL_MsgKind_Launch: {result = str8_lit("Launch");}break;
case CTRL_MsgKind_Attach: {result = str8_lit("Attach");}break;
case CTRL_MsgKind_Kill: {result = str8_lit("Kill");}break;
case CTRL_MsgKind_Detach: {result = str8_lit("Detach");}break;
case CTRL_MsgKind_Run: {result = str8_lit("Run");}break;
case CTRL_MsgKind_SingleStep: {result = str8_lit("SingleStep");}break;
case CTRL_MsgKind_SetUserEntryPoints: {result = str8_lit("SetUserEntryPoints");}break;
case CTRL_MsgKind_SetModuleDebugInfoPath: {result = str8_lit("SetModuleDebugInfoPath");}break;
}
return result;
}
////////////////////////////////
//~ rjf: Machine/Handle Pair Type Functions
@@ -2823,6 +2842,9 @@ ctrl_thread__entry_point(void *p)
for(CTRL_MsgNode *msg_n = msgs.first; msg_n != 0 && done == 0; msg_n = msg_n->next)
{
CTRL_Msg *msg = &msg_n->v;
{
log_infof("[user -> ctrl %S message]\n", ctrl_string_from_msg_kind(msg->kind));
}
MemoryCopyArray(ctrl_state->exception_code_filters, msg->exception_code_filters);
switch(msg->kind)
{
+1
View File
@@ -636,6 +636,7 @@ read_only global CTRL_Entity ctrl_entity_nil =
internal U64 ctrl_hash_from_string(String8 string);
internal U64 ctrl_hash_from_machine_id_handle(CTRL_MachineID machine_id, DMN_Handle handle);
internal CTRL_EventCause ctrl_event_cause_from_dmn_event_kind(DMN_EventKind event_kind);
internal String8 ctrl_string_from_msg_kind(CTRL_MsgKind kind);
////////////////////////////////
//~ rjf: Machine/Handle Pair Type Functions
+1 -8
View File
@@ -2163,16 +2163,9 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
str8_list_push(scratch.arena, &debug_strings, debug_string);
keep_going = 1;
// rjf: generate event, given sufficient amount of text
// rjf: exit loop, given sufficient amount of text
if(debug_strings.total_size >= KB(4))
{
String8 debug_strings_joined = str8_list_join(arena, &debug_strings, 0);
MemoryZeroStruct(&debug_strings);
DMN_Event *e = dmn_event_list_push(arena, &events);
e->kind = DMN_EventKind_DebugString;
e->process = dmn_w32_handle_from_entity(process);
e->thread = dmn_w32_handle_from_entity(thread);
e->string = debug_strings_joined;
keep_going = 0;
}
}break;