Skip to content

Commit 18010db

Browse files
committed
per-row command cells in watch windows when evaluating cfgs; table-drive per-collection commands
1 parent 6498666 commit 18010db

File tree

8 files changed

+108
-414
lines changed

8 files changed

+108
-414
lines changed

src/raddbg/generated/raddbg.meta.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ RD_VocabInfo rd_vocab_info_table[277] =
226226
{str8_lit_comp("set_columns"), str8_lit_comp(""), str8_lit_comp("Set Columns"), str8_lit_comp(""), RD_IconKind_Thumbnails},
227227
{str8_lit_comp("toggle_address_visibility"), str8_lit_comp(""), str8_lit_comp("Toggle Address Visibility"), str8_lit_comp(""), RD_IconKind_Thumbnails},
228228
{str8_lit_comp("toggle_code_bytes_visibility"), str8_lit_comp(""), str8_lit_comp("Toggle Code Bytes Visibility"), str8_lit_comp(""), RD_IconKind_Thumbnails},
229-
{str8_lit_comp("enable_cfg"), str8_lit_comp(""), str8_lit_comp("Enable Config Tree"), str8_lit_comp(""), RD_IconKind_Null},
230-
{str8_lit_comp("disable_cfg"), str8_lit_comp(""), str8_lit_comp("Disable Config Tree"), str8_lit_comp(""), RD_IconKind_Null},
229+
{str8_lit_comp("enable_cfg"), str8_lit_comp(""), str8_lit_comp("Enable Config Tree"), str8_lit_comp(""), RD_IconKind_CheckHollow},
230+
{str8_lit_comp("disable_cfg"), str8_lit_comp(""), str8_lit_comp("Disable Config Tree"), str8_lit_comp(""), RD_IconKind_CheckFilled},
231231
{str8_lit_comp("select_cfg"), str8_lit_comp(""), str8_lit_comp("Select Config Tree"), str8_lit_comp(""), RD_IconKind_CheckHollow},
232232
{str8_lit_comp("remove_cfg"), str8_lit_comp(""), str8_lit_comp("Remove Config Tree"), str8_lit_comp(""), RD_IconKind_Trash},
233233
{str8_lit_comp("name_cfg"), str8_lit_comp(""), str8_lit_comp("Name Config Tree"), str8_lit_comp(""), RD_IconKind_Null},
@@ -287,16 +287,16 @@ RD_VocabInfo rd_vocab_info_table[277] =
287287

