diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index 08a5d24b3db9d..7a196820cf744 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -645,25 +645,23 @@ void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) { LLDB_LOG(log, "Debugger connected to process {0}. Image base = {1:x}", debugger->GetProcess().GetProcessId(), image_base); - ModuleSP module; - // During attach, we won't have the executable module, so find it now. - const DWORD pid = debugger->GetProcess().GetProcessId(); - const std::string file_name = GetProcessExecutableName(pid); - if (file_name.empty()) { - return; - } - - FileSpec executable_file(file_name); - FileSystem::Instance().Resolve(executable_file); - ModuleSpec module_spec(executable_file); - Status error; - module = - GetTarget().GetOrCreateModule(module_spec, true /* notify */, &error); + ModuleSP module = GetTarget().GetExecutableModule(); if (!module) { - return; - } + const DWORD pid = debugger->GetProcess().GetProcessId(); + const std::string file_name = GetProcessExecutableName(pid); + if (file_name.empty()) + return; - GetTarget().SetExecutableModule(module, eLoadDependentsNo); + FileSpec executable_file(file_name); + FileSystem::Instance().Resolve(executable_file); + ModuleSpec module_spec(executable_file); + Status error; + module = + GetTarget().GetOrCreateModule(module_spec, /*notify=*/true, &error); + if (!module) + return; + GetTarget().SetExecutableModule(module, eLoadDependentsNo); + } if (auto dyld = GetDynamicLoader()) dyld->OnLoadModule(module, ModuleSpec(), image_base);