void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) { DebuggerThreadSP debugger = m_session_data->m_debugger; WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Debugger connected to process %I64u. Image base = 0x%I64x", debugger->GetProcess().GetProcessId(), image_base); ModuleSP module = GetTarget().GetExecutableModule(); if (!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, true); ModuleSpec module_spec(executable_file); Error error; module = GetTarget().GetSharedModule(module_spec, &error); if (!module) { return; } GetTarget().SetExecutableModule(module, false); } bool load_addr_changed; module->SetLoadAddress(GetTarget(), image_base, false, load_addr_changed); ModuleList loaded_modules; loaded_modules.Append(module); GetTarget().ModulesDidLoad(loaded_modules); // Add the main executable module to the list of pending module loads. We can't call // GetTarget().ModulesDidLoad() here because we still haven't returned from DoLaunch() / DoAttach() yet // so the target may not have set the process instance to `this` yet. llvm::sys::ScopedLock lock(m_mutex); const HostThreadWindows &wmain_thread = debugger->GetMainThread().GetNativeThread(); m_session_data->m_new_threads[wmain_thread.GetThreadId()] = debugger->GetMainThread(); }
void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) { // Either we successfully attached to an existing process, or we successfully launched a new // process under the debugger. ModuleSP module = GetTarget().GetExecutableModule(); bool load_addr_changed; module->SetLoadAddress(GetTarget(), image_base, false, load_addr_changed); // Notify the target that the executable module has loaded. This will cause any pending // breakpoints to be resolved to explicit brekapoint sites. ModuleList loaded_modules; loaded_modules.Append(module); GetTarget().ModulesDidLoad(loaded_modules); llvm::sys::ScopedLock lock(m_mutex); DebuggerThreadSP debugger = m_session_data->m_debugger; const HostThreadWindows &wmain_thread = debugger->GetMainThread().GetNativeThread(); m_session_data->m_new_threads[wmain_thread.GetThreadId()] = debugger->GetMainThread(); }