[msan] Common flags in MSan.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@181194 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/msan/msan.cc b/lib/msan/msan.cc
index e872abf..7bc0e4f 100644
--- a/lib/msan/msan.cc
+++ b/lib/msan/msan.cc
@@ -114,6 +114,7 @@
static atomic_uint32_t NumStackOriginDescrs;
static void ParseFlagsFromString(Flags *f, const char *str) {
+ ParseCommonFlagsFromString(str);
ParseFlag(str, &f->poison_heap_with_zeroes, "poison_heap_with_zeroes");
ParseFlag(str, &f->poison_stack_with_zeroes, "poison_stack_with_zeroes");
ParseFlag(str, &f->poison_in_malloc, "poison_in_malloc");
@@ -123,28 +124,26 @@
f->exit_code = 1;
Die();
}
- ParseFlag(str, &f->num_callers, "num_callers");
ParseFlag(str, &f->report_umrs, "report_umrs");
ParseFlag(str, &f->verbosity, "verbosity");
- ParseFlag(str, &f->strip_path_prefix, "strip_path_prefix");
- ParseFlag(str, &f->fast_unwind_on_fatal, "fast_unwind_on_fatal");
- ParseFlag(str, &f->fast_unwind_on_malloc, "fast_unwind_on_malloc");
ParseFlag(str, &f->wrap_signals, "wrap_signals");
}
static void InitializeFlags(Flags *f, const char *options) {
- internal_memset(f, 0, sizeof(*f));
+ CommonFlags *cf = common_flags();
+ cf->external_symbolizer_path = GetEnv("MSAN_SYMBOLIZER_PATH");
+ cf->strip_path_prefix = "";
+ cf->fast_unwind_on_fatal = false;
+ cf->fast_unwind_on_malloc = true;
+ cf->malloc_context_size = 20;
+ internal_memset(f, 0, sizeof(*f));
f->poison_heap_with_zeroes = false;
f->poison_stack_with_zeroes = false;
f->poison_in_malloc = true;
f->exit_code = 77;
- f->num_callers = 20;
f->report_umrs = true;
f->verbosity = 0;
- f->strip_path_prefix = "";
- f->fast_unwind_on_fatal = false;
- f->fast_unwind_on_malloc = true;
f->wrap_signals = true;
// Override from user-specified string.
@@ -201,7 +200,8 @@
++msan_report_count;
StackTrace stack;
- GetStackTrace(&stack, kStackTraceMax, pc, bp, flags()->fast_unwind_on_fatal);
+ GetStackTrace(&stack, kStackTraceMax, pc, bp,
+ common_flags()->fast_unwind_on_fatal);
u32 report_origin =
(__msan_track_origins && OriginIsValid(origin)) ? origin : 0;
@@ -276,7 +276,7 @@
Die();
}
- const char *external_symbolizer = GetEnv("MSAN_SYMBOLIZER_PATH");
+ const char *external_symbolizer = common_flags()->external_symbolizer_path;
if (external_symbolizer && external_symbolizer[0]) {
CHECK(InitializeExternalSymbolizer(external_symbolizer));
}
@@ -302,7 +302,7 @@
(void)sp;
StackTrace stack;
GetStackTrace(&stack, kStackTraceMax, pc, bp,
- flags()->fast_unwind_on_fatal);
+ common_flags()->fast_unwind_on_fatal);
ReportExpectedUMRNotFound(&stack);
Die();
}
diff --git a/lib/msan/msan.h b/lib/msan/msan.h
index 90f30af..baaba49 100644
--- a/lib/msan/msan.h
+++ b/lib/msan/msan.h
@@ -15,6 +15,7 @@
#ifndef MSAN_H
#define MSAN_H
+#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "msan_interface_internal.h"
@@ -81,9 +82,9 @@
StackTrace stack; \
stack.size = 0; \
if (__msan_get_track_origins() && msan_inited) \
- GetStackTrace(&stack, flags()->num_callers, \
+ GetStackTrace(&stack, common_flags()->malloc_context_size, \
StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), \
- flags()->fast_unwind_on_malloc)
+ common_flags()->fast_unwind_on_malloc)
} // namespace __msan
diff --git a/lib/msan/msan_flags.h b/lib/msan/msan_flags.h
index dfad8a4..64ef845 100644
--- a/lib/msan/msan_flags.h
+++ b/lib/msan/msan_flags.h
@@ -19,17 +19,11 @@
// Flags.
struct Flags {
int exit_code;
- int num_callers;
int verbosity;
bool poison_heap_with_zeroes; // default: false
bool poison_stack_with_zeroes; // default: false
bool poison_in_malloc; // default: true
bool report_umrs;
- const char *strip_path_prefix;
- // Use fast (frame-pointer-based) unwinder on fatal errors (if available).
- bool fast_unwind_on_fatal;
- // Use fast (frame-pointer-based) unwinder on malloc/free (if available).
- bool fast_unwind_on_malloc;
bool wrap_signals;
};
diff --git a/lib/msan/msan_report.cc b/lib/msan/msan_report.cc
index 5611a5f..734fc96 100644
--- a/lib/msan/msan_report.cc
+++ b/lib/msan/msan_report.cc
@@ -14,6 +14,7 @@
#include "msan.h"
#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_mutex.h"
#include "sanitizer_common/sanitizer_report_decorator.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
@@ -44,7 +45,8 @@
static void PrintStack(const uptr *trace, uptr size) {
SymbolizerScope sym_scope;
- StackTrace::PrintStack(trace, size, true, flags()->strip_path_prefix, 0);
+ StackTrace::PrintStack(trace, size, true,
+ common_flags()->strip_path_prefix, 0);
}
static void DescribeOrigin(u32 origin) {
@@ -80,7 +82,8 @@
SymbolizeCode(pc, &ai, 1);
}
ReportErrorSummary(error_type,
- StripPathPrefix(ai.file, flags()->strip_path_prefix),
+ StripPathPrefix(ai.file,
+ common_flags()->strip_path_prefix),
ai.line, ai.function);
}