Skip to content

Commit 404ad62

Browse files
committed
more convergence; split scheduler into machines, process, and threads tabs. most people just care about threads, and so that should be the default/common case
1 parent 81be64d commit 404ad62

File tree

5 files changed

+201
-12
lines changed

5 files changed

+201
-12
lines changed

src/raddbg/generated/raddbg.meta.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//- GENERATED CODE
55

66
C_LINKAGE_BEGIN
7-
RD_VocabInfo rd_vocab_info_table[283] =
7+
RD_VocabInfo rd_vocab_info_table[285] =
88
{
99
{str8_lit_comp("auto_view_rule"), str8_lit_comp("auto_view_rules"), str8_lit_comp("Auto View Rule"), str8_lit_comp("Auto View Rules"), RD_IconKind_Binoculars},
1010
{str8_lit_comp("file_path_map"), str8_lit_comp("file_path_maps"), str8_lit_comp("File Path Map"), str8_lit_comp("File Path Maps"), RD_IconKind_FileOutline},
@@ -53,7 +53,9 @@ RD_VocabInfo rd_vocab_info_table[283] =
5353
{str8_lit_comp("vtx_size"), str8_lit_comp("vtx_sizes"), str8_lit_comp("Vertex Buffer Size"), str8_lit_comp("Vertex Buffer Sizes"), RD_IconKind_Null},
5454
{str8_lit_comp("label"), str8_lit_comp("labels"), str8_lit_comp("Label"), str8_lit_comp("Labels"), RD_IconKind_Null},
5555
{str8_lit_comp("thread"), str8_lit_comp("threads"), str8_lit_comp("Thread"), str8_lit_comp("Threads"), RD_IconKind_Thread},
56-
{str8_lit_comp("process"), str8_lit_comp("processes"), str8_lit_comp("Process"), str8_lit_comp("Processes"), RD_IconKind_Threads},
56+
{str8_lit_comp("threads"), str8_lit_comp(""), str8_lit_comp("Threads"), str8_lit_comp(""), RD_IconKind_Threads},
57+
{str8_lit_comp("process"), str8_lit_comp("processes"), str8_lit_comp("Process"), str8_lit_comp("Processes"), RD_IconKind_Scheduler},
58+
{str8_lit_comp("processes"), str8_lit_comp(""), str8_lit_comp("Processes"), str8_lit_comp(""), RD_IconKind_Scheduler},
5759
{str8_lit_comp("machine"), str8_lit_comp("machines"), str8_lit_comp("Machine"), str8_lit_comp("Machines"), RD_IconKind_Machine},
5860
{str8_lit_comp("module"), str8_lit_comp("modules"), str8_lit_comp("Module"), str8_lit_comp("Modules"), RD_IconKind_Module},
5961
{str8_lit_comp("getting_started"), str8_lit_comp(""), str8_lit_comp("Getting Started"), str8_lit_comp(""), RD_IconKind_QuestionMark},

src/raddbg/generated/raddbg.meta.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ RD_Query query;
555555
.os_event = rd_regs()->os_event,\
556556

557557
C_LINKAGE_BEGIN
558-
extern RD_VocabInfo rd_vocab_info_table[283];
558+
extern RD_VocabInfo rd_vocab_info_table[285];
559559
extern RD_NameSchemaInfo rd_name_schema_info_table[10];
560560
extern Rng1U64 rd_reg_slot_range_table[38];
561561
extern String8 rd_binding_version_remap_old_name_table[8];

src/raddbg/raddbg.mdesk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ RD_VocabTable:
6565
{vtx_size _ "Vertex Buffer Size" _ Null }
6666
{label _ "Label" _ Null }
6767
{thread _ "Thread" _ Thread }
68-
{process processes "Process" "Processes" Threads }
68+
{threads "" "Threads" "" Threads }
69+
{process processes "Process" "Processes" Scheduler }
70+
{processes "" "Processes" "" Scheduler }
6971
{machine _ "Machine" _ Machine }
7072
{module _ "Module" _ Module }
7173
{getting_started "" "Getting Started" "" QuestionMark }

src/raddbg/raddbg_core.c

Lines changed: 187 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,161 @@ E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(top_level_cfg)
560560
return num;
561561
}
562562

