[ASan/Win] Minor improvements towards enabling coverage

llvm-svn: 233918
This commit is contained in:
Timur Iskhodzhanov
2015-04-02 14:48:08 +00:00
parent 022e7fe144
commit ad3ec82bb1
4 changed files with 28 additions and 5 deletions

View File

@@ -219,8 +219,15 @@ const char *StripPathPrefix(const char *filepath,
const char *StripModuleName(const char *module) {
if (module == 0)
return 0;
if (const char *slash_pos = internal_strrchr(module, '/'))
if (SANITIZER_WINDOWS) {
// On Windows, both slash and backslash are possible.
// Pick the one that goes last.
if (const char *bslash_pos = internal_strrchr(module, '\\'))
return StripModuleName(bslash_pos + 1);
}
if (const char *slash_pos = internal_strrchr(module, '/')) {
return slash_pos + 1;
}
return module;
}

View File

@@ -113,12 +113,13 @@ void BackgroundThread(void *arg) {
}
void MaybeStartBackgroudThread() {
if (!SANITIZER_LINUX) return; // Need to implement/test on other platforms.
#if SANITIZER_LINUX // Need to implement/test on other platforms.
// Start the background thread if one of the rss limits is given.
if (!common_flags()->hard_rss_limit_mb &&
!common_flags()->soft_rss_limit_mb) return;
if (!&real_pthread_create) return; // Can't spawn the thread anyway.
internal_start_thread(BackgroundThread, nullptr);
#endif
}
} // namespace __sanitizer

View File

@@ -834,9 +834,7 @@ void InitializeCoverage(bool enabled, const char *dir) {
coverage_dir = dir;
coverage_data.Init();
if (enabled) coverage_data.Enable();
#if !SANITIZER_WINDOWS
if (!common_flags()->coverage_direct) Atexit(__sanitizer_cov_dump);
#endif
}
void ReInitializeCoverage(bool enabled, const char *dir) {

View File

@@ -353,9 +353,26 @@ uptr GetListOfModules(LoadedModule *modules, uptr max_modules,
};
#ifndef SANITIZER_GO
// We can't use atexit() directly at __asan_init time as the CRT is not fully
// initialized at this point. Place the functions into a vector and use
// atexit() as soon as it is ready for use (i.e. after .CRT$XIC initializers).
InternalMmapVectorNoCtor<void (*)(void)> atexit_functions;
int Atexit(void (*function)(void)) {
return atexit(function);
atexit_functions.push_back(function);
return 0;
}
static int RunAtexit() {
int ret = 0;
for (uptr i = 0; i < atexit_functions.size(); ++i) {
ret |= atexit(atexit_functions[i]);
}
return ret;
}
#pragma section(".CRT$XID", long, read) // NOLINT
static __declspec(allocate(".CRT$XID")) int (*__run_atexit)() = RunAtexit;
#endif
// ------------------ sanitizer_libc.h