mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-18 10:02:23 -07:00
fix debug engine incorrectly using visual run state to soft halt, when ctrl thread did not necessarily report it was running; was leading to 'phantom halts'; other small fixes, dead code elimination, and begin sketching out proper cross-window drag/drop
This commit is contained in:
@@ -1577,7 +1577,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
D_EventList result = {0};
|
||||
d_state->frame_index += 1;
|
||||
d_state->frame_eval_memread_endt_us = os_now_microseconds() + 5000;
|
||||
B32 ctrl_running_pre_tick = d_state->ctrl_is_running;
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: sync with ctrl thread
|
||||
@@ -1615,12 +1614,14 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
case CTRL_EventKind_Started:
|
||||
{
|
||||
d_state->ctrl_is_running = 1;
|
||||
d_state->ctrl_thread_run_state = 1;
|
||||
}break;
|
||||
|
||||
case CTRL_EventKind_Stopped:
|
||||
{
|
||||
B32 should_snap = !(d_state->ctrl_soft_halt_issued);
|
||||
d_state->ctrl_is_running = 0;
|
||||
d_state->ctrl_thread_run_state = 0;
|
||||
d_state->ctrl_soft_halt_issued = 0;
|
||||
|
||||
// rjf: exception or unexpected trap -> push error
|
||||
@@ -1680,7 +1681,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
{
|
||||
// rjf: the first process? -> clear session output & reset all bp hit counts
|
||||
CTRL_EntityList existing_processes = ctrl_entity_list_from_kind(d_state->ctrl_entity_store, CTRL_EntityKind_Process);
|
||||
if(existing_processes.count == 0)
|
||||
if(existing_processes.count == 1)
|
||||
{
|
||||
MTX_Op op = {r1u64(0, 0xffffffffffffffffull), str8_lit("[new session]\n")};
|
||||
mtx_push_op(d_state->output_log_key, op);
|
||||
@@ -2563,7 +2564,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
ctrl_msg_list_concat_in_place(&d_state->ctrl_msgs, &msgs_copy);
|
||||
if(d_state->ctrl_msgs.count != 0)
|
||||
{
|
||||
if(!d_state->ctrl_soft_halt_issued && ctrl_running_pre_tick)
|
||||
if(!d_state->ctrl_soft_halt_issued && d_state->ctrl_thread_run_state)
|
||||
{
|
||||
d_state->ctrl_soft_halt_issued = 1;
|
||||
ctrl_halt();
|
||||
|
||||
@@ -394,6 +394,7 @@ struct D_State
|
||||
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;
|
||||
|
||||
@@ -448,6 +448,12 @@ os_get_modifiers(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal B32
|
||||
os_key_is_down(OS_Key key)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal Vec2F32
|
||||
os_mouse_from_window(OS_Handle handle)
|
||||
{
|
||||
|
||||
+2
-1
@@ -173,7 +173,8 @@ internal Vec2F32 os_dim_from_monitor(OS_Handle monitor);
|
||||
|
||||
internal void os_send_wakeup_event(void);
|
||||
internal OS_EventList os_get_events(Arena *arena, B32 wait);
|
||||
internal OS_Modifiers os_get_modifiers(void);
|
||||
internal OS_Modifiers os_get_modifiers(void);
|
||||
internal B32 os_key_is_down(OS_Key key);
|
||||
internal Vec2F32 os_mouse_from_window(OS_Handle window);
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -197,6 +197,12 @@ os_get_modifiers(void)
|
||||
return f;
|
||||
}
|
||||
|
||||
internal B32
|
||||
os_key_is_down(OS_Key key)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal Vec2F32
|
||||
os_mouse_from_window(OS_Handle window)
|
||||
{
|
||||
|
||||
@@ -314,6 +314,9 @@ os_w32_vkey_from_os_key(OS_Key key)
|
||||
vkey_table[OS_Key_Num7] = VK_NUMPAD7;
|
||||
vkey_table[OS_Key_Num8] = VK_NUMPAD8;
|
||||
vkey_table[OS_Key_Num9] = VK_NUMPAD9;
|
||||
vkey_table[OS_Key_LeftMouseButton] = VK_LBUTTON;
|
||||
vkey_table[OS_Key_MiddleMouseButton] = VK_MBUTTON;
|
||||
vkey_table[OS_Key_RightMouseButton] = VK_RBUTTON;
|
||||
}
|
||||
result = vkey_table[key];
|
||||
}
|
||||
@@ -356,10 +359,10 @@ os_w32_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case WM_SIZE:
|
||||
case WM_PAINT:
|
||||
{
|
||||
{
|
||||
PAINTSTRUCT ps = {0};
|
||||
BeginPaint(hwnd, &ps);
|
||||
update();
|
||||
update();
|
||||
EndPaint(hwnd, &ps);
|
||||
}break;
|
||||
|
||||
@@ -533,27 +536,27 @@ os_w32_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
F32 new_dpi = (F32)(wParam & 0xffff);
|
||||
window->dpi = new_dpi;
|
||||
}break;
|
||||
|
||||
//- rjf: [file drop]
|
||||
case WM_DROPFILES:
|
||||
{
|
||||
HDROP drop = (HDROP)wParam;
|
||||
POINT drop_pt = {0};
|
||||
DragQueryPoint(drop, &drop_pt);
|
||||
ScreenToClient(window->hwnd, &drop_pt);
|
||||
U64 num_files_dropped = DragQueryFile(drop, 0xffffffff, 0, 0);
|
||||
OS_Event *event = os_w32_push_event(OS_EventKind_FileDrop, window);
|
||||
event->pos = v2f32((F32)drop_pt.x, (F32)drop_pt.y);
|
||||
for(U64 idx = 0; idx < num_files_dropped; idx += 1)
|
||||
{
|
||||
U64 name_size = DragQueryFile(drop, idx, 0, 0) + 1;
|
||||
U8 *name_ptr = push_array(os_w32_event_arena, U8, name_size);
|
||||
DragQueryFile(drop, idx, (char *)name_ptr, name_size);
|
||||
str8_list_push(os_w32_event_arena, &event->strings, str8(name_ptr, name_size));
|
||||
}
|
||||
DragFinish(drop);
|
||||
}break;
|
||||
|
||||
|
||||
//- rjf: [file drop]
|
||||
case WM_DROPFILES:
|
||||
{
|
||||
HDROP drop = (HDROP)wParam;
|
||||
POINT drop_pt = {0};
|
||||
DragQueryPoint(drop, &drop_pt);
|
||||
ScreenToClient(window->hwnd, &drop_pt);
|
||||
U64 num_files_dropped = DragQueryFile(drop, 0xffffffff, 0, 0);
|
||||
OS_Event *event = os_w32_push_event(OS_EventKind_FileDrop, window);
|
||||
event->pos = v2f32((F32)drop_pt.x, (F32)drop_pt.y);
|
||||
for(U64 idx = 0; idx < num_files_dropped; idx += 1)
|
||||
{
|
||||
U64 name_size = DragQueryFile(drop, idx, 0, 0) + 1;
|
||||
U8 *name_ptr = push_array(os_w32_event_arena, U8, name_size);
|
||||
DragQueryFile(drop, idx, (char *)name_ptr, name_size);
|
||||
str8_list_push(os_w32_event_arena, &event->strings, str8(name_ptr, name_size));
|
||||
}
|
||||
DragFinish(drop);
|
||||
}break;
|
||||
|
||||
//- rjf: [custom border]
|
||||
case WM_NCPAINT:
|
||||
{
|
||||
@@ -1027,8 +1030,8 @@ os_window_open(Vec2F32 resolution, OS_WindowFlags flags, String8 title)
|
||||
(int)resolution.y,
|
||||
0, 0,
|
||||
os_w32_gfx_state->hInstance,
|
||||
0);
|
||||
DragAcceptFiles(hwnd, 1);
|
||||
0);
|
||||
DragAcceptFiles(hwnd, 1);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
@@ -1412,6 +1415,18 @@ os_get_modifiers(void)
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
internal B32
|
||||
os_key_is_down(OS_Key key)
|
||||
{
|
||||
B32 down = 0;
|
||||
WPARAM vkey = os_w32_vkey_from_os_key(key);
|
||||
if(GetKeyState(vkey) & 0x8000)
|
||||
{
|
||||
down = 1;
|
||||
}
|
||||
return down;
|
||||
}
|
||||
|
||||
internal Vec2F32
|
||||
os_mouse_from_window(OS_Handle handle)
|
||||
{
|
||||
|
||||
@@ -9421,12 +9421,6 @@ rd_init(CmdLine *cmdln)
|
||||
rd_state->entities_root = rd_entity_alloc(&d_nil_entity, RD_EntityKind_Root);
|
||||
rd_state->key_map_arena = arena_alloc();
|
||||
rd_state->popup_arena = arena_alloc();
|
||||
#if 0 // TODO(rjf): @msgs
|
||||
rd_state->view_spec_table_size = 256;
|
||||
rd_state->view_spec_table = push_array(arena, RD_ViewSpec *, rd_state->view_spec_table_size);
|
||||
rd_state->view_rule_spec_table_size = 1024;
|
||||
rd_state->view_rule_spec_table = push_array(arena, RD_ViewRuleSpec *, d_state->view_rule_spec_table_size);
|
||||
#endif
|
||||
rd_state->code_ctx_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_code_ctx_menu_"));
|
||||
rd_state->entity_ctx_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_entity_ctx_menu_"));
|
||||
rd_state->tab_ctx_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_tab_ctx_menu_"));
|
||||
@@ -9446,22 +9440,6 @@ rd_init(CmdLine *cmdln)
|
||||
rd_entity_equip_name(local_machine, str8_lit("This PC"));
|
||||
}
|
||||
|
||||
// rjf: register gfx layer views
|
||||
#if 0 // TODO(rjf): @msgs
|
||||
{
|
||||
RD_ViewSpecInfoArray array = {rd_gfx_view_kind_spec_info_table, ArrayCount(rd_gfx_view_kind_spec_info_table)};
|
||||
rd_register_view_specs(array);
|
||||
}
|
||||
#endif
|
||||
|
||||
// rjf: register gfx layer view rules
|
||||
#if 0 // TODO(rjf): @msgs
|
||||
{
|
||||
RD_ViewRuleSpecInfoArray array = {rd_gfx_view_rule_spec_info_table, ArrayCount(rd_gfx_view_rule_spec_info_table)};
|
||||
rd_register_view_rule_specs(array);
|
||||
}
|
||||
#endif
|
||||
|
||||
// rjf: set up user / project paths
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
@@ -14144,7 +14122,7 @@ rd_frame(void)
|
||||
}
|
||||
|
||||
// rjf: no stop-causing thread, but have selected thread? -> snap to selected
|
||||
CTRL_Entity *selected_thread = &ctrl_entity_nil; // TODO(rjf): ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_base_regs()->thread);
|
||||
CTRL_Entity *selected_thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_base_regs()->thread);
|
||||
if(thread == &ctrl_entity_nil && selected_thread != &ctrl_entity_nil)
|
||||
{
|
||||
rd_cmd(RD_CmdKind_FindThread);
|
||||
|
||||
@@ -424,6 +424,7 @@ ui_state_alloc(void)
|
||||
Arena *arena = arena_alloc();
|
||||
UI_State *ui = push_array(arena, UI_State, 1);
|
||||
ui->arena = arena;
|
||||
ui->external_key = ui_key_from_string(ui_key_zero(), str8_lit("###external_interaction_key###"));
|
||||
ui->build_arenas[0] = arena_alloc();
|
||||
ui->build_arenas[1] = arena_alloc();
|
||||
ui->drag_state_arena = arena_alloc();
|
||||
@@ -832,6 +833,19 @@ ui_begin_build(OS_Handle window, UI_EventList *events, UI_IconInfo *icon_info, U
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: detect external press & holds
|
||||
for(EachEnumVal(UI_MouseButtonKind, k))
|
||||
{
|
||||
if(ui_key_match(ui_state->active_box_key[k], ui_key_zero()) && os_key_is_down(OS_Key_LeftMouseButton+k))
|
||||
{
|
||||
ui_state->active_box_key[k] = ui_state->external_key;
|
||||
}
|
||||
else if(ui_key_match(ui_state->active_box_key[k], ui_state->external_key) && !os_key_is_down(OS_Key_LeftMouseButton+k))
|
||||
{
|
||||
ui_state->active_box_key[k] = ui_key_zero();
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: fill build phase parameters
|
||||
{
|
||||
ui_state->events = events;
|
||||
@@ -1435,6 +1449,7 @@ ui_end_build(void)
|
||||
}
|
||||
|
||||
//- rjf: hover cursor
|
||||
if(!ui_key_match(ui_state->active_box_key[UI_MouseButtonKind_Left], ui_state->external_key))
|
||||
{
|
||||
UI_Box *hot = ui_box_from_key(ui_state->hot_box_key);
|
||||
UI_Box *active = ui_box_from_key(ui_state->active_box_key[UI_MouseButtonKind_Left]);
|
||||
|
||||
@@ -625,6 +625,9 @@ struct UI_State
|
||||
//- rjf: main arena
|
||||
Arena *arena;
|
||||
|
||||
//- rjf: fixed keys
|
||||
UI_Key external_key;
|
||||
|
||||
//- rjf: build arenas
|
||||
Arena *build_arenas[2];
|
||||
U64 build_index;
|
||||
|
||||
Reference in New Issue
Block a user