forked from OSchip/llvm-project
[Sanitizer] Make "suppressions" and "print_suppressions" common runtime flags.
No functionality change. llvm-svn: 214343
This commit is contained in:
parent
42af3601c2
commit
77f646c623
|
@ -43,8 +43,6 @@ static void InitializeFlags() {
|
|||
f->resolution = 0;
|
||||
f->max_leaks = 0;
|
||||
f->exitcode = 23;
|
||||
f->print_suppressions = true;
|
||||
f->suppressions="";
|
||||
f->use_registers = true;
|
||||
f->use_globals = true;
|
||||
f->use_stacks = true;
|
||||
|
@ -72,8 +70,6 @@ static void InitializeFlags() {
|
|||
ParseFlag(options, &f->log_pointers, "log_pointers", "");
|
||||
ParseFlag(options, &f->log_threads, "log_threads", "");
|
||||
ParseFlag(options, &f->exitcode, "exitcode", "");
|
||||
ParseFlag(options, &f->print_suppressions, "print_suppressions", "");
|
||||
ParseFlag(options, &f->suppressions, "suppressions", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,12 +87,12 @@ void InitializeSuppressions() {
|
|||
SuppressionContext::Init();
|
||||
char *suppressions_from_file;
|
||||
uptr buffer_size;
|
||||
if (ReadFileToBuffer(flags()->suppressions, &suppressions_from_file,
|
||||
if (ReadFileToBuffer(common_flags()->suppressions, &suppressions_from_file,
|
||||
&buffer_size, 1 << 26 /* max_len */))
|
||||
SuppressionContext::Get()->Parse(suppressions_from_file);
|
||||
if (flags()->suppressions[0] && !buffer_size) {
|
||||
if (common_flags()->suppressions[0] && !buffer_size) {
|
||||
Printf("LeakSanitizer: failed to read suppressions file '%s'\n",
|
||||
flags()->suppressions);
|
||||
common_flags()->suppressions);
|
||||
Die();
|
||||
}
|
||||
if (&__lsan_default_suppressions)
|
||||
|
@ -446,7 +442,7 @@ void DoLeakCheck() {
|
|||
Printf("%s", d.End());
|
||||
param.leak_report.ReportTopLeaks(flags()->max_leaks);
|
||||
}
|
||||
if (flags()->print_suppressions)
|
||||
if (common_flags()->print_suppressions)
|
||||
PrintMatchedSuppressions();
|
||||
if (unsuppressed_count > 0) {
|
||||
param.leak_report.PrintSummary();
|
||||
|
|
|
@ -51,10 +51,6 @@ struct Flags {
|
|||
int max_leaks;
|
||||
// If nonzero kill the process with this exit code upon finding leaks.
|
||||
int exitcode;
|
||||
// Print matched suppressions after leak checking.
|
||||
bool print_suppressions;
|
||||
// Suppressions file name.
|
||||
const char* suppressions;
|
||||
|
||||
// Flags controlling the root set of reachable memory.
|
||||
// Global variables (.data and .bss).
|
||||
|
|
|
@ -63,6 +63,8 @@ void SetCommonFlagsDefaults(CommonFlags *f) {
|
|||
f->coverage_direct = SANITIZER_ANDROID;
|
||||
f->coverage_dir = ".";
|
||||
f->full_address_space = false;
|
||||
f->suppressions = "";
|
||||
f->print_suppressions = true;
|
||||
}
|
||||
|
||||
void ParseCommonFlagsFromString(CommonFlags *f, const char *str) {
|
||||
|
@ -144,6 +146,9 @@ void ParseCommonFlagsFromString(CommonFlags *f, const char *str) {
|
|||
ParseFlag(str, &f->full_address_space, "full_address_space",
|
||||
"Sanitize complete address space; "
|
||||
"by default kernel area on 32-bit platforms will not be sanitized");
|
||||
ParseFlag(str, &f->suppressions, "suppressions", "Suppressions file name.");
|
||||
ParseFlag(str, &f->print_suppressions, "print_suppressions",
|
||||
"Print matched suppressions at exit.");
|
||||
|
||||
// Do a sanity check for certain flags.
|
||||
if (f->malloc_context_size < 1)
|
||||
|
|
|
@ -57,6 +57,8 @@ struct CommonFlags {
|
|||
bool coverage_direct;
|
||||
const char *coverage_dir;
|
||||
bool full_address_space;
|
||||
const char *suppressions;
|
||||
bool print_suppressions;
|
||||
};
|
||||
|
||||
inline CommonFlags *common_flags() {
|
||||
|
|
|
@ -44,8 +44,6 @@ static void ParseFlags(Flags *f, const char *env) {
|
|||
ParseFlag(env, &f->report_signal_unsafe, "report_signal_unsafe", "");
|
||||
ParseFlag(env, &f->report_atomic_races, "report_atomic_races", "");
|
||||
ParseFlag(env, &f->force_seq_cst_atomics, "force_seq_cst_atomics", "");
|
||||
ParseFlag(env, &f->suppressions, "suppressions", "");
|
||||
ParseFlag(env, &f->print_suppressions, "print_suppressions", "");
|
||||
ParseFlag(env, &f->print_benign, "print_benign", "");
|
||||
ParseFlag(env, &f->exitcode, "exitcode", "");
|
||||
ParseFlag(env, &f->halt_on_error, "halt_on_error", "");
|
||||
|
@ -78,8 +76,6 @@ void InitializeFlags(Flags *f, const char *env) {
|
|||
f->report_signal_unsafe = true;
|
||||
f->report_atomic_races = true;
|
||||
f->force_seq_cst_atomics = false;
|
||||
f->suppressions = "";
|
||||
f->print_suppressions = false;
|
||||
f->print_benign = false;
|
||||
f->exitcode = 66;
|
||||
f->halt_on_error = false;
|
||||
|
@ -101,6 +97,7 @@ void InitializeFlags(Flags *f, const char *env) {
|
|||
// Override some common flags defaults.
|
||||
f->allow_addr2line = true;
|
||||
f->detect_deadlocks = true;
|
||||
f->print_suppressions = false;
|
||||
|
||||
// Let a frontend override.
|
||||
ParseFlags(f, __tsan_default_options());
|
||||
|
|
|
@ -44,10 +44,6 @@ struct Flags : CommonFlags, DDFlags {
|
|||
// If set, all atomics are effectively sequentially consistent (seq_cst),
|
||||
// regardless of what user actually specified.
|
||||
bool force_seq_cst_atomics;
|
||||
// Suppressions filename.
|
||||
const char *suppressions;
|
||||
// Print matched suppressions at exit.
|
||||
bool print_suppressions;
|
||||
// Print matched "benign" races at exit.
|
||||
bool print_benign;
|
||||
// Override exit status if something was reported.
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
// matched. Default is print_suppressions=true.
|
||||
// RUN: LSAN_BASE="use_registers=0:use_stacks=0"
|
||||
// RUN: %clangxx_lsan %s -o %t
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 ASAN_OPTIONS=$ASAN_OPTIONS:print_suppressions=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 ASAN_OPTIONS=$ASAN_OPTIONS:print_suppressions=0 %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-print
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// RUN: %clangxx_lsan %s -o %t
|
||||
|
||||
// RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp1
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions=%t.supp1 not %run %t 2>&1 | FileCheck %s
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions=%t.supp1 ASAN_OPTIONS=$ASAN_OPTIONS:suppressions=%t.supp1 not %run %t 2>&1 | FileCheck %s
|
||||
|
||||
// RUN: echo "leak:%t" > %t.supp2
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions="%t.supp2":symbolize=false %run %t
|
||||
// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions="%t.supp2":symbolize=false ASAN_OPTIONS=$ASAN_OPTIONS:suppressions="%t.supp2" %run %t
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
Loading…
Reference in New Issue