communicate ctrl -> df start/stop events on launch (as well as normal runs) - prohibit demoting high-level step operations into launches if targets are running, but no process creation events have been identified yet

This commit is contained in:
Ryan Fleury
2024-01-23 15:23:51 -08:00
parent bae91cd40c
commit 2c8e17be3b
3 changed files with 64 additions and 5 deletions
+52
View File
@@ -1871,6 +1871,14 @@ ctrl_thread__launch_and_handshake(CTRL_Msg *msg)
}
U32 id = demon_launch_process(&opts);
//- rjf: record start
{
CTRL_EventList evts = {0};
CTRL_Event *event = ctrl_event_list_push(scratch.arena, &evts);
event->kind = CTRL_EventKind_Started;
ctrl_c2u_push_events(&evts);
}
//- rjf: run to handshake
DEMON_Event *stop_event = 0;
if(id != 0)
@@ -1920,6 +1928,24 @@ ctrl_thread__launch_and_handshake(CTRL_Msg *msg)
ctrl_c2u_push_events(&evts);
}
//- rjf: record stop
{
CTRL_EventList evts = {0};
CTRL_Event *event = ctrl_event_list_push(scratch.arena, &evts);
event->kind = CTRL_EventKind_Stopped;
if(stop_event != 0)
{
event->cause = ctrl_event_cause_from_demon_event_kind(stop_event->kind);
event->machine_id = CTRL_MachineID_Client;
event->entity = ctrl_handle_from_demon(stop_event->thread);
event->parent = ctrl_handle_from_demon(stop_event->process);
event->exception_code = stop_event->code;
event->vaddr_rng = r1u64(stop_event->address, stop_event->address);
event->rip_vaddr = stop_event->instruction_pointer;
}
ctrl_c2u_push_events(&evts);
}
//- rjf: push request resolution event
{
CTRL_EventList evts = {0};
@@ -1953,6 +1979,14 @@ ctrl_thread__launch_and_init(CTRL_Msg *msg)
}
U32 id = demon_launch_process(&opts);
//- rjf: record start
{
CTRL_EventList evts = {0};
CTRL_Event *event = ctrl_event_list_push(scratch.arena, &evts);
event->kind = CTRL_EventKind_Started;
ctrl_c2u_push_events(&evts);
}
//- rjf: run to initialization (entry point)
DEMON_Event *stop_event = 0;
if(id != 0)
@@ -2168,6 +2202,24 @@ ctrl_thread__launch_and_init(CTRL_Msg *msg)
ctrl_c2u_push_events(&evts);
}
//- rjf: record stop
{
CTRL_EventList evts = {0};
CTRL_Event *event = ctrl_event_list_push(scratch.arena, &evts);
event->kind = CTRL_EventKind_Stopped;
if(stop_event != 0)
{
event->cause = ctrl_event_cause_from_demon_event_kind(stop_event->kind);
event->machine_id = CTRL_MachineID_Client;
event->entity = ctrl_handle_from_demon(stop_event->thread);
event->parent = ctrl_handle_from_demon(stop_event->process);
event->exception_code = stop_event->code;
event->vaddr_rng = r1u64(stop_event->address, stop_event->address);
event->rip_vaddr = stop_event->instruction_pointer;
}
ctrl_c2u_push_events(&evts);
}
//- rjf: push request resolution event
{
CTRL_EventList evts = {0};
+6 -2
View File
@@ -3805,6 +3805,10 @@ df_push_ctrl_msg(CTRL_Msg *msg)
{
CTRL_Msg *dst = ctrl_msg_list_push(df_state->ctrl_msg_arena, &df_state->ctrl_msgs);
ctrl_msg_deep_copy(df_state->ctrl_msg_arena, dst, msg);
if(dst->kind == CTRL_MsgKind_LaunchAndInit)
{
df_state->ctrl_is_running = 1;
}
if(df_state->ctrl_soft_halt_issued == 0 && df_ctrl_targets_running())
{
df_state->ctrl_soft_halt_issued = 1;
@@ -7132,7 +7136,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
DF_CmdParams params = df_cmd_params_zero();
df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Continue));
}
else
else if(!df_ctrl_targets_running())
{
DF_CmdParams params = df_cmd_params_zero();
df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_LaunchAndRun));
@@ -7187,7 +7191,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
}
df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(step_cmd_kind));
}
else
else if(!df_ctrl_targets_running())
{
DF_EntityList targets = df_push_active_target_list(scratch.arena);
DF_CmdParams p = params;
+6 -3
View File
@@ -2353,9 +2353,12 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem)
if(sig.clicked)
{
String8 new_path = str8_chop_last_slash(str8_chop_last_slash(path_query.path));
new_path = path_normalized_from_string(scratch.arena, new_path);
String8 new_cmd = push_str8f(scratch.arena, "%S/", new_path);
df_view_equip_spec(view, view->spec, df_entity_from_handle(view->entity), new_cmd, &df_g_nil_cfg_node);
if(new_path.size != 0)
{
new_path = path_normalized_from_string(scratch.arena, new_path);
String8 new_cmd = push_str8f(scratch.arena, "%S/", new_path);
df_view_equip_spec(view, view->spec, df_entity_from_handle(view->entity), new_cmd, &df_g_nil_cfg_node);
}
}
}