Skip to content

[LLDB] Show exit code on Windows if process can't launch #141290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ void ProcessDebugger::OnExitProcess(uint32_t exit_code) {
// of the error otherwise WaitForDebuggerConnection() will be blocked.
// An example of this issue is when a process fails to load a dependent DLL.
if (m_session_data && !m_session_data->m_initial_stop_received) {
Status error(exit_code, eErrorTypeWin32);
Status error = Status::FromErrorStringWithFormatv(
"Process prematurely exited with {0:x}", exit_code);
OnDebuggerError(error, 0);
}
}
Expand Down
5 changes: 5 additions & 0 deletions lldb/test/API/windows/launch/missing-dll/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
C_SOURCES := main.c
DYLIB_C_SOURCES := dummy_dll.c
DYLIB_NAME := dummy_dll

include Makefile.rules
27 changes: 27 additions & 0 deletions lldb/test/API/windows/launch/missing-dll/TestMissingDll.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class MissingDllTestCase(TestBase):
@skipUnlessWindows
def test(self):
"""
Test that lldb reports the application's exit code (STATUS_DLL_NOT_FOUND),
rather than trying to treat it as a Win32 error number.
"""

self.build()
exe = self.getBuildArtifact("a.out")
dll = self.getBuildArtifact("dummy_dll.dll")
self.assertTrue(remove_file(dll))
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)

launch_info = lldb.SBLaunchInfo(None)
launch_info.SetWorkingDirectory(self.get_process_working_directory())

error = lldb.SBError()
target.Launch(launch_info, error)
self.assertFailure(error, "Process prematurely exited with 0xc0000135")
1 change: 1 addition & 0 deletions lldb/test/API/windows/launch/missing-dll/dummy_dll.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__declspec(dllexport) void SomeFunction(void) {}
6 changes: 6 additions & 0 deletions lldb/test/API/windows/launch/missing-dll/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__declspec(dllimport) void SomeFunction(void);

int main(void) {
SomeFunction();
return 0;
}
Loading