[lldb][Windows] Always call SetExecutableModule on debugger connected
authorAlvin Wong <alvin@alvinhc.com>
Wed, 28 Sep 2022 09:58:51 +0000 (12:58 +0300)
committerMartin Storsjö <martin@martin.st>
Fri, 30 Sep 2022 10:51:56 +0000 (13:51 +0300)
commitfe17e026959cc263c12fafa3a8e9e83503f9a18b
tree89367dea64f96cf5825b6fe98144413d172f9094
parent67bcf9825ad8e41c93c4db06e98f62ee66b4e2cc
[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
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/test/Shell/Target/Inputs/main.c [new file with mode: 0644]
lldb/test/Shell/Target/Inputs/shlib.c [new file with mode: 0644]
lldb/test/Shell/Target/dependent-modules-nodupe-windows.test [new file with mode: 0644]