563+
////////////////////////////////
564+
//~ rjf: Machine Eval Hooks
565+
566+
E_LOOKUP_INFO_FUNCTION_DEF(machine)
567+
{
568+
E_LookupInfo result = E_LOOKUP_INFO_FUNCTION_NAME(default)(arena, lhs, filter);
569+
result.named_expr_count += 1;
570+
return result;
571+
}
572+
573+
E_LOOKUP_ACCESS_FUNCTION_DEF(machine)
574+
{
575+
Temp scratch = scratch_begin(&arena, 1);
576+
E_LookupAccess result = E_LOOKUP_ACCESS_FUNCTION_NAME(default)(arena, kind, lhs, rhs, user_data);
577+
if(kind == E_ExprKind_MemberAccess && rhs->kind == E_ExprKind_LeafMember && str8_match(rhs->string, str8_lit("processes"), 0))
578+
{
579+
E_Eval eval = e_eval_from_expr(scratch.arena, lhs);
580+
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space);
581+
result.irtree_and_type.root = e_irtree_set_space(arena, e_space_make(RD_EvalSpaceKind_MetaCtrlEntity), e_irtree_leaf_u128(arena, u128_make(entity->handle.machine_id, entity->handle.dmn_handle.u64[0])));
582+
result.irtree_and_type.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("machine_processes"));
583+
result.irtree_and_type.mode = E_Mode_Offset;
584+
}
585+
scratch_end(scratch);
586+
return result;
587+
}
588+
589+
E_LOOKUP_RANGE_FUNCTION_DEF(machine)
590+
{
591+
Temp scratch = scratch_begin(&arena, 1);
592+
E_LOOKUP_RANGE_FUNCTION_NAME(default)(arena, lhs, idx_range, exprs, exprs_strings, user_data);
593+
E_IRTreeAndType lhs_irtree = e_irtree_and_type_from_expr(scratch.arena, lhs);
594+
E_Type *lhs_type = e_type_from_key__cached(lhs_irtree.type_key);
595+
String8 extras[] =
596+
{
597+
str8_lit("processes"),
598+
};
599+
Rng1U64 extras_idx_range = r1u64(lhs_type->count, lhs_type->count + ArrayCount(extras));
600+
Rng1U64 extras_read_range = intersect_1u64(extras_idx_range, idx_range);
601+
U64 extras_count = dim_1u64(extras_read_range);
602+
for(U64 extras_idx = 0; extras_idx < extras_count; extras_idx += 1)
603+
{
604+
U64 out_idx = extras_idx_range.min - idx_range.min + extras_idx;
605+
exprs[out_idx] = e_expr_irext_member_access(arena, lhs, &lhs_irtree, extras[extras_idx]);
606+
}
607+
scratch_end(scratch);
608+
}
609+
610+
////////////////////////////////
611+
//~ rjf: Process Eval Hooks
612+
613+
E_LOOKUP_INFO_FUNCTION_DEF(process)
614+
{
615+
E_LookupInfo result = E_LOOKUP_INFO_FUNCTION_NAME(default)(arena, lhs, filter);
616+
result.named_expr_count += 1;
617+
return result;
618+
}
619+
620+
E_LOOKUP_ACCESS_FUNCTION_DEF(process)
621+
{
622+
Temp scratch = scratch_begin(&arena, 1);
623+
E_LookupAccess result = E_LOOKUP_ACCESS_FUNCTION_NAME(default)(arena, kind, lhs, rhs, user_data);
624+
if(kind == E_ExprKind_MemberAccess && rhs->kind == E_ExprKind_LeafMember && str8_match(rhs->string, str8_lit("modules"), 0))
625+
{
626+
E_Eval eval = e_eval_from_expr(scratch.arena, lhs);
627+
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space);
628+
result.irtree_and_type.root = e_irtree_set_space(arena, rd_eval_space_from_ctrl_entity(entity, RD_EvalSpaceKind_MetaCtrlEntity), e_irtree_leaf_u128(arena, u128_make(entity->handle.machine_id, entity->handle.dmn_handle.u64[0])));
629+
result.irtree_and_type.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("process_modules"));
630+
result.irtree_and_type.mode = E_Mode_Offset;
631+
}
632+
if(kind == E_ExprKind_MemberAccess && rhs->kind == E_ExprKind_LeafMember && str8_match(rhs->string, str8_lit("threads"), 0))
633+
{
634+
E_Eval eval = e_eval_from_expr(scratch.arena, lhs);
635+
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space);
636+
result.irtree_and_type.root = e_irtree_set_space(arena, e_space_make(RD_EvalSpaceKind_MetaCtrlEntity), e_irtree_leaf_u128(arena, u128_make(entity->handle.machine_id, entity->handle.dmn_handle.u64[0])));
637+
result.irtree_and_type.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("process_threads"));
638+
result.irtree_and_type.mode = E_Mode_Offset;
639+
}
640+
scratch_end(scratch);
641+
return result;
642+
}
643+
644+
E_LOOKUP_RANGE_FUNCTION_DEF(process)
645+
{
646+
Temp scratch = scratch_begin(&arena, 1);
647+
E_LOOKUP_RANGE_FUNCTION_NAME(default)(arena, lhs, idx_range, exprs, exprs_strings, user_data);
648+
E_IRTreeAndType lhs_irtree = e_irtree_and_type_from_expr(scratch.arena, lhs);
649+
E_Type *lhs_type = e_type_from_key__cached(lhs_irtree.type_key);
650+
String8 extras[] =
651+
{
652+
str8_lit("modules"),
653+
//str8_lit("threads"),
654+
};
655+
Rng1U64 extras_idx_range = r1u64(lhs_type->count, lhs_type->count + ArrayCount(extras));
656+
Rng1U64 extras_read_range = intersect_1u64(extras_idx_range, idx_range);
657+
U64 extras_count = dim_1u64(extras_read_range);
658+
for(U64 extras_idx = 0; extras_idx < extras_count; extras_idx += 1)
659+
{
660+
U64 out_idx = extras_idx_range.min - idx_range.min + extras_idx;
661+
exprs[out_idx] = e_expr_irext_member_access(arena, lhs, &lhs_irtree, extras[0]);
662+
}
663+
scratch_end(scratch);
664+
}
665+
666+
typedef struct RD_ProcessLookupAccel RD_ProcessLookupAccel;
667+
struct RD_ProcessLookupAccel
668+
{
669+
CTRL_EntityArray children;
670+
};
671+
672+
E_LOOKUP_INFO_FUNCTION_DEF(process_modules)
673+
{
674+
E_LookupInfo result = {0};
675+
Temp scratch = scratch_begin(&arena, 1);
676+
{
677+
E_OpList oplist = e_oplist_from_irtree(scratch.arena, lhs->root);
678+
String8 bytecode = e_bytecode_from_oplist(scratch.arena, &oplist);
679+
E_Interpretation interpret = e_interpret(bytecode);
680+
CTRL_Entity *process = rd_ctrl_entity_from_eval_space(interpret.space);
681+
CTRL_EntityList modules = {0};
682+
for(CTRL_Entity *child = process->first; child != &ctrl_entity_nil; child = child->next)
683+
{
684+
if(child->kind == CTRL_EntityKind_Module)
685+
{
686+
ctrl_entity_list_push(scratch.arena, &modules, child);
687+
}
688+
}
689+
RD_ProcessLookupAccel *accel = push_array(arena, RD_ProcessLookupAccel, 1);
690+
accel->children = ctrl_entity_array_from_list(arena, &modules);
691+
result.user_data = accel;
692+
result.idxed_expr_count = modules.count;
693+
}
694+
scratch_end(scratch);
695+
return result;
696+
}
697+
698+
E_LOOKUP_ACCESS_FUNCTION_DEF(process_modules)
699+
{
700+
E_LookupAccess result = {{&e_irnode_nil}};
701+
if(kind == E_ExprKind_ArrayIndex)
702+
{
703+
Temp scratch = scratch_begin(&arena, 1);
704+
RD_ProcessLookupAccel *accel = (RD_ProcessLookupAccel *)user_data;
705+
E_Value rhs_value = e_value_from_expr(rhs);
706+
if(0 <= rhs_value.u64 && rhs_value.u64 < accel->children.count)
707+
{
708+
CTRL_Entity *entity = accel->children.v[rhs_value.u64];
709+
result.irtree_and_type.root = e_irtree_set_space(arena, rd_eval_space_from_ctrl_entity(entity, RD_EvalSpaceKind_MetaCtrlEntity), e_irtree_const_u(arena, 0));
710+
result.irtree_and_type.type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, str8_lit("module"));
711+
result.irtree_and_type.mode = E_Mode_Offset;
712+
}
713+
scratch_end(scratch);
714+
}
715+
return result;
716+
}
717+
563718
////////////////////////////////
564719
//~ rjf: Thread Eval Hooks
565720

