forked from OSchip/llvm-project
[UBSan] Parse common runtime flags before using a symbolizer
llvm-svn: 201217
This commit is contained in:
parent
5b3a6bd370
commit
c34a997669
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "ubsan_diag.h"
|
||||
#include "sanitizer_common/sanitizer_common.h"
|
||||
#include "sanitizer_common/sanitizer_flags.h"
|
||||
#include "sanitizer_common/sanitizer_libc.h"
|
||||
#include "sanitizer_common/sanitizer_report_decorator.h"
|
||||
#include "sanitizer_common/sanitizer_stacktrace.h"
|
||||
|
@ -21,6 +22,22 @@
|
|||
|
||||
using namespace __ubsan;
|
||||
|
||||
static void InitializeSanitizerCommon() {
|
||||
static StaticSpinMutex init_mu;
|
||||
SpinMutexLock l(&init_mu);
|
||||
static bool initialized;
|
||||
if (initialized)
|
||||
return;
|
||||
if (0 == internal_strcmp(SanitizerToolName, "SanitizerTool")) {
|
||||
// UBSan is run in a standalone mode. Initialize it now.
|
||||
SanitizerToolName = "UndefinedBehaviorSanitizer";
|
||||
CommonFlags *cf = common_flags();
|
||||
SetCommonFlagsDefaults(cf);
|
||||
cf->print_summary = false;
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
Location __ubsan::getCallerLocation(uptr CallerLoc) {
|
||||
if (!CallerLoc)
|
||||
return Location();
|
||||
|
@ -32,6 +49,8 @@ Location __ubsan::getCallerLocation(uptr CallerLoc) {
|
|||
Location __ubsan::getFunctionLocation(uptr Loc, const char **FName) {
|
||||
if (!Loc)
|
||||
return Location();
|
||||
// FIXME: We may need to run initialization earlier.
|
||||
InitializeSanitizerCommon();
|
||||
|
||||
AddressInfo Info;
|
||||
if (!Symbolizer::GetOrInit()->SymbolizePC(Loc, &Info, 1) ||
|
||||
|
|
Loading…
Reference in New Issue