1e996fd30SGreg Clayton //===-- PlatformLinux.cpp ---------------------------------------*- C++ -*-===// 2e996fd30SGreg Clayton // 3e996fd30SGreg Clayton // The LLVM Compiler Infrastructure 4e996fd30SGreg Clayton // 5e996fd30SGreg Clayton // This file is distributed under the University of Illinois Open Source 6e996fd30SGreg Clayton // License. See LICENSE.TXT for details. 7e996fd30SGreg Clayton // 8e996fd30SGreg Clayton //===----------------------------------------------------------------------===// 9e996fd30SGreg Clayton 10*93a64300SDaniel Malea #include "lldb/lldb-python.h" 11*93a64300SDaniel Malea 12e996fd30SGreg Clayton #include "PlatformLinux.h" 13e996fd30SGreg Clayton 14e996fd30SGreg Clayton // C Includes 15ecc11474SStephen Wilson #include <stdio.h> 16ecc11474SStephen Wilson #include <sys/utsname.h> 17ecc11474SStephen Wilson 18e996fd30SGreg Clayton // C++ Includes 19e996fd30SGreg Clayton // Other libraries and framework includes 20e996fd30SGreg Clayton // Project includes 21e996fd30SGreg Clayton #include "lldb/Core/Error.h" 2228041352SGreg Clayton #include "lldb/Core/Debugger.h" 23e996fd30SGreg Clayton #include "lldb/Core/Module.h" 24e996fd30SGreg Clayton #include "lldb/Core/ModuleList.h" 251f746071SGreg Clayton #include "lldb/Core/ModuleSpec.h" 26ecc11474SStephen Wilson #include "lldb/Core/PluginManager.h" 27e996fd30SGreg Clayton #include "lldb/Core/StreamString.h" 28e996fd30SGreg Clayton #include "lldb/Host/FileSpec.h" 29e996fd30SGreg Clayton #include "lldb/Host/Host.h" 30ecc11474SStephen Wilson #include "lldb/Target/Target.h" 31e996fd30SGreg Clayton #include "lldb/Target/Process.h" 32e996fd30SGreg Clayton 33e996fd30SGreg Clayton using namespace lldb; 34e996fd30SGreg Clayton using namespace lldb_private; 35e996fd30SGreg Clayton 3628041352SGreg Clayton static uint32_t g_initialize_count = 0; 3728041352SGreg Clayton 38ecc11474SStephen Wilson Platform * 39b3a40ba8SGreg Clayton PlatformLinux::CreateInstance (bool force, const ArchSpec *arch) 40ecc11474SStephen Wilson { 41b3a40ba8SGreg Clayton bool create = force; 42b3a40ba8SGreg Clayton if (create == false && arch && arch->IsValid()) 43b3a40ba8SGreg Clayton { 44b3a40ba8SGreg Clayton const llvm::Triple &triple = arch->GetTriple(); 4570512317SGreg Clayton switch (triple.getVendor()) 4670512317SGreg Clayton { 4770512317SGreg Clayton case llvm::Triple::PC: 48b3a40ba8SGreg Clayton create = true; 4970512317SGreg Clayton break; 5070512317SGreg Clayton 51dbc6c0bbSGreg Clayton #if defined(__linux__) 52dbc6c0bbSGreg Clayton // Only accept "unknown" for the vendor if the host is linux and 53dbc6c0bbSGreg Clayton // it "unknown" wasn't specified (it was just returned becasue it 54dbc6c0bbSGreg Clayton // was NOT specified_ 5570512317SGreg Clayton case llvm::Triple::UnknownArch: 5670512317SGreg Clayton create = !arch->TripleVendorWasSpecified(); 5770512317SGreg Clayton break; 58dbc6c0bbSGreg Clayton #endif 5970512317SGreg Clayton default: 6070512317SGreg Clayton break; 6170512317SGreg Clayton } 6270512317SGreg Clayton 6370512317SGreg Clayton if (create) 6470512317SGreg Clayton { 6570512317SGreg Clayton switch (triple.getOS()) 6670512317SGreg Clayton { 6770512317SGreg Clayton case llvm::Triple::Linux: 6870512317SGreg Clayton break; 6970512317SGreg Clayton 70dbc6c0bbSGreg Clayton #if defined(__linux__) 71dbc6c0bbSGreg Clayton // Only accept "unknown" for the OS if the host is linux and 72dbc6c0bbSGreg Clayton // it "unknown" wasn't specified (it was just returned becasue it 73dbc6c0bbSGreg Clayton // was NOT specified) 7470512317SGreg Clayton case llvm::Triple::UnknownOS: 7570512317SGreg Clayton create = !arch->TripleOSWasSpecified(); 7670512317SGreg Clayton break; 77dbc6c0bbSGreg Clayton #endif 7870512317SGreg Clayton default: 7970512317SGreg Clayton create = false; 8070512317SGreg Clayton break; 8170512317SGreg Clayton } 8270512317SGreg Clayton } 83b3a40ba8SGreg Clayton } 84b3a40ba8SGreg Clayton if (create) 8528041352SGreg Clayton return new PlatformLinux(true); 86b3a40ba8SGreg Clayton return NULL; 87ecc11474SStephen Wilson } 88ecc11474SStephen Wilson 89ecc11474SStephen Wilson const char * 90ecc11474SStephen Wilson PlatformLinux::GetPluginNameStatic() 91ecc11474SStephen Wilson { 92ecc11474SStephen Wilson return "plugin.platform.linux"; 93ecc11474SStephen Wilson } 94ecc11474SStephen Wilson 95ecc11474SStephen Wilson const char * 9628041352SGreg Clayton PlatformLinux::GetShortPluginNameStatic (bool is_host) 97ecc11474SStephen Wilson { 9828041352SGreg Clayton if (is_host) 9928041352SGreg Clayton return Platform::GetHostPlatformName (); 10028041352SGreg Clayton else 10128041352SGreg Clayton return "remote-linux"; 10228041352SGreg Clayton } 10328041352SGreg Clayton 10428041352SGreg Clayton const char * 10528041352SGreg Clayton PlatformLinux::GetPluginDescriptionStatic (bool is_host) 10628041352SGreg Clayton { 10728041352SGreg Clayton if (is_host) 10828041352SGreg Clayton return "Local Linux user platform plug-in."; 10928041352SGreg Clayton else 11028041352SGreg Clayton return "Remote Linux user platform plug-in."; 111ecc11474SStephen Wilson } 112ecc11474SStephen Wilson 113e996fd30SGreg Clayton void 114e996fd30SGreg Clayton PlatformLinux::Initialize () 115e996fd30SGreg Clayton { 11628041352SGreg Clayton if (g_initialize_count++ == 0) 117ecc11474SStephen Wilson { 11828041352SGreg Clayton #if defined(__linux__) 11928041352SGreg Clayton PlatformSP default_platform_sp (new PlatformLinux(true)); 12028041352SGreg Clayton default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); 121e996fd30SGreg Clayton Platform::SetDefaultPlatform (default_platform_sp); 12228041352SGreg Clayton #endif 12328041352SGreg Clayton PluginManager::RegisterPlugin(PlatformLinux::GetShortPluginNameStatic(false), 12428041352SGreg Clayton PlatformLinux::GetPluginDescriptionStatic(false), 12528041352SGreg Clayton PlatformLinux::CreateInstance); 126ecc11474SStephen Wilson } 127e996fd30SGreg Clayton } 128e996fd30SGreg Clayton 129e996fd30SGreg Clayton void 130e996fd30SGreg Clayton PlatformLinux::Terminate () 131e996fd30SGreg Clayton { 13228041352SGreg Clayton if (g_initialize_count > 0) 13328041352SGreg Clayton { 13428041352SGreg Clayton if (--g_initialize_count == 0) 13528041352SGreg Clayton { 13628041352SGreg Clayton PluginManager::UnregisterPlugin (PlatformLinux::CreateInstance); 137e996fd30SGreg Clayton } 13828041352SGreg Clayton } 13928041352SGreg Clayton } 140e996fd30SGreg Clayton 141e996fd30SGreg Clayton Error 142e996fd30SGreg Clayton PlatformLinux::ResolveExecutable (const FileSpec &exe_file, 143e996fd30SGreg Clayton const ArchSpec &exe_arch, 144ea5e0cc3SGreg Clayton lldb::ModuleSP &exe_module_sp, 145ea5e0cc3SGreg Clayton const FileSpecList *module_search_paths_ptr) 146e996fd30SGreg Clayton { 147e996fd30SGreg Clayton Error error; 148e996fd30SGreg Clayton // Nothing special to do here, just use the actual file and architecture 149e996fd30SGreg Clayton 15028041352SGreg Clayton char exe_path[PATH_MAX]; 151e996fd30SGreg Clayton FileSpec resolved_exe_file (exe_file); 152e996fd30SGreg Clayton 15328041352SGreg Clayton if (IsHost()) 15428041352SGreg Clayton { 15528041352SGreg Clayton // If we have "ls" as the exe_file, resolve the executable location based on 156e996fd30SGreg Clayton // the current path variables 157e996fd30SGreg Clayton if (!resolved_exe_file.Exists()) 15828041352SGreg Clayton { 15928041352SGreg Clayton exe_file.GetPath(exe_path, sizeof(exe_path)); 16028041352SGreg Clayton resolved_exe_file.SetFile(exe_path, true); 16128041352SGreg Clayton } 16228041352SGreg Clayton 16328041352SGreg Clayton if (!resolved_exe_file.Exists()) 164e996fd30SGreg Clayton resolved_exe_file.ResolveExecutableLocation (); 165e996fd30SGreg Clayton 16628041352SGreg Clayton if (resolved_exe_file.Exists()) 16728041352SGreg Clayton error.Clear(); 16828041352SGreg Clayton else 16928041352SGreg Clayton { 17028041352SGreg Clayton exe_file.GetPath(exe_path, sizeof(exe_path)); 17128041352SGreg Clayton error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path); 17228041352SGreg Clayton } 17328041352SGreg Clayton } 17428041352SGreg Clayton else 17528041352SGreg Clayton { 17628041352SGreg Clayton if (m_remote_platform_sp) 17728041352SGreg Clayton { 17828041352SGreg Clayton error = m_remote_platform_sp->ResolveExecutable (exe_file, 17928041352SGreg Clayton exe_arch, 1800c90ef47SGreg Clayton exe_module_sp, 1810c90ef47SGreg Clayton NULL); 18228041352SGreg Clayton } 18328041352SGreg Clayton else 18428041352SGreg Clayton { 18528041352SGreg Clayton // We may connect to a process and use the provided executable (Don't use local $PATH). 186e996fd30SGreg Clayton 187e996fd30SGreg Clayton if (resolved_exe_file.Exists()) 18828041352SGreg Clayton error.Clear(); 18928041352SGreg Clayton else 19028041352SGreg Clayton error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path); 19128041352SGreg Clayton } 19228041352SGreg Clayton } 19328041352SGreg Clayton 19428041352SGreg Clayton if (error.Success()) 195e996fd30SGreg Clayton { 196ea5e0cc3SGreg Clayton ModuleSpec module_spec (resolved_exe_file, exe_arch); 197e996fd30SGreg Clayton if (exe_arch.IsValid()) 198e996fd30SGreg Clayton { 199ea5e0cc3SGreg Clayton error = ModuleList::GetSharedModule (module_spec, 200e996fd30SGreg Clayton exe_module_sp, 201e996fd30SGreg Clayton NULL, 2020c90ef47SGreg Clayton NULL, 203e996fd30SGreg Clayton NULL); 204e996fd30SGreg Clayton 205e635db49SSean Callanan // TODO find out why exe_module_sp might be NULL 206e635db49SSean Callanan if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL) 207e996fd30SGreg Clayton { 208e996fd30SGreg Clayton exe_module_sp.reset(); 209e996fd30SGreg Clayton error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain the architecture %s", 210e996fd30SGreg Clayton exe_file.GetDirectory().AsCString(""), 211e996fd30SGreg Clayton exe_file.GetDirectory() ? "/" : "", 212e996fd30SGreg Clayton exe_file.GetFilename().AsCString(""), 213e996fd30SGreg Clayton exe_arch.GetArchitectureName()); 214e996fd30SGreg Clayton } 215e996fd30SGreg Clayton } 216e996fd30SGreg Clayton else 217e996fd30SGreg Clayton { 218e996fd30SGreg Clayton // No valid architecture was specified, ask the platform for 219e996fd30SGreg Clayton // the architectures that we should be using (in the correct order) 220e996fd30SGreg Clayton // and see if we can find a match that way 221e996fd30SGreg Clayton StreamString arch_names; 222ea5e0cc3SGreg Clayton for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx) 223e996fd30SGreg Clayton { 224ea5e0cc3SGreg Clayton error = ModuleList::GetSharedModule (module_spec, 225e996fd30SGreg Clayton exe_module_sp, 226e996fd30SGreg Clayton NULL, 2270c90ef47SGreg Clayton NULL, 228e996fd30SGreg Clayton NULL); 229e996fd30SGreg Clayton // Did we find an executable using one of the 230e996fd30SGreg Clayton if (error.Success()) 231e996fd30SGreg Clayton { 232e996fd30SGreg Clayton if (exe_module_sp && exe_module_sp->GetObjectFile()) 233e996fd30SGreg Clayton break; 234e996fd30SGreg Clayton else 235e996fd30SGreg Clayton error.SetErrorToGenericError(); 236e996fd30SGreg Clayton } 237e996fd30SGreg Clayton 238e996fd30SGreg Clayton if (idx > 0) 239e996fd30SGreg Clayton arch_names.PutCString (", "); 240ea5e0cc3SGreg Clayton arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName()); 241e996fd30SGreg Clayton } 242e996fd30SGreg Clayton 243e996fd30SGreg Clayton if (error.Fail() || !exe_module_sp) 244e996fd30SGreg Clayton { 245e996fd30SGreg Clayton error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain any '%s' platform architectures: %s", 246e996fd30SGreg Clayton exe_file.GetDirectory().AsCString(""), 247e996fd30SGreg Clayton exe_file.GetDirectory() ? "/" : "", 248e996fd30SGreg Clayton exe_file.GetFilename().AsCString(""), 249e996fd30SGreg Clayton GetShortPluginName(), 250e996fd30SGreg Clayton arch_names.GetString().c_str()); 251e996fd30SGreg Clayton } 252e996fd30SGreg Clayton } 253e996fd30SGreg Clayton } 254e996fd30SGreg Clayton 255e996fd30SGreg Clayton return error; 256e996fd30SGreg Clayton } 257e996fd30SGreg Clayton 258e996fd30SGreg Clayton Error 25978decfd0SStephen Wilson PlatformLinux::GetFile (const FileSpec &platform_file, 26028041352SGreg Clayton const UUID *uuid_ptr, FileSpec &local_file) 261e996fd30SGreg Clayton { 26228041352SGreg Clayton if (IsRemote()) 26328041352SGreg Clayton { 26428041352SGreg Clayton if (m_remote_platform_sp) 26528041352SGreg Clayton return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file); 26628041352SGreg Clayton } 26728041352SGreg Clayton 268e996fd30SGreg Clayton // Default to the local case 269e996fd30SGreg Clayton local_file = platform_file; 270e996fd30SGreg Clayton return Error(); 271e996fd30SGreg Clayton } 272e996fd30SGreg Clayton 273e996fd30SGreg Clayton 274e996fd30SGreg Clayton //------------------------------------------------------------------ 275e996fd30SGreg Clayton /// Default Constructor 276e996fd30SGreg Clayton //------------------------------------------------------------------ 27728041352SGreg Clayton PlatformLinux::PlatformLinux (bool is_host) : 27828041352SGreg Clayton Platform(is_host), // This is the local host platform 27928041352SGreg Clayton m_remote_platform_sp () 280e996fd30SGreg Clayton { 281e996fd30SGreg Clayton } 282e996fd30SGreg Clayton 283e996fd30SGreg Clayton //------------------------------------------------------------------ 284e996fd30SGreg Clayton /// Destructor. 285e996fd30SGreg Clayton /// 286e996fd30SGreg Clayton /// The destructor is virtual since this class is designed to be 287e996fd30SGreg Clayton /// inherited from by the plug-in instance. 288e996fd30SGreg Clayton //------------------------------------------------------------------ 289e996fd30SGreg Clayton PlatformLinux::~PlatformLinux() 290e996fd30SGreg Clayton { 291e996fd30SGreg Clayton } 292e996fd30SGreg Clayton 293e996fd30SGreg Clayton bool 29413e8e1c3SJohnny Chen PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) 295e996fd30SGreg Clayton { 29628041352SGreg Clayton bool success = false; 29728041352SGreg Clayton if (IsHost()) 29828041352SGreg Clayton { 29928041352SGreg Clayton success = Platform::GetProcessInfo (pid, process_info); 30028041352SGreg Clayton } 30128041352SGreg Clayton else 30228041352SGreg Clayton { 30328041352SGreg Clayton if (m_remote_platform_sp) 30428041352SGreg Clayton success = m_remote_platform_sp->GetProcessInfo (pid, process_info); 30528041352SGreg Clayton } 30628041352SGreg Clayton return success; 307e996fd30SGreg Clayton } 308e996fd30SGreg Clayton 309e996fd30SGreg Clayton bool 310e996fd30SGreg Clayton PlatformLinux::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) 311e996fd30SGreg Clayton { 312e996fd30SGreg Clayton if (idx == 0) 313e996fd30SGreg Clayton { 314e996fd30SGreg Clayton arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture); 315e996fd30SGreg Clayton return arch.IsValid(); 316e996fd30SGreg Clayton } 317542e4075SGreg Clayton else if (idx == 1) 318542e4075SGreg Clayton { 319542e4075SGreg Clayton // If the default host architecture is 64-bit, look for a 32-bit variant 320542e4075SGreg Clayton ArchSpec hostArch 321542e4075SGreg Clayton = Host::GetArchitecture(Host::eSystemDefaultArchitecture); 322542e4075SGreg Clayton if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) 323542e4075SGreg Clayton { 324542e4075SGreg Clayton arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32); 325542e4075SGreg Clayton return arch.IsValid(); 326542e4075SGreg Clayton } 327542e4075SGreg Clayton } 328e996fd30SGreg Clayton return false; 329e996fd30SGreg Clayton } 330ecc11474SStephen Wilson 331ecc11474SStephen Wilson void 332ecc11474SStephen Wilson PlatformLinux::GetStatus (Stream &strm) 333ecc11474SStephen Wilson { 334ecc11474SStephen Wilson struct utsname un; 335ecc11474SStephen Wilson 336ecc11474SStephen Wilson if (uname(&un)) { 337ecc11474SStephen Wilson strm << "Linux"; 338ecc11474SStephen Wilson return; 339ecc11474SStephen Wilson } 340ecc11474SStephen Wilson 341ecc11474SStephen Wilson strm << un.sysname << ' ' << un.release << ' ' << un.version << '\n'; 342ecc11474SStephen Wilson } 343ecc11474SStephen Wilson 344ecc11474SStephen Wilson size_t 345ecc11474SStephen Wilson PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target, 346ecc11474SStephen Wilson BreakpointSite *bp_site) 347ecc11474SStephen Wilson { 348ecc11474SStephen Wilson ArchSpec arch = target.GetArchitecture(); 34928041352SGreg Clayton const uint8_t *trap_opcode = NULL; 35028041352SGreg Clayton size_t trap_opcode_size = 0; 351ecc11474SStephen Wilson 352ecc11474SStephen Wilson switch (arch.GetCore()) 353ecc11474SStephen Wilson { 354ecc11474SStephen Wilson default: 355ecc11474SStephen Wilson assert(false && "CPU type not supported!"); 356ecc11474SStephen Wilson break; 357ecc11474SStephen Wilson 358ecc11474SStephen Wilson case ArchSpec::eCore_x86_32_i386: 359ecc11474SStephen Wilson case ArchSpec::eCore_x86_64_x86_64: 36028041352SGreg Clayton { 36128041352SGreg Clayton static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC }; 36228041352SGreg Clayton trap_opcode = g_i386_breakpoint_opcode; 36328041352SGreg Clayton trap_opcode_size = sizeof(g_i386_breakpoint_opcode); 36428041352SGreg Clayton } 365ecc11474SStephen Wilson break; 366ecc11474SStephen Wilson } 367ecc11474SStephen Wilson 36828041352SGreg Clayton if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size)) 36928041352SGreg Clayton return trap_opcode_size; 37028041352SGreg Clayton return 0; 37128041352SGreg Clayton } 37228041352SGreg Clayton 37328041352SGreg Clayton Error 37428041352SGreg Clayton PlatformLinux::LaunchProcess (ProcessLaunchInfo &launch_info) 37528041352SGreg Clayton { 37628041352SGreg Clayton Error error; 37728041352SGreg Clayton 37828041352SGreg Clayton if (IsHost()) 37928041352SGreg Clayton { 38028041352SGreg Clayton if (launch_info.GetFlags().Test (eLaunchFlagLaunchInShell)) 38128041352SGreg Clayton { 38228041352SGreg Clayton const bool is_localhost = true; 383d1cf11a7SGreg Clayton const bool will_debug = launch_info.GetFlags().Test(eLaunchFlagDebug); 384d1cf11a7SGreg Clayton const bool first_arg_is_full_shell_command = false; 385d1cf11a7SGreg Clayton if (!launch_info.ConvertArgumentsForLaunchingInShell (error, 386d1cf11a7SGreg Clayton is_localhost, 387d1cf11a7SGreg Clayton will_debug, 388d1cf11a7SGreg Clayton first_arg_is_full_shell_command)) 38928041352SGreg Clayton return error; 39028041352SGreg Clayton } 39128041352SGreg Clayton error = Platform::LaunchProcess (launch_info); 39228041352SGreg Clayton } 39328041352SGreg Clayton else 39428041352SGreg Clayton { 39528041352SGreg Clayton error.SetErrorString ("the platform is not currently connected"); 39628041352SGreg Clayton } 39728041352SGreg Clayton return error; 398ecc11474SStephen Wilson } 39913e8e1c3SJohnny Chen 40013e8e1c3SJohnny Chen lldb::ProcessSP 401fb2b629dSPeter Collingbourne PlatformLinux::Attach(ProcessAttachInfo &attach_info, 40213e8e1c3SJohnny Chen Debugger &debugger, 40313e8e1c3SJohnny Chen Target *target, 40413e8e1c3SJohnny Chen Listener &listener, 40513e8e1c3SJohnny Chen Error &error) 40613e8e1c3SJohnny Chen { 40728041352SGreg Clayton lldb::ProcessSP process_sp; 40828041352SGreg Clayton if (IsHost()) 40928041352SGreg Clayton { 41028041352SGreg Clayton if (target == NULL) 41128041352SGreg Clayton { 41228041352SGreg Clayton TargetSP new_target_sp; 41328041352SGreg Clayton ArchSpec emptyArchSpec; 41428041352SGreg Clayton 41528041352SGreg Clayton error = debugger.GetTargetList().CreateTarget (debugger, 416a0ca6601SGreg Clayton NULL, 41728041352SGreg Clayton emptyArchSpec, 41828041352SGreg Clayton false, 41928041352SGreg Clayton m_remote_platform_sp, 42028041352SGreg Clayton new_target_sp); 42128041352SGreg Clayton target = new_target_sp.get(); 42228041352SGreg Clayton } 42328041352SGreg Clayton else 42428041352SGreg Clayton error.Clear(); 42528041352SGreg Clayton 42628041352SGreg Clayton if (target && error.Success()) 42728041352SGreg Clayton { 42828041352SGreg Clayton debugger.GetTargetList().SetSelectedTarget(target); 42928041352SGreg Clayton 4300c90ef47SGreg Clayton process_sp = target->CreateProcess (listener, 4310c90ef47SGreg Clayton attach_info.GetProcessPluginName(), 4320c90ef47SGreg Clayton NULL); 43328041352SGreg Clayton 43428041352SGreg Clayton if (process_sp) 43528041352SGreg Clayton error = process_sp->Attach (attach_info); 43628041352SGreg Clayton } 43728041352SGreg Clayton } 43828041352SGreg Clayton else 43928041352SGreg Clayton { 44028041352SGreg Clayton if (m_remote_platform_sp) 44128041352SGreg Clayton process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error); 44228041352SGreg Clayton else 44328041352SGreg Clayton error.SetErrorString ("the platform is not currently connected"); 44428041352SGreg Clayton } 44528041352SGreg Clayton return process_sp; 44613e8e1c3SJohnny Chen } 447