288288
RD_NameSchemaInfo rd_name_schema_info_table[10] =
289289
{
290-
{str8_lit_comp("settings"), str8_lit_comp("x:\n{\n @default(1) 'hover_animations': bool,\n @default(1) 'press_animations': bool,\n @default(0) 'focus_animations': bool,\n @default(1) 'tooltip_animations': bool,\n @default(1) 'menu_animations': bool,\n @default(1) 'scrolling_animations': bool,\n @default(1) 'background_blur': bool,\n @default(1) 'thread_lines': bool,\n @default(1) 'breakpoint_lines': bool,\n @default(1) 'thread_glow': bool,\n @default(1) 'breakpoint_glow': bool,\n @default(0) 'opaque_backgrounds': bool,\n @default(1) 'smooth_main_text': bool,\n @default(0) 'smooth_code_text': bool,\n @default(1) 'hint_main_text': bool,\n @default(1) 'hint_code_text': bool,\n @default(2) 'tab_width': @range[1, 32] u64,\n @can_be_per_window 'main_font_size': @range[6, 72] u64,\n @can_be_per_window 'code_font_size': @range[1, 32] u64,\n}\n"), str8_lit_comp("")},
291-
{str8_lit_comp("target"), str8_lit_comp("x:\n{\n 'label': code_string,\n 'executable': path,\n 'arguments': string,\n 'working_directory': path,\n 'entry_point': code_string,\n 'stdout_path': path,\n 'stderr_path': path,\n 'stdin_path': path,\n 'debug_subprocesses': bool,\n}\n"), str8_lit_comp("launch_and_run,launch_and_init,select_cfg,remove_cfg")},
292-
{str8_lit_comp("breakpoint"), str8_lit_comp("x:\n{\n 'label': code_string,\n 'condition': code_string,\n 'location': location,\n 'hit_count': u64,\n 'disabled': bool,\n}\n"), str8_lit_comp("enable_cfg,remove_cfg")},
293-
{str8_lit_comp("watch_pin"), str8_lit_comp("x:\n{\n 'expression': code_string,\n 'view_rule': code_string,\n 'location': location,\n}\n"), str8_lit_comp("remove_cfg")},
294-
{str8_lit_comp("file_path_map"), str8_lit_comp("x:{'source':path, 'dest':path}"), str8_lit_comp("remove_cfg")},
295-
{str8_lit_comp("auto_view_rule"), str8_lit_comp("x:{'source':code_string, 'dest':code_string}"), str8_lit_comp("remove_cfg")},
296-
{str8_lit_comp("machine"), str8_lit_comp("x:{'frozen':bool, 'label':code_string}"), str8_lit_comp("")},
297-
{str8_lit_comp("process"), str8_lit_comp("x:{'frozen':bool, 'label':code_string, 'id':u64}"), str8_lit_comp("")},
298-
{str8_lit_comp("module"), str8_lit_comp("x:{'exe':path, 'dbg':path, 'vaddr_range':vaddr_range}"), str8_lit_comp("")},
299-
{str8_lit_comp("thread"), str8_lit_comp("x:{'frozen':bool, 'label':code_string, 'id':u64}"), str8_lit_comp("")},
290+
{str8_lit_comp("settings"), str8_lit_comp("x:\n{\n @default(1) 'hover_animations': bool,\n @default(1) 'press_animations': bool,\n @default(0) 'focus_animations': bool,\n @default(1) 'tooltip_animations': bool,\n @default(1) 'menu_animations': bool,\n @default(1) 'scrolling_animations': bool,\n @default(1) 'background_blur': bool,\n @default(1) 'thread_lines': bool,\n @default(1) 'breakpoint_lines': bool,\n @default(1) 'thread_glow': bool,\n @default(1) 'breakpoint_glow': bool,\n @default(0) 'opaque_backgrounds': bool,\n @default(1) 'smooth_main_text': bool,\n @default(0) 'smooth_code_text': bool,\n @default(1) 'hint_main_text': bool,\n @default(1) 'hint_code_text': bool,\n @default(2) 'tab_width': @range[1, 32] u64,\n @can_be_per_window 'main_font_size': @range[6, 72] u64,\n @can_be_per_window 'code_font_size': @range[1, 32] u64,\n}\n")},
291+
{str8_lit_comp("target"), str8_lit_comp("@commands(launch_and_run, launch_and_init, select_cfg, remove_cfg)\n@collection_commands(add_target)\nx:\n{\n 'label': code_string,\n 'executable': path,\n 'arguments': string,\n 'working_directory': path,\n 'entry_point': code_string,\n 'stdout_path': path,\n 'stderr_path': path,\n 'stdin_path': path,\n 'debug_subprocesses': bool,\n}\n")},
292+
{str8_lit_comp("breakpoint"), str8_lit_comp("@commands(enable_cfg, remove_cfg)\n@collection_commands(add_breakpoint, add_address_breakpoint, add_function_breakpoint)\nx:\n{\n 'label': code_string,\n 'condition': code_string,\n 'location': location,\n 'hit_count': u64,\n 'disabled': bool,\n}\n")},
293+
{str8_lit_comp("watch_pin"), str8_lit_comp("@commands(remove_cfg)\n@collection_commands(add_watch_pin)\nx:\n{\n 'expression': code_string,\n 'view_rule': code_string,\n 'location': location,\n}\n")},
294+
{str8_lit_comp("file_path_map"), str8_lit_comp("@collection_commands(add_file_path_map) @commands(remove_cfg) x:{'source':path, 'dest':path}")},
295+
{str8_lit_comp("auto_view_rule"), str8_lit_comp("@collection_commands(add_auto_view_rule) @commands(remove_cfg) x:{'source':code_string, 'dest':code_string}")},
296+
{str8_lit_comp("machine"), str8_lit_comp("x:{'frozen':bool, 'label':code_string}")},
297+
{str8_lit_comp("process"), str8_lit_comp("x:{'frozen':bool, 'label':code_string, 'id':u64}")},
298+
{str8_lit_comp("module"), str8_lit_comp("x:{'exe':path, 'dbg':path, 'vaddr_range':vaddr_range}")},
299+
{str8_lit_comp("thread"), str8_lit_comp("x:{'frozen':bool, 'label':code_string, 'id':u64}")},
300300
};
301301

