Refactor android fallback procmaps init. NFC.
llvm-svn: 314518
This commit is contained in:
parent
0e16a59e83
commit
5207630d7e
|
@ -462,21 +462,30 @@ extern "C" __attribute__((weak)) int dl_iterate_phdr(
|
||||||
int (*)(struct dl_phdr_info *, size_t, void *), void *);
|
int (*)(struct dl_phdr_info *, size_t, void *), void *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ListOfModules::init() {
|
static bool requiresProcmaps() {
|
||||||
clear();
|
|
||||||
#if SANITIZER_ANDROID && __ANDROID_API__ <= 22
|
#if SANITIZER_ANDROID && __ANDROID_API__ <= 22
|
||||||
u32 api_level = AndroidGetApiLevel();
|
|
||||||
// Fall back to /proc/maps if dl_iterate_phdr is unavailable or broken.
|
// Fall back to /proc/maps if dl_iterate_phdr is unavailable or broken.
|
||||||
// The runtime check allows the same library to work with
|
// The runtime check allows the same library to work with
|
||||||
// both K and L (and future) Android releases.
|
// both K and L (and future) Android releases.
|
||||||
if (api_level <= ANDROID_LOLLIPOP_MR1) { // L or earlier
|
return AndroidGetApiLevel() <= ANDROID_LOLLIPOP_MR1;
|
||||||
MemoryMappingLayout memory_mapping(false);
|
#else
|
||||||
memory_mapping.DumpListOfModules(&modules_);
|
return false;
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
DlIteratePhdrData data = {&modules_, true};
|
}
|
||||||
dl_iterate_phdr(dl_iterate_phdr_cb, &data);
|
|
||||||
|
static void procmapsInit(InternalMmapVector<LoadedModule> *modules) {
|
||||||
|
MemoryMappingLayout memory_mapping(false);
|
||||||
|
memory_mapping.DumpListOfModules(modules);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListOfModules::init() {
|
||||||
|
clear();
|
||||||
|
if (requiresProcmaps()) {
|
||||||
|
procmapsInit(&modules_);
|
||||||
|
} else {
|
||||||
|
DlIteratePhdrData data = {&modules_, true};
|
||||||
|
dl_iterate_phdr(dl_iterate_phdr_cb, &data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getrusage does not give us the current RSS, only the max RSS.
|
// getrusage does not give us the current RSS, only the max RSS.
|
||||||
|
|
Loading…
Reference in New Issue