dbg_engine: minidump memory64 parsing; rename switch -> better thing for what it is

This commit is contained in:
Ryan Fleury
2026-05-18 19:40:47 -07:00
parent a73105b296
commit 80d68b7f95
7 changed files with 394 additions and 333 deletions
+65 -6
View File
@@ -1302,6 +1302,7 @@ d_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list)
D_Entity *process = d_entity_alloc(store, machine, D_EntityKind_Process, event->arch, event->entity, (U64)event->entity_id);
process->tls_model = event->tls_model;
process->target_os = event->target_os;
d_entity_equip_string(store, process, event->string);
}
}break;
case D_EventKind_EndProc:
@@ -1436,9 +1437,9 @@ d_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list)
module->tls_index = event->tls_index;
module->tls_offset = event->tls_offset;
D_Entity *first_module = d_entity_child_from_kind(process, D_EntityKind_Module);
if(first_module == module)
if(first_module == module && process->string.size == 0)
{
d_entity_equip_string(store, process, str8_skip_last_slash(event->string));
d_entity_equip_string(store, process, event->string);
}
scratch_end(scratch);
}break;
@@ -5156,6 +5157,9 @@ d_ctrl_thread__open_crash_dump(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
U64 modules_count = 0;
MDMP_MemoryDescriptor32 *memories = 0;
U64 memories_count = 0;
MDMP_MemoryDescriptor64 *memories64 = 0;
U64 memories64_count = 0;
U64 memories64_base_foff = 0;
{
for EachIndex(idx, directories_count)
{
@@ -5195,6 +5199,16 @@ d_ctrl_thread__open_crash_dump(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
memories = (MDMP_MemoryDescriptor32 *)(data.str + off);
memories_count = Min(memories_count_32, memories_count_max);
}break;
case MDMP_StreamKind_Memory64List:
{
U64 memories64_count = 0;
U64 off = dir->location.foff;
off += str8_deserial_read_struct(data, off, &memories64_count);
off += str8_deserial_read_struct(data, off, &memories64_base_foff);
U64 memories64_count_max = (data.size - off) / sizeof(MDMP_MemoryDescriptor64);
memories64 = (MDMP_MemoryDescriptor64 *)(data.str + off);
memories64_count = Min(memories64_count, memories64_count_max);
}break;
}
}
}
@@ -5219,6 +5233,7 @@ d_ctrl_thread__open_crash_dump(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
evt->entity = process;
evt->arch = arch;
evt->target_os = OperatingSystem_Windows;
evt->string = path;
}
// rjf: thread creation
@@ -5245,7 +5260,9 @@ d_ctrl_thread__open_crash_dump(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
// rjf: module loads
for EachIndex(idx, modules_count)
{
// rjf: unpack module
MDMP_Module *module = &modules[idx];
Rng1U64 vaddr_range = r1u64(module->image_base_vaddr, module->image_base_vaddr + module->image_size);
String8 module_name = {0};
{
U64 module_name_off = module->module_name_foff;
@@ -5256,33 +5273,75 @@ d_ctrl_thread__open_crash_dump(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
String16 module_name_16 = str16((U16 *)module_name_raw_data.str, module_name_raw_data.size / sizeof(U16));
module_name = str8_from_16(scratch.arena, module_name_16);
}
// rjf: open module
D_Handle module_handle = d_dump_handle_make(D_MachineID_Local, handle_id_gen);
handle_id_gen += 1;
d_ctrl_thread__module_open(process, module_handle, vaddr_range, module_name, r1u64(0, 0), 0);
// rjf: open debug info
String8 initial_debug_info_path = d_initial_debug_info_path_from_module(scratch.arena, module_handle);
U64 debug_info_timestamp = properties_from_file_path(initial_debug_info_path).modified;
DI_Key initial_dbgi_key = di_key_from_path_timestamp(initial_debug_info_path, debug_info_timestamp);
di_open(initial_dbgi_key);
// rjf: push module load event
{
D_Event *evt = d_event_list_push(scratch.arena, &evts);
evt->kind = D_EventKind_NewModule;
evt->msg_id = msg->msg_id;
evt->entity = d_dump_handle_make(D_MachineID_Local, handle_id_gen);
evt->entity = module_handle;
evt->parent = process;
evt->arch = arch;
evt->vaddr_rng = r1u64(module->image_base_vaddr, module->image_base_vaddr + module->image_size);
evt->vaddr_rng = vaddr_range;
evt->string = module_name;
// TODO(rjf): evt->stack_base = ; (use thread->stack)
// TODO(rjf): evt->tls_root = ; (use thread->thread_context)
handle_id_gen += 1;
}
// rjf: push debug info initial path set event
{
D_Event *evt = d_event_list_push(scratch.arena, &evts);
evt->kind = D_EventKind_ModuleDebugInfoPathChange;
evt->msg_id = msg->msg_id;
evt->entity = module_handle;
evt->parent = process;
evt->timestamp = debug_info_timestamp;
evt->string = initial_debug_info_path;
}
}
// rjf: allocate parse artifact arena
arena = arena_alloc();
// rjf: gather memory ranges
memory_ranges_count = memories_count;
memory_ranges_count = memories_count + memories64_count;
memory_ranges = push_array(arena, D_DumpMemoryRange, memory_ranges_count);
for EachIndex(idx, memories_count)
{
memory_ranges[idx].base_vaddr = memories[idx].start_of_memory_range;
memory_ranges[idx].foff_range = r1u64(memories[idx].memory_location.foff, memories[idx].memory_location.foff+memories[idx].memory_location.data_size);
}
{
U64 foff = memories64_base_foff;
for EachIndex(idx, memories64_count)
{
memory_ranges[memories_count + idx].base_vaddr = memories64[memories_count + idx].start_of_memory_range;
memory_ranges[memories_count + idx].foff_range = r1u64(foff, foff+memories64[idx].size);
foff += memories64[idx].size;
}
}
}
}
}
//- rjf: record stop
{
D_Event *event = d_event_list_push(scratch.arena, &evts);
event->kind = D_EventKind_Stopped;
event->cause = D_EventCause_Finished;
event->msg_id = msg->msg_id;
}
//- rjf: push all events from the parse
ins_atomic_u64_inc_eval(&d_ctrl_state->mem_gen);
+7 -5
View File
@@ -269,7 +269,7 @@ RD_VocabInfo rd_vocab_info_table[360] =
{str8_lit_comp("tab_settings"), str8_lit_comp(""), str8_lit_comp("Selected Tab Settings"), str8_lit_comp(""), RD_IconKind_Gear},
{str8_lit_comp("set_current_path"), str8_lit_comp(""), str8_lit_comp("Set Current Path"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("open"), str8_lit_comp(""), str8_lit_comp("Open"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("switch"), str8_lit_comp(""), str8_lit_comp("Switch"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("open_source_file_from_debug_info"), str8_lit_comp(""), str8_lit_comp("Open Source File From Debug Info"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("switch_to_partner_file"), str8_lit_comp(""), str8_lit_comp("Switch To Partner File"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("show_file_in_explorer"), str8_lit_comp(""), str8_lit_comp("Show File In Explorer"), str8_lit_comp(""), RD_IconKind_FolderClosedFilled},
{str8_lit_comp("go_to_disassembly"), str8_lit_comp(""), str8_lit_comp("Go To Disassembly"), str8_lit_comp(""), RD_IconKind_Glasses},
@@ -671,7 +671,7 @@ RD_CmdKindInfo rd_cmd_kind_info_table[249] =
{ str8_lit_comp("tab_settings"), str8_lit_comp("Opens settings for a tab."), str8_lit_comp("view,options"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1)|(RD_CmdKindFlag_ListInTextPt*0)|(RD_CmdKindFlag_ListInTextRng*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), D_EntityKind_Null}},
{ str8_lit_comp("set_current_path"), str8_lit_comp("Sets the debugger's current path, which is used as a starting point when browsing for files."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*1)|(RD_CmdKindFlag_ListInTextPt*0)|(RD_CmdKindFlag_ListInTextRng*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), D_EntityKind_Null}},
{ str8_lit_comp("open"), str8_lit_comp("Opens a file."), str8_lit_comp("code,source,file"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1)|(RD_CmdKindFlag_ListInTextPt*0)|(RD_CmdKindFlag_ListInTextRng*0), {(RD_QueryFlag_AllowFiles*1)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_FilePath, str8_lit_comp("folder:\"$input\""), str8_lit_comp(""), D_EntityKind_Null}},
{ str8_lit_comp("switch"), str8_lit_comp("Switches to a recent file."), str8_lit_comp("code,source,file"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*0)|(RD_CmdKindFlag_ListInTextPt*0)|(RD_CmdKindFlag_ListInTextRng*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_Cfg, str8_lit_comp("query:source_files"), str8_lit_comp(""), D_EntityKind_Null}},
{ str8_lit_comp("open_source_file_from_debug_info"), str8_lit_comp("Opens a source file found within loaded debug info."), str8_lit_comp("code,source,file"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*0)|(RD_CmdKindFlag_ListInTextPt*0)|(RD_CmdKindFlag_ListInTextRng*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_Cfg, str8_lit_comp("query:source_files"), str8_lit_comp(""), D_EntityKind_Null}},
{ str8_lit_comp("switch_to_partner_file"), str8_lit_comp("Switches to the focused file's partner; or from header to implementation or vice versa."), str8_lit_comp("code,source,file"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1)|(RD_CmdKindFlag_ListInTextPt*0)|(RD_CmdKindFlag_ListInTextRng*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), D_EntityKind_Null}},
{ str8_lit_comp("show_file_in_explorer"), str8_lit_comp("Opens the operating system's file explorer and shows the selected file."), str8_lit_comp(""), str8_lit_comp("$file,"), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1)|(RD_CmdKindFlag_ListInTextPt*0)|(RD_CmdKindFlag_ListInTextRng*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), D_EntityKind_Null}},
{ str8_lit_comp("go_to_disassembly"), str8_lit_comp("Goes to the disassembly, if any, for a given source code line."), str8_lit_comp("code,source,disassembly,disasm"), str8_lit_comp("$text_pt,"), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1)|(RD_CmdKindFlag_ListInTextPt*1)|(RD_CmdKindFlag_ListInTextRng*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp(""), str8_lit_comp(""), D_EntityKind_Null}},
@@ -871,7 +871,7 @@ struct {String8 string; CFG_Binding binding;} rd_default_binding_table[114] =
{str8_lit_comp("open_tab"), {WM_Key_T, 0 |WM_Modifier_Ctrl }},
{str8_lit_comp("tab_settings"), {WM_Key_T, 0 |WM_Modifier_Ctrl |WM_Modifier_Alt}},
{str8_lit_comp("open"), {WM_Key_O, 0 |WM_Modifier_Ctrl }},
{str8_lit_comp("switch"), {WM_Key_I, 0 |WM_Modifier_Ctrl }},
{str8_lit_comp("open_source_file_from_debug_info"), {WM_Key_I, 0 |WM_Modifier_Ctrl }},
{str8_lit_comp("switch_to_partner_file"), {WM_Key_O, 0 |WM_Modifier_Alt}},
{str8_lit_comp("new_project"), {WM_Key_N, 0 |WM_Modifier_Ctrl |WM_Modifier_Shift }},
{str8_lit_comp("open_project"), {WM_Key_O, 0 |WM_Modifier_Ctrl |WM_Modifier_Shift }},
@@ -946,7 +946,7 @@ struct {String8 string; CFG_Binding binding;} rd_default_binding_table[114] =
{str8_lit_comp("toggle_dev_menu"), {WM_Key_D, 0 |WM_Modifier_Ctrl |WM_Modifier_Shift |WM_Modifier_Alt}},
};
String8 rd_binding_version_remap_old_name_table[8] =
String8 rd_binding_version_remap_old_name_table[9] =
{
str8_lit_comp("commands"),
str8_lit_comp("load_user"),
@@ -956,9 +956,10 @@ str8_lit_comp("open_profile"),
str8_lit_comp("address_breakpoint"),
str8_lit_comp("function_breakpoint"),
str8_lit_comp("toggle_breakpoint_cursor"),
str8_lit_comp("switch"),
};
String8 rd_binding_version_remap_new_name_table[8] =
String8 rd_binding_version_remap_new_name_table[9] =
{
str8_lit_comp("run_command"),
str8_lit_comp("open_user"),
@@ -968,6 +969,7 @@ str8_lit_comp("open_project"),
str8_lit_comp("add_address_breakpoint"),
str8_lit_comp("add_function_breakpoint"),
str8_lit_comp("toggle_breakpoint"),
str8_lit_comp("open_source_file_from_debug_info"),
};
String8 rd_icon_kind_text_table[75] =
+3 -3
View File
@@ -156,7 +156,7 @@ RD_CmdKind_TabBarBottom,
RD_CmdKind_TabSettings,
RD_CmdKind_SetCurrentPath,
RD_CmdKind_Open,
RD_CmdKind_Switch,
RD_CmdKind_OpenSourceFileFromDebugInfo,
RD_CmdKind_SwitchToPartnerFile,
RD_CmdKind_ShowFileInExplorer,
RD_CmdKind_GoToDisassembly,
@@ -607,8 +607,8 @@ extern RD_VocabInfo rd_vocab_info_table[360];
extern RD_NameSchemaInfo rd_name_schema_info_table[39];
extern String8 rd_reg_slot_code_name_table[49];
extern Rng1U64 rd_reg_slot_range_table[49];
extern String8 rd_binding_version_remap_old_name_table[8];
extern String8 rd_binding_version_remap_new_name_table[8];
extern String8 rd_binding_version_remap_old_name_table[9];
extern String8 rd_binding_version_remap_new_name_table[9];
extern String8 rd_icon_kind_text_table[75];
extern String8 rd_code_color_slot_name_table[14];
extern String8 rd_theme_preset_display_string_table[11];
+3 -2
View File
@@ -1027,7 +1027,7 @@ RD_CmdTable: // | | | |
//- rjf: files
{SetCurrentPath 0 1 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 FileOutline "set_current_path" "Set Current Path" "Sets the debugger's current path, which is used as a starting point when browsing for files." "" "" }
{Open 1 1 0 0 `folder:\\"$input\\"` FilePath null Nil Null 1 0 0 0 0 1 1 FileOutline "open" "Open" "Opens a file." "code,source,file" "" }
{Switch 1 0 0 0 "query:source_files" Cfg null RecentFile Null 0 0 0 0 0 1 1 FileOutline "switch" "Switch" "Switches to a recent file." "code,source,file" "" }
{OpenSourceFileFromDebugInfo 1 0 0 0 "query:source_files" Cfg null RecentFile Null 0 0 0 0 0 1 1 FileOutline "open_source_file_from_debug_info" "Open Source File From Debug Info" "Opens a source file found within loaded debug info." "code,source,file" "" }
{SwitchToPartnerFile 1 1 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 FileOutline "switch_to_partner_file" "Switch To Partner File" "Switches to the focused file's partner; or from header to implementation or vice versa." "code,source,file" "" }
{ShowFileInExplorer 1 1 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 FolderClosedFilled "show_file_in_explorer" "Show File In Explorer" "Opens the operating system's file explorer and shows the selected file." "" "$file," }
@@ -1331,7 +1331,7 @@ RD_DefaultBindingTable:
//- rjf: files
{ "open" O ctrl 0 0 }
{ "switch" I ctrl 0 0 }
{ "open_source_file_from_debug_info" I ctrl 0 0 }
{ "switch_to_partner_file" O 0 0 alt }
//- rjf: setting config paths
@@ -1449,6 +1449,7 @@ RD_BindingVersionRemapTable:
{"address_breakpoint" "add_address_breakpoint"}
{"function_breakpoint" "add_function_breakpoint"}
{"toggle_breakpoint_cursor" "toggle_breakpoint"}
{"switch" "open_source_file_from_debug_info"}
}
@data(String8) rd_binding_version_remap_old_name_table:
+4 -4
View File
@@ -650,7 +650,7 @@ rd_name_from_ctrl_entity(Arena *arena, D_Entity *entity)
{
string = str8_lit("unnamed");
}
if(entity->kind == D_EntityKind_Module)
if(entity->kind == D_EntityKind_Module || entity->kind == D_EntityKind_Process)
{
string = str8_skip_last_slash(string);
}
@@ -4426,7 +4426,7 @@ rd_view_ui(Rng2F32 rect)
// rjf: is file eval? -> switch to file
else if(cell_info.file_path.size != 0)
{
rd_cmd(RD_CmdKind_Switch, .cfg = 0, .file_path = cell_info.file_path);
rd_cmd(RD_CmdKind_FindCodeLocation, .cfg = 0, .file_path = cell_info.file_path, .cursor = txt_pt(0, 0));
}
}
@@ -6710,7 +6710,7 @@ rd_window_frame(void)
String8 cmds[] =
{
rd_cmd_kind_info_table[RD_CmdKind_Open].string,
rd_cmd_kind_info_table[RD_CmdKind_Switch].string,
rd_cmd_kind_info_table[RD_CmdKind_OpenSourceFileFromDebugInfo].string,
{0},//-
rd_cmd_kind_info_table[RD_CmdKind_NewProject].string,
rd_cmd_kind_info_table[RD_CmdKind_OpenProject].string,
@@ -13862,7 +13862,7 @@ rd_frame(void)
log_user_errorf("Couldn't open file at \"%S\".", path);
}
}break;
case RD_CmdKind_Switch:
case RD_CmdKind_OpenSourceFileFromDebugInfo:
{
String8 path = rd_regs()->file_path;
rd_cmd(RD_CmdKind_FindCodeLocation, .file_path = path, .cursor = txt_pt(0, 0), .vaddr = 0, .force_focus = 1, .prefer_new_tab = 1);
+1 -1
View File
@@ -545,7 +545,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, D_Entity *entity, B32 include_extr
.color = color);
//- rjf: push PID
if(entity->kind == D_EntityKind_Process)
if(entity->kind == D_EntityKind_Process && entity->id != 0)
{
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
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 = ui_top_font_size()*0.85f);
-1
View File
@@ -1736,7 +1736,6 @@ win32_exception_filter(EXCEPTION_POINTERS* exception_ptrs)
info.ClientPointers = FALSE;
BOOL dump_successful = dbg_MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), file, MiniDumpNormal, &info, 0, 0);
CloseHandle(file);
if(dump_successful)
{
#if !BUILD_CONSOLE_INTERFACE