diff options
Diffstat (limited to 'unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp')
-rw-r--r-- | unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | 73 |
1 files changed, 65 insertions, 8 deletions
diff --git a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 4bac9ebd404f6..d1eb3a7e9c9e0 100644 --- a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -6,21 +6,15 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// - -#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0) -// Workaround for MSVC standard library bug, which fails to include <thread> -// when -// exceptions are disabled. -#include <eh.h> -#endif #include <future> #include "GDBRemoteTestUtils.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" -#include "lldb/Core/DataBuffer.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" @@ -298,6 +292,7 @@ TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) { client.Disconnect(); server_thread.join(); + GTEST_LOG_(INFO) << "Formatted output: " << ss.GetData(); auto object_sp = StructuredData::ParseJSON(ss.GetString()); ASSERT_TRUE(bool(object_sp)); auto dict_sp = object_sp->GetAsDictionary(); @@ -313,3 +308,65 @@ TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) { << ss.GetString(); ASSERT_EQ(10, num_packets); } + +TEST_F(GDBRemoteCommunicationClientTest, SendSignalsToIgnore) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::tid_t tid = 0x47; + const uint32_t reg_num = 4; + std::future<Error> result = std::async(std::launch::async, [&] { + return client.SendSignalsToIgnore({2, 3, 5, 7, 0xB, 0xD, 0x11}); + }); + + HandlePacket(server, "QPassSignals:02;03;05;07;0b;0d;11", "OK"); + EXPECT_TRUE(result.get().Success()); + + result = std::async(std::launch::async, [&] { + return client.SendSignalsToIgnore(std::vector<int32_t>()); + }); + + 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()); +} |