[NFC] Extract InitializePlatformCommonFlags

And move some Android specifi declarations from headers

Differential Revision: https://reviews.llvm.org/D90811
This commit is contained in:
Vitaly Buka 2020-11-04 18:52:15 -08:00
parent 796650d990
commit 6c164d6080
7 changed files with 29 additions and 15 deletions

View File

@ -215,6 +215,12 @@ static void ProcessThreads(SuspendedThreadsList const &, Frontier *) {}
#else
#if SANITIZER_ANDROID
// FIXME: Move this out into *libcdep.cpp
extern "C" SANITIZER_WEAK_ATTRIBUTE void __libc_iterate_dynamic_tls(
pid_t, void (*cb)(void *, void *, uptr, void *), void *);
#endif
// Scans thread data (stacks and TLS) for heap pointers.
static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
Frontier *frontier) {

View File

@ -126,10 +126,7 @@ void InitializeCommonFlags(CommonFlags *cf) {
cf->coverage |= cf->html_cov_report;
SetVerbosity(cf->verbosity);
#if SANITIZER_ANDROID
if (!HAS_ANDROID_THREAD_PROPERTIES_API)
cf->detect_leaks = false;
#endif
InitializePlatformCommonFlags(cf);
}
} // namespace __sanitizer

View File

@ -62,6 +62,10 @@ void RegisterIncludeFlags(FlagParser *parser, CommonFlags *cf);
// and perform initializations common to all sanitizers (e.g. setting
// verbosity).
void InitializeCommonFlags(CommonFlags *cf = &common_flags_dont_use);
// Platform specific flags initialization.
void InitializePlatformCommonFlags(CommonFlags *cf);
} // namespace __sanitizer
#endif // SANITIZER_FLAGS_H

View File

@ -153,16 +153,6 @@ ALWAYS_INLINE uptr *get_android_tls_ptr() {
return reinterpret_cast<uptr *>(&__get_tls()[TLS_SLOT_SANITIZER]);
}
// Bionic provides this API since S.
extern "C" SANITIZER_WEAK_ATTRIBUTE void __libc_get_static_tls_bounds(void **,
void **);
extern "C" SANITIZER_WEAK_ATTRIBUTE void __libc_iterate_dynamic_tls(
pid_t, void (*cb)(void *, void *, uptr, void *), void *);
#define HAS_ANDROID_THREAD_PROPERTIES_API (&__libc_iterate_dynamic_tls != 0)
#else
#define HAS_ANDROID_THREAD_PROPERTIES_API (0)
#endif // SANITIZER_ANDROID
} // namespace __sanitizer

View File

@ -445,10 +445,16 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) {
}
#endif // SANITIZER_NETBSD
#if SANITIZER_ANDROID
// Bionic provides this API since S.
extern "C" SANITIZER_WEAK_ATTRIBUTE void __libc_get_static_tls_bounds(void **,
void **);
#endif
#if !SANITIZER_GO
static void GetTls(uptr *addr, uptr *size) {
#if SANITIZER_ANDROID
if (HAS_ANDROID_THREAD_PROPERTIES_API) {
if (&__libc_get_static_tls_bounds) {
void *start_addr;
void *end_addr;
__libc_get_static_tls_bounds(&start_addr, &end_addr);
@ -900,6 +906,13 @@ uptr MapDynamicShadow(uptr shadow_size_bytes, uptr shadow_scale,
return shadow_start;
}
void InitializePlatformCommonFlags(CommonFlags *cf) {
#if SANITIZER_ANDROID
if (&__libc_get_static_tls_bounds == nullptr)
cf->detect_leaks = false;
#endif
}
} // namespace __sanitizer
#endif

View File

@ -1333,6 +1333,8 @@ u32 GetNumberOfCPUs() {
return (u32)sysconf(_SC_NPROCESSORS_ONLN);
}
void InitializePlatformCommonFlags(CommonFlags *cf) {}
} // namespace __sanitizer
#endif // SANITIZER_MAC

View File

@ -1138,6 +1138,8 @@ void LogFullErrorReport(const char *buffer) {
}
#endif // SANITIZER_WIN_TRACE
void InitializePlatformCommonFlags(CommonFlags *cf) {}
} // namespace __sanitizer
#endif // _WIN32