diff options
author | Anthony Ha <anthonyha96@gmail.com> | 2024-04-18 12:24:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-18 12:24:24 -0700 |
commit | 22c26fa13d46e174e3d862e5f40cff06d804af0c (patch) | |
tree | 93c9f73389bac09d71f94a328194da8d88d336ca /lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | |
parent | 515269b0ac0e061731eb5546c44083bf771db4d8 (diff) | |
download | llvm-22c26fa13d46e174e3d862e5f40cff06d804af0c.zip llvm-22c26fa13d46e174e3d862e5f40cff06d804af0c.tar.gz llvm-22c26fa13d46e174e3d862e5f40cff06d804af0c.tar.bz2 |
[lldb] Skip remote PutFile when MD5 hashes equal (#88812)
This PR adds a check within `PutFile` to exit early when both local and
destination files have matching MD5 hashes. If they differ, or there is
trouble getting the hashes, the regular code path to put the file is
run.
As I needed this to talk to an `lldb-server` which runs the gdb-remote
protocol, I enabled `CalculateMD5` within `Platform/gdb-server` and also
found and fixed a parsing bug within it as well. Before this PR, the
client is incorrectly parsing the response packet containing the
checksum; after this PR, hopefully this is fixed. There is a test for
the parsing behavior included in this PR.
---------
Co-authored-by: Anthony Ha <antha@microsoft.com>
Diffstat (limited to 'lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp')
-rw-r--r-- | lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index f93cf8c..6b11ec4 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -592,3 +592,26 @@ TEST_F(GDBRemoteCommunicationClientTest, WriteMemoryTags) { std::vector<uint8_t>{0x99}, "QMemTags:456789,0:80000000:99", "E03", false); } + +TEST_F(GDBRemoteCommunicationClientTest, CalculateMD5) { + FileSpec file_spec("/foo/bar", FileSpec::Style::posix); + uint64_t low, high; + std::future<bool> async_result = std::async(std::launch::async, [&] { + return client.CalculateMD5(file_spec, low, high); + }); + + lldb_private::StreamString stream; + stream.PutCString("vFile:MD5:"); + stream.PutStringAsRawHex8(file_spec.GetPath(false)); + HandlePacket(server, stream.GetString().str(), + "F," + "deadbeef01020304" + "05060708deadbeef"); + ASSERT_TRUE(async_result.get()); + + // Server and client puts/parses low, and then high + const uint64_t expected_low = 0xdeadbeef01020304; + const uint64_t expected_high = 0x05060708deadbeef; + EXPECT_EQ(expected_low, low); + EXPECT_EQ(expected_high, high); +} |