This is an archive of the discontinued LLVM Phabricator instance.

Add filepath to qModuleInfo packet
ClosedPublic

Authored by tberghammer on Mar 10 2015, 12:07 PM.

Details

Summary

Add filepath to qModuleInfo packet

The file path is currently required on android because the executable only contain the name of the system libraries without their path. This CL add an extra field to the qModuleInfo packet to return the full path of a module and add logic to locate a shared module on android.

Diff Detail

Repository
rL LLVM

Event Timeline

tberghammer retitled this revision from to Add filepath to qModuleInfo packet.
tberghammer updated this object.
tberghammer edited the test plan for this revision. (Show Details)
tberghammer added a reviewer: ovyalov.
tberghammer added a subscriber: Unknown Object (MLST).
ovyalov edited edge metadata.Mar 10 2015, 4:29 PM

Please see my comments

source/Host/android/HostInfoAndroid.cpp
47 ↗(On Diff #21616)

How we can handle application's native libraries loaded into zygote process?

If application loads a library via System.loadLibrary a load path might have a following format:

/data/app/com.google.ovyalov.ndktest-1/lib/x86/libprober.so

Depending on a target architecture x86 is replaced with arm64-v8a, armeabi, armeabi-v7a, mips, mips64 or x86_64.

As far as I can see from /proc/${PID}/environ there is no LD_LIBRARY_PATH variable - just LD_PRELOAD=libsigchain.so

88 ↗(On Diff #21616)

Could you use FileSpec here instead of path concatenation?

FileSpec file_candidate(path);
file_candidate.AppendPathComponent(module_path);

http://stackoverflow.com/questions/5103443/how-to-check-what-shared-library-is-loaded-at-run-time

Potentially, we may add optional pid request field to qModuleInfo and then try either to call remotely dlopen(NULL, RTLD_NOW) in a zygote process (it might be tricky since this requires dl library loaded into a process) or parse /proc/$pid/maps

tberghammer edited edge metadata.

http://stackoverflow.com/questions/5103443/how-to-check-what-shared-library-is-loaded-at-run-time

Potentially, we may add optional pid request field to qModuleInfo and then try either to call remotely dlopen(NULL, RTLD_NOW) in a zygote process (it might be tricky since this requires dl library loaded into a process) or parse /proc/$pid/maps

The problem with this approach is that qModuleInfo is usually called before starting the inferior (at least for native applications) so we have ho process to use for this purpose.

source/Host/android/HostInfoAndroid.cpp
47 ↗(On Diff #21616)

I think (hope) when a library is loaded by System.loadLibrary then the debugger will capture the full path of the library, but currently a few feature is missing to try it out with a zygote child. If it isn't the case then we have to improve this function to handle that case also.

I think LD_LIBRARY_PATH is generally not used in android, but the bionic linker supports it so if somebody want to use it, then it is possible to do so. I can imagine a few case when you want to do it, so I would like to support it in lldb to be consistent with the library loader.

88 ↗(On Diff #21616)

Done

ovyalov accepted this revision.Mar 11 2015, 10:26 AM
ovyalov edited edge metadata.
This revision is now accepted and ready to land.Mar 11 2015, 10:26 AM
This revision was automatically updated to reflect the committed changes.