302302
Rng1U64 rd_reg_slot_range_table[38] =

src/raddbg/generated/raddbg.meta.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ struct RD_NameSchemaInfo
450450
{
451451
String8 name;
452452
String8 schema;
453-
String8 cmd_names;
454453
};
455454

456455
typedef struct RD_Regs RD_Regs;

src/raddbg/raddbg.mdesk

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ RD_VocabTable:
105105
////////////////////////////////
106106
//~ rjf: Schemas
107107

108-
@table(name schema cmd_names) RD_SchemaTable:
108+
@table(name schema) RD_SchemaTable:
109109
{
110110
//- rjf: settings
111111
{
@@ -138,7 +138,10 @@ RD_VocabTable:
138138
//- rjf: targets
139139
{
140140
target,
141-
```x:
141+
```
142+
@commands(launch_and_run, launch_and_init, select_cfg, remove_cfg)
143+
@collection_commands(add_target)
144+
x:
142145
{
143146
'label': code_string,
144147
'executable': path,
@@ -151,13 +154,15 @@ RD_VocabTable:
151154
'debug_subprocesses': bool,
152155
}
153156
```,
154-
`launch_and_run,launch_and_init,select_cfg,remove_cfg`,
155157
}
156158

157159
//- rjf: breakpoints
158160
{
159161
breakpoint,
160-
```x:
162+
```
163+
@commands(enable_cfg, remove_cfg)
164+
@collection_commands(add_breakpoint, add_address_breakpoint, add_function_breakpoint)
165+
x:
161166
{
162167
'label': code_string,
163168
'condition': code_string,
@@ -166,34 +171,33 @@ RD_VocabTable:
166171
'disabled': bool,
167172
}
168173
```,
169-
`enable_cfg,remove_cfg`,
170174
}
171175

172176
//- rjf: watch pins
173177
{
174178
watch_pin,
175-
```x:
179+
```
180+
@commands(remove_cfg)
181+
@collection_commands(add_watch_pin)
182+
x:
176183
{
177184
'expression': code_string,
178185
'view_rule': code_string,
179186
'location': location,
180187
}
181188
```,
182-
`remove_cfg`,
183189
}
184190

185191
//- rjf: file path maps
186192
{
187193
file_path_map,
188-
```x:{'source':path, 'dest':path}```,
189-
`remove_cfg`,
194+
```@collection_commands(add_file_path_map) @commands(remove_cfg) x:{'source':path, 'dest':path}```,
190195
}
191196

192197
//- rjf: auto view rules
193198
{
194199
auto_view_rule,
195-
```x:{'source':code_string, 'dest':code_string}```,
196-
`remove_cfg`,
200+
```@collection_commands(add_auto_view_rule) @commands(remove_cfg) x:{'source':code_string, 'dest':code_string}```,
197201
}
198202

199203
//- rjf: machines
@@ -225,12 +229,11 @@ RD_VocabTable:
225229
{
226230
`String8 name`;
227231
`String8 schema`;
228-
`String8 cmd_names`;
229232
}
230233

231234
@data(RD_NameSchemaInfo) rd_name_schema_info_table:
232235
{
233-
@expand(RD_SchemaTable a) `{str8_lit_comp("$(a.name)"), str8_lit_comp("$(a.schema)"), str8_lit_comp("$(a.cmd_names)")}`
236+
@expand(RD_SchemaTable a) `{str8_lit_comp("$(a.name)"), str8_lit_comp("$(a.schema)")}`
234237
}
235238

236239
////////////////////////////////
@@ -501,8 +504,8 @@ RD_CmdTable: // | | | |
501504
{ToggleCodeBytesVisibility 1 1 Null null Nil Null 0 0 0 0 0 0 Thumbnails "toggle_code_bytes_visibility""Toggle Code Bytes Visibility" "Toggles the visibility of machine code bytes in a disassembly view." "" "$disasm," }
502505

503506
//- rjf: general config operations
504-
{EnableCfg 0 0 Null null Nil Null 0 0 0 0 0 0 Null "enable_cfg" "Enable Config Tree" "Enables a config tree." "" "" }
505-
{DisableCfg 0 0 Null null Nil Null 0 0 0 0 0 0 Null "disable_cfg" "Disable Config Tree" "Disables a config tree." "" "" }
507+
{EnableCfg 0 0 Null null Nil Null 0 0 0 0 0 0 CheckHollow "enable_cfg" "Enable Config Tree" "Enables a config tree." "" "" }
508+
{DisableCfg 0 0 Null null Nil Null 0 0 0 0 0 0 CheckFilled "disable_cfg" "Disable Config Tree" "Disables a config tree." "" "" }
506509
{SelectCfg 0 0 Null null Nil Null 0 0 0 0 0 0 CheckHollow "select_cfg" "Select Config Tree" "Selects a config tree, disabling all others of the same kind." "" "" }
507510
{RemoveCfg 0 0 Null null Nil Null 0 0 0 0 0 0 Trash "remove_cfg" "Remove Config Tree" "Removes a config tree." "" "" }
508511
{NameCfg 0 0 Null null Nil Null 0 0 0 0 0 0 Null "name_cfg" "Name Config Tree" "Equips a config tree with a label." "" "" }

src/raddbg/raddbg_core.c

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,11 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg, Vec4F32 secondary_color, F32
13931393
if(condition.size != 0)
13941394
{
13951395
dr_fstrs_push_new(arena, &result, &params, str8_lit("if "), .font = rd_font_from_slot(RD_FontSlot_Code));
1396-
DR_FStrList fstrs = rd_fstrs_from_code_string(arena, 1.f, 0, params.color, condition);
1397-
dr_fstrs_concat_in_place(&result, &fstrs);
1396+
RD_Font(RD_FontSlot_Code)
1397+
{
1398+
DR_FStrList fstrs = rd_fstrs_from_code_string(arena, 1.f, 0, params.color, condition);
1399+
dr_fstrs_concat_in_place(&result, &fstrs);
1400+
}
13981401
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
13991402
}
14001403
}
@@ -5732,7 +5735,7 @@ rd_window_frame(void)
57325735

57335736
//- rjf: center column
57345737
UI_PrefWidth(ui_children_sum(1.f)) UI_Row
5735-
UI_PrefWidth(ui_em(2.25f, 1))
5738+
UI_PrefWidth(ui_em(2.5f, 1))
57365739
RD_Font(RD_FontSlot_Icons)
57375740
UI_FontSize(ui_top_font_size()*0.85f)
57385741
{
@@ -8577,20 +8580,11 @@ E_LOOKUP_INFO_FUNCTION_DEF(top_level_cfg)
85778580
String8 cfg_name = rd_singular_from_code_name_plural(lhs_type->name);
85788581
RD_CfgList cfgs_list = rd_cfg_top_level_list_from_string(scratch.arena, cfg_name);\
85798582
String8List cmds_list = {0};
8580-
// TODO(rjf): @cfg hack - probably want to table-drive this
8581-
if(str8_match(cfg_name, str8_lit("target"), 0))
8582-
{
8583-
str8_list_push(arena, &cmds_list, rd_cmd_kind_info_table[RD_CmdKind_AddTarget].string);
8584-
}
8585-
else if(str8_match(cfg_name, str8_lit("breakpoint"), 0))
8583+
MD_Node *schema = rd_schema_from_name(scratch.arena, cfg_name);
8584+
MD_Node *collection_cmds_root = md_tag_from_string(schema, str8_lit("collection_commands"), 0);
8585+
for MD_EachNode(cmd, collection_cmds_root->first)
85868586
{
8587-
str8_list_push(arena, &cmds_list, rd_cmd_kind_info_table[RD_CmdKind_AddBreakpoint].string);
8588-
str8_list_push(arena, &cmds_list, rd_cmd_kind_info_table[RD_CmdKind_AddAddressBreakpoint].string);
8589-
str8_list_push(arena, &cmds_list, rd_cmd_kind_info_table[RD_CmdKind_AddFunctionBreakpoint].string);
8590-
}
8591-
else if(str8_match(cfg_name, str8_lit("watch_pin"), 0))
8592-
{
8593-
str8_list_push(arena, &cmds_list, rd_cmd_kind_info_table[RD_CmdKind_AddWatchPin].string);
8587+
str8_list_push(arena, &cmds_list, cmd->string);
85948588
}
85958589
RD_TopLevelCfgLookupAccel *accel = push_array(arena, RD_TopLevelCfgLookupAccel, 1);
85968590
accel->cfgs = rd_cfg_array_from_list(arena, &cfgs_list);
@@ -11082,7 +11076,6 @@ rd_title_fstrs_from_code_name(Arena *arena, String8 code_name, Vec4F32 secondary
1108211076
//- rjf: push icon
1108311077
if(info->icon_kind != RD_IconKind_Null)
1108411078
{
11085-
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
1108611079
dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[info->icon_kind], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = secondary_color);
1108711080
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
1108811081
}
@@ -13163,27 +13156,6 @@ rd_frame(void)
1316313156
rd_cfg_release(recent_projects.last->v);
1316413157
}
1316513158
}
13166-
13167-
//- TODO(rjf): @cfg set up debugging config state
13168-
if(kind == RD_CmdKind_OpenUser)
13169-
{
13170-
RD_Cfg *user = rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("user"));
13171-
{
13172-
RD_Cfg *watch = rd_cfg_new(user, str8_lit("watch"));
13173-
RD_Cfg *expr = rd_cfg_new(watch, str8_lit("expression"));
13174-
rd_cfg_new(expr, str8_lit("current_thread"));
13175-
}
13176-
{
13177-
RD_Cfg *watch = rd_cfg_new(user, str8_lit("watch"));
13178-
RD_Cfg *expr = rd_cfg_new(watch, str8_lit("expression"));
13179-
rd_cfg_new(expr, str8_lit("targets[0]"));
13180-
}
13181-
{
13182-
RD_Cfg *watch = rd_cfg_new(user, str8_lit("watch"));
13183-
RD_Cfg *expr = rd_cfg_new(watch, str8_lit("expression"));
13184-
rd_cfg_new(expr, str8_lit("basics"));
13185-
}
13186-
}
1318713159
}break;
1318813160

1318913161
//- rjf: writing config changes

src/raddbg/raddbg_core.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -889,20 +889,6 @@ read_only global RD_ViewUIRule rd_nil_view_ui_rule =
889889
RD_VIEW_UI_FUNCTION_NAME(null),
890890
};
891891

892-
#if 0 // TODO(rjf): @cfg
893-
read_only global RD_ViewRuleInfo rd_nil_view_rule_info =
894-
{
895-
{0},
896-
{0},
897-
{0},
898-
{0},
899-
RD_IconKind_Null,
900-
0,
901-
EV_EXPAND_RULE_INFO_FUNCTION_NAME(nil),
902-
RD_VIEW_RULE_UI_FUNCTION_NAME(null)
903-
};
904-
#endif
905-
906892
read_only global RD_ViewState rd_nil_view_state =
907893
{
908894
&rd_nil_view_state,

0 commit comments

Comments
 (0)