narrow scope of name resolution for debugger collections; default launching to not attach to child processes, set up msgs to parameterize this

This commit is contained in:
Ryan Fleury
2024-10-28 15:37:28 -07:00
parent 41cddf96b8
commit 4769d0a8d4
8 changed files with 41 additions and 24 deletions
+10 -7
View File
@@ -271,6 +271,7 @@ ctrl_serialized_string_from_msg_list(Arena *arena, CTRL_MsgList *msgs)
str8_serial_push_struct(scratch.arena, &msgs_srlzed, &msg->entity_id);
str8_serial_push_struct(scratch.arena, &msgs_srlzed, &msg->exit_code);
str8_serial_push_struct(scratch.arena, &msgs_srlzed, &msg->env_inherit);
str8_serial_push_struct(scratch.arena, &msgs_srlzed, &msg->debug_subprocesses);
str8_serial_push_array (scratch.arena, &msgs_srlzed, &msg->exception_code_filters[0], ArrayCount(msg->exception_code_filters));
// rjf: write path string
@@ -371,6 +372,7 @@ ctrl_msg_list_from_serialized_string(Arena *arena, String8 string)
read_off += str8_deserial_read_struct(string, read_off, &msg->entity_id);
read_off += str8_deserial_read_struct(string, read_off, &msg->exit_code);
read_off += str8_deserial_read_struct(string, read_off, &msg->env_inherit);
read_off += str8_deserial_read_struct(string, read_off, &msg->debug_subprocesses);
read_off += str8_deserial_read_array (string, read_off, &msg->exception_code_filters[0], ArrayCount(msg->exception_code_filters));
// rjf: read path string
@@ -4359,13 +4361,14 @@ ctrl_thread__launch(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
//- rjf: launch
OS_ProcessLaunchParams params = {0};
{
params.cmd_line = msg->cmd_line_string_list;
params.path = msg->path;
params.env = msg->env_string_list;
params.inherit_env = msg->env_inherit;
params.stdout_file = stdout_handle;
params.stderr_file = stderr_handle;
params.stdin_file = stdin_handle;
params.cmd_line = msg->cmd_line_string_list;
params.path = msg->path;
params.env = msg->env_string_list;
params.inherit_env = msg->env_inherit;
params.debug_subprocesses = msg->debug_subprocesses;
params.stdout_file = stdout_handle;
params.stderr_file = stderr_handle;
params.stdin_file = stdin_handle;
}
U32 id = dmn_ctrl_launch(ctrl_ctx, &params);
+1
View File
@@ -546,6 +546,7 @@ struct CTRL_Msg
U32 entity_id;
U32 exit_code;
B32 env_inherit;
B32 debug_subprocesses;
U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64];
String8 path;
String8List entry_points;
+1 -1
View File
@@ -101,7 +101,7 @@ di_init(void)
di_shared->p2u_ring_cv = os_condition_variable_alloc();
di_shared->p2u_ring_size = KB(64);
di_shared->p2u_ring_base = push_array_no_zero(arena, U8, di_shared->p2u_ring_size);
di_shared->parse_thread_count = Max(2, os_get_system_info()->logical_processor_count/2);
di_shared->parse_thread_count = Max(2, (os_get_system_info()->logical_processor_count*2)/3);
di_shared->parse_threads = push_array(arena, OS_Handle, di_shared->parse_thread_count);
for(U64 idx = 0; idx < di_shared->parse_thread_count; idx += 1)
{
+9 -1
View File
@@ -1256,7 +1256,15 @@ dmn_ctrl_launch(DMN_CtrlCtx *ctx, OS_ProcessLaunchParams *params)
String16 env16 = str16_from_8(scratch.arena, env);
//- rjf: launch
DWORD creation_flags = CREATE_UNICODE_ENVIRONMENT|DEBUG_PROCESS;
DWORD creation_flags = CREATE_UNICODE_ENVIRONMENT;
if(params->debug_subprocesses)
{
creation_flags |= DEBUG_PROCESS;
}
else
{
creation_flags |= DEBUG_ONLY_THIS_PROCESS;
}
BOOL inherit_handles = 0;
STARTUPINFOW startup_info = {sizeof(startup_info)};
if(!os_handle_match(params->stdout_file, os_handle_zero()))
+11 -9
View File
@@ -1364,7 +1364,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
//- rjf: try members
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("member"), 0)))
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("member"), 0))) ProfScope("try to map name as member")
{
U64 data_member_num = e_num_from_string(e_parse_ctx->member_map, token_string);
if(data_member_num != 0)
@@ -1375,7 +1375,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
//- rjf: try locals
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("local"), 0)))
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("local"), 0))) ProfScope("try to map name as local")
{
E_Module *module = e_parse_ctx->primary_module;
RDI_Parsed *rdi = module->rdi;
@@ -1439,7 +1439,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
//- rjf: try registers
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("reg"), 0)))
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("reg"), 0))) ProfScope("try to map name as register")
{
U64 reg_num = e_num_from_string(e_parse_ctx->regs_map, token_string);
if(reg_num != 0)
@@ -1453,7 +1453,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
//- rjf: try register aliases
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("reg"), 0)))
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("reg"), 0))) ProfScope("try to map name as register alias")
{
U64 alias_num = e_num_from_string(e_parse_ctx->reg_alias_map, token_string);
if(alias_num != 0)
@@ -1467,7 +1467,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
//- rjf: try global variables
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("global"), 0)))
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("global"), 0))) ProfScope("try to map name as global variable")
{
for(U64 module_idx = 0; module_idx < e_parse_ctx->modules_count; module_idx += 1)
{
@@ -1511,7 +1511,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
//- rjf: try thread variables
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("thread_variable"), 0)))
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("thread_variable"), 0))) ProfScope("try to map name as thread variable")
{
for(U64 module_idx = 0; module_idx < e_parse_ctx->modules_count; module_idx += 1)
{
@@ -1551,7 +1551,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
//- rjf: try procedures
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("procedure"), 0)))
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("procedure"), 0))) ProfScope("try to map name as procedure")
{
for(U64 module_idx = 0; module_idx < e_parse_ctx->modules_count; module_idx += 1)
{
@@ -1593,7 +1593,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
//- rjf: try types
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("type"), 0)))
if(mapped_identifier == 0 && (resolution_qualifier.size == 0 || str8_match(resolution_qualifier, str8_lit("type"), 0))) ProfScope("try to map name as type")
{
type_key = e_leaf_type_from_name(token_string);
if(!e_type_key_match(e_type_key_zero(), type_key))
@@ -1622,7 +1622,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
//- rjf: attach on map
if(mapped_identifier != 0)
if(mapped_identifier != 0) ProfScope("attach on map")
{
it += 1;
@@ -2113,7 +2113,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
internal E_Parse
e_parse_expr_from_text_tokens(Arena *arena, String8 text, E_TokenArray *tokens)
{
ProfBegin("parse '%.*s'", str8_varg(text));
E_Parse parse = e_parse_expr_from_text_tokens__prec(arena, text, tokens, e_max_precedence);
ProfEnd();
return parse;
}
+2
View File
@@ -484,6 +484,7 @@ rdi_parsed_from_name_map(RDI_Parsed *rdi, RDI_NameMap *mapptr, RDI_ParsedNameMap
RDI_PROC RDI_NameMapNode*
rdi_name_map_lookup(RDI_Parsed *p, RDI_ParsedNameMap *map, RDI_U8 *str, RDI_U64 len)
{
ProfBeginFunction();
RDI_NameMapNode *result = 0;
if(map->bucket_count > 0)
{
@@ -520,6 +521,7 @@ rdi_name_map_lookup(RDI_Parsed *p, RDI_ParsedNameMap *map, RDI_U8 *str, RDI_U64
}
}
ProfEnd();
return result;
}
+1
View File
@@ -121,6 +121,7 @@ struct OS_ProcessLaunchParams
String8 path;
String8List env;
B32 inherit_env;
B32 debug_subprocesses;
B32 consoleless;
OS_Handle stdout_file;
OS_Handle stderr_file;
+6 -6
View File
@@ -8800,10 +8800,10 @@ EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(auto_view_rules){ return rd_ev
//- rjf: control entity groups
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(machines) { return rd_ev_view_rule_expr_expand_info__meta_ctrl_entities(arena, view, str8_zero(), expr, params, CTRL_EntityKind_Machine); }
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(machines) { return rd_ev_view_rule_expr_expand_range_info__meta_ctrl_entities(arena, view, str8_zero(), expr, params, idx_range, user_data, CTRL_EntityKind_Machine); }
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(machines) { return rd_ev_view_rule_expr_id_from_num__meta_ctrl_entities(num, user_data, CTRL_EntityKind_Machine); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(machines) { return rd_ev_view_rule_expr_num_from_id__meta_ctrl_entities(id, user_data, CTRL_EntityKind_Machine); }
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(machines) { return rd_ev_view_rule_expr_expand_info__meta_ctrl_entities(arena, view, str8_zero(), expr, params, CTRL_EntityKind_Machine); }
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(machines) { return rd_ev_view_rule_expr_expand_range_info__meta_ctrl_entities(arena, view, str8_zero(), expr, params, idx_range, user_data, CTRL_EntityKind_Machine); }
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(machines) { return rd_ev_view_rule_expr_id_from_num__meta_ctrl_entities(num, user_data, CTRL_EntityKind_Machine); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(machines) { return rd_ev_view_rule_expr_num_from_id__meta_ctrl_entities(id, user_data, CTRL_EntityKind_Machine); }
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(processes) { return rd_ev_view_rule_expr_expand_info__meta_ctrl_entities(arena, view, filter, expr, params, CTRL_EntityKind_Process); }
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(processes) { return rd_ev_view_rule_expr_expand_range_info__meta_ctrl_entities(arena, view, filter, expr, params, idx_range, user_data, CTRL_EntityKind_Process); }
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(processes) { return rd_ev_view_rule_expr_id_from_num__meta_ctrl_entities(num, user_data, CTRL_EntityKind_Process); }
@@ -9171,7 +9171,7 @@ rd_ev_view_rule_expr_expand_range_info__meta_entities(Arena *arena, EV_View *vie
}
if(!rd_entity_is_nil(entity))
{
String8 entity_expr_string = (kind == RD_EntityKind_Watch ? entity->string : push_str8f(arena, "$%I64u", entity->id));
String8 entity_expr_string = (kind == RD_EntityKind_Watch ? entity->string : push_str8f(arena, "entity:$%I64u", entity->id));
if(kind == RD_EntityKind_Watch)
{
result.row_strings[row_expr_idx] = entity_expr_string;
@@ -9280,7 +9280,7 @@ rd_ev_view_rule_expr_expand_range_info__meta_ctrl_entities(Arena *arena, EV_View
for EachIndex(row_expr_idx, result.row_exprs_count)
{
CTRL_Entity *entity = accel->entities.v[idx_range.min + row_expr_idx];
String8 entity_expr_string = push_str8f(arena, "$_%I64x_%I64x", entity->handle.machine_id, entity->handle.dmn_handle.u64[0]);
String8 entity_expr_string = push_str8f(arena, "ctrl_entity:$_%I64x_%I64x", entity->handle.machine_id, entity->handle.dmn_handle.u64[0]);
result.row_exprs[row_expr_idx] = e_parse_expr_from_text(arena, entity_expr_string);
result.row_members[row_expr_idx] = &e_member_nil;
}