diff options
author | Stephane Sezer <sas@cd80.net> | 2017-03-31 18:00:48 +0000 |
---|---|---|
committer | Stephane Sezer <sas@cd80.net> | 2017-03-31 18:00:48 +0000 |
commit | 48d1427c30b73b7ceef154100c774f753c600e31 (patch) | |
tree | 1875221d4e2820b97f0c3adf721c6f258f2331d5 /lldb/unittests/Process | |
parent | 303abb803ae201ebdc040128e0fdf8eab14f5944 (diff) | |
download | bcm5719-llvm-48d1427c30b73b7ceef154100c774f753c600e31.tar.gz bcm5719-llvm-48d1427c30b73b7ceef154100c774f753c600e31.zip |
Verify memory address range validity in GDBRemoteCommunicationClient
Summary:
This aims to verify the validity of the response from the debugging
server in GDBRemoteCommunicationClient::GetMemoryRegionInfo. I was
working with ds2 (https://github.com/facebook/ds2) and encountered a bug
that caused the server's response to have a 'size' value of 0, which
caused lldb to behave incorrectly.
Reviewers: k8stone, labath, clayborg
Reviewed By: labath, clayborg
Subscribers: clayborg, sas, lldb-commits
Differential Revision: https://reviews.llvm.org/D31485
Change by Alex Langford <apl@fb.com>
llvm-svn: 299239
Diffstat (limited to 'lldb/unittests/Process')
-rw-r--r-- | lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 120c88d714c..d1eb3a7e9c9 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -13,6 +13,7 @@ #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/StructuredData.h" +#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/DataBuffer.h" #include "llvm/ADT/ArrayRef.h" @@ -331,3 +332,41 @@ TEST_F(GDBRemoteCommunicationClientTest, SendSignalsToIgnore) { HandlePacket(server, "QPassSignals:", "OK"); EXPECT_TRUE(result.get().Success()); } + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0xa000; + MemoryRegionInfo region_info; + std::future<Error> result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + // name is: /foo/bar.so + HandlePacket(server, + "qMemoryRegionInfo:a000", + "start:a000;size:2000;permissions:rx;name:2f666f6f2f6261722e736f;"); + EXPECT_TRUE(result.get().Success()); + +} + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0x4000; + MemoryRegionInfo region_info; + std::future<Error> result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + HandlePacket(server, "qMemoryRegionInfo:4000", "start:4000;size:0000;"); + EXPECT_FALSE(result.get().Success()); +} |