This is an archive of the discontinued LLVM Phabricator instance.

Add qModuleInfo request in order to get module information (uuid, triple,..) by module path from remote platform.
ClosedPublic

Authored by ovyalov on Feb 17 2015, 4:08 PM.

Details

Reviewers
vharron
clayborg
Summary

Taking into account comments on http://reviews.llvm.org/D7574, I decided to reconsider the solution - manual modules download from a target isn't reliable solution and may lead to some subtle errors.
The idea behind the alternative solution is to use module's UUID as unique identifier and download module from remote target if such module isn't presented in local cache.
This CL is first of a few steps - add new qModuleInfo request, so platform by given path can return some module context - UUID, triple, file size,...

The ultimate solution will include extending PlatformRemoteGDBServer::ResolveExecutable and GetSharedModule methods with such logic flow:

  • For each given module get its UUID using qModuleInfo or fallback to content MD5 if module doesn't have UUID.
  • Check local cache for module with such UUID. If module exists in cache - use it, otherwise download a module from a target and put into cache.
  • Introduce new bool property to allow conditional modules' download.

Please let me know whether it sounds reasonable to you.

Diff Detail

Event Timeline

ovyalov updated this revision to Diff 20119.Feb 17 2015, 4:08 PM
ovyalov retitled this revision from to Add qModuleInfo request in order to get module information (uuid, triple,..) by module path from remote platform. .
ovyalov updated this object.
ovyalov edited the test plan for this revision. (Show Details)
ovyalov added reviewers: clayborg, vharron.
ovyalov added a subscriber: Unknown Object (MLST).
vharron accepted this revision.Feb 19 2015, 9:47 AM
vharron edited edge metadata.
vharron added inline comments.
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
1131

Maybe return an error code if there is no UUID in the module? Or add timestamp or timestamp+date as UUID?

This revision is now accepted and ready to land.Feb 19 2015, 9:47 AM
clayborg requested changes to this revision.Feb 19 2015, 11:48 AM
clayborg edited edge metadata.

We need to deal with files that contains more than 1 architecture slice and either pick the right one and return it, or return multiple matches. See inlined comments.

source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
1126

The module_path can represent a fat file with multiple architectures (or it could be a .a file with many many .o files inside of it).

You actually want to use:

FileSpec module_spec(module_path.c_str(), true);
ModuleSpecList module_specs;
if (ObjectFile::GetModuleSpecifications(module_spec, 0, 0, module_specs))
{
}

and you probably want to return all values that it comes up with. (triple + UUID for each slice). If you want to limit it down, you will need to match the architecture against the current process' architecture and return just that one. This is of course only if "module_specs" has more than 1 module specs inside it.

If you choose to return multiple items, you will need to convert your answer over to using JSON like some of the packets Jason Molenda has added to debugserver. If you limit it down to 1 item, then you can just figure out which one you want from the list if there is more than one and just return that.

1131–1134

Check uuid_str to see if it is empty and if not, do the above "uuid:" code, else maybe get the MD5 checksum and return a "md5:XXXXXXXXX" value instead?

This revision now requires changes to proceed.Feb 19 2015, 11:48 AM
ovyalov updated this revision to Diff 20435.Feb 20 2015, 2:41 PM
ovyalov edited edge metadata.
  • Added md5:.. output field if module doesn't have UUID.
  • qModuleInfo takes additional arch triple request param that should match module's architecture.

Please take another look.
Thank you.

Hi all,

In this instance, we are using this uuid to determine if the module is already cached on the host, right?

If a fat binary has multiple architectures in a single file and each arch has it's own uuid, wouldn't we just combine (add/xor/whatever) the uuids to get a single uuid for the entire file?

Hi Vince,

Hi all,

In this instance, we are using this uuid to determine if the module is already cached on the host, right?

yes, the plan to have local cache on host side with UUID used a key.

If a fat binary has multiple architectures in a single file and each arch has it's own uuid, wouldn't we just combine (add/xor/whatever) the uuids to get a single uuid for the entire file?

My understanding that in case of a fat binary with multiple architectures there is still a single UUID that represents a whole module's binary file, i.e. UUID shouldn't be tied to an architecture.

ovyalov updated this revision to Diff 20525.Feb 23 2015, 11:10 AM
ovyalov edited edge metadata.
  • Added file_offset, file_size response fields for qModuleInfo request
  • Made MD5 computation functions to take offset, length parameters to get MD% from a file's slice.

Please take another look.
Thank you.

clayborg requested changes to this revision.Feb 23 2015, 11:25 AM
clayborg edited edge metadata.

A few changes only for the MD5 computation calls: don't require people to pass magic values of 0 for offset and 0 for length when they want the whole file. See inlined comments.

source/Host/common/FileSystem.cpp
57–68

Can we make one version where offset and length are supplied and one that doesn't require it? I hate to have magic values like 0 and 0 for offset and length unless we can make them default argument values.

81–91

Can we make one version where offset and length are supplied and one that doesn't require it? I hate to have magic values like 0 and 0 for offset and length unless we can make them default argument values.

source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
395 ↗(On Diff #20525)

Call the version that doesn't require file offset and size.

source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
828

Call the version that doesn't require file offset and size.

source/Target/Platform.cpp
1470 ↗(On Diff #20525)

Call the version that doesn't require file offset and size.

This revision now requires changes to proceed.Feb 23 2015, 11:25 AM
ovyalov updated this revision to Diff 20534.Feb 23 2015, 1:14 PM
ovyalov edited edge metadata.

Overloaded CalculateMD5 and CalculateMD5AsString methods in order to have versions with and without offset/length.

Thank you.

Please let me know whether this CL looks good to go.

clayborg accepted this revision.Feb 24 2015, 5:49 PM
clayborg edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Feb 24 2015, 5:49 PM
ovyalov closed this revision.Feb 25 2015, 2:18 PM

AFFECTED FILES

/lldb/trunk/docs/lldb-gdb-remote.txt
/lldb/trunk/include/lldb/Host/FileSystem.h
/lldb/trunk/source/Host/common/FileSystem.cpp
/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
/lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp
/lldb/trunk/source/Utility/StringExtractorGDBRemote.h

USERS

ovyalov (Author)

http://reviews.llvm.org/rL230556