lldb::ProcessSP PlatformPOSIX::Attach (ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Error &error) { lldb::ProcessSP process_sp; Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (IsHost()) { if (target == NULL) { TargetSP new_target_sp; error = debugger.GetTargetList().CreateTarget (debugger, NULL, NULL, false, NULL, new_target_sp); target = new_target_sp.get(); if (log) log->Printf ("PlatformPOSIX::%s created new target", __FUNCTION__); } else { error.Clear(); if (log) log->Printf ("PlatformPOSIX::%s target already existed, setting target", __FUNCTION__); } if (target && error.Success()) { debugger.GetTargetList().SetSelectedTarget(target); if (log) { ModuleSP exe_module_sp = target->GetExecutableModule (); log->Printf("PlatformPOSIX::%s set selected target to %p %s", __FUNCTION__, (void *)target, exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str() : "<null>"); } process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), attach_info.GetProcessPluginName(), NULL); if (process_sp) { // Set UnixSignals appropriately. process_sp->SetUnixSignals (Host::GetUnixSignals ()); auto listener_sp = attach_info.GetHijackListener(); if (listener_sp == nullptr) { listener_sp.reset(new Listener("lldb.PlatformPOSIX.attach.hijack")); attach_info.SetHijackListener(listener_sp); } process_sp->HijackProcessEvents(listener_sp.get()); error = process_sp->Attach (attach_info); } } } else { if (m_remote_platform_sp) process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error); else error.SetErrorString ("the platform is not currently connected"); } return process_sp; }