summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-12-19 21:40:04 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-12-19 21:40:04 +0000
commit2f8c8d59b2a2694b27ca7b287998fd602dc56539 (patch)
tree8e3dc8189405c2b86ebf3f5438bc1032cf45094a /compiler-rt/lib/sanitizer_common/sanitizer_flags.cc
parent186eac3c0c1e6575a64a0d98c43ac651af66ff28 (diff)
downloadbcm5719-llvm-2f8c8d59b2a2694b27ca7b287998fd602dc56539.tar.gz
bcm5719-llvm-2f8c8d59b2a2694b27ca7b287998fd602dc56539.zip
[Sanitizer] Refactor CommonFlags interface. NFC.
Add CommonFlags::SetDefaults() and CommonFlags::ParseFromString(), so that this object can be easily tested. Enforce that ParseCommonFlagsFromString() and SetCommonFlagsDefaults() work only with singleton CommonFlags, shared across all sanitizer runtimes. llvm-svn: 224617
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_flags.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_flags.cc146
1 files changed, 73 insertions, 73 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc
index 81d57e0f738..c7e8dca484f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc
@@ -34,147 +34,147 @@ IntrusiveList<FlagDescription> flag_descriptions;
# define SANITIZER_NEEDS_SEGV 1
#endif
-void SetCommonFlagsDefaults(CommonFlags *f) {
- f->symbolize = true;
- f->external_symbolizer_path = 0;
- f->allow_addr2line = false;
- f->strip_path_prefix = "";
- f->fast_unwind_on_check = false;
- f->fast_unwind_on_fatal = false;
- f->fast_unwind_on_malloc = true;
- f->handle_ioctl = false;
- f->malloc_context_size = 1;
- f->log_path = "stderr";
- f->verbosity = 0;
- f->detect_leaks = true;
- f->leak_check_at_exit = true;
- f->allocator_may_return_null = false;
- f->print_summary = true;
- f->check_printf = true;
+void CommonFlags::SetDefaults() {
+ symbolize = true;
+ external_symbolizer_path = 0;
+ allow_addr2line = false;
+ strip_path_prefix = "";
+ fast_unwind_on_check = false;
+ fast_unwind_on_fatal = false;
+ fast_unwind_on_malloc = true;
+ handle_ioctl = false;
+ malloc_context_size = 1;
+ log_path = "stderr";
+ verbosity = 0;
+ detect_leaks = true;
+ leak_check_at_exit = true;
+ allocator_may_return_null = false;
+ print_summary = true;
+ check_printf = true;
// TODO(glider): tools may want to set different defaults for handle_segv.
- f->handle_segv = SANITIZER_NEEDS_SEGV;
- f->allow_user_segv_handler = false;
- f->use_sigaltstack = true;
- f->detect_deadlocks = false;
- f->clear_shadow_mmap_threshold = 64 * 1024;
- f->color = "auto";
- f->legacy_pthread_cond = false;
- f->intercept_tls_get_addr = false;
- f->coverage = false;
- f->coverage_direct = SANITIZER_ANDROID;
- f->coverage_dir = ".";
- f->full_address_space = false;
- f->suppressions = "";
- f->print_suppressions = true;
- f->disable_coredump = (SANITIZER_WORDSIZE == 64);
- f->symbolize_inline_frames = true;
- f->stack_trace_format = "DEFAULT";
+ handle_segv = SANITIZER_NEEDS_SEGV;
+ allow_user_segv_handler = false;
+ use_sigaltstack = true;
+ detect_deadlocks = false;
+ clear_shadow_mmap_threshold = 64 * 1024;
+ color = "auto";
+ legacy_pthread_cond = false;
+ intercept_tls_get_addr = false;
+ coverage = false;
+ coverage_direct = SANITIZER_ANDROID;
+ coverage_dir = ".";
+ full_address_space = false;
+ suppressions = "";
+ print_suppressions = true;
+ disable_coredump = (SANITIZER_WORDSIZE == 64);
+ symbolize_inline_frames = true;
+ stack_trace_format = "DEFAULT";
}
-void ParseCommonFlagsFromString(CommonFlags *f, const char *str) {
- ParseFlag(str, &f->symbolize, "symbolize",
+void CommonFlags::ParseFromString(const char *str) {
+ ParseFlag(str, &symbolize, "symbolize",
"If set, use the online symbolizer from common sanitizer runtime to turn "
"virtual addresses to file/line locations.");
- ParseFlag(str, &f->external_symbolizer_path, "external_symbolizer_path",
+ ParseFlag(str, &external_symbolizer_path, "external_symbolizer_path",
"Path to external symbolizer. If empty, the tool will search $PATH for "
"the symbolizer.");
- ParseFlag(str, &f->allow_addr2line, "allow_addr2line",
+ ParseFlag(str, &allow_addr2line, "allow_addr2line",
"If set, allows online symbolizer to run addr2line binary to symbolize "
"stack traces (addr2line will only be used if llvm-symbolizer binary is "
"unavailable.");
- ParseFlag(str, &f->strip_path_prefix, "strip_path_prefix",
+ ParseFlag(str, &strip_path_prefix, "strip_path_prefix",
"Strips this prefix from file paths in error reports.");
- ParseFlag(str, &f->fast_unwind_on_check, "fast_unwind_on_check",
+ ParseFlag(str, &fast_unwind_on_check, "fast_unwind_on_check",
"If available, use the fast frame-pointer-based unwinder on "
"internal CHECK failures.");
- ParseFlag(str, &f->fast_unwind_on_fatal, "fast_unwind_on_fatal",
+ ParseFlag(str, &fast_unwind_on_fatal, "fast_unwind_on_fatal",
"If available, use the fast frame-pointer-based unwinder on fatal "
"errors.");
- ParseFlag(str, &f->fast_unwind_on_malloc, "fast_unwind_on_malloc",
+ ParseFlag(str, &fast_unwind_on_malloc, "fast_unwind_on_malloc",
"If available, use the fast frame-pointer-based unwinder on "
"malloc/free.");
- ParseFlag(str, &f->handle_ioctl, "handle_ioctl",
+ ParseFlag(str, &handle_ioctl, "handle_ioctl",
"Intercept and handle ioctl requests.");
- ParseFlag(str, &f->malloc_context_size, "malloc_context_size",
+ ParseFlag(str, &malloc_context_size, "malloc_context_size",
"Max number of stack frames kept for each allocation/deallocation.");
- ParseFlag(str, &f->log_path, "log_path",
+ ParseFlag(str, &log_path, "log_path",
"Write logs to \"log_path.pid\". The special values are \"stdout\" and "
"\"stderr\". The default is \"stderr\".");
- ParseFlag(str, &f->verbosity, "verbosity",
+ ParseFlag(str, &verbosity, "verbosity",
"Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).");
- ParseFlag(str, &f->detect_leaks, "detect_leaks",
+ ParseFlag(str, &detect_leaks, "detect_leaks",
"Enable memory leak detection.");
- ParseFlag(str, &f->leak_check_at_exit, "leak_check_at_exit",
+ ParseFlag(str, &leak_check_at_exit, "leak_check_at_exit",
"Invoke leak checking in an atexit handler. Has no effect if "
"detect_leaks=false, or if __lsan_do_leak_check() is called before the "
"handler has a chance to run.");
- ParseFlag(str, &f->allocator_may_return_null, "allocator_may_return_null",
+ ParseFlag(str, &allocator_may_return_null, "allocator_may_return_null",
"If false, the allocator will crash instead of returning 0 on "
"out-of-memory.");
- ParseFlag(str, &f->print_summary, "print_summary",
+ ParseFlag(str, &print_summary, "print_summary",
"If false, disable printing error summaries in addition to error "
"reports.");
- ParseFlag(str, &f->check_printf, "check_printf",
+ ParseFlag(str, &check_printf, "check_printf",
"Check printf arguments.");
- ParseFlag(str, &f->handle_segv, "handle_segv",
+ ParseFlag(str, &handle_segv, "handle_segv",
"If set, registers the tool's custom SEGV handler (both SIGBUS and "
"SIGSEGV on OSX).");
- ParseFlag(str, &f->allow_user_segv_handler, "allow_user_segv_handler",
+ ParseFlag(str, &allow_user_segv_handler, "allow_user_segv_handler",
"If set, allows user to register a SEGV handler even if the tool "
"registers one.");
- ParseFlag(str, &f->use_sigaltstack, "use_sigaltstack",
+ ParseFlag(str, &use_sigaltstack, "use_sigaltstack",
"If set, uses alternate stack for signal handling.");
- ParseFlag(str, &f->detect_deadlocks, "detect_deadlocks",
+ ParseFlag(str, &detect_deadlocks, "detect_deadlocks",
"If set, deadlock detection is enabled.");
- ParseFlag(str, &f->clear_shadow_mmap_threshold,
+ ParseFlag(str, &clear_shadow_mmap_threshold,
"clear_shadow_mmap_threshold",
"Large shadow regions are zero-filled using mmap(NORESERVE) instead of "
"memset(). This is the threshold size in bytes.");
- ParseFlag(str, &f->color, "color",
+ ParseFlag(str, &color, "color",
"Colorize reports: (always|never|auto).");
- ParseFlag(str, &f->legacy_pthread_cond, "legacy_pthread_cond",
+ ParseFlag(str, &legacy_pthread_cond, "legacy_pthread_cond",
"Enables support for dynamic libraries linked with libpthread 2.2.5.");
- ParseFlag(str, &f->intercept_tls_get_addr, "intercept_tls_get_addr",
+ ParseFlag(str, &intercept_tls_get_addr, "intercept_tls_get_addr",
"Intercept __tls_get_addr.");
- ParseFlag(str, &f->help, "help", "Print the flag descriptions.");
- ParseFlag(str, &f->mmap_limit_mb, "mmap_limit_mb",
+ ParseFlag(str, &help, "help", "Print the flag descriptions.");
+ ParseFlag(str, &mmap_limit_mb, "mmap_limit_mb",
"Limit the amount of mmap-ed memory (excluding shadow) in Mb; "
"not a user-facing flag, used mosly for testing the tools");
- ParseFlag(str, &f->hard_rss_limit_mb, "hard_rss_limit_mb",
+ ParseFlag(str, &hard_rss_limit_mb, "hard_rss_limit_mb",
"RSS limit in Mb."
" If non-zero, a background thread is spawned at startup"
" which periodically reads RSS and aborts the process if the"
" limit is reached");
- ParseFlag(str, &f->coverage, "coverage",
+ ParseFlag(str, &coverage, "coverage",
"If set, coverage information will be dumped at program shutdown (if the "
"coverage instrumentation was enabled at compile time).");
- ParseFlag(str, &f->coverage_direct, "coverage_direct",
+ ParseFlag(str, &coverage_direct, "coverage_direct",
"If set, coverage information will be dumped directly to a memory "
"mapped file. This way data is not lost even if the process is "
"suddenly killed.");
- ParseFlag(str, &f->coverage_dir, "coverage_dir",
+ ParseFlag(str, &coverage_dir, "coverage_dir",
"Target directory for coverage dumps. Defaults to the current "
"directory.");
- ParseFlag(str, &f->full_address_space, "full_address_space",
+ ParseFlag(str, &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",
+ ParseFlag(str, &suppressions, "suppressions", "Suppressions file name.");
+ ParseFlag(str, &print_suppressions, "print_suppressions",
"Print matched suppressions at exit.");
- ParseFlag(str, &f->disable_coredump, "disable_coredump",
+ ParseFlag(str, &disable_coredump, "disable_coredump",
"Disable core dumping. By default, disable_core=1 on 64-bit to avoid "
"dumping a 16T+ core file. Ignored on OSes that don't dump core by"
"default and for sanitizers that don't reserve lots of virtual memory.");
- ParseFlag(str, &f->symbolize_inline_frames, "symbolize_inline_frames",
+ ParseFlag(str, &symbolize_inline_frames, "symbolize_inline_frames",
"Print inlined frames in stacktraces. Defaults to true.");
- ParseFlag(str, &f->stack_trace_format, "stack_trace_format",
+ ParseFlag(str, &stack_trace_format, "stack_trace_format",
"Format string used to render stack frames. "
"See sanitizer_stacktrace_printer.h for the format description. "
"Use DEFAULT to get default format.");
// Do a sanity check for certain flags.
- if (f->malloc_context_size < 1)
- f->malloc_context_size = 1;
+ if (malloc_context_size < 1)
+ malloc_context_size = 1;
}
static bool GetFlagValue(const char *env, const char *name,
OpenPOWER on IntegriCloud