[compiler-rt] r181194 - [msan] Common flags in MSan.
Sergey Matveev
earthdok at google.com
Mon May 6 06:15:14 PDT 2013
Author: smatveev
Date: Mon May 6 08:15:14 2013
New Revision: 181194
URL: http://llvm.org/viewvc/llvm-project?rev=181194&view=rev
Log:
[msan] Common flags in MSan.
Modified:
compiler-rt/trunk/lib/msan/msan.cc
compiler-rt/trunk/lib/msan/msan.h
compiler-rt/trunk/lib/msan/msan_flags.h
compiler-rt/trunk/lib/msan/msan_report.cc
Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=181194&r1=181193&r2=181194&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Mon May 6 08:15:14 2013
@@ -114,6 +114,7 @@ static const char *StackOriginDescr[kNum
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 @@ static void ParseFlagsFromString(Flags *
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 @@ void PrintWarningWithOrigin(uptr pc, upt
++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 @@ void __msan_init() {
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 __msan_set_expect_umr(int expect_um
(void)sp;
StackTrace stack;
GetStackTrace(&stack, kStackTraceMax, pc, bp,
- flags()->fast_unwind_on_fatal);
+ common_flags()->fast_unwind_on_fatal);
ReportExpectedUMRNotFound(&stack);
Die();
}
Modified: compiler-rt/trunk/lib/msan/msan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.h?rev=181194&r1=181193&r2=181194&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.h (original)
+++ compiler-rt/trunk/lib/msan/msan.h Mon May 6 08:15:14 2013
@@ -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 @@ void UnpoisonMappedDSO(struct link_map *
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
Modified: compiler-rt/trunk/lib/msan/msan_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_flags.h?rev=181194&r1=181193&r2=181194&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_flags.h (original)
+++ compiler-rt/trunk/lib/msan/msan_flags.h Mon May 6 08:15:14 2013
@@ -19,17 +19,11 @@ namespace __msan {
// 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;
};
Modified: compiler-rt/trunk/lib/msan/msan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_report.cc?rev=181194&r1=181193&r2=181194&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_report.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_report.cc Mon May 6 08:15:14 2013
@@ -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 @@ class Decorator: private __sanitizer::An
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 @@ static void ReportSummary(const char *er
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);
}
More information about the llvm-commits
mailing list