Skip to content

Commit 31aab0a

Browse files
committed
[LLDB] Show exit code on Windows if process can't launch
1 parent 441b967 commit 31aab0a

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ void ProcessDebugger::OnExitProcess(uint32_t exit_code) {
483483
// of the error otherwise WaitForDebuggerConnection() will be blocked.
484484
// An example of this issue is when a process fails to load a dependent DLL.
485485
if (m_session_data && !m_session_data->m_initial_stop_received) {
486-
Status error(exit_code, eErrorTypeWin32);
486+
Status error = Status::FromErrorStringWithFormatv(
487+
"Process prematurely exited with {0:x}", exit_code);
487488
OnDebuggerError(error, 0);
488489
}
489490
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
C_SOURCES := main.c
2+
DYLIB_C_SOURCES := dummy_dll.c
3+
DYLIB_NAME := dummy_dll
4+
5+
include Makefile.rules
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import lldb
2+
from lldbsuite.test.decorators import *
3+
from lldbsuite.test.lldbtest import *
4+
from lldbsuite.test import lldbutil
5+
6+
7+
class MissingDllTestCase(TestBase):
8+
@skipUnlessWindows
9+
def test(self):
10+
self.build()
11+
exe = self.getBuildArtifact("a.out")
12+
dll = self.getBuildArtifact("dummy_dll.dll")
13+
self.assertTrue(remove_file(dll))
14+
target = self.dbg.CreateTarget(exe)
15+
self.assertTrue(target, VALID_TARGET)
16+
17+
launch_info = lldb.SBLaunchInfo(None)
18+
launch_info.SetWorkingDirectory(self.get_process_working_directory())
19+
20+
error = lldb.SBError()
21+
target.Launch(launch_info, error)
22+
self.assertFailure(error, "Process prematurely exited with 0xc0000135")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__declspec(dllexport) void SomeFunction(void) {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__declspec(dllimport) void SomeFunction(void);
2+
3+
int main(void) {
4+
SomeFunction();
5+
return 0;
6+
}

0 commit comments

Comments
 (0)