Skip to content

Commit b7f6b30

Browse files
committed
eliminate unnecessary complication for debugger query evaluations; formalize them in the schemas, use set-hook rule to automatically plug in querying functions for them
1 parent 404ad62 commit b7f6b30

File tree

9 files changed

+107
-353
lines changed

9 files changed

+107
-353
lines changed

src/eval/eval_ir.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ E_LOOKUP_ACCESS_FUNCTION_DEF(default)
221221
B32 r_found = 0;
222222
E_TypeKey r_type = zero_struct;
223223
U64 r_value = 0;
224+
String8 r_query_name = {0};
224225
B32 r_is_constant_value = 0;
225226
{
226227
Temp scratch = scratch_begin(&arena, 1);
@@ -231,6 +232,10 @@ E_LOOKUP_ACCESS_FUNCTION_DEF(default)
231232
r_type = match.type_key;
232233
r_value = match.off;
233234
}
235+
if(match.kind == E_MemberKind_Query)
236+
{
237+
r_query_name = exprr->string;
238+
}
234239
if(match.kind == E_MemberKind_Null)
235240
{
236241
E_Type *type = e_type_from_key__cached(check_type_key);
@@ -290,6 +295,7 @@ E_LOOKUP_ACCESS_FUNCTION_DEF(default)
290295
{
291296
// rjf: build tree
292297
E_IRNode *new_tree = l.root;
298+
E_TypeKey new_tree_type = r_type;
293299
E_Mode mode = l.mode;
294300
if(l_restype_kind == E_TypeKind_Ptr ||
295301
l_restype_kind == E_TypeKind_LRef ||
@@ -625,7 +631,7 @@ E_IRGEN_FUNCTION_DEF(slice)
625631
E_TypeKey sized_base_ptr_type_key = e_type_key_cons_ptr(e_type_state->ctx->primary_module->arch, element_type_key, count, 0);
626632
E_MemberList slice_type_members = {0};
627633
e_member_list_push(scratch.arena, &slice_type_members, count_member);
628-
e_member_list_push(scratch.arena, &slice_type_members, &(E_Member){.kind = E_MemberKind_DataField, .type_key = sized_base_ptr_type_key, .name = base_ptr_member->name, .pretty_name = base_ptr_member->pretty_name, .off = base_ptr_member->off});
634+
e_member_list_push(scratch.arena, &slice_type_members, &(E_Member){.kind = E_MemberKind_DataField, .type_key = sized_base_ptr_type_key, .name = base_ptr_member->name, .off = base_ptr_member->off});
629635
E_MemberArray slice_type_members_array = e_member_array_from_list(scratch.arena, &slice_type_members);
630636
slice_type_key = e_type_key_cons(.arch = e_type_state->ctx->primary_module->arch,
631637
.kind = E_TypeKind_Struct,

src/eval/eval_types.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ e_type_key_cons_base(Type *type)
501501
for(U64 idx = 0; idx < type->count; idx += 1)
502502
{
503503
E_TypeKey member_type_key = e_type_key_cons_base(type->members[idx].type);
504-
e_member_list_push_new(scratch.arena, &members, .name = type->members[idx].name, .off = type->members[idx].value, .type_key = member_type_key, .pretty_name = type->members[idx].pretty_name);
504+
e_member_list_push_new(scratch.arena, &members, .name = type->members[idx].name, .off = type->members[idx].value, .type_key = member_type_key);
505505
}
506506
E_MemberArray members_array = e_member_array_from_list(scratch.arena, &members);
507507
result = e_type_key_cons(.arch = arch_from_context(),
@@ -1413,7 +1413,6 @@ e_type_member_copy(Arena *arena, E_Member *src)
14131413
E_Member *dst = push_array(arena, E_Member, 1);
14141414
MemoryCopyStruct(dst, src);
14151415
dst->name = push_str8_copy(arena, src->name);
1416-
dst->pretty_name = push_str8_copy(arena, src->pretty_name);
14171416
dst->inheritance_key_chain = e_type_key_list_copy(arena, &src->inheritance_key_chain);
14181417
return dst;
14191418
}

src/eval/eval_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef enum E_MemberKind
5959
E_MemberKind_VirtualBase,
6060
E_MemberKind_NestedType,
6161
E_MemberKind_Padding,
62+
E_MemberKind_Query,
6263
E_MemberKind_COUNT
6364
}
6465
E_MemberKind;
@@ -80,7 +81,6 @@ struct E_Member
8081
E_MemberKind kind;
8182
E_TypeKey type_key;
8283
String8 name;
83-
String8 pretty_name;
8484
U64 off;
8585
E_TypeKeyList inheritance_key_chain;
8686
};

src/raddbg/generated/raddbg.meta.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,15 @@ RD_VocabInfo rd_vocab_info_table[285] =
296296
RD_NameSchemaInfo rd_name_schema_info_table[10] =
297297
{
298298
{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")},
299-
{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")},
299+
{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 'environment': query,\n}\n")},
300300
{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")},
301301
{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")},
302302
{str8_lit_comp("file_path_map"), str8_lit_comp("@collection_commands(add_file_path_map) @commands(remove_cfg) x:{'source':path, 'dest':path}")},
303303
{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}")},
304-
{str8_lit_comp("machine"), str8_lit_comp("x:{'frozen':bool, 'label':code_string}")},
305-
{str8_lit_comp("process"), str8_lit_comp("x:{'frozen':bool, 'label':code_string, 'id':u64}")},
304+
{str8_lit_comp("machine"), str8_lit_comp("x:{'label':code_string, 'frozen':bool, 'processes':query}")},
305+
{str8_lit_comp("process"), str8_lit_comp("x:{'label':code_string, 'id':u64, 'frozen':bool, 'modules':query, 'threads':query}")},
306306
{str8_lit_comp("module"), str8_lit_comp("x:{'exe':path, 'dbg':path, 'vaddr_range':vaddr_range}")},
307-
{str8_lit_comp("thread"), str8_lit_comp("x:{'frozen':bool, 'label':code_string, 'id':u64}")},
307+
{str8_lit_comp("thread"), str8_lit_comp("x:{'label':code_string, 'id':u64, 'frozen':bool, 'call_stack':query}")},
308308
};
309309

310310
Rng1U64 rd_reg_slot_range_table[38] =

src/raddbg/raddbg.mdesk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ RD_VocabTable:
159159
'stderr_path': path,
160160
'stdin_path': path,
161161
'debug_subprocesses': bool,
162+
'environment': query,
162163
}
163164
```,
164165
}
@@ -210,13 +211,13 @@ RD_VocabTable:
210211
//- rjf: machines
211212
{
212213
machine,
213-
```x:{'frozen':bool, 'label':code_string}```,
214+
```x:{'label':code_string, 'frozen':bool, 'processes':query}```,
214215
}
215216

216217
//- rjf: processes
217218
{
218219
process,
219-
```x:{'frozen':bool, 'label':code_string, 'id':u64}```,
220+
```x:{'label':code_string, 'id':u64, 'frozen':bool, 'modules':query, 'threads':query}```,
220221
}
221222

222223
//- rjf: modules
@@ -228,7 +229,7 @@ RD_VocabTable:
228229
//- rjf: threads
229230
{
230231
thread,
231-
```x:{'frozen':bool, 'label':code_string, 'id':u64}```,
232+
```x:{'label':code_string, 'id':u64, 'frozen':bool, 'call_stack':query}```,
232233
}
233234
}
234235

0 commit comments

Comments
 (0)