Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb][Windows] Always call SetExecutableModule on debugger connected
In `ProcessWindows::OnDebuggerConnected` (triggered from `CREATE_PROCESS_DEBUG_EVENT`), we should always call `Target::SetExecutableModule` regardless of whether LLDB has already preloaded the executable modules. `SetExecutableModule` has the side effect of clearing the module list of the Target, which help make sure that module #0 is the executable module and the rest of the modules are listed according to the DLL load order in the process (technically this has no real consequences but it seems to make more sense anyway.) It also fixes an issue where the modules preloaded by LLDB will be duplicated when the debuggee process actually loads the DLL. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D134636
- Loading branch information
1 parent
67bcf98
commit fe17e02
Showing
4 changed files
with
44 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__declspec(dllimport) void exportFunc(void); | ||
int main() { exportFunc(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__declspec(dllexport) void exportFunc(void) {} |
24 changes: 24 additions & 0 deletions
24
lldb/test/Shell/Target/dependent-modules-nodupe-windows.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# REQUIRES: system-windows | ||
|
||
# Checks that dependent modules preloaded by LLDB are not duplicated when the | ||
# process actually loads the DLL. | ||
|
||
# RUN: %clang_host -g0 -O0 -shared %S/Inputs/shlib.c -o %t.shlib.dll \ | ||
# RUN: %if windows-msvc %{-Wl,-implib:%t.shlib.lib%} \ | ||
# RUN: %else %{-Wl,--out-implib=%t.shlib.lib%} | ||
# RUN: %clang_host -g0 -O0 %S/Inputs/main.c %t.shlib.lib -o %t.main.exe | ||
# RUN: %lldb -b -o "#before" -o "target modules list" -o "b main" -o run \ | ||
# RUN: -o "#after" -o "target modules list" %t.main.exe | FileCheck %s | ||
|
||
# CHECK-LABEL: #before | ||
# CHECK-NEXT: target modules list | ||
# CHECK-NEXT: .main.exe | ||
# CHECK-NEXT: .shlib.dll | ||
|
||
# CHECK-LABEL: #after | ||
# CHECK-NEXT: target modules list | ||
# CHECK-NEXT: .main.exe | ||
# CHECK-NEXT: ntdll.dll | ||
# CHECK-NEXT: kernel32.dll | ||
# CHECK: .shlib.dll | ||
# CHECK-NOT: .shlib.dll |