From 306f8d84c5d3e8f9f68861b88e44172637b93507 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 13 Sep 2024 11:59:46 -0700 Subject: [PATCH] remainder of entity code -> df; exception code filters -> df --- src/dbg_engine/dbg_engine_core.c | 295 +------------------------ src/dbg_engine/dbg_engine_core.h | 24 +- src/dbg_frontend/dbg_frontend_core.c | 301 +++++++++++++++++++++++++- src/dbg_frontend/dbg_frontend_core.h | 18 ++ src/dbg_frontend/dbg_frontend_views.c | 6 +- 5 files changed, 323 insertions(+), 321 deletions(-) diff --git a/src/dbg_engine/dbg_engine_core.c b/src/dbg_engine/dbg_engine_core.c index 7735d892..7143f6de 100644 --- a/src/dbg_engine/dbg_engine_core.c +++ b/src/dbg_engine/dbg_engine_core.c @@ -337,114 +337,6 @@ d_cmd_list_push_new(Arena *arena, D_CmdList *cmds, D_CmdKind kind, D_CmdParams * cmds->count += 1; } -//////////////////////////////// -//~ rjf: Name Allocation - -internal U64 -d_name_bucket_idx_from_string_size(U64 size) -{ - U64 size_rounded = u64_up_to_pow2(size+1); - size_rounded = ClampBot((1<<4), size_rounded); - U64 bucket_idx = 0; - switch(size_rounded) - { - case 1<<4: {bucket_idx = 0;}break; - case 1<<5: {bucket_idx = 1;}break; - case 1<<6: {bucket_idx = 2;}break; - case 1<<7: {bucket_idx = 3;}break; - case 1<<8: {bucket_idx = 4;}break; - case 1<<9: {bucket_idx = 5;}break; - case 1<<10:{bucket_idx = 6;}break; - default:{bucket_idx = ArrayCount(d_state->free_name_chunks)-1;}break; - } - return bucket_idx; -} - -internal String8 -d_name_alloc(String8 string) -{ - if(string.size == 0) {return str8_zero();} - U64 bucket_idx = d_name_bucket_idx_from_string_size(string.size); - - // rjf: loop -> find node, allocate if not there - // - // (we do a loop here so that all allocation logic goes through - // the same path, such that we *always* pull off a free list, - // rather than just using what was pushed onto an arena directly, - // which is not undoable; the free lists we control, and are thus - // trivially undoable) - // - D_NameChunkNode *node = 0; - for(;node == 0;) - { - node = d_state->free_name_chunks[bucket_idx]; - - // rjf: pull from bucket free list - if(node != 0) - { - if(bucket_idx == ArrayCount(d_state->free_name_chunks)-1) - { - node = 0; - D_NameChunkNode *prev = 0; - for(D_NameChunkNode *n = d_state->free_name_chunks[bucket_idx]; - n != 0; - prev = n, n = n->next) - { - if(n->size >= string.size+1) - { - if(prev == 0) - { - d_state->free_name_chunks[bucket_idx] = n->next; - } - else - { - prev->next = n->next; - } - node = n; - break; - } - } - } - else - { - SLLStackPop(d_state->free_name_chunks[bucket_idx]); - } - } - - // rjf: no found node -> allocate new, push onto associated free list - if(node == 0) - { - U64 chunk_size = 0; - if(bucket_idx < ArrayCount(d_state->free_name_chunks)-1) - { - chunk_size = 1<<(bucket_idx+4); - } - else - { - chunk_size = u64_up_to_pow2(string.size); - } - U8 *chunk_memory = push_array(d_state->arena, U8, chunk_size); - D_NameChunkNode *chunk = (D_NameChunkNode *)chunk_memory; - SLLStackPush(d_state->free_name_chunks[bucket_idx], chunk); - } - } - - // rjf: fill string & return - String8 allocated_string = str8((U8 *)node, string.size); - MemoryCopy((U8 *)node, string.str, string.size); - return allocated_string; -} - -internal void -d_name_release(String8 string) -{ - if(string.size == 0) {return;} - U64 bucket_idx = d_name_bucket_idx_from_string_size(string.size); - D_NameChunkNode *node = (D_NameChunkNode *)string.str; - node->size = u64_up_to_pow2(string.size); - SLLStackPush(d_state->free_name_chunks[bucket_idx], node); -} - //////////////////////////////// //~ rjf: View Rule Spec Stateful Functions @@ -912,9 +804,6 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread) return result; } -//////////////////////////////// -//~ rjf: Modules & Debug Info Mappings - //////////////////////////////// //~ rjf: Debug Info Lookups @@ -1562,170 +1451,9 @@ internal String8List d_cfg_strings_from_core(Arena *arena, String8 root_path, D_CfgSrc source) { ProfBeginFunction(); - local_persist char *spaces = " "; - local_persist char *slashes= "////////////////////////////////////////////////////////////////////////////////"; + String8List strs = {0}; - //- rjf: write all entities - { - for(EachEnumVal(DF_EntityKind, k)) - { - DF_EntityKindFlags k_flags = d_entity_kind_flags_table[k]; - if(!(k_flags & DF_EntityKindFlag_IsSerializedToConfig)) - { - continue; - } - B32 first = 1; - DF_EntityList entities = d_query_cached_entity_list_with_kind(k); - for(DF_EntityNode *n = entities.first; n != 0; n = n->next) - { - DF_Entity *entity = n->entity; - if(entity->cfg_src != source) - { - continue; - } - if(first) - { - first = 0; - String8 title_name = d_entity_kind_name_lower_plural_table[k]; - str8_list_pushf(arena, &strs, "/// %S %.*s\n\n", - title_name, - (int)Max(0, 79 - (title_name.size + 5)), - slashes); - } - DF_EntityRec rec = {0}; - S64 depth = 0; - for(DF_Entity *e = entity; !df_entity_is_nil(e); e = rec.next) - { - //- rjf: get next iteration - rec = df_entity_rec_depth_first_pre(e, entity); - - //- rjf: unpack entity info - typedef U32 EntityInfoFlags; - enum - { - EntityInfoFlag_HasName = (1<<0), - EntityInfoFlag_HasDisabled = (1<<1), - EntityInfoFlag_HasTxtPt = (1<<2), - EntityInfoFlag_HasVAddr = (1<<3), - EntityInfoFlag_HasColor = (1<<4), - EntityInfoFlag_HasChildren = (1<<5), - }; - String8 entity_name_escaped = e->string; - if(d_entity_kind_flags_table[e->kind] & DF_EntityKindFlag_NameIsPath) - { - Temp scratch = scratch_begin(&arena, 1); - String8 path_normalized = path_normalized_from_string(scratch.arena, e->string); - entity_name_escaped = path_relative_dst_from_absolute_dst_src(arena, path_normalized, root_path); - scratch_end(scratch); - } - else - { - entity_name_escaped = d_cfg_escaped_from_raw_string(arena, e->string); - } - EntityInfoFlags info_flags = 0; - if(entity_name_escaped.size != 0) { info_flags |= EntityInfoFlag_HasName; } - if(!!e->disabled) { info_flags |= EntityInfoFlag_HasDisabled; } - if(e->flags & DF_EntityFlag_HasTextPoint) { info_flags |= EntityInfoFlag_HasTxtPt; } - if(e->flags & DF_EntityFlag_HasVAddr) { info_flags |= EntityInfoFlag_HasVAddr; } - if(e->flags & DF_EntityFlag_HasColor) { info_flags |= EntityInfoFlag_HasColor; } - if(!df_entity_is_nil(e->first)) { info_flags |= EntityInfoFlag_HasChildren; } - - //- rjf: write entity info - B32 opened_brace = 0; - switch(info_flags) - { - //- rjf: default path -> entity has lots of stuff, so write all info generically - default: - { - opened_brace = 1; - - // rjf: write entity title - str8_list_pushf(arena, &strs, "%S:\n{\n", d_entity_kind_name_lower_table[e->kind]); - - // rjf: write this entity's info - if(entity_name_escaped.size != 0) - { - str8_list_pushf(arena, &strs, "name: \"%S\"\n", entity_name_escaped); - } - if(e->disabled) - { - str8_list_pushf(arena, &strs, "disabled: 1\n"); - } - if(e->flags & DF_EntityFlag_HasColor) - { - Vec4F32 hsva = df_hsva_from_entity(e); - Vec4F32 rgba = rgba_from_hsva(hsva); - U32 rgba_hex = u32_from_rgba(rgba); - str8_list_pushf(arena, &strs, "color: 0x%x\n", rgba_hex); - } - if(e->flags & DF_EntityFlag_HasTextPoint) - { - str8_list_pushf(arena, &strs, "line: %I64d\n", e->text_point.line); - } - if(e->flags & DF_EntityFlag_HasVAddr) - { - str8_list_pushf(arena, &strs, "vaddr: (0x%I64x)\n", e->vaddr); - } - }break; - - //- rjf: single-line fast-paths - case EntityInfoFlag_HasName: - {str8_list_pushf(arena, &strs, "%S: \"%S\"\n", d_entity_kind_name_lower_table[e->kind], entity_name_escaped);}break; - case EntityInfoFlag_HasName|EntityInfoFlag_HasTxtPt: - {str8_list_pushf(arena, &strs, "%S: (\"%S\":%I64d)\n", d_entity_kind_name_lower_table[e->kind], entity_name_escaped, e->text_point.line);}break; - case EntityInfoFlag_HasVAddr: - {str8_list_pushf(arena, &strs, "%S: (0x%I64x)\n", d_entity_kind_name_lower_table[e->kind], e->vaddr);}break; - - //- rjf: empty - case 0: - {}break; - } - - // rjf: push - depth += rec.push_count; - - // rjf: pop - if(rec.push_count == 0) - { - for(S64 pop_idx = 0; pop_idx < rec.pop_count + opened_brace; pop_idx += 1) - { - if(depth > 0) - { - depth -= 1; - } - str8_list_pushf(arena, &strs, "}\n"); - } - } - - // rjf: separate top-level entities with extra newline - if(df_entity_is_nil(rec.next) && (rec.pop_count != 0 || n->next == 0)) - { - str8_list_pushf(arena, &strs, "\n"); - } - } - } - } - } - - //- rjf: write exception code filters - if(source == D_CfgSrc_Project) - { - str8_list_push(arena, &strs, str8_lit("/// exception code filters ////////////////////////////////////////////////////\n")); - str8_list_push(arena, &strs, str8_lit("\n")); - str8_list_push(arena, &strs, str8_lit("exception_code_filters:\n")); - str8_list_push(arena, &strs, str8_lit("{\n")); - for(CTRL_ExceptionCodeKind k = (CTRL_ExceptionCodeKind)(CTRL_ExceptionCodeKind_Null+1); - k < CTRL_ExceptionCodeKind_COUNT; - k = (CTRL_ExceptionCodeKind)(k+1)) - { - String8 name = ctrl_exception_code_kind_lowercase_code_string_table[k]; - B32 value = !!(d_state->ctrl_exception_code_filters[k/64] & (1ull<<(k%64))); - str8_list_pushf(arena, &strs, " %S: %i\n", name, value); - } - str8_list_push(arena, &strs, str8_lit("}\n\n")); - } - ProfEnd(); return strs; } @@ -2041,15 +1769,6 @@ d_init(void) d_state->view_rule_spec_table = push_array(arena, D_ViewRuleSpec *, d_state->view_rule_spec_table_size); d_state->ctrl_msg_arena = arena_alloc(); - // rjf: set up initial exception filtering rules - for(CTRL_ExceptionCodeKind k = (CTRL_ExceptionCodeKind)0; k < CTRL_ExceptionCodeKind_COUNT; k = (CTRL_ExceptionCodeKind)(k+1)) - { - if(ctrl_exception_code_kind_default_enable_table[k]) - { - d_state->ctrl_exception_code_filters[k/64] |= 1ull<<(k%64); - } - } - // rjf: register core view rules { D_ViewRuleSpecInfoArray array = {d_core_view_rule_spec_info_table, ArrayCount(d_core_view_rule_spec_info_table)}; @@ -2077,7 +1796,7 @@ d_init(void) } internal D_EventList -d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps) +d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64]) { ProfBeginFunction(); Temp scratch = scratch_begin(&arena, 1); @@ -2627,7 +2346,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P msg->path = working_directory; msg->cmd_line_string_list = cmdln_strings; msg->env_inherit = 1; - MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); + MemoryCopyArray(msg->exception_code_filters, exception_code_filters); str8_list_push(scratch.arena, &msg->entry_points, custom_entry_point_name); msg->env_string_list = env; } @@ -2666,7 +2385,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P msg->kind = CTRL_MsgKind_Kill; msg->exit_code = 1; msg->entity = process->handle; - MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); + MemoryCopyArray(msg->exception_code_filters, exception_code_filters); } } @@ -2692,7 +2411,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); msg->kind = CTRL_MsgKind_Detach; msg->entity = n->v->handle; - MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); + MemoryCopyArray(msg->exception_code_filters, exception_code_filters); } }break; case D_CmdKind_Continue: @@ -2956,7 +2675,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); msg->kind = CTRL_MsgKind_Attach; msg->entity_id = pid; - MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); + MemoryCopyArray(msg->exception_code_filters, exception_code_filters); } }break; } @@ -2977,7 +2696,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P msg->run_flags = run_flags; msg->entity = run_thread->handle; msg->parent = process->handle; - MemoryCopyArray(msg->exception_code_filters, d_state->ctrl_exception_code_filters); + MemoryCopyArray(msg->exception_code_filters, exception_code_filters); MemoryCopyStruct(&msg->traps, &run_traps); D_BreakpointArray *bp_batches[] = { diff --git a/src/dbg_engine/dbg_engine_core.h b/src/dbg_engine/dbg_engine_core.h index 552f3e3c..38d17b3d 100644 --- a/src/dbg_engine/dbg_engine_core.h +++ b/src/dbg_engine/dbg_engine_core.h @@ -415,17 +415,6 @@ struct D_RunLocalsCache //////////////////////////////// //~ rjf: Main State Types -//- rjf: name allocator types - -typedef struct D_NameChunkNode D_NameChunkNode; -struct D_NameChunkNode -{ - D_NameChunkNode *next; - U64 size; -}; - -//- rjf: core bundle state type - typedef struct D_State D_State; struct D_State { @@ -444,9 +433,6 @@ struct D_State // rjf: output log key U128 output_log_key; - // rjf: name allocator - D_NameChunkNode *free_name_chunks[8]; - // rjf: per-run caches D_UnwindCache unwind_cache; U64 tls_base_cache_reggen_idx; @@ -475,7 +461,6 @@ struct D_State U128 ctrl_last_run_param_state_hash; B32 ctrl_is_running; B32 ctrl_soft_halt_issued; - U64 ctrl_exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64]; Arena *ctrl_msg_arena; CTRL_MsgList ctrl_msgs; @@ -542,13 +527,6 @@ internal D_CmdParams d_cmd_params_copy(Arena *arena, D_CmdParams *src); //- rjf: command lists internal void d_cmd_list_push_new(Arena *arena, D_CmdList *cmds, D_CmdKind kind, D_CmdParams *params); -//////////////////////////////// -//~ rjf: Name Allocation - -internal U64 d_name_bucket_idx_from_string_size(U64 size); -internal String8 d_name_alloc(String8 string); -internal void d_name_release(String8 string); - //////////////////////////////// //~ rjf: View Rule Spec Stateful Functions @@ -633,6 +611,6 @@ internal B32 d_next_cmd(D_Cmd **cmd); //~ rjf: Main Layer Top-Level Calls internal void d_init(void); -internal D_EventList d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps); +internal D_EventList d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64]); #endif // DBG_ENGINE_CORE_H diff --git a/src/dbg_frontend/dbg_frontend_core.c b/src/dbg_frontend/dbg_frontend_core.c index 182f7a73..1fc19ad3 100644 --- a/src/dbg_frontend/dbg_frontend_core.c +++ b/src/dbg_frontend/dbg_frontend_core.c @@ -1010,6 +1010,114 @@ df_get_hover_regs(void) return df_state->hover_regs; } +//////////////////////////////// +//~ rjf: Name Allocation + +internal U64 +df_name_bucket_idx_from_string_size(U64 size) +{ + U64 size_rounded = u64_up_to_pow2(size+1); + size_rounded = ClampBot((1<<4), size_rounded); + U64 bucket_idx = 0; + switch(size_rounded) + { + case 1<<4: {bucket_idx = 0;}break; + case 1<<5: {bucket_idx = 1;}break; + case 1<<6: {bucket_idx = 2;}break; + case 1<<7: {bucket_idx = 3;}break; + case 1<<8: {bucket_idx = 4;}break; + case 1<<9: {bucket_idx = 5;}break; + case 1<<10:{bucket_idx = 6;}break; + default:{bucket_idx = ArrayCount(df_state->free_name_chunks)-1;}break; + } + return bucket_idx; +} + +internal String8 +df_name_alloc(String8 string) +{ + if(string.size == 0) {return str8_zero();} + U64 bucket_idx = df_name_bucket_idx_from_string_size(string.size); + + // rjf: loop -> find node, allocate if not there + // + // (we do a loop here so that all allocation logic goes through + // the same path, such that we *always* pull off a free list, + // rather than just using what was pushed onto an arena directly, + // which is not undoable; the free lists we control, and are thus + // trivially undoable) + // + D_NameChunkNode *node = 0; + for(;node == 0;) + { + node = df_state->free_name_chunks[bucket_idx]; + + // rjf: pull from bucket free list + if(node != 0) + { + if(bucket_idx == ArrayCount(df_state->free_name_chunks)-1) + { + node = 0; + D_NameChunkNode *prev = 0; + for(D_NameChunkNode *n = df_state->free_name_chunks[bucket_idx]; + n != 0; + prev = n, n = n->next) + { + if(n->size >= string.size+1) + { + if(prev == 0) + { + df_state->free_name_chunks[bucket_idx] = n->next; + } + else + { + prev->next = n->next; + } + node = n; + break; + } + } + } + else + { + SLLStackPop(df_state->free_name_chunks[bucket_idx]); + } + } + + // rjf: no found node -> allocate new, push onto associated free list + if(node == 0) + { + U64 chunk_size = 0; + if(bucket_idx < ArrayCount(df_state->free_name_chunks)-1) + { + chunk_size = 1<<(bucket_idx+4); + } + else + { + chunk_size = u64_up_to_pow2(string.size); + } + U8 *chunk_memory = push_array(df_state->arena, U8, chunk_size); + D_NameChunkNode *chunk = (D_NameChunkNode *)chunk_memory; + SLLStackPush(df_state->free_name_chunks[bucket_idx], chunk); + } + } + + // rjf: fill string & return + String8 allocated_string = str8((U8 *)node, string.size); + MemoryCopy((U8 *)node, string.str, string.size); + return allocated_string; +} + +internal void +df_name_release(String8 string) +{ + if(string.size == 0) {return;} + U64 bucket_idx = df_name_bucket_idx_from_string_size(string.size); + D_NameChunkNode *node = (D_NameChunkNode *)string.str; + node->size = u64_up_to_pow2(string.size); + SLLStackPush(df_state->free_name_chunks[bucket_idx], node); +} + //////////////////////////////// //~ rjf: Entity State Functions @@ -1133,7 +1241,7 @@ df_entity_release(DF_Entity *entity) task->e->gen += 1; if(task->e->string.size != 0) { - d_name_release(task->e->string); + df_name_release(task->e->string); } if(task->e->params_arena != 0) { @@ -1289,11 +1397,11 @@ df_entity_equip_name(DF_Entity *entity, String8 name) df_require_entity_nonnil(entity, return); if(entity->string.size != 0) { - d_name_release(entity->string); + df_name_release(entity->string); } if(name.size != 0) { - entity->string = d_name_alloc(name); + entity->string = df_name_alloc(name); } else { @@ -8327,8 +8435,170 @@ internal String8List df_cfg_strings_from_gfx(Arena *arena, String8 root_path, D_CfgSrc source) { ProfBeginFunction(); + local_persist char *spaces = " "; + local_persist char *slashes= "////////////////////////////////////////////////////////////////////////////////"; String8List strs = {0}; + //- rjf: write all entities + { + for(EachEnumVal(DF_EntityKind, k)) + { + DF_EntityKindFlags k_flags = d_entity_kind_flags_table[k]; + if(!(k_flags & DF_EntityKindFlag_IsSerializedToConfig)) + { + continue; + } + B32 first = 1; + DF_EntityList entities = d_query_cached_entity_list_with_kind(k); + for(DF_EntityNode *n = entities.first; n != 0; n = n->next) + { + DF_Entity *entity = n->entity; + if(entity->cfg_src != source) + { + continue; + } + if(first) + { + first = 0; + String8 title_name = d_entity_kind_name_lower_plural_table[k]; + str8_list_pushf(arena, &strs, "/// %S %.*s\n\n", + title_name, + (int)Max(0, 79 - (title_name.size + 5)), + slashes); + } + DF_EntityRec rec = {0}; + S64 depth = 0; + for(DF_Entity *e = entity; !df_entity_is_nil(e); e = rec.next) + { + //- rjf: get next iteration + rec = df_entity_rec_depth_first_pre(e, entity); + + //- rjf: unpack entity info + typedef U32 EntityInfoFlags; + enum + { + EntityInfoFlag_HasName = (1<<0), + EntityInfoFlag_HasDisabled = (1<<1), + EntityInfoFlag_HasTxtPt = (1<<2), + EntityInfoFlag_HasVAddr = (1<<3), + EntityInfoFlag_HasColor = (1<<4), + EntityInfoFlag_HasChildren = (1<<5), + }; + String8 entity_name_escaped = e->string; + if(d_entity_kind_flags_table[e->kind] & DF_EntityKindFlag_NameIsPath) + { + Temp scratch = scratch_begin(&arena, 1); + String8 path_normalized = path_normalized_from_string(scratch.arena, e->string); + entity_name_escaped = path_relative_dst_from_absolute_dst_src(arena, path_normalized, root_path); + scratch_end(scratch); + } + else + { + entity_name_escaped = d_cfg_escaped_from_raw_string(arena, e->string); + } + EntityInfoFlags info_flags = 0; + if(entity_name_escaped.size != 0) { info_flags |= EntityInfoFlag_HasName; } + if(!!e->disabled) { info_flags |= EntityInfoFlag_HasDisabled; } + if(e->flags & DF_EntityFlag_HasTextPoint) { info_flags |= EntityInfoFlag_HasTxtPt; } + if(e->flags & DF_EntityFlag_HasVAddr) { info_flags |= EntityInfoFlag_HasVAddr; } + if(e->flags & DF_EntityFlag_HasColor) { info_flags |= EntityInfoFlag_HasColor; } + if(!df_entity_is_nil(e->first)) { info_flags |= EntityInfoFlag_HasChildren; } + + //- rjf: write entity info + B32 opened_brace = 0; + switch(info_flags) + { + //- rjf: default path -> entity has lots of stuff, so write all info generically + default: + { + opened_brace = 1; + + // rjf: write entity title + str8_list_pushf(arena, &strs, "%S:\n{\n", d_entity_kind_name_lower_table[e->kind]); + + // rjf: write this entity's info + if(entity_name_escaped.size != 0) + { + str8_list_pushf(arena, &strs, "name: \"%S\"\n", entity_name_escaped); + } + if(e->disabled) + { + str8_list_pushf(arena, &strs, "disabled: 1\n"); + } + if(e->flags & DF_EntityFlag_HasColor) + { + Vec4F32 hsva = df_hsva_from_entity(e); + Vec4F32 rgba = rgba_from_hsva(hsva); + U32 rgba_hex = u32_from_rgba(rgba); + str8_list_pushf(arena, &strs, "color: 0x%x\n", rgba_hex); + } + if(e->flags & DF_EntityFlag_HasTextPoint) + { + str8_list_pushf(arena, &strs, "line: %I64d\n", e->text_point.line); + } + if(e->flags & DF_EntityFlag_HasVAddr) + { + str8_list_pushf(arena, &strs, "vaddr: (0x%I64x)\n", e->vaddr); + } + }break; + + //- rjf: single-line fast-paths + case EntityInfoFlag_HasName: + {str8_list_pushf(arena, &strs, "%S: \"%S\"\n", d_entity_kind_name_lower_table[e->kind], entity_name_escaped);}break; + case EntityInfoFlag_HasName|EntityInfoFlag_HasTxtPt: + {str8_list_pushf(arena, &strs, "%S: (\"%S\":%I64d)\n", d_entity_kind_name_lower_table[e->kind], entity_name_escaped, e->text_point.line);}break; + case EntityInfoFlag_HasVAddr: + {str8_list_pushf(arena, &strs, "%S: (0x%I64x)\n", d_entity_kind_name_lower_table[e->kind], e->vaddr);}break; + + //- rjf: empty + case 0: + {}break; + } + + // rjf: push + depth += rec.push_count; + + // rjf: pop + if(rec.push_count == 0) + { + for(S64 pop_idx = 0; pop_idx < rec.pop_count + opened_brace; pop_idx += 1) + { + if(depth > 0) + { + depth -= 1; + } + str8_list_pushf(arena, &strs, "}\n"); + } + } + + // rjf: separate top-level entities with extra newline + if(df_entity_is_nil(rec.next) && (rec.pop_count != 0 || n->next == 0)) + { + str8_list_pushf(arena, &strs, "\n"); + } + } + } + } + } + + //- rjf: write exception code filters + if(source == D_CfgSrc_Project) + { + str8_list_push(arena, &strs, str8_lit("/// exception code filters ////////////////////////////////////////////////////\n")); + str8_list_push(arena, &strs, str8_lit("\n")); + str8_list_push(arena, &strs, str8_lit("exception_code_filters:\n")); + str8_list_push(arena, &strs, str8_lit("{\n")); + for(CTRL_ExceptionCodeKind k = (CTRL_ExceptionCodeKind)(CTRL_ExceptionCodeKind_Null+1); + k < CTRL_ExceptionCodeKind_COUNT; + k = (CTRL_ExceptionCodeKind)(k+1)) + { + String8 name = ctrl_exception_code_kind_lowercase_code_string_table[k]; + B32 value = !!(df_state->ctrl_exception_code_filters[k/64] & (1ull<<(k%64))); + str8_list_pushf(arena, &strs, " %S: %i\n", name, value); + } + str8_list_push(arena, &strs, str8_lit("}\n\n")); + } + //- rjf: serialize windows { B32 first = 1; @@ -9219,6 +9489,15 @@ df_init(CmdLine *cmdln) scratch_end(scratch); } + // rjf: set up initial exception filtering rules + for(CTRL_ExceptionCodeKind k = (CTRL_ExceptionCodeKind)0; k < CTRL_ExceptionCodeKind_COUNT; k = (CTRL_ExceptionCodeKind)(k+1)) + { + if(ctrl_exception_code_kind_default_enable_table[k]) + { + df_state->ctrl_exception_code_filters[k/64] |= 1ull<<(k%64); + } + } + // rjf: unpack icon image data { Temp scratch = scratch_begin(0, 0); @@ -10349,11 +10628,11 @@ df_frame(void) { if(val) { - d_state->ctrl_exception_code_filters[kind/64] |= (1ull<<(kind%64)); + df_state->ctrl_exception_code_filters[kind/64] |= (1ull<<(kind%64)); } else { - d_state->ctrl_exception_code_filters[kind/64] &= ~(1ull<<(kind%64)); + df_state->ctrl_exception_code_filters[kind/64] &= ~(1ull<<(kind%64)); } } } @@ -13750,13 +14029,21 @@ df_frame(void) // D_PathMapArray path_maps = {0}; { - // TODO(rjf) + // TODO(rjf): @msgs + } + + ////////////////////////////// + //- rjf: gather exception code filters + // + U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64] = {0}; + { + // TODO(rjf): @msgs } ////////////////////////////// //- rjf: tick debug engine // - D_EventList engine_events = d_tick(scratch.arena, &targets, &breakpoints, &path_maps); + D_EventList engine_events = d_tick(scratch.arena, &targets, &breakpoints, &path_maps, exception_code_filters); ////////////////////////////// //- rjf: no selected thread? -> try to snap to any existing thread diff --git a/src/dbg_frontend/dbg_frontend_core.h b/src/dbg_frontend/dbg_frontend_core.h index 53aa4f80..91e8032e 100644 --- a/src/dbg_frontend/dbg_frontend_core.h +++ b/src/dbg_frontend/dbg_frontend_core.h @@ -832,6 +832,13 @@ struct DF_EvalVizViewCacheSlot //////////////////////////////// //~ rjf: Main Per-Process Graphical State +typedef struct D_NameChunkNode D_NameChunkNode; +struct D_NameChunkNode +{ + D_NameChunkNode *next; + U64 size; +}; + typedef struct D_EntityListCache D_EntityListCache; struct D_EntityListCache { @@ -872,6 +879,9 @@ struct DF_State // rjf: autosave timer F32 seconds_until_autosave; + // rjf: name allocator + D_NameChunkNode *free_name_chunks[8]; + // rjf: entity state Arena *entities_arena; DF_Entity *entities_base; @@ -958,6 +968,7 @@ struct DF_State U64 cfg_cached_timestamp[D_CfgSrc_COUNT]; Arena *cfg_arena; D_CfgTable cfg_table; + U64 ctrl_exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64]; // rjf: running theme state DF_Theme cfg_theme_target; @@ -1173,6 +1184,13 @@ internal void df_queue_drag_drop(void); internal void df_set_hover_regs(void); internal DF_Regs *df_get_hover_regs(void); +//////////////////////////////// +//~ rjf: Name Allocation + +internal U64 df_name_bucket_idx_from_string_size(U64 size); +internal String8 df_name_alloc(String8 string); +internal void df_name_release(String8 string); + //////////////////////////////// //~ rjf: Entity Stateful Functions diff --git a/src/dbg_frontend/dbg_frontend_views.c b/src/dbg_frontend/dbg_frontend_views.c index 04466eda..43441aba 100644 --- a/src/dbg_frontend/dbg_frontend_views.c +++ b/src/dbg_frontend/dbg_frontend_views.c @@ -8453,7 +8453,7 @@ DF_VIEW_UI_FUNCTION_DEF(exception_filters) } node->v[node->count].name = name; node->v[node->count].matches = matches; - node->v[node->count].is_enabled = !!(d_state->ctrl_exception_code_filters[k/64] & (1ull<<(k%64))); + node->v[node->count].is_enabled = !!(df_state->ctrl_exception_code_filters[k/64] & (1ull<<(k%64))); node->v[node->count].exception_code_kind = k; node->count += 1; opts_list.option_count += 1; @@ -8505,11 +8505,11 @@ DF_VIEW_UI_FUNCTION_DEF(exception_filters) CTRL_ExceptionCodeKind k = opt->exception_code_kind; if(opt->is_enabled) { - d_state->ctrl_exception_code_filters[k/64] &= ~(1ull<<(k%64)); + df_state->ctrl_exception_code_filters[k/64] &= ~(1ull<<(k%64)); } else { - d_state->ctrl_exception_code_filters[k/64] |= (1ull<<(k%64)); + df_state->ctrl_exception_code_filters[k/64] |= (1ull<<(k%64)); } } }