sketch out thread color events & client-driven thread color state, plug thread colors back into ui

This commit is contained in:
Ryan Fleury
2024-09-16 17:37:50 -07:00
parent 35659a4525
commit a7ca8dd0a0
12 changed files with 54 additions and 21 deletions
+2 -1
View File
@@ -242,7 +242,7 @@ Rng1U64 rd_reg_slot_range_table[32] =
{OffsetOf(RD_Regs, os_event), OffsetOf(RD_Regs, os_event) + sizeof(OS_Event *)},
};
RD_CmdKindInfo rd_cmd_kind_info_table[217] =
RD_CmdKindInfo rd_cmd_kind_info_table[218] =
{
{0},
{ str8_lit_comp("launch_and_run"), str8_lit_comp("Starts debugging a new instance of a target, then runs."), str8_lit_comp("launch,start,run,target"), str8_lit_comp("Launch and Run"), RD_IconKind_Play, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*1), RD_RegSlot_EntityList, str8_lit_comp(""), RD_EntityKind_Target}},
@@ -275,6 +275,7 @@ RD_CmdKindInfo rd_cmd_kind_info_table[217] =
{ str8_lit_comp("thaw_local_machine"), str8_lit_comp("Thaws the local machine."), str8_lit_comp(""), str8_lit_comp("Thaw Local Machine"), RD_IconKind_Machine, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}},
{ str8_lit_comp("freeze_entity"), str8_lit_comp("Freezes an entity."), str8_lit_comp(""), str8_lit_comp("Freeze Entity"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}},
{ str8_lit_comp("thaw_entity"), str8_lit_comp("Thaws an entity."), str8_lit_comp(""), str8_lit_comp("Thaw Entity"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}},
{ str8_lit_comp("set_thread_color"), str8_lit_comp("Sets the passed entity's color."), str8_lit_comp(""), str8_lit_comp("Set Thread Color"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}},
{ str8_lit_comp("attach"), str8_lit_comp("Attaches to a process that is already running on the local machine."), str8_lit_comp(""), str8_lit_comp("Attach"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*1), RD_RegSlot_PID, str8_lit_comp(""), RD_EntityKind_Nil}},
{ str8_lit_comp("exit"), str8_lit_comp("Exits the debugger."), str8_lit_comp("quit,close,abort"), str8_lit_comp("Exit"), RD_IconKind_X, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), RD_EntityKind_Nil}},
{ str8_lit_comp("run_command"), str8_lit_comp("Runs a command from the command palette."), str8_lit_comp("help,cmd"), str8_lit_comp("Run Command"), RD_IconKind_Null, (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Required*1), RD_RegSlot_String, str8_lit_comp("commands"), RD_EntityKind_Nil}},
+1
View File
@@ -120,6 +120,7 @@ RD_CmdKind_FreezeLocalMachine,
RD_CmdKind_ThawLocalMachine,
RD_CmdKind_FreezeEntity,
RD_CmdKind_ThawEntity,
RD_CmdKind_SetEntityColor,
RD_CmdKind_Attach,
RD_CmdKind_Exit,
RD_CmdKind_RunCommand,
+20
View File
@@ -8324,6 +8324,26 @@ rd_theme_color_from_txt_token_kind(TXT_TokenKind kind)
return color;
}
internal Vec4F32
rd_rgba_from_thread(CTRL_Entity *thread)
{
Vec4F32 result = rd_rgba_from_theme_color(RD_ThemeColor_Thread0);
if(thread->rgba != 0)
{
result = rgba_from_u32(thread->rgba);
}
else
{
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
CTRL_Entity *main_thread = ctrl_entity_child_from_kind(process, CTRL_EntityKind_Thread);
if(main_thread != thread)
{
result = rd_rgba_from_theme_color(RD_ThemeColor_Thread1);
}
}
return result;
}
//- rjf: code -> palette
internal UI_Palette *
+1
View File
@@ -1309,6 +1309,7 @@ internal String8List rd_cmd_name_list_from_binding(Arena *arena, RD_Binding bind
//- rjf: colors
internal Vec4F32 rd_rgba_from_theme_color(RD_ThemeColor color);
internal RD_ThemeColor rd_theme_color_from_txt_token_kind(TXT_TokenKind kind);
internal Vec4F32 rd_rgba_from_thread(CTRL_Entity *thread);
//- rjf: code -> palette
internal UI_Palette *rd_palette_from_code(RD_PaletteCode code);
+2 -5
View File
@@ -2504,10 +2504,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, B32 modifiable, U32 default_radix, R
{
cell_icon = RD_IconKind_RightArrow;
CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_regs()->thread);
if(thread->rgba != 0)
{
cell_base_color = rgba_from_u32(thread->rgba);
}
cell_base_color = rd_rgba_from_thread(thread);
}
}break;
}
@@ -7193,7 +7190,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(memory)
Annotation *annotation = push_array(scratch.arena, Annotation, 1);
annotation->name_string = thread->string.size ? thread->string : push_str8f(scratch.arena, "TID: %I64u", thread->id);
annotation->kind_string = str8_lit("Stack");
annotation->color = (thread->rgba != 0) ? rgba_from_u32(thread->rgba) : rd_rgba_from_theme_color(RD_ThemeColor_Text);
annotation->color = rd_rgba_from_thread(thread);
annotation->vaddr_range = stack_vaddr_range;
for(U64 vaddr = stack_vaddr_range_in_viz.min; vaddr < stack_vaddr_range_in_viz.max; vaddr += 1)
{
+2 -10
View File
@@ -1059,7 +1059,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
U64 thread_rip_voff = ctrl_voff_from_vaddr(module, thread_rip_vaddr);
// rjf: thread info => color
Vec4F32 color = rd_rgba_from_theme_color(RD_ThemeColor_Text);
Vec4F32 color = rd_rgba_from_thread(thread);
{
if(unwind_count != 0)
{
@@ -1072,10 +1072,6 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
{
color = rd_rgba_from_theme_color(RD_ThemeColor_ThreadError);
}
else if(thread->rgba != 0)
{
color = rgba_from_u32(thread->rgba);
}
if(d_ctrl_targets_running() && d_ctrl_last_run_frame_idx() < rd_state->frame_index)
{
color.w *= 0.5f;
@@ -1219,7 +1215,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
U64 thread_rip_voff = ctrl_voff_from_vaddr(module, thread_rip_vaddr);
// rjf: thread info => color
Vec4F32 color = v4f32(1, 1, 1, 1);
Vec4F32 color = rd_rgba_from_thread(thread);
{
if(unwind_count != 0)
{
@@ -1232,10 +1228,6 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
{
color = rd_rgba_from_theme_color(RD_ThemeColor_ThreadError);
}
else if(thread->rgba != 0)
{
color = rgba_from_u32(thread->rgba);
}
if(d_ctrl_targets_running() && d_ctrl_last_run_frame_idx() < rd_state->frame_index)
{
color.w *= 0.5f;