@@ -2854,6 +3009,16 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, Vec4F32 secon
28543009
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
28553010
}
28563011

3012+
//- rjf: push frozen icon, if frozen
3013+
if((entity->kind == CTRL_EntityKind_Machine ||
3014+
entity->kind == CTRL_EntityKind_Process ||
3015+
entity->kind == CTRL_EntityKind_Thread) &&
3016+
ctrl_entity_tree_is_frozen(entity))
3017+
{
3018+
dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[RD_IconKind_Locked], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = rd_rgba_from_theme_color(RD_ThemeColor_TextNegative));
3019+
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
3020+
}
3021+
28573022
//- rjf: push containing process prefix
28583023
if(entity->kind == CTRL_EntityKind_Thread ||
28593024
entity->kind == CTRL_EntityKind_Module)
@@ -2867,6 +3032,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, Vec4F32 secon
28673032
if(process_name.size != 0)
28683033
{
28693034
dr_fstrs_push_new(arena, &result, &params, process_name, .font = rd_font_from_slot(RD_FontSlot_Main), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Main), .color = process_color);
3035+
dr_fstrs_push_new(arena, &result, &params, push_str8f(arena, "(PID: %I64u)", process->id), .font = rd_font_from_slot(RD_FontSlot_Main), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Main), .color = secondary_color, .size = size*0.9f);
28703036
dr_fstrs_push_new(arena, &result, &params, str8_lit(" / "), .color = secondary_color);
28713037
}
28723038
}
@@ -2878,6 +3044,13 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, Vec4F32 secon
28783044
.raster_flags = rd_raster_flags_from_slot(name_is_code ? RD_FontSlot_Code : RD_FontSlot_Main),
28793045
.color = color);
28803046

