This is an archive of the discontinued LLVM Phabricator instance.

ComputeSupportExeDirectory for Linux
ClosedPublic

Authored by chaoren on Mar 23 2015, 5:36 PM.

Details

Summary

Fixes http://reviews.llvm.org/D8511

The original method of using dladdr() could return the incorrect relative
path if not dynamically linked against liblldb and the working directory
has changed. This is not a problem when built with python, since
ScriptInterpreterPython::InitializePrivate calls
HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, ...) and caches the
correct path before any changes to the working directory.

The /proc/self/exe approach fails if run using Python, but works for all other
cases (including for android, which doesn't have dladdr()).

So if we combine the two, we should reasonably cover all corner cases.

Diff Detail

Event Timeline

chaoren updated this revision to Diff 22532.Mar 23 2015, 5:36 PM
chaoren retitled this revision from to ComputeSupportExeDirectory for Linux.
chaoren updated this object.
chaoren edited the test plan for this revision. (Show Details)
chaoren added reviewers: ovyalov, vharron, clayborg.
chaoren added a subscriber: Unknown Object (MLST).
chaoren updated this object.Mar 23 2015, 5:38 PM
ovyalov added inline comments.Mar 23 2015, 6:21 PM
source/Host/linux/HostInfoLinux.cpp
225

Do we need to keep this method around since HostInfoPosix::ComputeSupportExeDirectory uses GetLLDBPath(lldb::ePathTypeLLDBShlibDir..) ?

chaoren added inline comments.Mar 23 2015, 7:20 PM
source/Host/linux/HostInfoLinux.cpp
225

This was added by me to fix this same problem. HostInfoPosix::ComputeSupportExeDirectory really wants to call HostInfoBase::ComputeSharedLibraryDirectory. I think it's more correct to move it to SupportExe because if dladdr() fails, then there should be no shared library anyway.

ovyalov accepted this revision.Mar 23 2015, 8:13 PM
ovyalov edited edge metadata.

lgtm

This revision is now accepted and ready to land.Mar 23 2015, 8:13 PM
clayborg accepted this revision.Mar 24 2015, 9:36 AM
clayborg edited edge metadata.

lgtm

This revision was automatically updated to reflect the committed changes.