Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb] Unify CalculateMD5 return types #91029

Merged
merged 3 commits into from
May 9, 2024

Conversation

Awfa
Copy link
Contributor

@Awfa Awfa commented May 3, 2024

This is a retake of #90921 which got reverted because I forgot to modify the CalculateMD5 unit test I had added in #88812

The prior failing build is here: https://lab.llvm.org/buildbot/#/builders/68/builds/73622
To make sure this error doesn't happen, I ran ninja ProcessGdbRemoteTests and then executed the resulting test binary and observed the CalculateMD5 test passed.

Overview

In my previous PR: #88812, @JDevlieghere suggested to match return types of the various calculate md5 functions.

This PR achieves that by changing the various calculate md5 functions to return llvm::ErrorOr<llvm::MD5::MD5Result>.
 
The suggestion was to go for std::optional<> but I opted for llvm::ErrorOr<> because local calculate md5 was already possibly returning ErrorOr.

To make sure I didn't break the md5 calculation functionality, I ran some tests for the gdb remote client, and things seem to work.

Testing

  1. Remote file doesn't exist
    image

  2. Remote file differs
    image

  3. Remote file matches
    image

Test gaps

Unfortunately, I had to modify lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp and I can't test the changes there. Hopefully, the existing test suite / code review from whomever is reading this will catch any issues.

@Awfa Awfa requested a review from JDevlieghere as a code owner May 3, 2024 23:30
@Awfa
Copy link
Contributor Author

Awfa commented May 3, 2024

@JDevlieghere , do you know if there's a way to run buildbot on a merge of this PR and main branch - just to validate the build/tests work before this merge?

The llvm contributing guide says this is normal workflow - but I worry since I am using a lot of the maintainers' time to merge / revert the changes for me since I don't have write access.

Unify CalculateMD5 return types
Copy link

github-actions bot commented May 4, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff d129ea8d2fa347e63deec0791faf389b84f20ce1 44223e9a62d116c50b52985ab944a5e2d48de95a -- lldb/include/lldb/Target/Platform.h lldb/include/lldb/Target/RemoteAwarePlatform.h lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Target/Platform.cpp lldb/source/Target/RemoteAwarePlatform.cpp lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
View the diff from clang-format here.
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 6dcf7ef3ea..24111396b0 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -595,9 +595,8 @@ TEST_F(GDBRemoteCommunicationClientTest, WriteMemoryTags) {
 
 TEST_F(GDBRemoteCommunicationClientTest, CalculateMD5) {
   FileSpec file_spec("/foo/bar", FileSpec::Style::posix);
-  std::future<ErrorOr<MD5::MD5Result>> async_result = std::async(std::launch::async, [&] {
-    return client.CalculateMD5(file_spec);
-  });
+  std::future<ErrorOr<MD5::MD5Result>> async_result = std::async(
+      std::launch::async, [&] { return client.CalculateMD5(file_spec); });
 
   lldb_private::StreamString stream;
   stream.PutCString("vFile:MD5:");

@Awfa
Copy link
Contributor Author

Awfa commented May 8, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
View the diff from clang-format here.

This formatter alert is outdated - by the time this arrived, my PR had the issue fixed already.

@JDevlieghere
Copy link
Member

@JDevlieghere , do you know if there's a way to run buildbot on a merge of this PR and main branch - just to validate the build/tests work before this merge?

Not that I know. When failures are macOS specific I'm happy to apply a PR locally and run the test suite and other folks with specific configurations might do the same, but that's about all I can think of.

The llvm contributing guide says this is normal workflow - but I worry since I am using a lot of the maintainers' time to merge / revert the changes for me since I don't have write access.

No worries, it's totally normal and we're happy to help with that!

@Awfa
Copy link
Contributor Author

Awfa commented May 9, 2024

@JDevlieghere , do you know if there's a way to run buildbot on a merge of this PR and main branch - just to validate the build/tests work before this merge?

Not that I know. When failures are macOS specific I'm happy to apply a PR locally and run the test suite and other folks with specific configurations might do the same, but that's about all I can think of.

The llvm contributing guide says this is normal workflow - but I worry since I am using a lot of the maintainers' time to merge / revert the changes for me since I don't have write access.

No worries, it's totally normal and we're happy to help with that!

Can I ask you merge this for me? Hopefully no reverts this time :)

@JDevlieghere JDevlieghere merged commit 95f208f into llvm:main May 9, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants