diff options
Diffstat (limited to 'lldb/source/Plugins/Platform')
8 files changed, 126 insertions, 5 deletions
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index a992b28143f..2fdebe127b8 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -165,6 +165,18 @@ PlatformFreeBSD::~PlatformFreeBSD() } //TODO:VK: inherit PlatformPOSIX + +bool +PlatformFreeBSD::GetModuleSpec (const FileSpec& module_file_spec, + const ArchSpec& arch, + ModuleSpec &module_spec) +{ + if (m_remote_platform_sp) + return m_remote_platform_sp->GetModuleSpec (module_file_spec, arch, module_spec); + + return Platform::GetModuleSpec (module_file_spec, arch, module_spec); +} + lldb_private::Error PlatformFreeBSD::RunShellCommand (const char *command, const char *working_dir, diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h index ce3f8cfad97..714b0d43e83 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h @@ -71,6 +71,11 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ + virtual bool + GetModuleSpec (const lldb_private::FileSpec& module_file_spec, + const lldb_private::ArchSpec& arch, + lldb_private::ModuleSpec &module_spec); + virtual lldb_private::Error RunShellCommand (const char *command, const char *working_dir, diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index 603b33d4a4e..257996a74b4 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -50,6 +50,17 @@ PlatformPOSIX::~PlatformPOSIX() { } +bool +PlatformPOSIX::GetModuleSpec (const FileSpec& module_file_spec, + const ArchSpec& arch, + ModuleSpec &module_spec) +{ + if (m_remote_platform_sp) + return m_remote_platform_sp->GetModuleSpec (module_file_spec, arch, module_spec); + + return Platform::GetModuleSpec (module_file_spec, arch, module_spec); +} + lldb_private::OptionGroupOptions* PlatformPOSIX::GetConnectionOptions (lldb_private::CommandInterpreter& interpreter) { diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h index 4fec694374f..1a8ddda8d18 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h @@ -31,6 +31,12 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ + + virtual bool + GetModuleSpec (const lldb_private::FileSpec& module_file_spec, + const lldb_private::ArchSpec& arch, + lldb_private::ModuleSpec &module_spec); + virtual lldb_private::OptionGroupOptions *GetConnectionOptions( lldb_private::CommandInterpreter &interpreter) override; @@ -115,7 +121,7 @@ public: 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) override;// Timeout in seconds to wait for shell program to finish - + virtual lldb_private::Error MakeDirectory (const char *path, uint32_t mode) override; diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp index 900b95e730f..9f59adb1713 100644 --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -201,6 +201,17 @@ PlatformWindows::~PlatformWindows() { } +bool +PlatformWindows::GetModuleSpec (const FileSpec& module_file_spec, + const ArchSpec& arch, + ModuleSpec &module_spec) +{ + if (m_remote_platform_sp) + return m_remote_platform_sp->GetModuleSpec (module_file_spec, arch, module_spec); + + return Platform::GetModuleSpec (module_file_spec, arch, module_spec); +} + Error PlatformWindows::ResolveExecutable (const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp, diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h index a2511067276..7a785656399 100644 --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h @@ -59,6 +59,11 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ + virtual bool + GetModuleSpec (const lldb_private::FileSpec& module_file_spec, + const lldb_private::ArchSpec& arch, + lldb_private::ModuleSpec &module_spec); + virtual Error ResolveExecutable(const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index cfb3161f8ef..6ab48c82078 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -27,6 +27,8 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -196,6 +198,73 @@ PlatformRemoteGDBServer::ResolveExecutable (const ModuleSpec &module_spec, return error; } +bool +PlatformRemoteGDBServer::GetModuleSpec (const FileSpec& module_file_spec, + const ArchSpec& arch, + ModuleSpec &module_spec) +{ + Log *log = GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PLATFORM); + + const auto module_path = module_file_spec.GetPath (); + + StringExtractorGDBRemote response; + if (!m_gdb_client.GetModuleInfo (module_path.c_str (), arch, response)) + { + if (log) + log->Printf ("PlatformRemoteGDBServer::%s - failed to get module info for %s:%s", + __FUNCTION__, module_path.c_str (), arch.GetTriple ().getTriple ().c_str ()); + return false; + } + + std::string name; + std::string value; + bool success; + StringExtractor extractor; + + module_spec.Clear (); + module_spec.GetFileSpec () = module_file_spec; + + while (response.GetNameColonValue (name, value)) + { + if (name == "uuid" || name == "md5") + { + extractor.GetStringRef ().swap (value); + extractor.SetFilePos (0); + extractor.GetHexByteString (value); + module_spec.GetUUID().SetFromCString (value.c_str(), value.size() / 2); + } + else if (name == "triple") + { + extractor.GetStringRef ().swap (value); + extractor.SetFilePos (0); + extractor.GetHexByteString (value); + module_spec.GetArchitecture().SetTriple (value.c_str ()); + } + else if (name == "file_offset") + { + const auto ival = StringConvert::ToUInt64 (value.c_str (), 0, 16, &success); + if (success) + module_spec.SetObjectOffset (ival); + } + else if (name == "file_size") + { + const auto ival = StringConvert::ToUInt64 (value.c_str (), 0, 16, &success); + if (success) + module_spec.SetObjectSize (ival); + } + } + + if (log) + { + StreamString stream; + module_spec.Dump (stream); + log->Printf ("PlatformRemoteGDBServer::%s - got module info for (%s:%s) : %s", + __FUNCTION__, module_path.c_str (), arch.GetTriple ().getTriple ().c_str (), stream.GetString ().c_str ()); + } + + return true; +} + Error PlatformRemoteGDBServer::GetFileWithUUID (const FileSpec &platform_file, const UUID *uuid_ptr, @@ -346,7 +415,6 @@ PlatformRemoteGDBServer::ConnectRemote (Args& args) { const char *url = args.GetArgumentAtIndex(0); m_gdb_client.SetConnection (new ConnectionFileDescriptor()); - // we're going to reuse the hostname when we connect to the debugserver std::string scheme; int port; @@ -380,7 +448,6 @@ PlatformRemoteGDBServer::ConnectRemote (Args& args) error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>"); } } - return error; } @@ -840,4 +907,4 @@ void PlatformRemoteGDBServer::CalculateTrapHandlerSymbolNames () { m_trap_handlers.push_back (ConstString ("_sigtramp")); -} +} diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h index 878a5186dc3..a920cf5ffac 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h @@ -68,6 +68,11 @@ public: lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr); + virtual bool + GetModuleSpec (const lldb_private::FileSpec& module_file_spec, + const lldb_private::ArchSpec& arch, + lldb_private::ModuleSpec &module_spec); + virtual const char * GetDescription (); @@ -127,7 +132,6 @@ public: virtual bool SetRemoteWorkingDirectory(const lldb_private::ConstString &path); - // Remote subclasses should override this and return a valid instance // name if connected. |

