diff options
author | Greg Clayton <gclayton@apple.com> | 2011-03-23 00:09:55 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-03-23 00:09:55 +0000 |
commit | d314e810a70e9104c8d30d9b0719bc5a3dc0acab (patch) | |
tree | 0d881e5b16df61aa732dea1555adecf675db83e8 /lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp | |
parent | 7ca3ddc2333a05f60be578cffc93610a34638602 (diff) | |
download | bcm5719-llvm-d314e810a70e9104c8d30d9b0719bc5a3dc0acab.tar.gz bcm5719-llvm-d314e810a70e9104c8d30d9b0719bc5a3dc0acab.zip |
Added new platform commands:
platform connect <args>
platform disconnect
Each platform can decide the args they want to use for "platform connect". I
will need to add a function that gets the connect options for the current
platform as each one can have different options and argument counts.
Hooked up more functionality in the PlatformMacOSX and PlatformRemoteiOS.
Also started an platform agnostic PlatformRemoteGDBServer.cpp which can end
up being used by one or more actual platforms. It can also be specialized and
allow for platform specific commands.
llvm-svn: 128123
Diffstat (limited to 'lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp')
-rw-r--r-- | lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp | 240 |
1 files changed, 240 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp new file mode 100644 index 00000000000..f8a73a3826d --- /dev/null +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -0,0 +1,240 @@ +//===-- PlatformRemoteGDBServer.cpp -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "PlatformRemoteGDBServer.h" + +// C Includes +#include <sys/sysctl.h> + +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/Error.h" +#include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ModuleList.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/Host.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" + +using namespace lldb; +using namespace lldb_private; + +static bool g_initialized = false; + +void +PlatformRemoteGDBServer::Initialize () +{ + if (g_initialized == false) + { + g_initialized = true; + PluginManager::RegisterPlugin (PlatformRemoteGDBServer::GetShortPluginNameStatic(), + PlatformRemoteGDBServer::GetDescriptionStatic(), + PlatformRemoteGDBServer::CreateInstance); + } +} + +void +PlatformRemoteGDBServer::Terminate () +{ + if (g_initialized) + { + g_initialized = false; + PluginManager::UnregisterPlugin (PlatformRemoteGDBServer::CreateInstance); + } +} + +Platform* +PlatformRemoteGDBServer::CreateInstance () +{ + return new PlatformRemoteGDBServer (); +} + +const char * +PlatformRemoteGDBServer::GetShortPluginNameStatic() +{ + return "remote-gdb-server"; +} + +const char * +PlatformRemoteGDBServer::GetDescriptionStatic() +{ + return "A platform that uses the GDB remote protocol as the communication transport."; +} + +const char * +PlatformRemoteGDBServer::GetDescription () +{ + if (m_platform_description.empty()) + { + if (IsConnected()) + { + // Send the get description packet + } + } + + if (!m_platform_description.empty()) + return m_platform_description.c_str(); + return GetDescriptionStatic(); +} + +Error +PlatformRemoteGDBServer::ResolveExecutable (const FileSpec &exe_file, + const ArchSpec &exe_arch, + lldb::ModuleSP &exe_module_sp) +{ + Error error; + error.SetErrorString ("PlatformRemoteGDBServer::ResolveExecutable() is unimplemented"); + return error; +} + +Error +PlatformRemoteGDBServer::GetFile (const FileSpec &platform_file, + const UUID *uuid_ptr, + FileSpec &local_file) +{ + // Default to the local case + local_file = platform_file; + return Error(); +} + + +void +PlatformRemoteGDBServer::GetStatus (Stream &strm) +{ + char sysctlstring[1024]; + size_t datalen; + int mib[CTL_MAXNAME]; + + uint32_t major = UINT32_MAX; + uint32_t minor = UINT32_MAX; + uint32_t update = UINT32_MAX; + strm.PutCString("Remote GDB server platform"); + if (GetOSVersion(major, minor, update)) + { + strm.Printf("OS version: %u", major); + if (minor != UINT32_MAX) + strm.Printf(".%u", minor); + if (update != UINT32_MAX) + strm.Printf(".%u", update); + + + mib[0] = CTL_KERN; + mib[1] = KERN_OSVERSION; + datalen = sizeof(sysctlstring); + if (::sysctl (mib, 2, sysctlstring, &datalen, NULL, 0) == 0) + { + sysctlstring[datalen] = '\0'; + strm.Printf(" (%s)", sysctlstring); + } + + strm.EOL(); + } + + mib[0] = CTL_KERN; + mib[1] = KERN_VERSION; + datalen = sizeof(sysctlstring); + if (::sysctl (mib, 2, sysctlstring, &datalen, NULL, 0) == 0) + { + sysctlstring[datalen] = '\0'; + strm.Printf("Kernel version: %s\n", sysctlstring); + } +} + + +//------------------------------------------------------------------ +/// Default Constructor +//------------------------------------------------------------------ +PlatformRemoteGDBServer::PlatformRemoteGDBServer () : + Platform(false) // This is a remote platform +{ +} + +//------------------------------------------------------------------ +/// Destructor. +/// +/// The destructor is virtual since this class is designed to be +/// inherited from by the plug-in instance. +//------------------------------------------------------------------ +PlatformRemoteGDBServer::~PlatformRemoteGDBServer() +{ +} + +uint32_t +PlatformRemoteGDBServer::FindProcessesByName (const char *name_match, + lldb::NameMatchType name_match_type, + ProcessInfoList &process_infos) +{ + return 0; +} + +bool +PlatformRemoteGDBServer::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +{ + return false; +} + +bool +PlatformRemoteGDBServer::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) +{ + return false; +} + +size_t +PlatformRemoteGDBServer::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site) +{ + // This isn't needed if the z/Z packets are supported in the GDB remote + // server. But we might need a packet to detect this. + return 0; +} + +bool +PlatformRemoteGDBServer::FetchRemoteOSVersion () +{ + return false; +} + +Error +PlatformRemoteGDBServer::ConnectRemote (Args& args) +{ + Error error; + if (args.GetArgumentCount() == 1) + { + const char *remote_url = args.GetArgumentAtIndex(0); + ConnectionStatus status = m_gdb_client.Connect(remote_url, &error); + if (status == eConnectionStatusSuccess) + { + m_gdb_client.GetHostInfo(); + } + } + else + { + error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>"); + } + + return error; +} + +Error +PlatformRemoteGDBServer::DisconnectRemote () +{ + Error error; + m_gdb_client.Disconnect(&error); + return error; +} + +const char * +PlatformRemoteGDBServer::GetRemoteInstanceName () +{ + return NULL; +} + |