This is an archive of the discontinued LLVM Phabricator instance.

Leave OS type and vendor as unspecified unknowns.
ClosedPublic

Authored by ovyalov on May 27 2015, 6:02 PM.

Details

Summary

Leave OS type and vendor as unspecified unknowns - so it can filled in by merging with target or host architecture.

Diff Detail

Event Timeline

ovyalov updated this revision to Diff 26654.May 27 2015, 6:02 PM
ovyalov retitled this revision from to Fill in unknown ArchSpec's OS type and environment on Android when resolving executable architecture..
ovyalov updated this object.
ovyalov edited the test plan for this revision. (Show Details)
ovyalov added a reviewer: tberghammer.
ovyalov added a subscriber: Unknown Object (MLST).
tberghammer edited edge metadata.May 28 2015, 6:13 AM

I don't really like the way we force some fix value into the triple on android. Do you know who is depending on this information to be filled in? I think it would be a better idea to change that function to accept unknown value both for OS and for Environment in case it isn't specified in the ELF file.

I don't really like the way we force some fix value into the triple on android. Do you know who is depending on this information to be filled in? I think it would be a better idea to change that function to accept unknown value both for OS and for Environment in case it isn't specified in the ELF file.

The problem that I stumbled upon is qProcessInfo - response field ostype is set to 'unknown' and eventually host side cannot find an appropriate dynamic loader for such process, no modules are loaded.

I checked your change again and I don't understand why it have any effect at all. The "process_info.GetArchitecture().MergeFrom(HostInfo::GetArchitecture());" call should fill in all of these details from the HostInfo even without your change assuming HostInfo::GetArchitecture() returns the correct value.

If it isn't filled by the MergeFrom call then we should fix that one instead of adding one more merge layer with hard coded values.

I checked your change again and I don't understand why it have any effect at all. The "process_info.GetArchitecture().MergeFrom(HostInfo::GetArchitecture());" call should fill in all of these details from the HostInfo even without your change assuming HostInfo::GetArchitecture() returns the correct value.

If it isn't filled by the MergeFrom call then we should fix that one instead of adding one more merge layer with hard coded values.

Presumably problem is in specified unknowns for os and environment set by ObjectFileELF::GetModuleSpecifications.
ArchSpec::MergeFrom updates os and environment only if corresponding item wasn't set in destination spec.
We may modify ObjectFileELF::GetModuleSpecifications to leave os and environment as unspecified unknowns if there is no explicit values for them.

I checked your change again and I don't understand why it have any effect at all. The "process_info.GetArchitecture().MergeFrom(HostInfo::GetArchitecture());" call should fill in all of these details from the HostInfo even without your change assuming HostInfo::GetArchitecture() returns the correct value.

If it isn't filled by the MergeFrom call then we should fix that one instead of adding one more merge layer with hard coded values.

Presumably problem is in specified unknowns for os and environment set by ObjectFileELF::GetModuleSpecifications.
ArchSpec::MergeFrom updates os and environment only if corresponding item wasn't set in destination spec.
We may modify ObjectFileELF::GetModuleSpecifications to leave os and environment as unspecified unknowns if there is no explicit values for them.

I would prefer that solution especially as the merge was added to handle this type of problems. For the first look I don't see any place where GetModuleSpecifications set os/environment to specified unknown but I might miss something.

ovyalov updated this revision to Diff 26726.May 28 2015, 1:06 PM
ovyalov retitled this revision from Fill in unknown ArchSpec's OS type and environment on Android when resolving executable architecture. to Leave OS type as unspecified unknown for ELF binaries..
ovyalov updated this object.
ovyalov added a reviewer: clayborg.

Leave OS type as unspecified unknown for ELF binaries - so it can be filled in by merging with target or host architecture.

clayborg accepted this revision.May 28 2015, 1:30 PM
clayborg edited edge metadata.

Looks good.

This revision is now accepted and ready to land.May 28 2015, 1:30 PM
tberghammer accepted this revision.May 29 2015, 2:57 AM
tberghammer edited edge metadata.

LGTM (Do you know why we set the vendor to "defined unknown"?)

LGTM (Do you know why we set the vendor to "defined unknown"?)

Hard to say - there are might be some historical reasons...
Potentially, we may leave it as unspecified unknown as well.

We should prefer unspecified unknown for now for anything that isn't known. We really want this triple to be "<arch>-*-<ostype>" or "<arch>-*-*. We should, at some point, try to get a wildcard patch into the LLVM triple where we get AnyOS added to llvm::Triple::OSType and AnyVendor added to the and llvm::Triple::VendorType. This would then allow the triples to print nicely ( x86_64-*-* instead of "x86_64-unknown-unknown" and not being able to tell if the unknowns are specified or not.

ovyalov updated this revision to Diff 26804.May 29 2015, 11:43 AM
ovyalov retitled this revision from Leave OS type as unspecified unknown for ELF binaries. to Leave OS type and vendor as unspecified unknowns..
ovyalov updated this object.
ovyalov edited edge metadata.

According to Greg's comment removed setting os type and vendor type to unknown altogether - if this will cause problem on some architectures, we can narrow down the scope, let's say apply only to ELF.

ovyalov closed this revision.May 29 2015, 3:50 PM

AFFECTED FILES

/lldb/trunk/source/Core/ArchSpec.cpp

USERS

ovyalov (Author)

http://reviews.llvm.org/rL238623