diff --git a/src/dbg_engine/generated/dbg_engine.meta.h b/src/dbg_engine/generated/dbg_engine.meta.h index 859bab04..31d446fe 100644 --- a/src/dbg_engine/generated/dbg_engine.meta.h +++ b/src/dbg_engine/generated/dbg_engine.meta.h @@ -1,139 +1,139 @@ -// Copyright (c) Epic Games Tools -// Licensed under the MIT license (https://opensource.org/license/mit/) - -//- GENERATED CODE - -#ifndef DBG_ENGINE_META_H -#define DBG_ENGINE_META_H - -typedef enum D_CmdKind -{ -D_CmdKind_Null, -D_CmdKind_LaunchAndRun, -D_CmdKind_LaunchAndStepInto, -D_CmdKind_Kill, -D_CmdKind_KillAll, -D_CmdKind_Detach, -D_CmdKind_Continue, -D_CmdKind_StepIntoInst, -D_CmdKind_StepOverInst, -D_CmdKind_StepIntoLine, -D_CmdKind_StepOverLine, -D_CmdKind_StepOut, -D_CmdKind_Halt, -D_CmdKind_SoftHaltRefresh, -D_CmdKind_SetThreadIP, -D_CmdKind_RunToLine, -D_CmdKind_Run, -D_CmdKind_Restart, -D_CmdKind_StepInto, -D_CmdKind_StepOver, -D_CmdKind_FreezeThread, -D_CmdKind_ThawThread, -D_CmdKind_FreezeProcess, -D_CmdKind_ThawProcess, -D_CmdKind_FreezeMachine, -D_CmdKind_ThawMachine, -D_CmdKind_FreezeLocalMachine, -D_CmdKind_ThawLocalMachine, -D_CmdKind_FreezeEntity, -D_CmdKind_ThawEntity, -D_CmdKind_SetEntityColor, -D_CmdKind_SetEntityName, -D_CmdKind_Attach, -D_CmdKind_OpenCrashDump, -D_CmdKind_COUNT, -} D_CmdKind; - -typedef enum D_EntityKind -{ -D_EntityKind_Null, -D_EntityKind_Root, -D_EntityKind_Machine, -D_EntityKind_Process, -D_EntityKind_Thread, -D_EntityKind_Module, -D_EntityKind_EntryPoint, -D_EntityKind_DebugInfoPath, -D_EntityKind_PendingThreadName, -D_EntityKind_PendingThreadColor, -D_EntityKind_Breakpoint, -D_EntityKind_AddressRangeAnnotation, -D_EntityKind_COUNT, -} D_EntityKind; - -typedef enum D_ExceptionCodeKind -{ -D_ExceptionCodeKind_Null, -D_ExceptionCodeKind_Win32CtrlC, -D_ExceptionCodeKind_Win32CtrlBreak, -D_ExceptionCodeKind_Win32WinRTOriginateError, -D_ExceptionCodeKind_Win32WinRTTransformError, -D_ExceptionCodeKind_Win32RPCCallCancelled, -D_ExceptionCodeKind_Win32DatatypeMisalignment, -D_ExceptionCodeKind_Win32AccessViolation, -D_ExceptionCodeKind_Win32InPageError, -D_ExceptionCodeKind_Win32InvalidHandle, -D_ExceptionCodeKind_Win32NotEnoughQuota, -D_ExceptionCodeKind_Win32IllegalInstruction, -D_ExceptionCodeKind_Win32CannotContinueException, -D_ExceptionCodeKind_Win32InvalidExceptionDisposition, -D_ExceptionCodeKind_Win32ArrayBoundsExceeded, -D_ExceptionCodeKind_Win32FloatingPointDenormalOperand, -D_ExceptionCodeKind_Win32FloatingPointDivisionByZero, -D_ExceptionCodeKind_Win32FloatingPointInexactResult, -D_ExceptionCodeKind_Win32FloatingPointInvalidOperation, -D_ExceptionCodeKind_Win32FloatingPointOverflow, -D_ExceptionCodeKind_Win32FloatingPointStackCheck, -D_ExceptionCodeKind_Win32FloatingPointUnderflow, -D_ExceptionCodeKind_Win32IntegerDivisionByZero, -D_ExceptionCodeKind_Win32IntegerOverflow, -D_ExceptionCodeKind_Win32PrivilegedInstruction, -D_ExceptionCodeKind_Win32StackOverflow, -D_ExceptionCodeKind_Win32UnableToLocateDLL, -D_ExceptionCodeKind_Win32OrdinalNotFound, -D_ExceptionCodeKind_Win32EntryPointNotFound, -D_ExceptionCodeKind_Win32DLLInitializationFailed, -D_ExceptionCodeKind_Win32FloatingPointSSEMultipleFaults, -D_ExceptionCodeKind_Win32FloatingPointSSEMultipleTraps, -D_ExceptionCodeKind_Win32AssertionFailed, -D_ExceptionCodeKind_Win32ModuleNotFound, -D_ExceptionCodeKind_Win32ProcedureNotFound, -D_ExceptionCodeKind_Win32SanitizerErrorDetected, -D_ExceptionCodeKind_Win32SanitizerRawAccessViolation, -D_ExceptionCodeKind_Win32DirectXDebugLayer, -D_ExceptionCodeKind_COUNT, -} D_ExceptionCodeKind; - -global B32 DEV_always_refresh = 0; -global B32 DEV_simulate_lag = 0; -global B32 DEV_draw_ui_text_pos = 0; -global B32 DEV_draw_ui_focus_debug = 0; -global B32 DEV_draw_ui_box_heatmap = 0; -global B32 DEV_eval_compiler_tooltips = 0; -global B32 DEV_eval_watch_key_tooltips = 0; -global B32 DEV_cmd_context_tooltips = 0; -global B32 DEV_updating_indicator = 0; -struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] = -{ -{&DEV_always_refresh, str8_lit_comp("always_refresh")}, -{&DEV_simulate_lag, str8_lit_comp("simulate_lag")}, -{&DEV_draw_ui_text_pos, str8_lit_comp("draw_ui_text_pos")}, -{&DEV_draw_ui_focus_debug, str8_lit_comp("draw_ui_focus_debug")}, -{&DEV_draw_ui_box_heatmap, str8_lit_comp("draw_ui_box_heatmap")}, -{&DEV_eval_compiler_tooltips, str8_lit_comp("eval_compiler_tooltips")}, -{&DEV_eval_watch_key_tooltips, str8_lit_comp("eval_watch_key_tooltips")}, -{&DEV_cmd_context_tooltips, str8_lit_comp("cmd_context_tooltips")}, -{&DEV_updating_indicator, str8_lit_comp("updating_indicator")}, -}; -C_LINKAGE_BEGIN -extern String8 d_entity_kind_code_name_table[12]; -extern String8 d_entity_kind_display_string_table[12]; -extern U32 d_exception_code_kind_code_table[38]; -extern String8 d_exception_code_kind_display_string_table[38]; -extern String8 d_exception_code_kind_lowercase_code_string_table[38]; -extern B8 d_exception_code_kind_default_enable_table[38]; - -C_LINKAGE_END - -#endif // DBG_ENGINE_META_H +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//- GENERATED CODE + +#ifndef DBG_ENGINE_META_H +#define DBG_ENGINE_META_H + +typedef enum D_CmdKind +{ +D_CmdKind_Null, +D_CmdKind_LaunchAndRun, +D_CmdKind_LaunchAndStepInto, +D_CmdKind_Kill, +D_CmdKind_KillAll, +D_CmdKind_Detach, +D_CmdKind_Continue, +D_CmdKind_StepIntoInst, +D_CmdKind_StepOverInst, +D_CmdKind_StepIntoLine, +D_CmdKind_StepOverLine, +D_CmdKind_StepOut, +D_CmdKind_Halt, +D_CmdKind_SoftHaltRefresh, +D_CmdKind_SetThreadIP, +D_CmdKind_RunToLine, +D_CmdKind_Run, +D_CmdKind_Restart, +D_CmdKind_StepInto, +D_CmdKind_StepOver, +D_CmdKind_FreezeThread, +D_CmdKind_ThawThread, +D_CmdKind_FreezeProcess, +D_CmdKind_ThawProcess, +D_CmdKind_FreezeMachine, +D_CmdKind_ThawMachine, +D_CmdKind_FreezeLocalMachine, +D_CmdKind_ThawLocalMachine, +D_CmdKind_FreezeEntity, +D_CmdKind_ThawEntity, +D_CmdKind_SetEntityColor, +D_CmdKind_SetEntityName, +D_CmdKind_Attach, +D_CmdKind_OpenCrashDump, +D_CmdKind_COUNT, +} D_CmdKind; + +typedef enum D_EntityKind +{ +D_EntityKind_Null, +D_EntityKind_Root, +D_EntityKind_Machine, +D_EntityKind_Process, +D_EntityKind_Thread, +D_EntityKind_Module, +D_EntityKind_EntryPoint, +D_EntityKind_DebugInfoPath, +D_EntityKind_PendingThreadName, +D_EntityKind_PendingThreadColor, +D_EntityKind_Breakpoint, +D_EntityKind_AddressRangeAnnotation, +D_EntityKind_COUNT, +} D_EntityKind; + +typedef enum D_ExceptionCodeKind +{ +D_ExceptionCodeKind_Null, +D_ExceptionCodeKind_Win32CtrlC, +D_ExceptionCodeKind_Win32CtrlBreak, +D_ExceptionCodeKind_Win32WinRTOriginateError, +D_ExceptionCodeKind_Win32WinRTTransformError, +D_ExceptionCodeKind_Win32RPCCallCancelled, +D_ExceptionCodeKind_Win32DatatypeMisalignment, +D_ExceptionCodeKind_Win32AccessViolation, +D_ExceptionCodeKind_Win32InPageError, +D_ExceptionCodeKind_Win32InvalidHandle, +D_ExceptionCodeKind_Win32NotEnoughQuota, +D_ExceptionCodeKind_Win32IllegalInstruction, +D_ExceptionCodeKind_Win32CannotContinueException, +D_ExceptionCodeKind_Win32InvalidExceptionDisposition, +D_ExceptionCodeKind_Win32ArrayBoundsExceeded, +D_ExceptionCodeKind_Win32FloatingPointDenormalOperand, +D_ExceptionCodeKind_Win32FloatingPointDivisionByZero, +D_ExceptionCodeKind_Win32FloatingPointInexactResult, +D_ExceptionCodeKind_Win32FloatingPointInvalidOperation, +D_ExceptionCodeKind_Win32FloatingPointOverflow, +D_ExceptionCodeKind_Win32FloatingPointStackCheck, +D_ExceptionCodeKind_Win32FloatingPointUnderflow, +D_ExceptionCodeKind_Win32IntegerDivisionByZero, +D_ExceptionCodeKind_Win32IntegerOverflow, +D_ExceptionCodeKind_Win32PrivilegedInstruction, +D_ExceptionCodeKind_Win32StackOverflow, +D_ExceptionCodeKind_Win32UnableToLocateDLL, +D_ExceptionCodeKind_Win32OrdinalNotFound, +D_ExceptionCodeKind_Win32EntryPointNotFound, +D_ExceptionCodeKind_Win32DLLInitializationFailed, +D_ExceptionCodeKind_Win32FloatingPointSSEMultipleFaults, +D_ExceptionCodeKind_Win32FloatingPointSSEMultipleTraps, +D_ExceptionCodeKind_Win32AssertionFailed, +D_ExceptionCodeKind_Win32ModuleNotFound, +D_ExceptionCodeKind_Win32ProcedureNotFound, +D_ExceptionCodeKind_Win32SanitizerErrorDetected, +D_ExceptionCodeKind_Win32SanitizerRawAccessViolation, +D_ExceptionCodeKind_Win32DirectXDebugLayer, +D_ExceptionCodeKind_COUNT, +} D_ExceptionCodeKind; + +global B32 DEV_always_refresh = 0; +global B32 DEV_simulate_lag = 0; +global B32 DEV_draw_ui_text_pos = 0; +global B32 DEV_draw_ui_focus_debug = 0; +global B32 DEV_draw_ui_box_heatmap = 0; +global B32 DEV_eval_compiler_tooltips = 0; +global B32 DEV_eval_watch_key_tooltips = 0; +global B32 DEV_cmd_context_tooltips = 0; +global B32 DEV_updating_indicator = 0; +struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] = +{ +{&DEV_always_refresh, str8_lit_comp("always_refresh")}, +{&DEV_simulate_lag, str8_lit_comp("simulate_lag")}, +{&DEV_draw_ui_text_pos, str8_lit_comp("draw_ui_text_pos")}, +{&DEV_draw_ui_focus_debug, str8_lit_comp("draw_ui_focus_debug")}, +{&DEV_draw_ui_box_heatmap, str8_lit_comp("draw_ui_box_heatmap")}, +{&DEV_eval_compiler_tooltips, str8_lit_comp("eval_compiler_tooltips")}, +{&DEV_eval_watch_key_tooltips, str8_lit_comp("eval_watch_key_tooltips")}, +{&DEV_cmd_context_tooltips, str8_lit_comp("cmd_context_tooltips")}, +{&DEV_updating_indicator, str8_lit_comp("updating_indicator")}, +}; +C_LINKAGE_BEGIN +extern String8 d_entity_kind_code_name_table[12]; +extern String8 d_entity_kind_display_string_table[12]; +extern U32 d_exception_code_kind_code_table[38]; +extern String8 d_exception_code_kind_display_string_table[38]; +extern String8 d_exception_code_kind_lowercase_code_string_table[38]; +extern B8 d_exception_code_kind_default_enable_table[38]; + +C_LINKAGE_END + +#endif // DBG_ENGINE_META_H diff --git a/src/linker/lnk_io.c b/src/linker/lnk_io.c index f50039df..20e180c0 100644 --- a/src/linker/lnk_io.c +++ b/src/linker/lnk_io.c @@ -111,10 +111,14 @@ lnk_file_open_with_rename_permissions(String8 path) internal B32 lnk_file_set_delete_on_close(File handle, B32 delete_file) { + B32 is_set = 0; #if OS_WINDOWS FILE_DISPOSITION_INFO file_disposition = {0}; file_disposition.DeleteFile = (BOOL)delete_file; - B32 is_set = SetFileInformationByHandle((HANDLE)handle.u64[0], FileDispositionInfo, &file_disposition, sizeof(file_disposition)); + is_set = SetFileInformationByHandle((HANDLE)handle.u64[0], FileDispositionInfo, &file_disposition, sizeof(file_disposition)); +#elif OS_LINUX + // no equivalent + is_set = 1; #else # error "TODO: file rename" #endif @@ -125,6 +129,7 @@ internal B32 lnk_file_rename(File handle, String8 new_name) { Temp scratch = scratch_begin(0,0); + B32 is_renamed = 0; #if OS_WINDOWS String16 new_name16 = str16_from_8(scratch.arena, new_name); @@ -137,9 +142,18 @@ lnk_file_rename(File handle, String8 new_name) rename_info->FileNameLength = new_name16.size * sizeof(new_name16.str[0]); MemoryCopy(rename_info->FileName, new_name16.str, new_name16.size * sizeof(new_name16.str[0])); - B32 is_renamed = SetFileInformationByHandle((HANDLE)handle.u64[0], FileRenameInfo, buffer, buffer_size); + is_renamed = SetFileInformationByHandle((HANDLE)handle.u64[0], FileRenameInfo, buffer, buffer_size); #else -#error "TODO: file rename" + char fd_proc_path[128]; + raddbg_snprintf(fd_proc_path, sizeof(fd_proc_path), "/proc/self/fd/%d", (int)handle.u64[0]); + + U64 path_max = 4096; + char *path = push_array(scratch.arena, char, path_max); + ssize_t path_size = readlink(fd_proc_path, path, path_max); + + if (path_size > 0) { + is_renamed = rename(path, (char *)push_cstr(scratch.arena, new_name).str) == 0; + } #endif scratch_end(scratch); return is_renamed; diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index 41033175..9178874e 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -10513,10 +10513,10 @@ rd_ipc_make_reply_source_location_from_address(Arena *arena, U64 vaddr) { Temp scratch = scratch_begin(&arena, 1); - D_Entity *process = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->process); + D_Entity *process = d_entity_from_handle(rd_base_regs()->process); if(process == &d_entity_nil) { - D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread); + D_Entity *thread = d_entity_from_handle(rd_base_regs()->thread); process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process); }