diff options
| author | Ed Maste <emaste@FreeBSD.org> | 2015-02-06 21:38:51 +0000 |
|---|---|---|
| committer | Ed Maste <emaste@FreeBSD.org> | 2015-02-06 21:38:51 +0000 |
| commit | 205afe679855a4ce8149cdaa94d3f0868ce796dc (patch) | |
| tree | 09bc83f73246ee3c7a779605cd0122093d2a8a19 /source/Plugins/Platform | |
| parent | 0cac4ca3916ac24ab6139d03cbfd18db9e715bfe (diff) | |
Notes
Diffstat (limited to 'source/Plugins/Platform')
6 files changed, 216 insertions, 86 deletions
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index 7aa940a530b4..3b38a5819934 100644 --- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -32,7 +32,7 @@ using namespace lldb; using namespace lldb_private; -Platform * +PlatformSP PlatformFreeBSD::CreateInstance (bool force, const lldb_private::ArchSpec *arch) { // The only time we create an instance is when we are creating a remote @@ -84,8 +84,8 @@ PlatformFreeBSD::CreateInstance (bool force, const lldb_private::ArchSpec *arch) } } if (create) - return new PlatformFreeBSD (is_host); - return NULL; + return PlatformSP(new PlatformFreeBSD (is_host)); + return PlatformSP(); } @@ -124,7 +124,7 @@ PlatformFreeBSD::Initialize () // Force a host flag to true for the default platform object. PlatformSP default_platform_sp (new PlatformFreeBSD(true)); default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); - Platform::SetDefaultPlatform (default_platform_sp); + Platform::SetHostPlatform (default_platform_sp); #endif PluginManager::RegisterPlugin(PlatformFreeBSD::GetPluginNameStatic(false), PlatformFreeBSD::GetDescriptionStatic(false), @@ -180,8 +180,7 @@ PlatformFreeBSD::RunShellCommand (const char *command, Error -PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file, - const ArchSpec &exe_arch, +PlatformFreeBSD::ResolveExecutable (const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) { @@ -189,35 +188,33 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file, // Nothing special to do here, just use the actual file and architecture char exe_path[PATH_MAX]; - FileSpec resolved_exe_file (exe_file); + ModuleSpec resolved_module_spec(module_spec); if (IsHost()) { - // If we have "ls" as the exe_file, resolve the executable location based on + // If we have "ls" as the module_spec's file, resolve the executable location based on // the current path variables - if (!resolved_exe_file.Exists()) + if (!resolved_module_spec.GetFileSpec().Exists()) { - exe_file.GetPath(exe_path, sizeof(exe_path)); - resolved_exe_file.SetFile(exe_path, true); + module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path)); + resolved_module_spec.GetFileSpec().SetFile(exe_path, true); } - if (!resolved_exe_file.Exists()) - resolved_exe_file.ResolveExecutableLocation (); + if (!resolved_module_spec.GetFileSpec().Exists()) + resolved_module_spec.GetFileSpec().ResolveExecutableLocation (); - if (resolved_exe_file.Exists()) + if (resolved_module_spec.GetFileSpec().Exists()) error.Clear(); else { - exe_file.GetPath(exe_path, sizeof(exe_path)); - error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path); + error.SetErrorStringWithFormat("unable to find executable for '%s'", resolved_module_spec.GetFileSpec().GetPath().c_str()); } } else { if (m_remote_platform_sp) { - error = m_remote_platform_sp->ResolveExecutable (exe_file, - exe_arch, + error = m_remote_platform_sp->ResolveExecutable (module_spec, exe_module_sp, module_search_paths_ptr); } @@ -226,25 +223,24 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file, // We may connect to a process and use the provided executable (Don't use local $PATH). // Resolve any executable within a bundle on MacOSX - Host::ResolveExecutableInBundle (resolved_exe_file); + Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec()); - if (resolved_exe_file.Exists()) { + if (resolved_module_spec.GetFileSpec().Exists()) + { error.Clear(); } else { - exe_file.GetPath(exe_path, sizeof(exe_path)); - error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path); + error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_module_spec.GetFileSpec().GetPath().c_str()); } } } if (error.Success()) { - ModuleSpec module_spec (resolved_exe_file, exe_arch); - if (module_spec.GetArchitecture().IsValid()) + if (resolved_module_spec.GetArchitecture().IsValid()) { - error = ModuleList::GetSharedModule (module_spec, + error = ModuleList::GetSharedModule (resolved_module_spec, exe_module_sp, module_search_paths_ptr, NULL, @@ -254,8 +250,8 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file, { exe_module_sp.reset(); error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s", - exe_file.GetPath().c_str(), - exe_arch.GetArchitectureName()); + resolved_module_spec.GetFileSpec().GetPath().c_str(), + resolved_module_spec.GetArchitecture().GetArchitectureName()); } } else @@ -264,10 +260,9 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file, // the architectures that we should be using (in the correct order) // and see if we can find a match that way StreamString arch_names; - ArchSpec platform_arch; - for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, platform_arch); ++idx) + for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx) { - error = ModuleList::GetSharedModule (module_spec, + error = ModuleList::GetSharedModule (resolved_module_spec, exe_module_sp, module_search_paths_ptr, NULL, @@ -283,21 +278,21 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file, if (idx > 0) arch_names.PutCString (", "); - arch_names.PutCString (platform_arch.GetArchitectureName()); + arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName()); } if (error.Fail() || !exe_module_sp) { - if (exe_file.Readable()) + if (resolved_module_spec.GetFileSpec().Readable()) { error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s", - exe_file.GetPath().c_str(), + resolved_module_spec.GetFileSpec().GetPath().c_str(), GetPluginName().GetCString(), arch_names.GetString().c_str()); } else { - error.SetErrorStringWithFormat("'%s' is not readable", exe_file.GetPath().c_str()); + error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str()); } } } @@ -326,6 +321,13 @@ PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite trap_opcode_size = sizeof(g_i386_opcode); } break; + case llvm::Triple::ppc: + case llvm::Triple::ppc64: + { + static const uint8_t g_ppc_opcode[] = { 0x7f, 0xe0, 0x00, 0x08 }; + trap_opcode = g_ppc_opcode; + trap_opcode_size = sizeof(g_ppc_opcode); + } } if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size)) @@ -404,7 +406,7 @@ PlatformFreeBSD::ConnectRemote (Args& args) else { if (!m_remote_platform_sp) - m_remote_platform_sp = Platform::Create ("remote-gdb-server", error); + m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error); if (m_remote_platform_sp) { @@ -507,7 +509,6 @@ lldb::ProcessSP PlatformFreeBSD::Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, - Listener &listener, Error &error) { lldb::ProcessSP process_sp; @@ -535,7 +536,7 @@ PlatformFreeBSD::Attach(ProcessAttachInfo &attach_info, // The freebsd always currently uses the GDB remote debugger plug-in // so even when debugging locally we are debugging remotely! // Just like the darwin plugin. - process_sp = target->CreateProcess (listener, "gdb-remote", NULL); + process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL); if (process_sp) error = process_sp->Attach (attach_info); @@ -544,7 +545,7 @@ PlatformFreeBSD::Attach(ProcessAttachInfo &attach_info, else { if (m_remote_platform_sp) - process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error); + process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error); else error.SetErrorString ("the platform is not currently connected"); } diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h index 62958a08a9e0..ce3f8cfad976 100644 --- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h +++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h @@ -24,7 +24,7 @@ public: //------------------------------------------------------------ // Class functions //------------------------------------------------------------ - static lldb_private::Platform* + static lldb::PlatformSP CreateInstance (bool force, const lldb_private::ArchSpec *arch); static void @@ -80,8 +80,7 @@ public: uint32_t timeout_sec); virtual lldb_private::Error - ResolveExecutable (const lldb_private::FileSpec &exe_file, - const lldb_private::ArchSpec &arch, + ResolveExecutable (const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr); @@ -135,7 +134,6 @@ public: Attach(lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Listener &listener, lldb_private::Error &error); // FreeBSD processes can not be launched by spawning and attaching. diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index cc4c693e1b43..b1be0f5b1fe1 100644 --- a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -15,7 +15,9 @@ // Project includes #include "lldb/Core/DataBufferHeap.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" #include "lldb/Host/File.h" #include "lldb/Host/FileCache.h" @@ -330,8 +332,14 @@ PlatformPOSIX::PutFile (const lldb_private::FileSpec& source, error = source_file.Read(buffer_sp->GetBytes(), bytes_read); if (bytes_read) { - WriteFile(dest_file, offset, buffer_sp->GetBytes(), bytes_read, error); - offset += bytes_read; + const uint64_t bytes_written = WriteFile(dest_file, offset, buffer_sp->GetBytes(), bytes_read, error); + offset += bytes_written; + if (bytes_written != bytes_read) + { + // We didn't write the correct numbe of bytes, so adjust + // the file position in the source file we are reading from... + source_file.SeekFromStart(offset); + } } else break; @@ -343,6 +351,18 @@ PlatformPOSIX::PutFile (const lldb_private::FileSpec& source, // std::string dst_path (destination.GetPath()); // if (chown_file(this,dst_path.c_str(),uid,gid) != 0) // return Error("unable to perform chown"); + + + uint64_t src_md5[2]; + uint64_t dst_md5[2]; + + if (FileSystem::CalculateMD5 (source, src_md5[0], src_md5[1]) && CalculateMD5 (destination, dst_md5[0], dst_md5[1])) + { + if (src_md5[0] != dst_md5[0] || src_md5[1] != dst_md5[1]) + { + error.SetErrorString("md5 checksum of installed file doesn't match, installation failed"); + } + } return error; } return Platform::PutFile(source,destination,uid,gid); @@ -616,6 +636,18 @@ PlatformPOSIX::GetRemoteOSBuildString (std::string &s) return false; } +size_t +PlatformPOSIX::GetEnvironment (StringList &env) +{ + if (IsRemote()) + { + if (m_remote_platform_sp) + return m_remote_platform_sp->GetEnvironment(env); + return 0; + } + return Host::GetEnvironment(env); +} + bool PlatformPOSIX::GetRemoteOSKernelDescription (std::string &s) { @@ -681,7 +713,7 @@ PlatformPOSIX::ConnectRemote (Args& args) else { if (!m_remote_platform_sp) - m_remote_platform_sp = Platform::Create ("remote-gdb-server", error); + m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error); if (m_remote_platform_sp && error.Success()) error = m_remote_platform_sp->ConnectRemote (args); @@ -739,11 +771,97 @@ PlatformPOSIX::DisconnectRemote () return error; } +Error +PlatformPOSIX::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + + if (IsHost()) + { + error = Platform::LaunchProcess (launch_info); + } + else + { + if (m_remote_platform_sp) + error = m_remote_platform_sp->LaunchProcess (launch_info); + else + error.SetErrorString ("the platform is not currently connected"); + } + return error; +} + +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__, + 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 ()); + + ListenerSP listener_sp (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; +} + lldb::ProcessSP PlatformPOSIX::DebugProcess (ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new target, else use existing one - Listener &listener, Error &error) { ProcessSP process_sp; @@ -754,12 +872,12 @@ PlatformPOSIX::DebugProcess (ProcessLaunchInfo &launch_info, // We still need to reap it from lldb but if we let the monitor thread also set the exit status, we set up a // race between debugserver & us for who will find out about the debugged process's death. launch_info.GetFlags().Set(eLaunchFlagDontSetExitStatus); - process_sp = Platform::DebugProcess (launch_info, debugger, target, listener, error); + process_sp = Platform::DebugProcess (launch_info, debugger, target, error); } else { if (m_remote_platform_sp) - process_sp = m_remote_platform_sp->DebugProcess (launch_info, debugger, target, listener, error); + process_sp = m_remote_platform_sp->DebugProcess (launch_info, debugger, target, error); else error.SetErrorString ("the platform is not currently connected"); } diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/source/Plugins/Platform/POSIX/PlatformPOSIX.h index 374e36495d88..aae415e6eefa 100644 --- a/source/Plugins/Platform/POSIX/PlatformPOSIX.h +++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.h @@ -31,8 +31,9 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ - virtual lldb_private::OptionGroupOptions* - GetConnectionOptions (lldb_private::CommandInterpreter& interpreter); + virtual lldb_private::OptionGroupOptions + *GetConnectionOptions( + lldb_private::CommandInterpreter &interpreter) override; const char * GetHostname () override; @@ -47,47 +48,47 @@ public: PutFile (const lldb_private::FileSpec& source, const lldb_private::FileSpec& destination, uint32_t uid = UINT32_MAX, - uint32_t gid = UINT32_MAX); + uint32_t gid = UINT32_MAX) override; virtual lldb::user_id_t OpenFile (const lldb_private::FileSpec& file_spec, uint32_t flags, uint32_t mode, - lldb_private::Error &error); + lldb_private::Error &error) override; virtual bool CloseFile (lldb::user_id_t fd, - lldb_private::Error &error); + lldb_private::Error &error) override; virtual uint64_t ReadFile (lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, - lldb_private::Error &error); + lldb_private::Error &error) override; virtual uint64_t WriteFile (lldb::user_id_t fd, uint64_t offset, const void* src, uint64_t src_len, - lldb_private::Error &error); + lldb_private::Error &error) override; virtual lldb::user_id_t - GetFileSize (const lldb_private::FileSpec& file_spec); + GetFileSize (const lldb_private::FileSpec& file_spec) override; virtual lldb_private::Error - CreateSymlink(const char *src, const char *dst); + CreateSymlink(const char *src, const char *dst) override; virtual lldb_private::Error GetFile (const lldb_private::FileSpec& source, - const lldb_private::FileSpec& destination); + const lldb_private::FileSpec& destination) override; virtual lldb_private::ConstString - GetRemoteWorkingDirectory(); + GetRemoteWorkingDirectory() override; virtual bool - SetRemoteWorkingDirectory(const lldb_private::ConstString &path); + SetRemoteWorkingDirectory(const lldb_private::ConstString &path) override; bool GetRemoteOSVersion () override; @@ -101,6 +102,9 @@ public: lldb_private::ArchSpec GetRemoteSystemArchitecture () override; + size_t + GetEnvironment (lldb_private::StringList &environment) override; + bool IsConnected () const override; @@ -110,40 +114,48 @@ public: int *status_ptr, // Pass NULL if you don't want the process exit status int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit std::string *command_output, // Pass NULL if you don't want the command output - uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish + uint32_t timeout_sec) override;// Timeout in seconds to wait for shell program to finish virtual lldb_private::Error - MakeDirectory (const char *path, uint32_t mode); + MakeDirectory (const char *path, uint32_t mode) override; virtual lldb_private::Error - GetFilePermissions (const char *path, uint32_t &file_permissions); + GetFilePermissions (const char *path, uint32_t &file_permissions) override; virtual lldb_private::Error - SetFilePermissions (const char *path, uint32_t file_permissions); + SetFilePermissions (const char *path, uint32_t file_permissions) override; virtual bool - GetFileExists (const lldb_private::FileSpec& file_spec); + GetFileExists (const lldb_private::FileSpec& file_spec) override; virtual lldb_private::Error - Unlink (const char *path); + Unlink (const char *path) override; + + lldb_private::Error + LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info) override; + + lldb::ProcessSP + Attach (lldb_private::ProcessAttachInfo &attach_info, + lldb_private::Debugger &debugger, + lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one + lldb_private::Error &error) override; lldb::ProcessSP DebugProcess (lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger, lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one - lldb_private::Listener &listener, lldb_private::Error &error) override; virtual std::string - GetPlatformSpecificConnectionInformation(); + GetPlatformSpecificConnectionInformation() override; virtual bool CalculateMD5 (const lldb_private::FileSpec& file_spec, uint64_t &low, - uint64_t &high); + uint64_t &high) override; virtual void - CalculateTrapHandlerSymbolNames (); + CalculateTrapHandlerSymbolNames () override; lldb_private::Error ConnectRemote (lldb_private::Args& args) override; diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 05fbc5101278..43eae4d906ec 100644 --- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -16,14 +16,15 @@ // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointLocation.h" -#include "lldb/Core/ConnectionFileDescriptor.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Error.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" +#include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamString.h" +#include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" @@ -56,7 +57,7 @@ PlatformRemoteGDBServer::Terminate () } } -Platform* +PlatformSP PlatformRemoteGDBServer::CreateInstance (bool force, const lldb_private::ArchSpec *arch) { bool create = force; @@ -65,8 +66,8 @@ PlatformRemoteGDBServer::CreateInstance (bool force, const lldb_private::ArchSpe create = !arch->TripleVendorWasSpecified() && !arch->TripleOSWasSpecified(); } if (create) - return new PlatformRemoteGDBServer (); - return NULL; + return PlatformSP(new PlatformRemoteGDBServer()); + return PlatformSP(); } @@ -100,14 +101,13 @@ PlatformRemoteGDBServer::GetDescription () } Error -PlatformRemoteGDBServer::ResolveExecutable (const FileSpec &exe_file, - const ArchSpec &exe_arch, +PlatformRemoteGDBServer::ResolveExecutable (const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) { Error error; //error.SetErrorString ("PlatformRemoteGDBServer::ResolveExecutable() is unimplemented"); - if (m_gdb_client.GetFileExists(exe_file)) + if (m_gdb_client.GetFileExists(module_spec.GetFileSpec())) return error; // TODO: get the remote end to somehow resolve this file error.SetErrorString("file not found on remote end"); @@ -421,7 +421,6 @@ lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess (lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger, lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one - lldb_private::Listener &listener, lldb_private::Error &error) { lldb::ProcessSP process_sp; @@ -473,7 +472,7 @@ PlatformRemoteGDBServer::DebugProcess (lldb_private::ProcessLaunchInfo &launch_i // The darwin always currently uses the GDB remote debugger plug-in // so even when debugging locally we are debugging remotely! - process_sp = target->CreateProcess (listener, "gdb-remote", NULL); + process_sp = target->CreateProcess (launch_info.GetListenerForProcess(debugger), "gdb-remote", NULL); if (process_sp) { @@ -488,10 +487,16 @@ PlatformRemoteGDBServer::DebugProcess (lldb_private::ProcessLaunchInfo &launch_i port + port_offset); assert (connect_url_len < (int)sizeof(connect_url)); error = process_sp->ConnectRemote (NULL, connect_url); + // Retry the connect remote one time... + if (error.Fail()) + error = process_sp->ConnectRemote (NULL, connect_url); if (error.Success()) error = process_sp->Launch(launch_info); else if (debugserver_pid != LLDB_INVALID_PROCESS_ID) + { + printf ("error: connect remote failed (%s)\n", error.AsCString()); m_gdb_client.KillSpawnedProcess(debugserver_pid); + } } } } @@ -509,7 +514,6 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach (lldb_private::ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new target, else use existing one - Listener &listener, Error &error) { lldb::ProcessSP process_sp; @@ -561,7 +565,7 @@ PlatformRemoteGDBServer::Attach (lldb_private::ProcessAttachInfo &attach_info, // The darwin always currently uses the GDB remote debugger plug-in // so even when debugging locally we are debugging remotely! - process_sp = target->CreateProcess (listener, "gdb-remote", NULL); + process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL); if (process_sp) { diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h index e236e97c8bb3..90b16b8b8fa9 100644 --- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h +++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h @@ -29,7 +29,7 @@ public: static void Terminate (); - static lldb_private::Platform* + static lldb::PlatformSP CreateInstance (bool force, const lldb_private::ArchSpec *arch); static lldb_private::ConstString @@ -64,8 +64,7 @@ public: // lldb_private::Platform functions //------------------------------------------------------------ virtual lldb_private::Error - ResolveExecutable (const lldb_private::FileSpec &exe_file, - const lldb_private::ArchSpec &arch, + ResolveExecutable (const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr); @@ -92,14 +91,12 @@ public: DebugProcess (lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger, lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one - lldb_private::Listener &listener, lldb_private::Error &error); virtual lldb::ProcessSP Attach (lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger, lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one - lldb_private::Listener &listener, lldb_private::Error &error); virtual bool |
