RemedyBG asks for binary

This commit is contained in:
Krzosa Karol
2026-01-19 08:17:43 +01:00
parent 70f28de0e1
commit 9d60b110f5
3 changed files with 32 additions and 20 deletions

View File

@@ -10,8 +10,7 @@ void CoRemove(String name) {
IterRemove(ActiveCoroutines) { IterRemove(ActiveCoroutines) {
IterRemovePrepare(ActiveCoroutines); IterRemovePrepare(ActiveCoroutines);
if (it.name == name) { if (it.name == name) {
mco_destroy(it.co); CoDestroy(&it);
Release(&it.arena);
remove_item = true; remove_item = true;
} }
} }

View File

@@ -175,5 +175,5 @@ RegisterVariable(String, ProjectDirectory, "");
RegisterVariable(String, VCVarsPath, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"); RegisterVariable(String, VCVarsPath, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat");
// PLUGIN_REMEDYBG // PLUGIN_REMEDYBG
RegisterVariable(String, BinaryUnderDebug, "build/te.exe"); RegisterVariable(String, BinaryUnderDebug, "");
RegisterVariable(String, RemedyBGPath, "remedybg.exe"); RegisterVariable(String, RemedyBGPath, "remedybg.exe");

View File

@@ -2097,7 +2097,7 @@ uint8_t command_buf[COMMAND_BUF_SIZE];
uint8_t reply_buf[REPLY_BUF_SIZE]; uint8_t reply_buf[REPLY_BUF_SIZE];
ClientContext RDBG_Ctx; ClientContext RDBG_Ctx;
bool RDBG_InitConnection() { bool RDBG_InitConnection(mco_coro *co) {
enum rdbg_CommandResult res; enum rdbg_CommandResult res;
if (RDBG_Ctx.command_pipe_handle != NULL) { if (RDBG_Ctx.command_pipe_handle != NULL) {
enum rdbg_TargetState state; enum rdbg_TargetState state;
@@ -2106,9 +2106,22 @@ bool RDBG_InitConnection() {
return true; return true;
} }
} }
Scratch scratch;
String session_name = Format(scratch, "te%llu", GetTimeNanos()); String file = "";
String remedy_string = Format(scratch, "%S --servername %S", RemedyBGPath, session_name); 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()); Exec(NullViewID, true, remedy_string, GetPrimaryDirectory());
MemoryZero(&RDBG_Ctx, sizeof(RDBG_Ctx)); MemoryZero(&RDBG_Ctx, sizeof(RDBG_Ctx));
RDBG_Ctx.cmd.data = command_buf; RDBG_Ctx.cmd.data = command_buf;
@@ -2136,7 +2149,7 @@ bool RDBG_InitConnection() {
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
rdbg_Id cfg_id; rdbg_Id cfg_id;
char *exe = Format(scratch, "%S/%S", ProjectDirectory, BinaryUnderDebug).data; char *exe = file.data;
char *args = NULL; char *args = NULL;
char *work_dir = ProjectDirectory.data; char *work_dir = ProjectDirectory.data;
char *env = NULL; char *env = NULL;
@@ -2157,8 +2170,8 @@ bool RDBG_InitConnection() {
return true; return true;
} }
void CMD_StartDebugging() { void CO_StartDebugging(mco_coro *co) {
bool conn = RDBG_InitConnection(); bool conn = RDBG_InitConnection(co);
if (!conn) { if (!conn) {
return; return;
} }
@@ -2193,10 +2206,10 @@ void CMD_StartDebugging() {
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
return; 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() { void CO_RunToLineInDebugger(mco_coro *co) {
bool conn = RDBG_InitConnection(); bool conn = RDBG_InitConnection(co);
if (!conn) { if (!conn) {
return; return;
} }
@@ -2210,10 +2223,10 @@ void CMD_RunToLineInDebugger() {
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
return; 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() { void CO_StopDebugging(mco_coro *co) {
bool conn = RDBG_InitConnection(); bool conn = RDBG_InitConnection(co);
if (!conn) { if (!conn) {
return; return;
} }
@@ -2225,10 +2238,10 @@ void CMD_StopDebugging() {
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
return; return;
} }
} RegisterCommand(CMD_StopDebugging, "shift-f5", "Stop debugging"); } RegisterCoroutineCommand(CO_StopDebugging, "shift-f5", "Stop debugging");
void CMD_AddBreakpoint() { void CO_AddBreakpoint(mco_coro *co) {
if (!RDBG_InitConnection()) { if (!RDBG_InitConnection(co)) {
return; return;
} }
@@ -2242,7 +2255,7 @@ void CMD_AddBreakpoint() {
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
return; return;
} }
} RegisterCommand(CMD_AddBreakpoint, "f9", "Add a breakpoint at filename + line"); } RegisterCoroutineCommand(CO_AddBreakpoint, "f9", "Add a breakpoint at filename + line");
void QuitDebugger() { void QuitDebugger() {
if (RDBG_Ctx.command_pipe_handle == NULL) { if (RDBG_Ctx.command_pipe_handle == NULL) {