diff options
Diffstat (limited to 'lldb/source/Plugins/Process')
4 files changed, 92 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 5dd4dc68027..13b1abe796d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -46,6 +46,7 @@ GDBRemoteCommunicationClient::GDBRemoteCommunicationClient(bool is_platform) : m_supports_vCont_S (eLazyBoolCalculate), m_qHostInfo_is_valid (eLazyBoolCalculate), m_supports_alloc_dealloc_memory (eLazyBoolCalculate), + m_supports_memory_region_info (eLazyBoolCalculate), m_supports_qProcessInfoPID (true), m_supports_qfProcessInfo (true), m_supports_qUserName (true), @@ -123,6 +124,7 @@ GDBRemoteCommunicationClient::ResetDiscoverableSettings() m_supports_vCont_S = eLazyBoolCalculate; m_qHostInfo_is_valid = eLazyBoolCalculate; m_supports_alloc_dealloc_memory = eLazyBoolCalculate; + m_supports_memory_region_info = eLazyBoolCalculate; m_supports_qProcessInfoPID = true; m_supports_qfProcessInfo = true; @@ -1086,6 +1088,77 @@ GDBRemoteCommunicationClient::DeallocateMemory (addr_t addr) return false; } +Error +GDBRemoteCommunicationClient::GetMemoryRegionInfo (lldb::addr_t addr, + lldb_private::MemoryRegionInfo ®ion_info) +{ + Error error; + region_info.Clear(); + + if (m_supports_memory_region_info != eLazyBoolNo) + { + m_supports_memory_region_info = eLazyBoolYes; + char packet[64]; + const int packet_len = ::snprintf(packet, sizeof(packet), "qMemoryRegionInfo:%llx", (uint64_t)addr); + assert (packet_len < sizeof(packet)); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) + { + std::string name; + std::string value; + addr_t addr_value; + bool success = true; + while (success && response.GetNameColonValue(name, value)) + { + if (name.compare ("start") == 0) + { + addr_value = Args::StringToUInt64(value.c_str(), LLDB_INVALID_ADDRESS, 16, &success); + if (success) + region_info.GetRange().SetRangeBase(addr_value); + } + else if (name.compare ("size") == 0) + { + addr_value = Args::StringToUInt64(value.c_str(), 0, 16, &success); + if (success) + region_info.GetRange().SetByteSize (addr_value); + } + else if (name.compare ("permissions") == 0) + { + if (value.find('r') != std::string::npos) + region_info.AddPermissions (ePermissionsReadable); + if (value.find('w') != std::string::npos) + region_info.AddPermissions (ePermissionsWritable); + if (value.find('x') != std::string::npos) + region_info.AddPermissions (ePermissionsExecutable); + } + else if (name.compare ("error") == 0) + { + StringExtractorGDBRemote name_extractor; + // Swap "value" over into "name_extractor" + name_extractor.GetStringRef().swap(value); + // Now convert the HEX bytes into a string value + name_extractor.GetHexByteString (value); + error.SetErrorString(value.c_str()); + } + } + } + else + { + m_supports_memory_region_info = eLazyBoolNo; + } + } + + if (m_supports_memory_region_info == eLazyBoolNo) + { + error.SetErrorString("qMemoryRegionInfo is not supported"); + } + if (error.Fail()) + region_info.Clear(); + return error; + +} + + int GDBRemoteCommunicationClient::SetSTDIN (char const *path) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 0f980fe102b..30d6fb0707e 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/ArchSpec.h" +#include "lldb/Target/Process.h" #include "GDBRemoteCommunication.h" @@ -196,6 +197,10 @@ public: bool DeallocateMemory (lldb::addr_t addr); + lldb_private::Error + GetMemoryRegionInfo (lldb::addr_t addr, + lldb_private::MemoryRegionInfo &range_info); + const lldb_private::ArchSpec & GetHostArchitecture (); @@ -332,6 +337,7 @@ protected: lldb_private::LazyBool m_supports_vCont_S; lldb_private::LazyBool m_qHostInfo_is_valid; lldb_private::LazyBool m_supports_alloc_dealloc_memory; + lldb_private::LazyBool m_supports_memory_region_info; bool m_supports_qProcessInfoPID:1, diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index ba6431291ad..6aa89fadaa9 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1704,6 +1704,15 @@ ProcessGDBRemote::DoAllocateMemory (size_t size, uint32_t permissions, Error &er } Error +ProcessGDBRemote::GetMemoryRegionInfo (addr_t load_addr, + MemoryRegionInfo ®ion_info) +{ + + Error error (m_gdb_comm.GetMemoryRegionInfo (load_addr, region_info)); + return error; +} + +Error ProcessGDBRemote::DoDeallocateMemory (lldb::addr_t addr) { Error error; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 2b298ffe2b1..15ccb34ef3a 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -167,6 +167,10 @@ public: DoAllocateMemory (size_t size, uint32_t permissions, lldb_private::Error &error); virtual lldb_private::Error + GetMemoryRegionInfo (lldb::addr_t load_addr, + lldb_private::MemoryRegionInfo ®ion_info); + + virtual lldb_private::Error DoDeallocateMemory (lldb::addr_t ptr); //------------------------------------------------------------------ |