mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-09-24 02:00:05 +00:00
eliminate os_core, move into base; eliminate regs, move into arch abstraction layer, define x64 regs in x64 layer; move win32 backend for os core (now base) functionality to top-level win32 layer
This commit is contained in:
+69
-79
@@ -784,7 +784,8 @@ rd_eval_space_read(E_Space space, void *out, Rng1U64 range)
|
||||
}
|
||||
if(regs_block != 0)
|
||||
{
|
||||
U64 regs_size = regs_block_size_from_arch(e_interpret_ctx->reg_arch);
|
||||
ARCH_Info *arch_info = arch_info_from_arch(entity->arch);
|
||||
U64 regs_size = arch_info->reg_block_size;
|
||||
Rng1U64 legal_range = r1u64(0, regs_size);
|
||||
Rng1U64 read_range = intersect_1u64(legal_range, range);
|
||||
U64 read_size = dim_1u64(read_range);
|
||||
@@ -1013,7 +1014,8 @@ rd_eval_space_write(E_Space space, void *in, Rng1U64 range)
|
||||
case D_EntityKind_Thread:
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
U64 regs_size = regs_block_size_from_arch(entity->arch);
|
||||
ARCH_Info *arch_info = arch_info_from_arch(entity->arch);
|
||||
U64 regs_size = arch_info->reg_block_size;
|
||||
Rng1U64 legal_range = r1u64(0, regs_size);
|
||||
Rng1U64 write_range = intersect_1u64(legal_range, range);
|
||||
U64 write_size = dim_1u64(write_range);
|
||||
@@ -1186,7 +1188,7 @@ rd_whole_range_from_eval_space(E_Space space)
|
||||
{
|
||||
U64 file_path_string_id = space.u64_0;
|
||||
String8 file_path = e_string_from_id(file_path_string_id);
|
||||
FileProperties props = os_properties_from_file_path(file_path);
|
||||
FileProperties props = properties_from_file_path(file_path);
|
||||
result = r1u64(0, props.size);
|
||||
}break;
|
||||
case D_EvalSpaceKind_Entity:
|
||||
@@ -4935,7 +4937,7 @@ rd_window_state_from_cfg(CFG_Node *cfg)
|
||||
B32 has_pos = 0;
|
||||
Vec2F32 pos = {0};
|
||||
Vec2F32 size = {0};
|
||||
OS_Handle preferred_monitor = {0};
|
||||
OS_Monitor preferred_monitor = {0};
|
||||
{
|
||||
CFG_Node *pos_cfg = cfg_node_child_from_string(window_cfg, str8_lit("pos"));
|
||||
has_pos = (pos_cfg != &cfg_nil_node);
|
||||
@@ -4945,7 +4947,7 @@ rd_window_state_from_cfg(CFG_Node *cfg)
|
||||
pos.y = (F32)f64_from_str8(pos_cfg->first->next->string);
|
||||
size.x = (F32)f64_from_str8(size_cfg->first->string);
|
||||
size.y = (F32)f64_from_str8(size_cfg->first->next->string);
|
||||
OS_HandleArray monitors = os_push_monitors_array(scratch.arena);
|
||||
OS_MonitorArray monitors = os_push_monitors_array(scratch.arena);
|
||||
for EachIndex(idx, monitors.count)
|
||||
{
|
||||
String8 monitor_name = os_name_from_monitor(scratch.arena, monitors.v[idx]);
|
||||
@@ -4983,8 +4985,8 @@ rd_window_state_from_cfg(CFG_Node *cfg)
|
||||
ws->hover_eval_arena = arena_alloc();
|
||||
ws->autocomp_arena = arena_alloc();
|
||||
ws->last_dpi = os_dpi_from_window(ws->os);
|
||||
OS_Handle zero_monitor = {0};
|
||||
if(!os_handle_match(zero_monitor, preferred_monitor))
|
||||
OS_Monitor zero_monitor = {0};
|
||||
if(!os_monitor_match(zero_monitor, preferred_monitor))
|
||||
{
|
||||
os_window_set_monitor(ws->os, preferred_monitor);
|
||||
}
|
||||
@@ -5019,7 +5021,7 @@ rd_window_state_from_cfg(CFG_Node *cfg)
|
||||
}
|
||||
|
||||
internal RD_WindowState *
|
||||
rd_window_state_from_os_handle(OS_Handle os)
|
||||
rd_window_state_from_os_handle(OS_Window os)
|
||||
{
|
||||
RD_WindowState *ws = &rd_nil_window_state;
|
||||
{
|
||||
@@ -5027,7 +5029,7 @@ rd_window_state_from_os_handle(OS_Handle os)
|
||||
w != &rd_nil_window_state;
|
||||
w = w->order_next)
|
||||
{
|
||||
if(os_handle_match(w->os, os))
|
||||
if(os_window_match(w->os, os))
|
||||
{
|
||||
ws = w;
|
||||
break;
|
||||
@@ -5343,7 +5345,7 @@ rd_window_frame(void)
|
||||
//- rjf: commit monitor
|
||||
if(!is_minimized)
|
||||
{
|
||||
OS_Handle monitor = os_monitor_from_window(ws->os);
|
||||
OS_Monitor monitor = os_monitor_from_window(ws->os);
|
||||
String8 monitor_name = os_name_from_monitor(scratch.arena, monitor);
|
||||
CFG_Node *monitor_root = cfg_node_child_from_string_or_alloc(rd_state->cfg, window, str8_lit("monitor"));
|
||||
if(!str8_match(monitor_root->first->string, monitor_name, 0))
|
||||
@@ -5478,7 +5480,7 @@ rd_window_frame(void)
|
||||
case RD_RegSlot_FilePath:
|
||||
UI_Tooltip
|
||||
{
|
||||
FileProperties props = os_properties_from_file_path(regs->file_path);
|
||||
FileProperties props = properties_from_file_path(regs->file_path);
|
||||
ui_set_next_pref_width(ui_children_sum(1));
|
||||
UI_Row
|
||||
{
|
||||
@@ -9434,11 +9436,11 @@ rd_theme_tree_from_name(Arena *arena, Access *access, String8 theme_name)
|
||||
}
|
||||
if(theme_tree == &md_nil_node)
|
||||
{
|
||||
String8 path = push_str8f(scratch.arena, "%S/raddbg/themes/%S", os_get_process_info()->user_program_data_path, theme_name);
|
||||
U64 endt_us = os_now_microseconds()+100;
|
||||
String8 path = str8f(scratch.arena, "%S/raddbg/themes/%S", get_process_info()->user_program_data_path, theme_name);
|
||||
U64 endt_us = now_time_us()+100;
|
||||
if(rd_state->frame_index <= 5)
|
||||
{
|
||||
endt_us = os_now_microseconds()+50000;
|
||||
endt_us = now_time_us()+50000;
|
||||
}
|
||||
U128 hash = fs_hash_from_path_range(path, r1u64(0, max_U64), endt_us);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
@@ -9515,17 +9517,6 @@ rd_code_color_slot_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: try to map as register alias
|
||||
if(!mapped)
|
||||
{
|
||||
U64 alias_num = e_num_from_string(e_ir_ctx->reg_alias_map, string);
|
||||
if(alias_num != 0)
|
||||
{
|
||||
mapped = 1;
|
||||
color = RD_CodeColorSlot_CodeRegister;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: try to map as macro
|
||||
if((!mapped || is_called) && allow_macros)
|
||||
{
|
||||
@@ -10100,11 +10091,11 @@ rd_init(CmdLine *cmdln)
|
||||
log_select(rd_state->log);
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
String8 user_program_data_path = os_get_process_info()->user_program_data_path;
|
||||
String8 user_program_data_path = get_process_info()->user_program_data_path;
|
||||
String8 user_data_folder = push_str8f(scratch.arena, "%S/raddbg/logs", user_program_data_path);
|
||||
rd_state->log_path = push_str8f(rd_state->arena, "%S/ui_thread.raddbg_log", user_data_folder);
|
||||
os_make_directory(user_data_folder);
|
||||
os_write_data_to_file_path(rd_state->log_path, str8_zero());
|
||||
make_directory(user_data_folder);
|
||||
write_data_to_file_path(rd_state->log_path, str8_zero());
|
||||
scratch_end(scratch);
|
||||
}
|
||||
rd_state->num_frames_requested = 2;
|
||||
@@ -10214,17 +10205,17 @@ rd_init(CmdLine *cmdln)
|
||||
B32 is_cfg = 0;
|
||||
if(!is_flag && !after_first_non_flag)
|
||||
{
|
||||
OS_Handle file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead, arg);
|
||||
File file = file_open(AccessFlag_Read|AccessFlag_ShareRead, arg);
|
||||
U8 raddbg_cfg_magic[] = "// raddbg ";
|
||||
U8 file_magic_maybe[ArrayCount(raddbg_cfg_magic)] = {0};
|
||||
os_file_read(file, r1u64(0, 10), file_magic_maybe);
|
||||
file_read(file, r1u64(0, 10), file_magic_maybe);
|
||||
if(MemoryMatchArray(raddbg_cfg_magic, file_magic_maybe))
|
||||
{
|
||||
is_cfg = 1;
|
||||
U8 header_suffix_buffer[256] = {0};
|
||||
String8 header_suffix = {0};
|
||||
header_suffix.str = header_suffix_buffer;
|
||||
header_suffix.size = os_file_read(file, r1u64(10, 10+256), header_suffix_buffer);
|
||||
header_suffix.size = file_read(file, r1u64(10, 10+256), header_suffix_buffer);
|
||||
String8 header_type_suffix = str8_skip(header_suffix, str8_find_needle(header_suffix, 0, str8_lit(" "), 0)+1);
|
||||
if(str8_match(header_type_suffix, str8_lit("user"), StringMatchFlag_RightSideSloppy))
|
||||
{
|
||||
@@ -10235,7 +10226,7 @@ rd_init(CmdLine *cmdln)
|
||||
implicit_project_arg = arg;
|
||||
}
|
||||
}
|
||||
os_file_close(file);
|
||||
file_close(file);
|
||||
}
|
||||
if(!is_flag)
|
||||
{
|
||||
@@ -10261,7 +10252,7 @@ rd_init(CmdLine *cmdln)
|
||||
PathStyle style = path_style_from_str8(exe_name);
|
||||
if(style == PathStyle_Relative)
|
||||
{
|
||||
String8 current_path = os_get_current_path(scratch.arena);
|
||||
String8 current_path = get_current_path(scratch.arena);
|
||||
exe_name = push_str8f(scratch.arena, "%S/%S", current_path, exe_name);
|
||||
exe_name = path_normalized_from_string(scratch.arena, exe_name);
|
||||
}
|
||||
@@ -10270,7 +10261,7 @@ rd_init(CmdLine *cmdln)
|
||||
|
||||
// rjf: get current directory, use as working directory
|
||||
{
|
||||
working_directory_string = path_normalized_from_string(scratch.arena, os_get_current_path(scratch.arena));
|
||||
working_directory_string = path_normalized_from_string(scratch.arena, get_current_path(scratch.arena));
|
||||
}
|
||||
|
||||
// rjf: unpack arguments
|
||||
@@ -10314,17 +10305,17 @@ rd_init(CmdLine *cmdln)
|
||||
{
|
||||
if(user_path.size != 0)
|
||||
{
|
||||
user_path = path_absolute_dst_from_relative_dst_src(scratch.arena, user_path, os_get_process_info()->initial_path);
|
||||
user_path = path_absolute_dst_from_relative_dst_src(scratch.arena, user_path, get_process_info()->initial_path);
|
||||
}
|
||||
if(project_path.size != 0)
|
||||
{
|
||||
project_path = path_absolute_dst_from_relative_dst_src(scratch.arena, project_path, os_get_process_info()->initial_path);
|
||||
project_path = path_absolute_dst_from_relative_dst_src(scratch.arena, project_path, get_process_info()->initial_path);
|
||||
}
|
||||
}
|
||||
{
|
||||
String8 user_program_data_path = os_get_process_info()->user_program_data_path;
|
||||
String8 user_program_data_path = get_process_info()->user_program_data_path;
|
||||
String8 user_data_folder = push_str8f(scratch.arena, "%S/raddbg", user_program_data_path);
|
||||
os_make_directory(user_data_folder);
|
||||
make_directory(user_data_folder);
|
||||
if(user_path.size == 0)
|
||||
{
|
||||
user_path = implicit_user_arg;
|
||||
@@ -10332,7 +10323,7 @@ rd_init(CmdLine *cmdln)
|
||||
if(user_path.size == 0)
|
||||
{
|
||||
String8 last_user_path = push_str8f(scratch.arena, "%S/last_user", user_data_folder);
|
||||
user_path = os_data_from_file_path(scratch.arena, last_user_path);
|
||||
user_path = data_from_file_path(scratch.arena, last_user_path);
|
||||
}
|
||||
if(user_path.size == 0)
|
||||
{
|
||||
@@ -10837,7 +10828,7 @@ rd_frame(void)
|
||||
if(frame_time_history_avg_us < frame_time_target_cap_us)
|
||||
{
|
||||
U64 spare_time = (frame_time_target_cap_us - frame_time_history_avg_us) + 4000;
|
||||
rd_state->frame_eval_memread_endt_us = os_now_microseconds() + spare_time;
|
||||
rd_state->frame_eval_memread_endt_us = now_time_us() + spare_time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10849,19 +10840,19 @@ rd_frame(void)
|
||||
//////////////////////////////
|
||||
//- rjf: begin measuring actual per-frame work
|
||||
//
|
||||
U64 begin_time_us = os_now_microseconds();
|
||||
U64 begin_time_us = now_time_us();
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: bind change
|
||||
//
|
||||
if(!rd_state->popup_active && rd_state->bind_change_active)
|
||||
{
|
||||
if(os_key_press(&events, os_handle_zero(), 0, OS_Key_Esc))
|
||||
if(os_key_press(&events, os_window_zero(), 0, OS_Key_Esc))
|
||||
{
|
||||
rd_request_frame();
|
||||
rd_state->bind_change_active = 0;
|
||||
}
|
||||
if(os_key_press(&events, os_handle_zero(), 0, OS_Key_Delete))
|
||||
if(os_key_press(&events, os_window_zero(), 0, OS_Key_Delete))
|
||||
{
|
||||
rd_request_frame();
|
||||
cfg_node_release(rd_state->cfg, cfg_node_from_id(rd_state->bind_change_binding_id));
|
||||
@@ -12042,7 +12033,6 @@ rd_frame(void)
|
||||
{
|
||||
E_IRCtx *ctx = ir_ctx;
|
||||
ctx->regs_map = d_string2reg_from_arch(eval_base_ctx->primary_module->arch);
|
||||
ctx->reg_alias_map = d_string2alias_from_arch(eval_base_ctx->primary_module->arch);
|
||||
ctx->locals_map = d_query_cached_locals_map_from_dbgi_key_voff(eval_base_ctx->primary_dbg_info->dbgi_key, rip_voff);
|
||||
ctx->member_map = d_query_cached_member_map_from_dbgi_key_voff(eval_base_ctx->primary_dbg_info->dbgi_key, rip_voff);
|
||||
ctx->macro_map = macro_map;
|
||||
@@ -12286,7 +12276,7 @@ rd_frame(void)
|
||||
String8 current_path_string = current_path->first->string;
|
||||
if(current_path_string.size == 0)
|
||||
{
|
||||
current_path_string = path_normalized_from_string(scratch.arena, os_get_current_path(scratch.arena));
|
||||
current_path_string = path_normalized_from_string(scratch.arena, get_current_path(scratch.arena));
|
||||
}
|
||||
String8 file_path = os_graphical_pick_file(scratch.arena, current_path_string);
|
||||
file_path = path_normalized_from_string(scratch.arena, file_path);
|
||||
@@ -12506,8 +12496,8 @@ rd_frame(void)
|
||||
|
||||
//- rjf: load the new file's data
|
||||
String8 file_path = rd_regs()->file_path;
|
||||
String8 file_data = os_data_from_file_path(scratch.arena, file_path);
|
||||
FileProperties file_props = os_properties_from_file_path(file_path);
|
||||
String8 file_data = data_from_file_path(scratch.arena, file_path);
|
||||
FileProperties file_props = properties_from_file_path(file_path);
|
||||
|
||||
//- rjf: determine if the file is good
|
||||
B32 file_is_okay = 0;
|
||||
@@ -12593,7 +12583,7 @@ rd_frame(void)
|
||||
CFG_NodePtrList all_user_windows = cfg_node_child_list_from_string(scratch.arena, file_root, str8_lit("window"));
|
||||
if(all_user_windows.count == 0)
|
||||
{
|
||||
OS_Handle monitor = os_primary_monitor();
|
||||
OS_Monitor monitor = os_primary_monitor();
|
||||
String8 monitor_name = os_name_from_monitor(scratch.arena, monitor);
|
||||
Vec2F32 monitor_dim = os_dim_from_monitor(monitor);
|
||||
F32 monitor_dpi = os_dpi_from_monitor(monitor);
|
||||
@@ -12676,9 +12666,9 @@ rd_frame(void)
|
||||
String8 project_path = rd_path_from_cfg(recent_project);
|
||||
if(project_path.size == 0)
|
||||
{
|
||||
String8 user_program_data_path = os_get_process_info()->user_program_data_path;
|
||||
String8 user_program_data_path = get_process_info()->user_program_data_path;
|
||||
String8 user_data_folder = push_str8f(scratch.arena, "%S/%S", user_program_data_path, str8_lit("raddbg"));
|
||||
os_make_directory(user_data_folder);
|
||||
make_directory(user_data_folder);
|
||||
project_path = push_str8f(scratch.arena, "%S/default.raddbg_project", user_data_folder);
|
||||
}
|
||||
rd_cmd(RD_CmdKind_OpenProject, .file_path = project_path);
|
||||
@@ -12688,7 +12678,7 @@ rd_frame(void)
|
||||
case RD_CmdKind_NewProject:
|
||||
{
|
||||
String8 new_path = rd_regs()->file_path;
|
||||
B32 file_will_be_overwritten = (os_properties_from_file_path(new_path).created != 0);
|
||||
B32 file_will_be_overwritten = (properties_from_file_path(new_path).created != 0);
|
||||
UI_Key key = ui_key_from_string(ui_key_zero(), str8_lit("new_config_overwrite_confirm"));
|
||||
if(file_will_be_overwritten && !rd_regs()->force_confirm && !ui_key_match(rd_state->popup_key, key))
|
||||
{
|
||||
@@ -12707,12 +12697,12 @@ rd_frame(void)
|
||||
default:{}break;
|
||||
case RD_CmdKind_NewUser:
|
||||
{
|
||||
os_delete_file_at_path(new_path);
|
||||
delete_file_at_path(new_path);
|
||||
rd_cmd(RD_CmdKind_OpenUser, .file_path = new_path);
|
||||
}break;
|
||||
case RD_CmdKind_NewProject:
|
||||
{
|
||||
os_delete_file_at_path(new_path);
|
||||
delete_file_at_path(new_path);
|
||||
rd_cmd(RD_CmdKind_OpenProject, .file_path = new_path);
|
||||
}break;
|
||||
}
|
||||
@@ -12721,7 +12711,7 @@ rd_frame(void)
|
||||
case RD_CmdKind_SaveProject:
|
||||
{
|
||||
String8 new_path = rd_regs()->file_path;
|
||||
B32 file_will_be_overwritten = (os_properties_from_file_path(new_path).created != 0);
|
||||
B32 file_will_be_overwritten = (properties_from_file_path(new_path).created != 0);
|
||||
UI_Key key = ui_key_from_string(ui_key_zero(), str8_lit("save_config_overwrite_confirm"));
|
||||
if(file_will_be_overwritten && !rd_regs()->force_confirm && !ui_key_match(rd_state->popup_key, key))
|
||||
{
|
||||
@@ -12785,8 +12775,8 @@ rd_frame(void)
|
||||
case RD_CmdKind_RecordUserAsLastOpened:
|
||||
{
|
||||
String8 file_path = rd_regs()->file_path;
|
||||
String8 last_user_path = push_str8f(scratch.arena, "%S/raddbg/last_user", os_get_process_info()->user_program_data_path);
|
||||
os_write_data_to_file_path(last_user_path, file_path);
|
||||
String8 last_user_path = str8f(scratch.arena, "%S/raddbg/last_user", get_process_info()->user_program_data_path);
|
||||
write_data_to_file_path(last_user_path, file_path);
|
||||
}break;
|
||||
|
||||
//- rjf: writing config changes
|
||||
@@ -12794,7 +12784,7 @@ rd_frame(void)
|
||||
case RD_CmdKind_WriteProjectData: dst_path = rd_state->project_path; bucket_name = str8_lit("project"); goto write;
|
||||
write:;
|
||||
{
|
||||
B32 dst_exists = (os_properties_from_file_path(dst_path).created != 0);
|
||||
B32 dst_exists = (properties_from_file_path(dst_path).created != 0);
|
||||
String8 temp_path = push_str8f(scratch.arena, "%S.temp", dst_path);
|
||||
String8 overwritten_path = push_str8f(scratch.arena, "%S.old", dst_path);
|
||||
CFG_Node *tree_root = cfg_node_child_from_string(cfg_node_root(), bucket_name);
|
||||
@@ -12805,17 +12795,17 @@ rd_frame(void)
|
||||
str8_list_push(scratch.arena, &strings, cfg_string_from_tree(scratch.arena, rd_state->cfg_schema_table, str8_chop_last_slash(dst_path), child));
|
||||
}
|
||||
String8 data = str8_list_join(scratch.arena, &strings, 0);
|
||||
B32 temp_write_good = os_write_data_to_file_path(temp_path, data);
|
||||
B32 old_del_good = (temp_write_good && os_delete_file_at_path(overwritten_path));
|
||||
B32 old_move_good = (temp_write_good && (!dst_exists || os_move_file_path(overwritten_path, dst_path)));
|
||||
B32 new_move_good = (old_move_good && os_move_file_path(dst_path, temp_path));
|
||||
B32 temp_write_good = write_data_to_file_path(temp_path, data);
|
||||
B32 old_del_good = (temp_write_good && delete_file_at_path(overwritten_path));
|
||||
B32 old_move_good = (temp_write_good && (!dst_exists || move_file_path(overwritten_path, dst_path)));
|
||||
B32 new_move_good = (old_move_good && move_file_path(dst_path, temp_path));
|
||||
if(new_move_good && dst_exists)
|
||||
{
|
||||
os_delete_file_at_path(overwritten_path);
|
||||
delete_file_at_path(overwritten_path);
|
||||
}
|
||||
else if(!new_move_good && old_move_good && dst_exists)
|
||||
{
|
||||
os_move_file_path(dst_path, overwritten_path);
|
||||
move_file_path(dst_path, overwritten_path);
|
||||
}
|
||||
}break;
|
||||
|
||||
@@ -13639,8 +13629,8 @@ rd_frame(void)
|
||||
//- rjf: files
|
||||
case RD_CmdKind_Open:
|
||||
{
|
||||
String8 path = path_absolute_dst_from_relative_dst_src(scratch.arena, rd_regs()->file_path, os_get_current_path(scratch.arena));
|
||||
FileProperties props = os_properties_from_file_path(path);
|
||||
String8 path = path_absolute_dst_from_relative_dst_src(scratch.arena, rd_regs()->file_path, get_current_path(scratch.arena));
|
||||
FileProperties props = properties_from_file_path(path);
|
||||
if(props.created != 0)
|
||||
{
|
||||
rd_cmd(RD_CmdKind_RecordFileInProject);
|
||||
@@ -13686,9 +13676,9 @@ rd_frame(void)
|
||||
{
|
||||
if(!str8_match(partner_ext_candidates[idx], file_ext, StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
String8 candidate = push_str8f(scratch.arena, "%S.%S", file_name, partner_ext_candidates[idx]);
|
||||
String8 candidate_path = push_str8f(scratch.arena, "%S/%S", file_folder, candidate);
|
||||
FileProperties candidate_props = os_properties_from_file_path(candidate_path);
|
||||
String8 candidate = str8f(scratch.arena, "%S.%S", file_name, partner_ext_candidates[idx]);
|
||||
String8 candidate_path = str8f(scratch.arena, "%S/%S", file_folder, candidate);
|
||||
FileProperties candidate_props = properties_from_file_path(candidate_path);
|
||||
if(candidate_props.modified != 0)
|
||||
{
|
||||
rd_cmd(RD_CmdKind_FindCodeLocation, .file_path = candidate_path, .cursor = txt_pt(0, 0), .vaddr = 0, .prefer_new_tab = 1);
|
||||
@@ -14173,7 +14163,7 @@ rd_frame(void)
|
||||
str8_list_push(temp.arena, &try_path_parts, try_n->string);
|
||||
}
|
||||
String8 try_path = str8_list_join(temp.arena, &try_path_parts, &(StringJoin){.sep = str8_lit("/")});
|
||||
FileProperties try_props = os_properties_from_file_path(try_path);
|
||||
FileProperties try_props = properties_from_file_path(try_path);
|
||||
if(try_props.modified != 0)
|
||||
{
|
||||
name_resolved = 1;
|
||||
@@ -14934,7 +14924,7 @@ rd_frame(void)
|
||||
String8 current_path_string = current_path->first->string;
|
||||
if(current_path_string.size == 0)
|
||||
{
|
||||
current_path_string = path_normalized_from_string(scratch.arena, os_get_current_path(scratch.arena));
|
||||
current_path_string = path_normalized_from_string(scratch.arena, get_current_path(scratch.arena));
|
||||
}
|
||||
initial_input = current_path_string;
|
||||
initial_input = push_str8f(scratch.arena, "%S/", initial_input);
|
||||
@@ -15373,8 +15363,8 @@ rd_frame(void)
|
||||
String8 name = rd_regs()->string;
|
||||
if(name.size != 0)
|
||||
{
|
||||
String8 themes_folder = push_str8f(scratch.arena, "%S/raddbg/themes", os_get_process_info()->user_program_data_path);
|
||||
if(os_make_directory(themes_folder))
|
||||
String8 themes_folder = str8f(scratch.arena, "%S/raddbg/themes", get_process_info()->user_program_data_path);
|
||||
if(make_directory(themes_folder))
|
||||
{
|
||||
String8 dst_path = push_str8f(scratch.arena, "%S/%S", themes_folder, name);
|
||||
CFG_Node *parent = cfg_node_from_id(rd_regs()->cfg);
|
||||
@@ -15385,7 +15375,7 @@ rd_frame(void)
|
||||
str8_list_push(scratch.arena, &strings, cfg_string_from_tree(scratch.arena, rd_state->cfg_schema_table, str8_chop_last_slash(dst_path), n->v));
|
||||
}
|
||||
String8 data = str8_list_join(scratch.arena, &strings, 0);
|
||||
if(os_write_data_to_file_path(dst_path, data))
|
||||
if(write_data_to_file_path(dst_path, data))
|
||||
{
|
||||
if(kind == RD_CmdKind_SaveAndSetTheme)
|
||||
{
|
||||
@@ -15645,7 +15635,7 @@ rd_frame(void)
|
||||
{
|
||||
Access *access = access_open();
|
||||
D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
|
||||
D_CallStack call_stack = d_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
|
||||
D_CallStack call_stack = d_call_stack_from_thread(access, thread->handle, 1, now_time_us()+10000);
|
||||
D_CallStackFrame *frame = d_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth);
|
||||
if(frame == 0)
|
||||
{
|
||||
@@ -15664,7 +15654,7 @@ rd_frame(void)
|
||||
{
|
||||
Access *access = access_open();
|
||||
D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
|
||||
D_CallStack call_stack = d_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
|
||||
D_CallStack call_stack = d_call_stack_from_thread(access, thread->handle, 1, now_time_us()+10000);
|
||||
D_CallStackFrame *current_frame = d_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth);
|
||||
D_CallStackFrame *next_frame = current_frame;
|
||||
if(current_frame != 0) switch(kind)
|
||||
@@ -16397,7 +16387,7 @@ rd_frame(void)
|
||||
D_Entity *module = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, evt->entity);
|
||||
D_Entity *debug_info_path = d_entity_child_from_kind(module, D_EntityKind_DebugInfoPath);
|
||||
String8 new_path = debug_info_path->string;
|
||||
if(new_path.size != 0 && os_file_path_exists(new_path))
|
||||
if(new_path.size != 0 && file_path_exists(new_path))
|
||||
{
|
||||
CFG_NodePtrList dbg_infos = cfg_node_top_level_list_from_string(scratch.arena, str8_lit("debug_info"));
|
||||
B32 path_found = 0;
|
||||
@@ -16749,7 +16739,7 @@ rd_frame(void)
|
||||
//
|
||||
if(DEV_simulate_lag)
|
||||
{
|
||||
os_sleep_milliseconds(300);
|
||||
sleep_ms(300);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
@@ -16817,7 +16807,7 @@ rd_frame(void)
|
||||
//////////////////////////////
|
||||
//- rjf: determine frame time, record into history
|
||||
//
|
||||
U64 end_time_us = os_now_microseconds();
|
||||
U64 end_time_us = now_time_us();
|
||||
U64 frame_time_us = end_time_us-begin_time_us;
|
||||
rd_state->frame_time_us_history[rd_state->frame_index%ArrayCount(rd_state->frame_time_us_history)] = frame_time_us;
|
||||
|
||||
@@ -16855,7 +16845,7 @@ rd_frame(void)
|
||||
ProfScope("collect logs")
|
||||
{
|
||||
LogScopeResult log = log_scope_end(scratch.arena);
|
||||
os_append_data_to_file_path(rd_state->log_path, log.strings[LogMsgKind_Info]);
|
||||
append_data_to_file_path(rd_state->log_path, log.strings[LogMsgKind_Info]);
|
||||
if(log.strings[LogMsgKind_UserError].size != 0)
|
||||
{
|
||||
String8 error_log = log.strings[LogMsgKind_UserError];
|
||||
|
||||
@@ -283,7 +283,7 @@ struct RD_WindowState
|
||||
|
||||
// rjf: top-level info & handles
|
||||
Arena *arena;
|
||||
OS_Handle os;
|
||||
OS_Window os;
|
||||
R_Handle r;
|
||||
UI_State *ui;
|
||||
F32 last_dpi;
|
||||
@@ -543,7 +543,7 @@ struct RD_State
|
||||
String8 bind_change_cmd_name;
|
||||
|
||||
// rjf: pre-stop focused window
|
||||
OS_Handle prestop_focused_window;
|
||||
OS_ExternalWindow prestop_focused_window;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -730,7 +730,7 @@ internal void rd_store_view_paramf(String8 key, char *fmt, ...);
|
||||
internal String8 rd_push_window_title(Arena *arena);
|
||||
internal CFG_Node *rd_window_from_cfg(CFG_Node *cfg);
|
||||
internal RD_WindowState *rd_window_state_from_cfg(CFG_Node *cfg);
|
||||
internal RD_WindowState *rd_window_state_from_os_handle(OS_Handle os);
|
||||
internal RD_WindowState *rd_window_state_from_os_handle(OS_Window os);
|
||||
internal void rd_window_frame(void);
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -122,18 +122,18 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(themes)
|
||||
|
||||
//- rjf: gather theme files
|
||||
{
|
||||
String8 theme_folder = push_str8f(scratch.arena, "%S/raddbg/themes", os_get_process_info()->user_program_data_path);
|
||||
OS_FileIter *it = os_file_iter_begin(scratch.arena, theme_folder, OS_FileIterFlag_SkipFolders);
|
||||
for(OS_FileInfo info = {0}; os_file_iter_next(scratch.arena, it, &info);)
|
||||
String8 theme_folder = push_str8f(scratch.arena, "%S/raddbg/themes", get_process_info()->user_program_data_path);
|
||||
FileIter *it = file_iter_begin(scratch.arena, theme_folder, FileIterFlag_SkipFolders);
|
||||
for(FileInfo info = {0}; file_iter_next(scratch.arena, it, &info);)
|
||||
{
|
||||
String8 name = info.name;
|
||||
FuzzyMatchRangeList name_matches = fuzzy_match_find(scratch.arena, filter, name);
|
||||
if(name_matches.count == name_matches.needle_part_count)
|
||||
{
|
||||
str8_list_push(scratch.arena, &names, push_str8_copy(arena, name));
|
||||
str8_list_push(scratch.arena, &names, str8_copy(arena, name));
|
||||
}
|
||||
}
|
||||
os_file_iter_end(it);
|
||||
file_iter_end(it);
|
||||
}
|
||||
|
||||
//- rjf: flatten & build accelerator
|
||||
@@ -269,11 +269,16 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(registers)
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
||||
Arch arch = thread->arch;
|
||||
U64 reg_count = regs_reg_code_count_from_arch(arch);
|
||||
String8 *reg_strings = regs_reg_code_string_table_from_arch(arch);
|
||||
ARCH_Info *arch_info = arch_info_from_arch(arch);
|
||||
U64 reg_count = arch_info->reg_code_count;
|
||||
String8 *reg_strings = arch_info->reg_code_name_table;
|
||||
String8List exprs_list = {0};
|
||||
for(U64 idx = 1; idx < reg_count; idx += 1)
|
||||
{
|
||||
if(arch_info->reg_code_base_table[idx] != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
FuzzyMatchRangeList matches = fuzzy_match_find(scratch.arena, filter, reg_strings[idx]);
|
||||
if(matches.count == matches.needle_part_count)
|
||||
{
|
||||
@@ -1041,8 +1046,9 @@ E_TYPE_ACCESS_FUNCTION_DEF(call_stack)
|
||||
if(0 <= rhs_value.u64 && rhs_value.u64 < call_stack->frames_count)
|
||||
{
|
||||
D_Entity *process = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, accel->process);
|
||||
ARCH_Info *arch_info = arch_info_from_arch(accel->arch);
|
||||
D_CallStackFrame *f = &call_stack->frames[rhs_value.u64];
|
||||
result.root = e_irtree_set_space(arena, rd_eval_space_from_ctrl_entity(process, D_EvalSpaceKind_Entity), e_irtree_const_u(arena, regs_rip_from_arch_block(accel->arch, f->regs)));
|
||||
result.root = e_irtree_set_space(arena, rd_eval_space_from_ctrl_entity(process, D_EvalSpaceKind_Entity), e_irtree_const_u(arena, arch_ip_from_reg_block(arch_info, f->regs)));
|
||||
result.type_key = e_type_key_cons(.arch = process->arch, .kind = E_TypeKind_Ptr, .direct_key = e_type_key_basic(E_TypeKind_Function), .count = 1, .depth = f->inline_depth);
|
||||
result.mode = E_Mode_Value;
|
||||
}
|
||||
|
||||
+34
-38
@@ -297,9 +297,7 @@
|
||||
#include "rdi_from_dwarf/rdi_from_dwarf.h"
|
||||
#include "rdi_from_dwarf/rdi_from_dwarf_2.h"
|
||||
#include "radbin/radbin.h"
|
||||
#include "regs/regs.h"
|
||||
#include "regs/rdi/regs_rdi.h"
|
||||
#include "regs/dwarf/regs_dwarf.h"
|
||||
#include "arch/arch_inc.h"
|
||||
#include "dbg_info/dbg_info.h"
|
||||
#include "disasm/disasm.h"
|
||||
#include "stap/stap_parse.h"
|
||||
@@ -352,9 +350,7 @@
|
||||
#include "rdi_from_dwarf/rdi_from_dwarf.c"
|
||||
#include "rdi_from_dwarf/rdi_from_dwarf_2.c"
|
||||
#include "radbin/radbin.c"
|
||||
#include "regs/regs.c"
|
||||
#include "regs/rdi/regs_rdi.c"
|
||||
#include "regs/dwarf/regs_dwarf.c"
|
||||
#include "arch/arch_inc.c"
|
||||
#include "dbg_info/dbg_info.c"
|
||||
#include "disasm/disasm.c"
|
||||
#include "stap/stap_parse.c"
|
||||
@@ -414,9 +410,9 @@ ipc_signaler_thread__entry_point(void *p)
|
||||
ThreadNameF("rd_ipc_signaler_thread");
|
||||
for(;;)
|
||||
{
|
||||
if(os_semaphore_take(ipc_sender2main_signal_semaphore, max_U64))
|
||||
if(semaphore_take(ipc_sender2main_signal_semaphore, max_U64))
|
||||
{
|
||||
if(os_semaphore_take(ipc_sender2main_lock_semaphore, max_U64))
|
||||
if(semaphore_take(ipc_sender2main_lock_semaphore, max_U64))
|
||||
{
|
||||
IPCInfo *ipc_info = (IPCInfo *)ipc_sender2main_shared_memory_base;
|
||||
String8 msg = str8((U8 *)(ipc_info+1), ipc_info->msg_size);
|
||||
@@ -436,7 +432,7 @@ ipc_signaler_thread__entry_point(void *p)
|
||||
cond_var_broadcast(ipc_s2m_ring_cv);
|
||||
os_send_wakeup_event();
|
||||
ipc_info->msg_size = 0;
|
||||
os_semaphore_drop(ipc_sender2main_lock_semaphore);
|
||||
semaphore_drop(ipc_sender2main_lock_semaphore);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -559,23 +555,23 @@ entry_point(CmdLine *cmd_line)
|
||||
//- rjf: set up shared resources for ipc to this instance; launch IPC signaler thread
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
U32 instance_pid = os_get_process_info()->pid;
|
||||
U32 instance_pid = get_process_info()->pid;
|
||||
|
||||
// rjf: set up cross-process sender -> main ring buffer
|
||||
String8 ipc_sender2main_shared_memory_name = push_str8f(scratch.arena, "_raddbg_ipc_sender2main_shared_memory_%i_", instance_pid);
|
||||
String8 ipc_sender2main_signal_semaphore_name = push_str8f(scratch.arena, "_raddbg_ipc_sender2main_signal_semaphore_%i_", instance_pid);
|
||||
String8 ipc_sender2main_lock_semaphore_name = push_str8f(scratch.arena, "_raddbg_ipc_sender2main_lock_semaphore_%i_", instance_pid);
|
||||
OS_Handle ipc_sender2main_shared_memory = os_shared_memory_alloc(IPC_SHARED_MEMORY_BUFFER_SIZE, ipc_sender2main_shared_memory_name);
|
||||
ipc_sender2main_shared_memory_base = (U8 *)os_shared_memory_view_open(ipc_sender2main_shared_memory, r1u64(0, IPC_SHARED_MEMORY_BUFFER_SIZE));
|
||||
String8 ipc_sender2main_shared_memory_name = str8f(scratch.arena, "_raddbg_ipc_sender2main_shared_memory_%i_", instance_pid);
|
||||
String8 ipc_sender2main_signal_semaphore_name = str8f(scratch.arena, "_raddbg_ipc_sender2main_signal_semaphore_%i_", instance_pid);
|
||||
String8 ipc_sender2main_lock_semaphore_name = str8f(scratch.arena, "_raddbg_ipc_sender2main_lock_semaphore_%i_", instance_pid);
|
||||
SharedMemory ipc_sender2main_shared_memory = shared_memory_alloc(IPC_SHARED_MEMORY_BUFFER_SIZE, ipc_sender2main_shared_memory_name);
|
||||
ipc_sender2main_shared_memory_base = (U8 *)shared_memory_view_open(ipc_sender2main_shared_memory, r1u64(0, IPC_SHARED_MEMORY_BUFFER_SIZE));
|
||||
ipc_sender2main_signal_semaphore = semaphore_alloc(0, 1, ipc_sender2main_signal_semaphore_name);
|
||||
ipc_sender2main_lock_semaphore = semaphore_alloc(1, 1, ipc_sender2main_lock_semaphore_name);
|
||||
|
||||
// rjf: set up cross-process main -> sender ring buffer
|
||||
String8 ipc_main2sender_shared_memory_name = push_str8f(scratch.arena, "_raddbg_ipc_main2sender_shared_memory_%i_", instance_pid);
|
||||
String8 ipc_main2sender_signal_semaphore_name = push_str8f(scratch.arena, "_raddbg_ipc_main2sender_signal_semaphore_%i_", instance_pid);
|
||||
String8 ipc_main2sender_lock_semaphore_name = push_str8f(scratch.arena, "_raddbg_ipc_main2sender_lock_semaphore_%i_", instance_pid);
|
||||
OS_Handle ipc_main2sender_shared_memory = os_shared_memory_alloc(IPC_SHARED_MEMORY_BUFFER_SIZE, ipc_main2sender_shared_memory_name);
|
||||
ipc_main2sender_shared_memory_base = (U8 *)os_shared_memory_view_open(ipc_main2sender_shared_memory, r1u64(0, IPC_SHARED_MEMORY_BUFFER_SIZE));
|
||||
String8 ipc_main2sender_shared_memory_name = str8f(scratch.arena, "_raddbg_ipc_main2sender_shared_memory_%i_", instance_pid);
|
||||
String8 ipc_main2sender_signal_semaphore_name = str8f(scratch.arena, "_raddbg_ipc_main2sender_signal_semaphore_%i_", instance_pid);
|
||||
String8 ipc_main2sender_lock_semaphore_name = str8f(scratch.arena, "_raddbg_ipc_main2sender_lock_semaphore_%i_", instance_pid);
|
||||
SharedMemory ipc_main2sender_shared_memory = shared_memory_alloc(IPC_SHARED_MEMORY_BUFFER_SIZE, ipc_main2sender_shared_memory_name);
|
||||
ipc_main2sender_shared_memory_base = (U8 *)shared_memory_view_open(ipc_main2sender_shared_memory, r1u64(0, IPC_SHARED_MEMORY_BUFFER_SIZE));
|
||||
ipc_main2sender_signal_semaphore = semaphore_alloc(0, 1, ipc_main2sender_signal_semaphore_name);
|
||||
ipc_main2sender_lock_semaphore = semaphore_alloc(1, 1, ipc_main2sender_lock_semaphore_name);
|
||||
|
||||
@@ -682,7 +678,7 @@ entry_point(CmdLine *cmd_line)
|
||||
if(ipc_command_frame)
|
||||
{
|
||||
if(ipc_main2sender_shared_memory_base != 0 &&
|
||||
os_semaphore_take(ipc_main2sender_lock_semaphore, os_now_microseconds()+5000000))
|
||||
semaphore_take(ipc_main2sender_lock_semaphore, now_time_us()+5000000))
|
||||
{
|
||||
IPCInfo *ipc_info = (IPCInfo *)ipc_main2sender_shared_memory_base;
|
||||
U8 *buffer = (U8 *)(ipc_info+1);
|
||||
@@ -691,8 +687,8 @@ entry_point(CmdLine *cmd_line)
|
||||
String8 msg = str8_list_join(scratch.arena, &rd_state->cmd_outputs, &join);
|
||||
ipc_info->msg_size = Min(buffer_max, msg.size);
|
||||
MemoryCopy(buffer, msg.str, ipc_info->msg_size);
|
||||
os_semaphore_drop(ipc_main2sender_signal_semaphore);
|
||||
os_semaphore_drop(ipc_main2sender_lock_semaphore);
|
||||
semaphore_drop(ipc_main2sender_signal_semaphore);
|
||||
semaphore_drop(ipc_main2sender_lock_semaphore);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -721,7 +717,7 @@ entry_point(CmdLine *cmd_line)
|
||||
//- rjf: no explicit PID? -> find PID to send message to, by looking for other raddbg instances
|
||||
if(dst_pid == 0)
|
||||
{
|
||||
U32 this_pid = os_get_process_info()->pid;
|
||||
U32 this_pid = get_process_info()->pid;
|
||||
DMN_ProcessIter it = {0};
|
||||
dmn_process_iter_begin(&it);
|
||||
for(DMN_ProcessInfo info = {0}; dmn_process_iter_next(scratch.arena, &it, &info);)
|
||||
@@ -740,23 +736,23 @@ entry_point(CmdLine *cmd_line)
|
||||
String8 ipc_sender2main_shared_memory_name = push_str8f(scratch.arena, "_raddbg_ipc_sender2main_shared_memory_%i_", dst_pid);
|
||||
String8 ipc_sender2main_signal_semaphore_name = push_str8f(scratch.arena, "_raddbg_ipc_sender2main_signal_semaphore_%i_", dst_pid);
|
||||
String8 ipc_sender2main_lock_semaphore_name = push_str8f(scratch.arena, "_raddbg_ipc_sender2main_lock_semaphore_%i_", dst_pid);
|
||||
OS_Handle ipc_sender2main_shared_memory = os_shared_memory_alloc(IPC_SHARED_MEMORY_BUFFER_SIZE, ipc_sender2main_shared_memory_name);
|
||||
ipc_sender2main_shared_memory_base = (U8 *)os_shared_memory_view_open(ipc_sender2main_shared_memory, r1u64(0, IPC_SHARED_MEMORY_BUFFER_SIZE));
|
||||
ipc_sender2main_signal_semaphore = os_semaphore_alloc(0, 1, ipc_sender2main_signal_semaphore_name);
|
||||
ipc_sender2main_lock_semaphore = os_semaphore_alloc(1, 1, ipc_sender2main_lock_semaphore_name);
|
||||
SharedMemory ipc_sender2main_shared_memory = shared_memory_alloc(IPC_SHARED_MEMORY_BUFFER_SIZE, ipc_sender2main_shared_memory_name);
|
||||
ipc_sender2main_shared_memory_base = (U8 *)shared_memory_view_open(ipc_sender2main_shared_memory, r1u64(0, IPC_SHARED_MEMORY_BUFFER_SIZE));
|
||||
ipc_sender2main_signal_semaphore = semaphore_alloc(0, 1, ipc_sender2main_signal_semaphore_name);
|
||||
ipc_sender2main_lock_semaphore = semaphore_alloc(1, 1, ipc_sender2main_lock_semaphore_name);
|
||||
String8 ipc_main2sender_shared_memory_name = push_str8f(scratch.arena, "_raddbg_ipc_main2sender_shared_memory_%i_", dst_pid);
|
||||
String8 ipc_main2sender_signal_semaphore_name = push_str8f(scratch.arena, "_raddbg_ipc_main2sender_signal_semaphore_%i_", dst_pid);
|
||||
String8 ipc_main2sender_lock_semaphore_name = push_str8f(scratch.arena, "_raddbg_ipc_main2sender_lock_semaphore_%i_", dst_pid);
|
||||
OS_Handle ipc_main2sender_shared_memory = os_shared_memory_alloc(IPC_SHARED_MEMORY_BUFFER_SIZE, ipc_main2sender_shared_memory_name);
|
||||
ipc_main2sender_shared_memory_base = (U8 *)os_shared_memory_view_open(ipc_main2sender_shared_memory, r1u64(0, IPC_SHARED_MEMORY_BUFFER_SIZE));
|
||||
ipc_main2sender_signal_semaphore = os_semaphore_alloc(0, 1, ipc_main2sender_signal_semaphore_name);
|
||||
ipc_main2sender_lock_semaphore = os_semaphore_alloc(1, 1, ipc_main2sender_lock_semaphore_name);
|
||||
SharedMemory ipc_main2sender_shared_memory = shared_memory_alloc(IPC_SHARED_MEMORY_BUFFER_SIZE, ipc_main2sender_shared_memory_name);
|
||||
ipc_main2sender_shared_memory_base = (U8 *)shared_memory_view_open(ipc_main2sender_shared_memory, r1u64(0, IPC_SHARED_MEMORY_BUFFER_SIZE));
|
||||
ipc_main2sender_signal_semaphore = semaphore_alloc(0, 1, ipc_main2sender_signal_semaphore_name);
|
||||
ipc_main2sender_lock_semaphore = semaphore_alloc(1, 1, ipc_main2sender_lock_semaphore_name);
|
||||
|
||||
//- rjf: got resources -> write message
|
||||
B32 wrote_message = 0;
|
||||
if(dst_pid != 0 &&
|
||||
ipc_sender2main_shared_memory_base != 0 &&
|
||||
os_semaphore_take(ipc_sender2main_lock_semaphore, max_U64))
|
||||
semaphore_take(ipc_sender2main_lock_semaphore, max_U64))
|
||||
{
|
||||
wrote_message = 1;
|
||||
IPCInfo *ipc_info = (IPCInfo *)ipc_sender2main_shared_memory_base;
|
||||
@@ -773,24 +769,24 @@ entry_point(CmdLine *cmd_line)
|
||||
String8 msg = str8_list_join(scratch.arena, &parts, &join);
|
||||
ipc_info->msg_size = Min(buffer_max, msg.size);
|
||||
MemoryCopy(buffer, msg.str, ipc_info->msg_size);
|
||||
os_semaphore_drop(ipc_sender2main_signal_semaphore);
|
||||
os_semaphore_drop(ipc_sender2main_lock_semaphore);
|
||||
semaphore_drop(ipc_sender2main_signal_semaphore);
|
||||
semaphore_drop(ipc_sender2main_lock_semaphore);
|
||||
}
|
||||
|
||||
//- rjf: wrote message -> wait for outputs, read outputs
|
||||
String8List outputs = {0};
|
||||
if(wrote_message &&
|
||||
ipc_main2sender_shared_memory_base != 0 &&
|
||||
os_semaphore_take(ipc_main2sender_signal_semaphore, os_now_microseconds()+10000000))
|
||||
semaphore_take(ipc_main2sender_signal_semaphore, now_time_us()+10000000))
|
||||
{
|
||||
if(os_semaphore_take(ipc_main2sender_lock_semaphore, max_U64))
|
||||
if(semaphore_take(ipc_main2sender_lock_semaphore, max_U64))
|
||||
{
|
||||
IPCInfo *ipc_info = (IPCInfo *)ipc_main2sender_shared_memory_base;
|
||||
String8 msg = str8((U8 *)(ipc_info+1), ipc_info->msg_size);
|
||||
msg.size = Min(msg.size, IPC_SHARED_MEMORY_BUFFER_SIZE - sizeof(IPCInfo));
|
||||
U8 split_char = 0;
|
||||
outputs = str8_split(scratch.arena, msg, &split_char, 1, 0);
|
||||
os_semaphore_drop(ipc_main2sender_lock_semaphore);
|
||||
semaphore_drop(ipc_main2sender_lock_semaphore);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1028,10 +1028,11 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
D_CallStack call_stack = d_call_stack_from_thread(access, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0);
|
||||
if(1 <= frame_num && frame_num <= call_stack.frames_count)
|
||||
{
|
||||
ARCH_Info *arch_info = arch_info_from_arch(entity->arch);
|
||||
D_CallStackFrame *f = &call_stack.frames[frame_num-1];
|
||||
info.callstack_unwind_index = f->unwind_count;
|
||||
info.callstack_inline_depth = f->inline_depth;
|
||||
info.callstack_vaddr = regs_rip_from_arch_block(entity->arch, f->regs);
|
||||
info.callstack_vaddr = arch_ip_from_reg_block(arch_info, f->regs);
|
||||
}
|
||||
access_close(access);
|
||||
}
|
||||
@@ -2148,7 +2149,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
|
||||
U128 hash = {0};
|
||||
TXT_TextInfo info = txt_text_info_from_key_lang(access, rd_regs()->text_key, rd_regs()->lang_kind, &hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
B32 file_is_missing = (rd_regs()->file_path.size != 0 && os_properties_from_file_path(rd_regs()->file_path).modified == 0);
|
||||
B32 file_is_missing = (rd_regs()->file_path.size != 0 && properties_from_file_path(rd_regs()->file_path).modified == 0);
|
||||
B32 key_has_data = !u128_match(hash, u128_zero()) && info.lines_count;
|
||||
ProfEnd();
|
||||
|
||||
@@ -2305,7 +2306,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
|
||||
}break;
|
||||
case RDI_ChecksumKind_Timestamp:
|
||||
{
|
||||
FileProperties props = os_properties_from_file_path(rd_regs()->file_path);
|
||||
FileProperties props = properties_from_file_path(rd_regs()->file_path);
|
||||
String8 timestamp_string = str8_struct(&props.modified);
|
||||
file_is_out_of_date = !MemoryIsZeroStruct(&props.modified) && !str8_match(timestamp_string, checksum_expected, 0);
|
||||
}break;
|
||||
@@ -3271,8 +3272,9 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
|
||||
//- rjf: fill selected thread stack range annotation
|
||||
if(selected_call_stack.concrete_frames_count > 0)
|
||||
{
|
||||
ARCH_Info *arch_info = arch_info_from_arch(selected_thread->arch);
|
||||
U64 stack_base_vaddr = selected_thread->stack_base;
|
||||
U64 stack_top_vaddr = regs_rsp_from_arch_block(selected_thread->arch, selected_call_stack.concrete_frames[0]->regs);
|
||||
U64 stack_top_vaddr = arch_sp_from_reg_block(arch_info, selected_call_stack.concrete_frames[0]->regs);
|
||||
Rng1U64 stack_vaddr_range = r1u64(stack_base_vaddr, stack_top_vaddr);
|
||||
Rng1U64 stack_vaddr_range_in_viz = intersect_1u64(stack_vaddr_range, viz_range_bytes);
|
||||
if(dim_1u64(stack_vaddr_range_in_viz) != 0)
|
||||
@@ -3294,13 +3296,14 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
|
||||
//- rjf: fill unwind frame annotations
|
||||
if(selected_call_stack.concrete_frames_count != 0) UI_Tag(str8_lit("weak"))
|
||||
{
|
||||
ARCH_Info *arch_info = arch_info_from_arch(selected_thread->arch);
|
||||
Vec4F32 symbol_color = ui_color_from_name(str8_lit("code_symbol"));
|
||||
U64 last_rip = regs_rip_from_arch_block(selected_thread->arch, selected_call_stack.concrete_frames[0]->regs);
|
||||
U64 last_stack_top = regs_rsp_from_arch_block(selected_thread->arch, selected_call_stack.concrete_frames[0]->regs);
|
||||
U64 last_rip = arch_ip_from_reg_block(arch_info, selected_call_stack.concrete_frames[0]->regs);
|
||||
U64 last_stack_top = arch_sp_from_reg_block(arch_info, selected_call_stack.concrete_frames[0]->regs);
|
||||
for(U64 idx = 1; idx < selected_call_stack.concrete_frames_count; idx += 1)
|
||||
{
|
||||
D_CallStackFrame *f = selected_call_stack.concrete_frames[idx];
|
||||
U64 f_stack_top = regs_rsp_from_arch_block(selected_thread->arch, f->regs);
|
||||
U64 f_stack_top = arch_sp_from_reg_block(arch_info, f->regs);
|
||||
Rng1U64 frame_vaddr_range = r1u64(last_stack_top, f_stack_top);
|
||||
Rng1U64 frame_vaddr_range_in_viz = intersect_1u64(frame_vaddr_range, viz_range_bytes);
|
||||
last_stack_top = f_stack_top;
|
||||
@@ -3308,7 +3311,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
|
||||
{
|
||||
Access *access = access_open();
|
||||
U64 f_rip_vaddr = last_rip;
|
||||
last_rip = regs_rip_from_arch_block(selected_thread->arch, f->regs);
|
||||
last_rip = arch_ip_from_reg_block(arch_info, f->regs);
|
||||
D_Entity *module = d_module_from_process_vaddr(selected_process, f_rip_vaddr);
|
||||
U64 f_rip_voff = d_voff_from_vaddr(module, f_rip_vaddr);
|
||||
DI_Key dbgi_key = d_dbgi_key_from_module(module);
|
||||
|
||||
@@ -550,6 +550,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, D_Entity *entity, B32 include_extr
|
||||
Access *access = access_open();
|
||||
D_Entity *process = d_entity_ancestor_from_kind(entity, D_EntityKind_Process);
|
||||
Arch arch = entity->arch;
|
||||
ARCH_Info *arch_info = arch_info_from_arch(entity->arch);
|
||||
B32 call_stack_high_priority = d_handle_match(entity->handle, rd_base_regs()->thread);
|
||||
D_CallStack call_stack = d_call_stack_from_thread(access, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0);
|
||||
B32 did_first_known = 0;
|
||||
@@ -558,7 +559,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, D_Entity *entity, B32 include_extr
|
||||
idx += 1)
|
||||
{
|
||||
D_CallStackFrame *f = &call_stack.frames[call_stack.frames_count - 1 - idx];
|
||||
U64 rip_vaddr = regs_rip_from_arch_block(arch, f->regs);
|
||||
U64 rip_vaddr = arch_ip_from_reg_block(arch_info, f->regs);
|
||||
D_Entity *module = d_module_from_process_vaddr(process, rip_vaddr);
|
||||
U64 rip_voff = d_voff_from_vaddr(module, rip_vaddr);
|
||||
String8 name = {0};
|
||||
@@ -653,7 +654,7 @@ rd_title_fstrs_from_file_path(Arena *arena, String8 file_path)
|
||||
{
|
||||
DR_FStrList fstrs = {0};
|
||||
String8 file_name = str8_skip_last_slash(file_path);
|
||||
FileProperties props = os_properties_from_file_path(file_path);
|
||||
FileProperties props = properties_from_file_path(file_path);
|
||||
RD_IconKind icon_kind = RD_IconKind_FileOutline;
|
||||
if(props.flags & FilePropertyFlag_IsFolder)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user