first pass at per-target output log labels

This commit is contained in:
Ryan Fleury
2026-06-02 12:10:47 -07:00
parent eb90ddc739
commit 1c29112e9c
16 changed files with 161 additions and 61 deletions
+1
View File
@@ -104,6 +104,7 @@ D_EntityKindTable:
{Thread thread "Thread" }
{Module module "Module" }
{EntryPoint entry_point "Entry Point" }
{LaunchMsgID launch_msg_id "Launch Message ID" }
{DebugInfoPath debug_info_path "Debug Info Path" }
{PendingThreadName pending_thread_name "Pending Thread Name" }
{PendingThreadColor pending_thread_color "Pending Thread Color" }
+1 -2
View File
@@ -86,8 +86,7 @@ d_init(void)
d_user_state = push_array(arena, D_UserState, 1);
d_user_state->arena = arena;
d_user_state->cmds_arena = arena_alloc();
d_user_state->output_log_key = c_key_make(c_root_alloc(), c_id_make(0, 0));
c_submit_data(d_user_state->output_log_key, 0, str8_zero());
d_user_state->output_log_root = c_root_alloc();
d_user_state->ctrl_entity_store = d_entity_ctx_rw_store_alloc();
d_user_state->ctrl_stop_arena = arena_alloc();
d_user_state->ctrl_msg_arena = arena_alloc();
+2
View File
@@ -140,6 +140,7 @@ struct D_Entity
U64 tls_index;
U64 tls_offset;
OperatingSystem target_os;
D_MsgID src_msg_id;
};
typedef struct D_EntityNode D_EntityNode;
@@ -248,6 +249,7 @@ struct D_Target
String8 stdout_path;
String8 stderr_path;
String8 stdin_path;
D_MsgID msg_id;
B32 debug_subprocesses;
String8List env;
};
+26 -6
View File
@@ -1302,6 +1302,7 @@ d_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list)
D_Entity *process = d_entity_alloc(store, machine, D_EntityKind_Process, event->arch, event->entity, (U64)event->entity_id);
process->tls_model = event->tls_model;
process->target_os = event->target_os;
process->src_msg_id = event->msg_id;
d_entity_equip_string(store, process, event->string);
}
}break;
@@ -1314,7 +1315,8 @@ d_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list)
entry = next)
{
next = entry->next;
if(entry->kind == D_EntityKind_EntryPoint && entry->id == process->id)
if(entry->id == process->id &&
(entry->kind == D_EntityKind_EntryPoint || entry->kind == D_EntityKind_LaunchMsgID))
{
d_entity_release(store, entry);
}
@@ -4536,9 +4538,21 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
default:{}break;
case DMN_EventKind_CreateProcess:
{
D_MsgID msg_id = 0;
for(D_Entity *entry = d_ctrl_state->ctrl_thread_entity_store->ctx.root->first;
entry != &d_entity_nil;
entry = entry->next)
{
if(entry->id == event->code && entry->kind == D_EntityKind_LaunchMsgID)
{
msg_id = entry->src_msg_id;
d_entity_release(d_ctrl_state->ctrl_thread_entity_store, entry);
break;
}
}
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_NewProc;
out_evt->msg_id = msg->msg_id;
out_evt->msg_id = msg_id;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->arch = event->arch;
out_evt->entity_id = event->code;
@@ -5081,15 +5095,21 @@ d_ctrl_thread__launch(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
file_close(stderr_handle);
file_close(stdin_handle);
//- rjf: record (id -> entry points), so that we know custom entry points for this PID
//- rjf: record (id -> entry points), and (id -> msg_id) so that we know custom entry points for this PID
D_EntityCtxRWStore *entity_ctx_rw_store = d_ctrl_state->ctrl_thread_entity_store;
MutexScopeW(d_ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
{
for(String8Node *n = msg->entry_points.first; n != 0; n = n->next)
{
String8 string = n->string;
D_Entity *entry = d_entity_alloc(entity_ctx_rw_store, entity_ctx_rw_store->ctx.root, D_EntityKind_EntryPoint, Arch_Null, d_handle_zero(), (U64)id);
d_entity_equip_string(entity_ctx_rw_store, entry, string);
{
String8 string = n->string;
D_Entity *entry = d_entity_alloc(entity_ctx_rw_store, entity_ctx_rw_store->ctx.root, D_EntityKind_EntryPoint, Arch_Null, d_handle_zero(), (U64)id);
d_entity_equip_string(entity_ctx_rw_store, entry, string);
}
{
D_Entity *entry = d_entity_alloc(entity_ctx_rw_store, entity_ctx_rw_store->ctx.root, D_EntityKind_LaunchMsgID, Arch_Null, d_handle_zero(), (U64)id);
entry->src_msg_id = msg->msg_id;
}
}
}
+2 -18
View File
@@ -377,7 +377,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
rng1u64_list_push(scratch.arena, &all_vaddr_ranges_on_same_line, vaddr_range);
}
}
// extend trap-net range across contiguous same-source-line, possibly unsorted, ranges
//
// TODO: @ns: converter should never produce these ranges in the first place,
@@ -1628,23 +1628,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
d_user_state->ctrl_last_stop_event.string = push_str8_copy(d_user_state->ctrl_stop_arena, d_user_state->ctrl_last_stop_event.string);
}
}break;
case D_EventKind_NewProc:
{
// rjf: the first process? -> clear session output
D_EntityArray existing_processes = d_entity_array_from_kind(D_EntityKind_Process);
if(existing_processes.count == 1)
{
MTX_Op op = {r1u64(0, 0xffffffffffffffffull), str8_lit("[new session]\n")};
mtx_push_op(d_user_state->output_log_key, op);
}
}break;
case D_EventKind_DebugString:
{
MTX_Op op = {r1u64(max_U64, max_U64), event->string};
mtx_push_op(d_user_state->output_log_key, op);
}break;
}
log_infof("}\n\n");
}
@@ -1822,6 +1805,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
// rjf: push message to launch
{
D_Msg *msg = d_msg_list_push(scratch.arena, &ctrl_msgs);
msg->msg_id = target->msg_id;
msg->kind = D_MsgKind_Launch;
msg->path = str8_copy(scratch.arena, working_directory);
msg->cmd_line_string_list = str8_list_copy(scratch.arena, &cmdln_strings);
+2 -2
View File
@@ -344,8 +344,8 @@ struct D_UserState
Arena *cmds_arena;
D_CmdList cmds;
// rjf: output log key
C_Key output_log_key;
// rjf: output log root
C_Root output_log_root;
// rjf: per-run caches
U64 tls_base_cache_reggen_idx;
+4 -2
View File
@@ -4,7 +4,7 @@
//- GENERATED CODE
C_LINKAGE_BEGIN
String8 d_entity_kind_code_name_table[12] =
String8 d_entity_kind_code_name_table[13] =
{
{0},
str8_lit_comp("root"),
@@ -13,6 +13,7 @@ str8_lit_comp("process"),
str8_lit_comp("thread"),
str8_lit_comp("module"),
str8_lit_comp("entry_point"),
str8_lit_comp("launch_msg_id"),
str8_lit_comp("debug_info_path"),
str8_lit_comp("pending_thread_name"),
str8_lit_comp("pending_thread_color"),
@@ -20,7 +21,7 @@ str8_lit_comp("breakpoint"),
str8_lit_comp("address_range_annotation"),
};
String8 d_entity_kind_display_string_table[12] =
String8 d_entity_kind_display_string_table[13] =
{
{0},
str8_lit_comp("Root"),
@@ -29,6 +30,7 @@ str8_lit_comp("Process"),
str8_lit_comp("Thread"),
str8_lit_comp("Module"),
str8_lit_comp("EntryPoint"),
str8_lit_comp("LaunchMsgID"),
str8_lit_comp("DebugInfoPath"),
str8_lit_comp("PendingThreadName"),
str8_lit_comp("PendingThreadColor"),
+3 -2
View File
@@ -54,6 +54,7 @@ D_EntityKind_Process,
D_EntityKind_Thread,
D_EntityKind_Module,
D_EntityKind_EntryPoint,
D_EntityKind_LaunchMsgID,
D_EntityKind_DebugInfoPath,
D_EntityKind_PendingThreadName,
D_EntityKind_PendingThreadColor,
@@ -127,8 +128,8 @@ struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] =
{&DEV_updating_indicator, str8_lit_comp("updating_indicator")},
};
C_LINKAGE_BEGIN
extern String8 d_entity_kind_code_name_table[12];
extern String8 d_entity_kind_display_string_table[12];
extern String8 d_entity_kind_code_name_table[13];
extern String8 d_entity_kind_display_string_table[13];
extern U32 d_exception_code_kind_code_table[38];
extern String8 d_exception_code_kind_display_string_table[38];
extern String8 d_exception_code_kind_lowercase_code_string_table[38];