From d7161ea6e6896509c6c7623cbd16fba65312df48 Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Thu, 30 Apr 2026 18:33:09 -0700 Subject: [PATCH] clean up stepping test, and remove switch for overriding crash dump path --- .github/workflows/builds.yml | 2 +- src/raddbg/raddbg_core.c | 1 + src/raddbg/raddbg_main.c | 4 +--- src/torture/torture.c | 9 +++++++++ src/torture/torture_dbg.c | 30 ++++++++++++++++-------------- src/torture/torture_dbg.h | 1 + 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 9d2d322e..e3e54643 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -68,7 +68,7 @@ jobs: call build meta raddbg_non_graphical || exit /b 1 call build asan meta torture radlink radbin mule_main mule_module "${{matrix.mode}}" "${{matrix.compiler}}" || exit /b 1 cd build - torture --gen_crash_dump || exit /b 1 + torture --gen_crash_dump -s:Dbg::* || exit /b 1 - name: upload torture crash dumps if: failure() uses: actions/upload-artifact@v7 diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index 0fa56b46..3d8b53c1 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -10437,6 +10437,7 @@ rd_ipc_make_reply_status(Arena *arena) rd_ipc_reply_push_b32 (arena, &s, "ok", 1); rd_ipc_reply_push_b32 (arena, &s, "running", d_ctrl_targets_running()); rd_ipc_reply_push_u64 (arena, &s, "run_gen", d_run_gen()); + rd_ipc_reply_push_u64 (arena, &s, "ip", d_ctrl_last_stop_event().rip_vaddr); rd_ipc_reply_block_end(arena, &s); scratch_end(scratch); return str8_list_join(arena, &s, 0); diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index 33d5e65f..7395e32b 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -862,9 +862,7 @@ entry_point(CmdLine *cmd_line) "--ipc \n" "This will launch the debugger in the non-graphical IPC mode, which is used to communicate with another running instance of the debugger. The debugger instance will launch, send the specified command, then immediately terminate. This may be used by editors or other programs to control the debugger.\n\n" "--gen_crash_dump\n" - "Bypass crash prompt and write dump to --crash_dump_path.\n\n" - "--crash_dump_path:\n" - "Sets crash dump file path.\n\n" + "Generate mini dump on crash.\n\n" )); }break; } diff --git a/src/torture/torture.c b/src/torture/torture.c index 5b2b1aa3..cd09c6ee 100644 --- a/src/torture/torture.c +++ b/src/torture/torture.c @@ -929,6 +929,15 @@ t_entry_point(CmdLine *cmdline) if (!cmd_line_has_flag(cmdline, str8_lit("print_stdout")) && IsDebuggerPresent()) { g_redirect_stdout = 0; } + + // automatically close child processes on exit + { + HANDLE job_handle = CreateJobObjectA(0, 0); + AssertAlways(job_handle != 0); + JOBOBJECT_EXTENDED_LIMIT_INFORMATION job_info = { .BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE }; + AssertAlways(SetInformationJobObject(job_handle, JobObjectExtendedLimitInformation, &job_info, sizeof(job_info))); + AssertAlways(AssignProcessToJobObject(job_handle, GetCurrentProcess())); + } #endif // Handle -out diff --git a/src/torture/torture_dbg.c b/src/torture/torture_dbg.c index cb671482..46a15c7a 100644 --- a/src/torture/torture_dbg.c +++ b/src/torture/torture_dbg.c @@ -40,6 +40,7 @@ t_dbg_send_cmd(String8 cmd, U64 timeout_us, Arena *reply_arena, RD_IpcReply *rep // parse reply Arena *a = reply_arena ? reply_arena : scratch.arena; String8 reply_text = str8_copy(a, g_output); + //fprintf(stderr, "Reply: %.*s\n", str8_varg(reply_text)); RD_IpcReply reply = rd_ipc_mdesk_reply_from_string(a, reply_text); if (rd_ipc_reply_is_ok(&reply) == 0) { goto exit; } if (md_node_is_nil(reply.msg)) { goto exit; } @@ -80,6 +81,7 @@ t_dbg_status(T_DbgStatus *status_out, U64 timeout_us) if ( ! rd_ipc_parse_b32(reply.msg, str8_lit("ok"), &is_ok)) { AssertAlways(0); goto exit; } if ( ! rd_ipc_parse_b32(reply.msg, str8_lit("running"), &status.running)) { AssertAlways(0); goto exit; } if ( ! rd_ipc_parse_int(reply.msg, str8_lit("run_gen"), &status.run_gen)) { AssertAlways(0); goto exit; } + if ( ! rd_ipc_parse_int(reply.msg, str8_lit("ip"), &status.ip)) { AssertAlways(0); goto exit; } if (status_out != 0) { *status_out = status; } exit:; @@ -254,8 +256,7 @@ t_dbg_launch(String8 cmdline, U64 timeout_us) String8 user_path = t_make_file_path(scratch.arena, str8_lit("test.raddbg_user")); String8 project_path = t_make_file_path(scratch.arena, str8_lit("test.raddbg_project")); - String8 crash_dump_path = t_make_file_path(scratch.arena, str8_lit("raddbg_crash_dump.dmp")); - cmdline = str8f(scratch.arena, "--gen_crash_dump --crash_dump_path:\"%S\" --user:\"%S\" --project:\"%S\" %S", crash_dump_path, user_path, project_path, cmdline); + cmdline = str8f(scratch.arena, "--gen_crash_dump --user:\"%S\" --project:\"%S\" %S", user_path, project_path, cmdline); // launch debugger OS_ProcessLaunchParams launch_opts = { @@ -268,15 +269,6 @@ t_dbg_launch(String8 cmdline, U64 timeout_us) if (os_handle_match(dbg_handle, os_handle_zero())) { AssertAlways(0 && "failed to launch debugger"); goto exit; } #if OS_WINDOWS - // automatically close child processes on exit - { - HANDLE job_handle = CreateJobObjectA(0, 0); - AssertAlways(job_handle != 0); - JOBOBJECT_EXTENDED_LIMIT_INFORMATION job_info = { .BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE }; - AssertAlways(SetInformationJobObject(job_handle, JobObjectExtendedLimitInformation, &job_info, sizeof(job_info))); - AssertAlways(AssignProcessToJobObject(job_handle, GetCurrentProcess())); - } - // cache debugger PID g_dbg_pid = GetProcessId((HANDLE)dbg_handle.u64[0]); #elif OS_LINUX @@ -583,9 +575,16 @@ t_dbg_script_invoke(T_DbgScript *script, U64 timeout_us) case T_DbgScriptCmdKind_Run: t_dbg_send_cmd(str8_lit("run"), timeout_us, 0, 0); break; case T_DbgScriptCmdKind_At: { // map IP -> source location - U64 ip = u64_from_str8(t_dbg_value_from_exprf(scratch.arena, "reg:rip"), 10); + U64 ip = u64_from_str8(t_dbg_value_from_exprf(scratch.arena, "reg:rip"), 10); + if (ip == 0) { + fprintf(stderr, "ERROR: invalid IP address: 0x%llx\n", (unsigned long long)ip); + goto exit; + } T_DbgSourceLocation loc = {0}; - AssertAlways(t_dbg_src_line(scratch.arena, ip, &loc, T_Dbg_DefaultTimeout)); + if (t_dbg_src_line(scratch.arena, ip, &loc, T_Dbg_DefaultTimeout) == 0) { + fprintf(stderr, "ERROR: failed to map IP (0x%llx) to source location\n", (unsigned long long)ip); + goto exit; + } // compute line where debugger must be S64 at_line_s64 = (S64)(program->line - program->file->line) + cmd->at.delta; @@ -666,7 +665,10 @@ T_RunSig(dbg_script_runner) } // debugger is ready -- now invoke script - t_dbg_script_invoke(&script, T_Dbg_DefaultTimeout); + if (t_dbg_script_invoke(&script, T_Dbg_DefaultTimeout) == 0) { + fprintf(stderr, "ERROR: %.*s: failed to run to completion\n", str8_varg(user_data)); + T_Ok(0); + } // clean up #if OS_WINDOWS diff --git a/src/torture/torture_dbg.h b/src/torture/torture_dbg.h index ab5fd0ad..7267a98d 100644 --- a/src/torture/torture_dbg.h +++ b/src/torture/torture_dbg.h @@ -111,6 +111,7 @@ typedef struct { B32 running; U64 run_gen; + U64 ip; } T_DbgStatus; typedef struct