From 9d60b110f517576b0d80f032ddf1cee963fcc811 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Mon, 19 Jan 2026 08:17:43 +0100 Subject: [PATCH] RemedyBG asks for binary --- src/text_editor/coroutines.cpp | 3 +- src/text_editor/globals.cpp | 2 +- src/text_editor/plugin_remedybg.cpp | 47 ++++++++++++++++++----------- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/text_editor/coroutines.cpp b/src/text_editor/coroutines.cpp index aa93f81..b43831e 100644 --- a/src/text_editor/coroutines.cpp +++ b/src/text_editor/coroutines.cpp @@ -10,8 +10,7 @@ void CoRemove(String name) { IterRemove(ActiveCoroutines) { IterRemovePrepare(ActiveCoroutines); if (it.name == name) { - mco_destroy(it.co); - Release(&it.arena); + CoDestroy(&it); remove_item = true; } } diff --git a/src/text_editor/globals.cpp b/src/text_editor/globals.cpp index e3871b8..a4d9c67 100644 --- a/src/text_editor/globals.cpp +++ b/src/text_editor/globals.cpp @@ -175,5 +175,5 @@ RegisterVariable(String, ProjectDirectory, ""); RegisterVariable(String, VCVarsPath, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"); // PLUGIN_REMEDYBG -RegisterVariable(String, BinaryUnderDebug, "build/te.exe"); +RegisterVariable(String, BinaryUnderDebug, ""); RegisterVariable(String, RemedyBGPath, "remedybg.exe"); \ No newline at end of file diff --git a/src/text_editor/plugin_remedybg.cpp b/src/text_editor/plugin_remedybg.cpp index 85fd7a4..031cd95 100644 --- a/src/text_editor/plugin_remedybg.cpp +++ b/src/text_editor/plugin_remedybg.cpp @@ -2097,7 +2097,7 @@ uint8_t command_buf[COMMAND_BUF_SIZE]; uint8_t reply_buf[REPLY_BUF_SIZE]; ClientContext RDBG_Ctx; -bool RDBG_InitConnection() { +bool RDBG_InitConnection(mco_coro *co) { enum rdbg_CommandResult res; if (RDBG_Ctx.command_pipe_handle != NULL) { enum rdbg_TargetState state; @@ -2106,9 +2106,22 @@ bool RDBG_InitConnection() { return true; } } - Scratch scratch; - String session_name = Format(scratch, "te%llu", GetTimeNanos()); - String remedy_string = Format(scratch, "%S --servername %S", RemedyBGPath, session_name); + + String file = ""; + if (BinaryUnderDebug.len) { + Window *window = GetWindow(PrimaryWindowID); + ResolvedOpen res = ResolveOpen(CoCurr->arena, window, BinaryUnderDebug, ResolveOpenMeta_DontError | ResolveOpenMeta_DontExec); + if (res.kind == OpenKind_Goto) { + file = Intern(&GlobalInternTable, res.path); + } + } + + if (file.len == 0) { + file = QueryUserFile(co); + } + + String session_name = Format(CoCurr->arena, "te%llu", GetTimeNanos()); + String remedy_string = Format(CoCurr->arena, "%S --servername %S", RemedyBGPath, session_name); Exec(NullViewID, true, remedy_string, GetPrimaryDirectory()); MemoryZero(&RDBG_Ctx, sizeof(RDBG_Ctx)); RDBG_Ctx.cmd.data = command_buf; @@ -2136,7 +2149,7 @@ bool RDBG_InitConnection() { MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); rdbg_Id cfg_id; - char *exe = Format(scratch, "%S/%S", ProjectDirectory, BinaryUnderDebug).data; + char *exe = file.data; char *args = NULL; char *work_dir = ProjectDirectory.data; char *env = NULL; @@ -2157,8 +2170,8 @@ bool RDBG_InitConnection() { return true; } -void CMD_StartDebugging() { - bool conn = RDBG_InitConnection(); +void CO_StartDebugging(mco_coro *co) { + bool conn = RDBG_InitConnection(co); if (!conn) { return; } @@ -2193,10 +2206,10 @@ void CMD_StartDebugging() { MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); return; } -} RegisterCommand(CMD_StartDebugging, "f5", "Start debugging, if debugger not active it starts it, uses BinaryUnderDebug"); +} RegisterCoroutineCommand(CO_StartDebugging, "f5", "Start debugging, if debugger not active it starts it, uses BinaryUnderDebug"); -void CMD_RunToLineInDebugger() { - bool conn = RDBG_InitConnection(); +void CO_RunToLineInDebugger(mco_coro *co) { + bool conn = RDBG_InitConnection(co); if (!conn) { return; } @@ -2210,10 +2223,10 @@ void CMD_RunToLineInDebugger() { MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); return; } -} RegisterCommand(CMD_RunToLineInDebugger, "ctrl-f10", "Instruct debugger to execute until line and column under caret"); +} RegisterCoroutineCommand(CO_RunToLineInDebugger, "ctrl-f10", "Instruct debugger to execute until line and column under caret"); -void CMD_StopDebugging() { - bool conn = RDBG_InitConnection(); +void CO_StopDebugging(mco_coro *co) { + bool conn = RDBG_InitConnection(co); if (!conn) { return; } @@ -2225,10 +2238,10 @@ void CMD_StopDebugging() { MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); return; } -} RegisterCommand(CMD_StopDebugging, "shift-f5", "Stop debugging"); +} RegisterCoroutineCommand(CO_StopDebugging, "shift-f5", "Stop debugging"); -void CMD_AddBreakpoint() { - if (!RDBG_InitConnection()) { +void CO_AddBreakpoint(mco_coro *co) { + if (!RDBG_InitConnection(co)) { return; } @@ -2242,7 +2255,7 @@ void CMD_AddBreakpoint() { MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); return; } -} RegisterCommand(CMD_AddBreakpoint, "f9", "Add a breakpoint at filename + line"); +} RegisterCoroutineCommand(CO_AddBreakpoint, "f9", "Add a breakpoint at filename + line"); void QuitDebugger() { if (RDBG_Ctx.command_pipe_handle == NULL) {