3047+
//- rjf: push PID
3048+
if(entity->kind == CTRL_EntityKind_Process)
3049+
{
3050+
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
3051+
dr_fstrs_push_new(arena, &result, &params, push_str8f(arena, " (PID: %I64u)", entity->id), .font = rd_font_from_slot(RD_FontSlot_Main), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Main), .color = secondary_color, .size = size*0.85f);
3052+
}
3053+
28813054
//- rjf: threads get callstack extras
28823055
if(entity->kind == CTRL_EntityKind_Thread && include_extras)
28833056
{
@@ -12588,8 +12761,8 @@ rd_frame(void)
1258812761
}
1258912762
evallable_ctrl_table[] =
1259012763
{
12591-
{ str8_lit("machine") },
12592-
{ str8_lit("process") },
12764+
{ str8_lit("machine"), .info = E_LOOKUP_INFO_FUNCTION_NAME(machine), .access = E_LOOKUP_ACCESS_FUNCTION_NAME(machine), .range = E_LOOKUP_RANGE_FUNCTION_NAME(machine) },
12765+
{ str8_lit("process"), .info = E_LOOKUP_INFO_FUNCTION_NAME(process), .access = E_LOOKUP_ACCESS_FUNCTION_NAME(process), .range = E_LOOKUP_RANGE_FUNCTION_NAME(process) },
1259312766
{ str8_lit("thread"), .info = E_LOOKUP_INFO_FUNCTION_NAME(thread), .access = E_LOOKUP_ACCESS_FUNCTION_NAME(thread), .range = E_LOOKUP_RANGE_FUNCTION_NAME(thread) },
1259412767
{ str8_lit("module") },
1259512768
};
@@ -12669,6 +12842,9 @@ rd_frame(void)
1266912842
e_lookup_rule_map_insert_new(scratch.arena, ctx->lookup_rule_map, str8_lit("call_stack"),
1267012843
.info = E_LOOKUP_INFO_FUNCTION_NAME(call_stack),
1267112844
.access = E_LOOKUP_ACCESS_FUNCTION_NAME(call_stack));
12845+
e_lookup_rule_map_insert_new(scratch.arena, ctx->lookup_rule_map, str8_lit("process_modules"),
12846+
.info = E_LOOKUP_INFO_FUNCTION_NAME(process_modules),
12847+
.access = E_LOOKUP_ACCESS_FUNCTION_NAME(process_modules));
1267212848
}
1267312849

