diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-03-24 04:28:38 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-03-24 04:28:38 +0000 |
| commit | 1cb6496eb024249cd9b67e9c53808553128dd0e7 (patch) | |
| tree | 2ebad6376e8dfd2960212fd3c4fe4743bfc7d1b1 /lldb/source/Target/Platform.cpp | |
| parent | a75d158c419435a7097d96de630ddc43d25154ad (diff) | |
| download | bcm5719-llvm-1cb6496eb024249cd9b67e9c53808553128dd0e7.tar.gz bcm5719-llvm-1cb6496eb024249cd9b67e9c53808553128dd0e7.zip | |
Did a lot more work on abtracting and organizing the platforms.
On Mac OS X we now have 3 platforms:
PlatformDarwin - must be subclassed to fill in the missing pure virtual funcs
but this implements all the common functionality between
remote-macosx and remote-ios. It also allows for another
platform to be used (remote-gdb-server for now) when doing
remote connections. Keeping this pluggable will allow for
flexibility.
PlatformMacOSX - Now implements both local and remote macosx desktop platforms.
PlatformRemoteiOS - Remote only iOS that knows how to locate SDK files in the
cached SDK locations on the host.
A new agnostic platform has been created:
PlatformRemoteGDBServer - this implements the platform using the GDB remote
protocol and uses the built in lldb_private::Host
static functions to implement many queries.
llvm-svn: 128193
Diffstat (limited to 'lldb/source/Target/Platform.cpp')
| -rw-r--r-- | lldb/source/Target/Platform.cpp | 112 |
1 files changed, 103 insertions, 9 deletions
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index a6df50d9e70..0f025147608 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -121,11 +121,10 @@ Platform::GetConnectedRemotePlatformAtIndex (uint32_t idx) //------------------------------------------------------------------ Platform::Platform (bool is_host) : m_is_host (is_host), - m_is_connected (is_host), // If this is the default host platform, then we are always connected m_os_version_set_while_connected (false), m_system_arch_set_while_connected (false), m_remote_url (), - m_remote_instance_name (), + m_name (), m_major_os_version (UINT32_MAX), m_minor_os_version (UINT32_MAX), m_update_os_version (UINT32_MAX) @@ -142,6 +141,52 @@ Platform::~Platform() { } +void +Platform::GetStatus (Stream &strm) +{ + uint32_t major = UINT32_MAX; + uint32_t minor = UINT32_MAX; + uint32_t update = UINT32_MAX; + std::string s; + strm.Printf ("Platform: %s\n", GetShortPluginName()); + + ArchSpec arch (GetSystemArchitecture()); + if (arch.IsValid()) + { + if (!arch.GetTriple().str().empty()) + strm.Printf("Triple: %s\n", arch.GetTriple().str().c_str()); + } + + if (GetOSVersion(major, minor, update)) + { + strm.Printf("OS: %u", major); + if (minor != UINT32_MAX) + strm.Printf(".%u", minor); + if (update != UINT32_MAX) + strm.Printf(".%u", update); + + if (GetOSBuildString (s)) + strm.Printf(" (%s)", s.c_str()); + + strm.EOL(); + } + + if (GetOSKernelDescription (s)) + strm.Printf("Kernel: %s\n", s.c_str()); + + if (IsHost()) + { + strm.Printf("Hostname: %s\n", GetHostname()); + } + else + { + if (IsConnected()) + strm.Printf("Remote hostname: %s\n", GetHostname()); + else + strm.PutCString("Not connected to a remote platform.\n"); + } +} + bool Platform::GetOSVersion (uint32_t &major, @@ -168,7 +213,7 @@ Platform::GetOSVersion (uint32_t &major, const bool is_connected = IsConnected(); - bool fetch_os_version = false; + bool fetch = false; if (success) { // We have valid OS version info, check to make sure it wasn't @@ -176,17 +221,17 @@ Platform::GetOSVersion (uint32_t &major, // to connecting, then lets fetch the actual OS version info // if we are now connected. if (is_connected && !m_os_version_set_while_connected) - fetch_os_version = true; + fetch = true; } else { // We don't have valid OS version info, fetch it if we are connected - fetch_os_version = is_connected; + fetch = is_connected; } - if (fetch_os_version) + if (fetch) { - success = FetchRemoteOSVersion (); + success = GetRemoteOSVersion (); m_os_version_set_while_connected = success; } } @@ -199,7 +244,56 @@ Platform::GetOSVersion (uint32_t &major, } return success; } - + +bool +Platform::GetOSBuildString (std::string &s) +{ + if (IsHost()) + return Host::GetOSBuildString (s); + else + return GetRemoteOSBuildString (s); +} + +bool +Platform::GetOSKernelDescription (std::string &s) +{ + if (IsHost()) + return Host::GetOSKernelDescription (s); + else + return GetRemoteOSKernelDescription (s); +} + +const char * +Platform::GetHostname () +{ + if (m_name.empty()) + { + if (IsHost()) + { + if (!Host::GetHostname(m_name)) + return "localhost"; + } + else + { + if (IsConnected()) + { + const char *instance_name = GetRemoteHostname (); + if (instance_name) + m_name.assign (instance_name); + } + else + { + return "remote"; + } + } + } + if (!m_name.empty()) + return m_name.c_str(); + return NULL; +} + + + bool Platform::SetOSVersion (uint32_t major, uint32_t minor, @@ -324,7 +418,7 @@ Platform::GetSystemArchitecture() if (fetch) { - m_system_arch = FetchRemoteSystemArchitecture (); + m_system_arch = GetRemoteSystemArchitecture (); m_system_arch_set_while_connected = m_system_arch.IsValid(); } } |

