forked from OSchip/llvm-project
parent
0c8ed9ce44
commit
6eff11e714
|
@ -114,6 +114,7 @@ static const char *StackOriginDescr[kNumStackOriginDescrs];
|
|||
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, const char *str) {
|
|||
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, uptr bp, u32 origin) {
|
|||
++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_umr) {
|
|||
(void)sp;
|
||||
StackTrace stack;
|
||||
GetStackTrace(&stack, kStackTraceMax, pc, bp,
|
||||
flags()->fast_unwind_on_fatal);
|
||||
common_flags()->fast_unwind_on_fatal);
|
||||
ReportExpectedUMRNotFound(&stack);
|
||||
Die();
|
||||
}
|
||||
|
|
|
@ -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 *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
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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::AnsiColorDecorator {
|
|||
|
||||
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 *error_type, StackTrace *stack) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue