diff options
Diffstat (limited to 'unittests/Process/gdb-remote')
4 files changed, 75 insertions, 23 deletions
| diff --git a/unittests/Process/gdb-remote/CMakeLists.txt b/unittests/Process/gdb-remote/CMakeLists.txt index de4cac11b233..694ba182d42f 100644 --- a/unittests/Process/gdb-remote/CMakeLists.txt +++ b/unittests/Process/gdb-remote/CMakeLists.txt @@ -2,4 +2,13 @@ add_lldb_unittest(ProcessGdbRemoteTests    GDBRemoteClientBaseTest.cpp    GDBRemoteCommunicationClientTest.cpp    GDBRemoteTestUtils.cpp + +  LINK_LIBS +    lldbCore +    lldbHost +    lldbPluginPlatformMacOSX +    lldbPluginProcessUtility +    lldbPluginProcessGDBRemote +  LINK_COMPONENTS +    Support    ) diff --git a/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp b/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp index 2cfd52f5767a..5e709815b2d5 100644 --- a/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp @@ -6,13 +6,6 @@  // 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" @@ -20,7 +13,7 @@  #include "Plugins/Process/Utility/LinuxSignals.h"  #include "Plugins/Process/gdb-remote/GDBRemoteClientBase.h"  #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h" -#include "lldb/Core/StreamGDBRemote.h" +#include "lldb/Utility/StreamGDBRemote.h"  #include "llvm/ADT/STLExtras.h" diff --git a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 4bac9ebd404f..d1eb3a7e9c9e 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()); +} diff --git a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp index 58cc9f50586a..08501f50f65a 100644 --- a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp @@ -7,13 +7,6 @@  //  //===----------------------------------------------------------------------===// -#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 "GDBRemoteTestUtils.h"  #include "lldb/Host/common/TCPSocket.h" | 
