summaryrefslogtreecommitdiff
path: root/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
commitf73363f1dd94996356cefbf24388f561891acf0b (patch)
treee3c31248bdb36eaec5fd833490d4278162dba2a0 /unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
parent160ee69dd7ae18978f4068116777639ea98dc951 (diff)
Notes
Diffstat (limited to 'unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp')
-rw-r--r--unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp50
1 files changed, 35 insertions, 15 deletions
diff --git a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 1d7632a67a30..41ca091c8f10 100644
--- a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -6,12 +6,10 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include <future>
-
-#include "GDBRemoteTestUtils.h"
-
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
+#include "GDBRemoteTestUtils.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/XML.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/StructuredData.h"
@@ -19,6 +17,8 @@
#include "lldb/lldb-enumerations.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include <future>
using namespace lldb_private::process_gdb_remote;
using namespace lldb_private;
@@ -43,10 +43,12 @@ void Handle_QThreadSuffixSupported(MockServer &server, bool supported) {
ASSERT_EQ(PacketResult::Success, server.SendUnimplementedResponse(nullptr));
}
-void HandlePacket(MockServer &server, StringRef expected, StringRef response) {
+void HandlePacket(MockServer &server,
+ const testing::Matcher<const std::string &> &expected,
+ StringRef response) {
StringExtractorGDBRemote request;
ASSERT_EQ(PacketResult::Success, server.GetPacket(request));
- ASSERT_EQ(expected, request.GetStringRef());
+ ASSERT_THAT(request.GetStringRef(), expected);
ASSERT_EQ(PacketResult::Success, server.SendPacket(response));
}
@@ -167,14 +169,14 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo) {
llvm::Triple triple("i386-pc-linux");
FileSpec file_specs[] = {
- FileSpec("/foo/bar.so", false, FileSpec::ePathSyntaxPosix),
- FileSpec("/foo/baz.so", false, FileSpec::ePathSyntaxPosix),
+ FileSpec("/foo/bar.so", false, FileSpec::Style::posix),
+ FileSpec("/foo/baz.so", false, FileSpec::Style::posix),
// This is a bit dodgy but we currently depend on GetModulesInfo not
// performing denormalization. It can go away once the users
// (DynamicLoaderPOSIXDYLD, at least) correctly set the path syntax for
// the FileSpecs they create.
- FileSpec("/foo/baw.so", false, FileSpec::ePathSyntaxWindows),
+ FileSpec("/foo/baw.so", false, FileSpec::Style::windows),
};
std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result =
std::async(std::launch::async,
@@ -192,7 +194,8 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo) {
ASSERT_EQ(1u, result->size());
EXPECT_EQ("/foo/bar.so", result.getValue()[0].GetFileSpec().GetPath());
EXPECT_EQ(triple, result.getValue()[0].GetArchitecture().GetTriple());
- EXPECT_EQ(UUID("@ABCDEFGHIJKLMNO", 16), result.getValue()[0].GetUUID());
+ EXPECT_EQ(UUID::fromData("@ABCDEFGHIJKLMNO", 16),
+ result.getValue()[0].GetUUID());
EXPECT_EQ(0u, result.getValue()[0].GetObjectOffset());
EXPECT_EQ(1234u, result.getValue()[0].GetObjectSize());
}
@@ -200,7 +203,7 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo) {
TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo_UUID20) {
llvm::Triple triple("i386-pc-linux");
- FileSpec file_spec("/foo/bar.so", false, FileSpec::ePathSyntaxPosix);
+ FileSpec file_spec("/foo/bar.so", false, FileSpec::Style::posix);
std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result =
std::async(std::launch::async,
[&] { return client.GetModulesInfo(file_spec, triple); });
@@ -216,14 +219,15 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo_UUID20) {
ASSERT_EQ(1u, result->size());
EXPECT_EQ("/foo/bar.so", result.getValue()[0].GetFileSpec().GetPath());
EXPECT_EQ(triple, result.getValue()[0].GetArchitecture().GetTriple());
- EXPECT_EQ(UUID("@ABCDEFGHIJKLMNOPQRS", 20), result.getValue()[0].GetUUID());
+ EXPECT_EQ(UUID::fromData("@ABCDEFGHIJKLMNOPQRS", 20),
+ result.getValue()[0].GetUUID());
EXPECT_EQ(0u, result.getValue()[0].GetObjectOffset());
EXPECT_EQ(1234u, result.getValue()[0].GetObjectSize());
}
TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfoInvalidResponse) {
llvm::Triple triple("i386-pc-linux");
- FileSpec file_spec("/foo/bar.so", false, FileSpec::ePathSyntaxPosix);
+ FileSpec file_spec("/foo/bar.so", false, FileSpec::Style::posix);
const char *invalid_responses[] = {
// no UUID
@@ -323,12 +327,22 @@ TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) {
return client.GetMemoryRegionInfo(addr, region_info);
});
- // name is: /foo/bar.so
HandlePacket(server,
"qMemoryRegionInfo:a000",
"start:a000;size:2000;permissions:rx;name:2f666f6f2f6261722e736f;");
+ if (XMLDocument::XMLEnabled()) {
+ // In case we have XML support, this will also do a "qXfer:memory-map".
+ // Preceeded by a query for supported extensions. Pretend we don't support
+ // that.
+ HandlePacket(server, testing::StartsWith("qSupported:"), "");
+ }
EXPECT_TRUE(result.get().Success());
-
+ EXPECT_EQ(addr, region_info.GetRange().GetRangeBase());
+ EXPECT_EQ(0x2000u, region_info.GetRange().GetByteSize());
+ EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetReadable());
+ EXPECT_EQ(MemoryRegionInfo::eNo, region_info.GetWritable());
+ EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetExecutable());
+ EXPECT_EQ("/foo/bar.so", region_info.GetName().GetStringRef());
}
TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {
@@ -339,6 +353,12 @@ TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {
});
HandlePacket(server, "qMemoryRegionInfo:4000", "start:4000;size:0000;");
+ if (XMLDocument::XMLEnabled()) {
+ // In case we have XML support, this will also do a "qXfer:memory-map".
+ // Preceeded by a query for supported extensions. Pretend we don't support
+ // that.
+ HandlePacket(server, testing::StartsWith("qSupported:"), "");
+ }
EXPECT_FALSE(result.get().Success());
}