diff options
author | Pavel Labath <labath@google.com> | 2016-09-08 10:07:04 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2016-09-08 10:07:04 +0000 |
commit | 2f1fbaebe25a4637cf75ec9ab1877c64584ede24 (patch) | |
tree | cca4e3ae0fd9afec5fbeeccd59b2b964262b3b88 /lldb/unittests/Process/gdb-remote | |
parent | 2b7ed1339cea63180bc3203ac57b4c5b12219589 (diff) | |
download | bcm5719-llvm-2f1fbaebe25a4637cf75ec9ab1877c64584ede24.tar.gz bcm5719-llvm-2f1fbaebe25a4637cf75ec9ab1877c64584ede24.zip |
gdb-remote: Add jModulesInfo packet
Summary:
This adds the jModulesInfo packet, which is the equivalent of qModulesInfo, but it enables us to
query multiple modules at once. This makes a significant speed improvement in case the
application has many (over a hundred) modules, and the communication link has a non-negligible
latency. This functionality is accessed by ProcessGdbRemote::PrefetchModuleSpecs(), which does
the caching. GetModuleSpecs() is modified to first consult the cache before asking the remote
stub. PrefetchModuleSpecs is currently only called from POSIX-DYLD dynamic loader plugin, after
it reads the list of modules from the inferior memory, but other uses are possible.
This decreases the attach time to an android application by about 40%.
Reviewers: clayborg
Subscribers: tberghammer, lldb-commits, danalbert
Differential Revision: https://reviews.llvm.org/D24236
llvm-svn: 280919
Diffstat (limited to 'lldb/unittests/Process/gdb-remote')
-rw-r--r-- | lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index c5d41ae81f4..1fa24c98bb9 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -19,6 +19,7 @@ #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" #include "lldb/Core/DataBuffer.h" +#include "lldb/Core/ModuleSpec.h" #include "llvm/ADT/ArrayRef.h" @@ -185,3 +186,76 @@ TEST_F(GDBRemoteCommunicationClientTest, SyncThreadState) { HandlePacket(server, "QSyncThreadState:0047;", "OK"); ASSERT_TRUE(async_result.get()); } + +TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + llvm::Triple triple("i386-pc-linux"); + + FileSpec file_specs[] = {FileSpec("/foo/bar.so", false), + FileSpec("/foo/baz.so", false)}; + std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result = + std::async(std::launch::async, + [&] { return client.GetModulesInfo(file_specs, triple); }); + HandlePacket( + server, "jModulesInfo:[" + R"({"file":"/foo/bar.so","triple":"i386-pc-linux"},)" + R"({"file":"/foo/baz.so","triple":"i386-pc-linux"}])", + R"([{"uuid":"404142434445464748494a4b4c4d4e4f","triple":"i386-pc-linux",)" + R"("file_path":"/foo/bar.so","file_offset":0,"file_size":1234}]])"); + + auto result = async_result.get(); + ASSERT_TRUE(result.hasValue()); + 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(0u, result.getValue()[0].GetObjectOffset()); + EXPECT_EQ(1234u, result.getValue()[0].GetObjectSize()); +} + +TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfoInvalidResponse) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + llvm::Triple triple("i386-pc-linux"); + FileSpec file_spec("/foo/bar.so", false); + + const char *invalid_responses[] = { + "OK", "E47", "[]", + // no UUID + R"([{"triple":"i386-pc-linux",)" + R"("file_path":"/foo/bar.so","file_offset":0,"file_size":1234}])", + // no triple + R"([{"uuid":"404142434445464748494a4b4c4d4e4f",)" + R"("file_path":"/foo/bar.so","file_offset":0,"file_size":1234}])", + // no file_path + R"([{"uuid":"404142434445464748494a4b4c4d4e4f","triple":"i386-pc-linux",)" + R"("file_offset":0,"file_size":1234}])", + // no file_offset + R"([{"uuid":"404142434445464748494a4b4c4d4e4f","triple":"i386-pc-linux",)" + R"("file_path":"/foo/bar.so","file_size":1234}])", + // no file_size + R"([{"uuid":"404142434445464748494a4b4c4d4e4f","triple":"i386-pc-linux",)" + R"("file_path":"/foo/bar.so","file_offset":0}])", + }; + + for (const char *response : invalid_responses) { + std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result = + std::async(std::launch::async, + [&] { return client.GetModulesInfo(file_spec, triple); }); + HandlePacket( + server, + R"(jModulesInfo:[{"file":"/foo/bar.so","triple":"i386-pc-linux"}])", + response); + + ASSERT_FALSE(async_result.get().hasValue()) << "response was: " << response; + } +} |