Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: build/sanitizers/sanitizer_options.cc

Issue 924923002: Add default options/suppressions for LeakSanitizer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/sanitizers/lsan_suppressions.cc ('k') | build/sanitizers/sanitizers.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/sanitizers/sanitizer_options.cc
diff --git a/build/sanitizers/sanitizer_options.cc b/build/sanitizers/sanitizer_options.cc
index af78bf855806434a5952861cf81316590be7ce51..6668c1eef3022958a551729b3f2c0fa52702fa17 100644
--- a/build/sanitizers/sanitizer_options.cc
+++ b/build/sanitizers/sanitizer_options.cc
@@ -12,6 +12,8 @@
#include <string.h>
#endif // ADDRESS_SANITIZER && OS_MACOSX
+#if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \
+ defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER)
// Functions returning default options are declared weak in the tools' runtime
// libraries. To make the linker pick the strong replacements for those
// functions from this module, we explicitly force its inclusion by passing
@@ -19,6 +21,19 @@
extern "C"
void _sanitizer_options_link_helper() { }
+// The callbacks we define here will be called from the sanitizer runtime, but
+// aren't referenced from the Chrome executable. We must ensure that those
+// callbacks are not sanitizer-instrumented, and that they aren't stripped by
+// the linker.
+#define SANITIZER_HOOK_ATTRIBUTE \
+ extern "C" \
+ __attribute__((no_sanitize_address)) \
+ __attribute__((no_sanitize_memory)) \
+ __attribute__((no_sanitize_thread)) \
+ __attribute__((visibility("default"))) \
+ __attribute__((used))
+#endif
+
#if defined(ADDRESS_SANITIZER)
// Default options for AddressSanitizer in various configurations:
// strict_memcmp=1 - disable the strict memcmp() checking
@@ -78,13 +93,7 @@ static const char kNaClFlag[] = "--type=nacl-loader";
#endif // OS_LINUX
#if defined(OS_LINUX) || defined(OS_MACOSX)
-extern "C"
-__attribute__((no_sanitize_address))
-__attribute__((visibility("default")))
-// The function isn't referenced from the executable itself. Make sure it isn't
-// stripped by the linker.
-__attribute__((used))
-const char *__asan_default_options() {
+SANITIZER_HOOK_ATTRIBUTE const char *__asan_default_options() {
#if defined(OS_MACOSX)
char*** argvp = _NSGetArgv();
int* argcp = _NSGetArgc();
@@ -120,26 +129,34 @@ const char kTsanDefaultOptions[] =
"report_thread_leaks=0 print_suppressions=1 history_size=7 "
"strip_path_prefix=Release/../../ ";
-extern "C"
-__attribute__((no_sanitize_thread))
-__attribute__((visibility("default")))
-// The function isn't referenced from the executable itself. Make sure it isn't
-// stripped by the linker.
-__attribute__((used))
-const char *__tsan_default_options() {
+SANITIZER_HOOK_ATTRIBUTE const char *__tsan_default_options() {
return kTsanDefaultOptions;
}
extern "C" char kTSanDefaultSuppressions[];
-extern "C"
-__attribute__((no_sanitize_thread))
-__attribute__((visibility("default")))
-// The function isn't referenced from the executable itself. Make sure it isn't
-// stripped by the linker.
-__attribute__((used))
-const char *__tsan_default_suppressions() {
+SANITIZER_HOOK_ATTRIBUTE const char *__tsan_default_suppressions() {
return kTSanDefaultSuppressions;
}
#endif // THREAD_SANITIZER && OS_LINUX
+
+#if defined(LEAK_SANITIZER)
+// Default options for LeakSanitizer:
+// print_suppressions=1 - print the list of matched suppressions.
+// strip_path_prefix=Release/../../ - prefixes up to and including this
+// substring will be stripped from source file paths in symbolized reports.
+const char kLsanDefaultOptions[] =
+ "print_suppressions=1 strip_path_prefix=Release/../../ ";
+
+SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_options() {
+ return kLsanDefaultOptions;
+}
+
+extern "C" char kLSanDefaultSuppressions[];
+
+SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_suppressions() {
+ return kLSanDefaultSuppressions;
+}
+
+#endif // LEAK_SANITIZER
« no previous file with comments | « build/sanitizers/lsan_suppressions.cc ('k') | build/sanitizers/sanitizers.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698