1267412850
//- rjf: add macro for collections with specific lookup rules (but no unique id rules)
@@ -14127,7 +14303,9 @@ X(call_stack)\
1412714303
X(breakpoints)\
1412814304
X(watch_pins)\
1412914305
X(targets)\
14130-
X(scheduler)\
14306+
X(threads)\
14307+
X(processes)\
14308+
X(machines)\
1413114309
X(modules)\
1413214310
Y(output, text, "query:output")\
1413314311
Y(disasm, disasm, "")\
@@ -14222,9 +14400,11 @@ Z(getting_started)
1422214400
RD_Cfg *root_1_0 = rd_cfg_new(root_1, str8_lit("0.50"));
1422314401
RD_Cfg *root_1_1 = rd_cfg_new(root_1, str8_lit("0.50"));
1422414402
rd_cfg_insert_child(root_1_0, root_1_0->last, targets);
14225-
rd_cfg_insert_child(root_1_1, root_1_1->last, scheduler);
14403+
rd_cfg_insert_child(root_1_1, root_1_1->last, threads);
14404+
rd_cfg_insert_child(root_1_1, root_1_1->last, processes);
14405+
rd_cfg_insert_child(root_1_1, root_1_1->last, machines);
1422614406
rd_cfg_new(targets, str8_lit("selected"));
14227-
rd_cfg_new(scheduler, str8_lit("selected"));
14407+
rd_cfg_new(threads, str8_lit("selected"));
1422814408

1422914409
// rjf: root 0_0 split
1423014410
RD_Cfg *root_0_0_0 = rd_cfg_new(root_0_0, str8_lit("0.25"));
@@ -14294,11 +14474,11 @@ Z(getting_started)
1429414474
rd_cfg_insert_child(root_0_0, root_0_0->last, watches);
1429514475
rd_cfg_insert_child(root_0_0, root_0_0->last, types);
1429614476
rd_cfg_new(watches, str8_lit("selected"));
14297-
rd_cfg_insert_child(root_0_1, root_0_1->last, scheduler);
14477+
rd_cfg_insert_child(root_0_1, root_0_1->last, threads);
1429814478
rd_cfg_insert_child(root_0_1, root_0_1->last, targets);
1429914479
rd_cfg_insert_child(root_0_1, root_0_1->last, breakpoints);
1430014480
rd_cfg_insert_child(root_0_1, root_0_1->last, watch_pins);
14301-
rd_cfg_new(scheduler, str8_lit("selected"));
14481+
rd_cfg_new(threads, str8_lit("selected"));
1430214482
rd_cfg_insert_child(root_0_2, root_0_2->last, disasm);
1430314483
rd_cfg_insert_child(root_0_2, root_0_2->last, output);
1430414484
rd_cfg_new(disasm, str8_lit("selected"));

src/raddbg/raddbg_views.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3398,7 +3398,12 @@ RD_VIEW_UI_FUNCTION_DEF(text)
33983398
DI_KeyList dbgi_keys = {0};
33993399
if(!file_is_missing)
34003400
{
3401-
RD_CodeViewBuildResult result = rd_code_view_build(scratch.arena, cv, RD_CodeViewBuildFlag_All, code_area_rect, data, &info, 0, r1u64(0, 0), di_key_zero());
3401+
RD_CodeViewBuildFlags flags = RD_CodeViewBuildFlag_All;
3402+
if(rd_regs()->file_path.size == 0)
3403+
{
3404+
flags &= ~RD_CodeViewBuildFlag_Margins;
3405+
}
3406+
RD_CodeViewBuildResult result = rd_code_view_build(scratch.arena, cv, flags, code_area_rect, data, &info, 0, r1u64(0, 0), di_key_zero());
34023407
dbgi_keys = result.dbgi_keys;
34033408
}
34043409

0 commit comments

Comments
 (0)