-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Skip remote PutFile when MD5 hashes equal #88812
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
Merged
bulbazord
merged 3 commits into
llvm:main
from
Awfa:users/awfa96/checksum_remote_putfile
Apr 18, 2024
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3419,7 +3419,7 @@ bool GDBRemoteCommunicationClient::GetFileExists( | |
} | ||
|
||
bool GDBRemoteCommunicationClient::CalculateMD5( | ||
const lldb_private::FileSpec &file_spec, uint64_t &high, uint64_t &low) { | ||
const lldb_private::FileSpec &file_spec, uint64_t &low, uint64_t &high) { | ||
Comment on lines
3421
to
+3422
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're changing the interface anyway, could we have this return an |
||
std::string path(file_spec.GetPath(false)); | ||
lldb_private::StreamString stream; | ||
stream.PutCString("vFile:MD5:"); | ||
|
@@ -3433,8 +3433,43 @@ bool GDBRemoteCommunicationClient::CalculateMD5( | |
return false; | ||
if (response.Peek() && *response.Peek() == 'x') | ||
return false; | ||
low = response.GetHexMaxU64(false, UINT64_MAX); | ||
high = response.GetHexMaxU64(false, UINT64_MAX); | ||
|
||
// GDBRemoteCommunicationServerCommon::Handle_vFile_MD5 concatenates low and | ||
// high hex strings. We can't use response.GetHexMaxU64 because that can't | ||
// handle the concatenated hex string. What would happen is parsing the low | ||
// would consume the whole response packet - which is a bug. Instead, we get | ||
Awfa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// the byte string for each low and high hex separately, and parse them. | ||
// | ||
// An alternate way to handle this is to change the server to put a | ||
// delimiter between the low/high parts, and change the client to parse the | ||
// delimiter. However, we choose not to do this so existing lldb-servers | ||
// don't have to be patched | ||
|
||
// The checksum is 128 bits encoded as hex | ||
// This means low/high are halves of 64 bits each, in otherwords, 8 bytes. | ||
// Each byte takes 2 hex characters in the response. | ||
const size_t MD5_HALF_LENGTH = sizeof(uint64_t) * 2; | ||
|
||
// Get low part | ||
auto part = | ||
response.GetStringRef().substr(response.GetFilePos(), MD5_HALF_LENGTH); | ||
if (part.size() != MD5_HALF_LENGTH) | ||
return false; | ||
response.SetFilePos(response.GetFilePos() + part.size()); | ||
|
||
if (part.getAsInteger(/*radix=*/16, low)) | ||
return false; | ||
|
||
// Get high part | ||
part = | ||
response.GetStringRef().substr(response.GetFilePos(), MD5_HALF_LENGTH); | ||
if (part.size() != MD5_HALF_LENGTH) | ||
return false; | ||
response.SetFilePos(response.GetFilePos() + part.size()); | ||
|
||
if (part.getAsInteger(/*radix=*/16, high)) | ||
return false; | ||
|
||
return true; | ||
} | ||
return false; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.