1*7c3d14c8STreehugger Robot//===-- sanitizer_flags.h ---------------------------------------*- C++ -*-===// 2*7c3d14c8STreehugger Robot// 3*7c3d14c8STreehugger Robot// The LLVM Compiler Infrastructure 4*7c3d14c8STreehugger Robot// 5*7c3d14c8STreehugger Robot// This file is distributed under the University of Illinois Open Source 6*7c3d14c8STreehugger Robot// License. See LICENSE.TXT for details. 7*7c3d14c8STreehugger Robot// 8*7c3d14c8STreehugger Robot//===----------------------------------------------------------------------===// 9*7c3d14c8STreehugger Robot// 10*7c3d14c8STreehugger Robot// This file describes common flags available in all sanitizers. 11*7c3d14c8STreehugger Robot// 12*7c3d14c8STreehugger Robot//===----------------------------------------------------------------------===// 13*7c3d14c8STreehugger Robot 14*7c3d14c8STreehugger Robot#ifndef COMMON_FLAG 15*7c3d14c8STreehugger Robot#error "Define COMMON_FLAG prior to including this file!" 16*7c3d14c8STreehugger Robot#endif 17*7c3d14c8STreehugger Robot 18*7c3d14c8STreehugger Robot// COMMON_FLAG(Type, Name, DefaultValue, Description) 19*7c3d14c8STreehugger Robot// Supported types: bool, const char *, int, uptr. 20*7c3d14c8STreehugger Robot// Default value must be a compile-time constant. 21*7c3d14c8STreehugger Robot// Description must be a string literal. 22*7c3d14c8STreehugger Robot 23*7c3d14c8STreehugger RobotCOMMON_FLAG( 24*7c3d14c8STreehugger Robot bool, symbolize, true, 25*7c3d14c8STreehugger Robot "If set, use the online symbolizer from common sanitizer runtime to turn " 26*7c3d14c8STreehugger Robot "virtual addresses to file/line locations.") 27*7c3d14c8STreehugger RobotCOMMON_FLAG( 28*7c3d14c8STreehugger Robot const char *, external_symbolizer_path, nullptr, 29*7c3d14c8STreehugger Robot "Path to external symbolizer. If empty, the tool will search $PATH for " 30*7c3d14c8STreehugger Robot "the symbolizer.") 31*7c3d14c8STreehugger RobotCOMMON_FLAG( 32*7c3d14c8STreehugger Robot bool, allow_addr2line, false, 33*7c3d14c8STreehugger Robot "If set, allows online symbolizer to run addr2line binary to symbolize " 34*7c3d14c8STreehugger Robot "stack traces (addr2line will only be used if llvm-symbolizer binary is " 35*7c3d14c8STreehugger Robot "unavailable.") 36*7c3d14c8STreehugger RobotCOMMON_FLAG(const char *, strip_path_prefix, "", 37*7c3d14c8STreehugger Robot "Strips this prefix from file paths in error reports.") 38*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, fast_unwind_on_check, false, 39*7c3d14c8STreehugger Robot "If available, use the fast frame-pointer-based unwinder on " 40*7c3d14c8STreehugger Robot "internal CHECK failures.") 41*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, fast_unwind_on_fatal, false, 42*7c3d14c8STreehugger Robot "If available, use the fast frame-pointer-based unwinder on fatal " 43*7c3d14c8STreehugger Robot "errors.") 44*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, fast_unwind_on_malloc, true, 45*7c3d14c8STreehugger Robot "If available, use the fast frame-pointer-based unwinder on " 46*7c3d14c8STreehugger Robot "malloc/free.") 47*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, handle_ioctl, false, "Intercept and handle ioctl requests.") 48*7c3d14c8STreehugger RobotCOMMON_FLAG(int, malloc_context_size, 1, 49*7c3d14c8STreehugger Robot "Max number of stack frames kept for each allocation/deallocation.") 50*7c3d14c8STreehugger RobotCOMMON_FLAG( 51*7c3d14c8STreehugger Robot const char *, log_path, "stderr", 52*7c3d14c8STreehugger Robot "Write logs to \"log_path.pid\". The special values are \"stdout\" and " 53*7c3d14c8STreehugger Robot "\"stderr\". The default is \"stderr\".") 54*7c3d14c8STreehugger RobotCOMMON_FLAG( 55*7c3d14c8STreehugger Robot bool, log_exe_name, false, 56*7c3d14c8STreehugger Robot "Mention name of executable when reporting error and " 57*7c3d14c8STreehugger Robot "append executable name to logs (as in \"log_path.exe_name.pid\").") 58*7c3d14c8STreehugger RobotCOMMON_FLAG( 59*7c3d14c8STreehugger Robot bool, log_to_syslog, SANITIZER_ANDROID || SANITIZER_MAC, 60*7c3d14c8STreehugger Robot "Write all sanitizer output to syslog in addition to other means of " 61*7c3d14c8STreehugger Robot "logging.") 62*7c3d14c8STreehugger RobotCOMMON_FLAG( 63*7c3d14c8STreehugger Robot int, verbosity, 0, 64*7c3d14c8STreehugger Robot "Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).") 65*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, detect_leaks, true, "Enable memory leak detection.") 66*7c3d14c8STreehugger RobotCOMMON_FLAG( 67*7c3d14c8STreehugger Robot bool, leak_check_at_exit, true, 68*7c3d14c8STreehugger Robot "Invoke leak checking in an atexit handler. Has no effect if " 69*7c3d14c8STreehugger Robot "detect_leaks=false, or if __lsan_do_leak_check() is called before the " 70*7c3d14c8STreehugger Robot "handler has a chance to run.") 71*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, allocator_may_return_null, false, 72*7c3d14c8STreehugger Robot "If false, the allocator will crash instead of returning 0 on " 73*7c3d14c8STreehugger Robot "out-of-memory.") 74*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, print_summary, true, 75*7c3d14c8STreehugger Robot "If false, disable printing error summaries in addition to error " 76*7c3d14c8STreehugger Robot "reports.") 77*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, check_printf, true, "Check printf arguments.") 78*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, handle_segv, SANITIZER_NEEDS_SEGV, 79*7c3d14c8STreehugger Robot "If set, registers the tool's custom SIGSEGV/SIGBUS handler.") 80*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, handle_abort, false, 81*7c3d14c8STreehugger Robot "If set, registers the tool's custom SIGABRT handler.") 82*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, handle_sigill, false, 83*7c3d14c8STreehugger Robot "If set, registers the tool's custom SIGILL handler.") 84*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, handle_sigfpe, true, 85*7c3d14c8STreehugger Robot "If set, registers the tool's custom SIGFPE handler.") 86*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, allow_user_segv_handler, false, 87*7c3d14c8STreehugger Robot "If set, allows user to register a SEGV handler even if the tool " 88*7c3d14c8STreehugger Robot "registers one.") 89*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, use_sigaltstack, true, 90*7c3d14c8STreehugger Robot "If set, uses alternate stack for signal handling.") 91*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, detect_deadlocks, false, 92*7c3d14c8STreehugger Robot "If set, deadlock detection is enabled.") 93*7c3d14c8STreehugger RobotCOMMON_FLAG( 94*7c3d14c8STreehugger Robot uptr, clear_shadow_mmap_threshold, 64 * 1024, 95*7c3d14c8STreehugger Robot "Large shadow regions are zero-filled using mmap(NORESERVE) instead of " 96*7c3d14c8STreehugger Robot "memset(). This is the threshold size in bytes.") 97*7c3d14c8STreehugger RobotCOMMON_FLAG(const char *, color, "auto", 98*7c3d14c8STreehugger Robot "Colorize reports: (always|never|auto).") 99*7c3d14c8STreehugger RobotCOMMON_FLAG( 100*7c3d14c8STreehugger Robot bool, legacy_pthread_cond, false, 101*7c3d14c8STreehugger Robot "Enables support for dynamic libraries linked with libpthread 2.2.5.") 102*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_tls_get_addr, false, "Intercept __tls_get_addr.") 103*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, help, false, "Print the flag descriptions.") 104*7c3d14c8STreehugger RobotCOMMON_FLAG(uptr, mmap_limit_mb, 0, 105*7c3d14c8STreehugger Robot "Limit the amount of mmap-ed memory (excluding shadow) in Mb; " 106*7c3d14c8STreehugger Robot "not a user-facing flag, used mosly for testing the tools") 107*7c3d14c8STreehugger RobotCOMMON_FLAG(uptr, hard_rss_limit_mb, 0, 108*7c3d14c8STreehugger Robot "Hard RSS limit in Mb." 109*7c3d14c8STreehugger Robot " If non-zero, a background thread is spawned at startup" 110*7c3d14c8STreehugger Robot " which periodically reads RSS and aborts the process if the" 111*7c3d14c8STreehugger Robot " limit is reached") 112*7c3d14c8STreehugger RobotCOMMON_FLAG(uptr, soft_rss_limit_mb, 0, 113*7c3d14c8STreehugger Robot "Soft RSS limit in Mb." 114*7c3d14c8STreehugger Robot " If non-zero, a background thread is spawned at startup" 115*7c3d14c8STreehugger Robot " which periodically reads RSS. If the limit is reached" 116*7c3d14c8STreehugger Robot " all subsequent malloc/new calls will fail or return NULL" 117*7c3d14c8STreehugger Robot " (depending on the value of allocator_may_return_null)" 118*7c3d14c8STreehugger Robot " until the RSS goes below the soft limit." 119*7c3d14c8STreehugger Robot " This limit does not affect memory allocations other than" 120*7c3d14c8STreehugger Robot " malloc/new.") 121*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, can_use_proc_maps_statm, true, 122*7c3d14c8STreehugger Robot "If false, do not attempt to read /proc/maps/statm." 123*7c3d14c8STreehugger Robot " Mostly useful for testing sanitizers.") 124*7c3d14c8STreehugger RobotCOMMON_FLAG( 125*7c3d14c8STreehugger Robot bool, coverage, false, 126*7c3d14c8STreehugger Robot "If set, coverage information will be dumped at program shutdown (if the " 127*7c3d14c8STreehugger Robot "coverage instrumentation was enabled at compile time).") 128*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, coverage_pcs, true, 129*7c3d14c8STreehugger Robot "If set (and if 'coverage' is set too), the coverage information " 130*7c3d14c8STreehugger Robot "will be dumped as a set of PC offsets for every module.") 131*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, coverage_order_pcs, false, 132*7c3d14c8STreehugger Robot "If true, the PCs will be dumped in the order they've" 133*7c3d14c8STreehugger Robot " appeared during the execution.") 134*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, coverage_bitset, false, 135*7c3d14c8STreehugger Robot "If set (and if 'coverage' is set too), the coverage information " 136*7c3d14c8STreehugger Robot "will also be dumped as a bitset to a separate file.") 137*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, coverage_counters, false, 138*7c3d14c8STreehugger Robot "If set (and if 'coverage' is set too), the bitmap that corresponds" 139*7c3d14c8STreehugger Robot " to coverage counters will be dumped.") 140*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, coverage_direct, SANITIZER_ANDROID, 141*7c3d14c8STreehugger Robot "If set, coverage information will be dumped directly to a memory " 142*7c3d14c8STreehugger Robot "mapped file. This way data is not lost even if the process is " 143*7c3d14c8STreehugger Robot "suddenly killed.") 144*7c3d14c8STreehugger RobotCOMMON_FLAG(const char *, coverage_dir, ".", 145*7c3d14c8STreehugger Robot "Target directory for coverage dumps. Defaults to the current " 146*7c3d14c8STreehugger Robot "directory.") 147*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, coverage_pc_buffer, true, 148*7c3d14c8STreehugger Robot "If set (and if 'coverage' is set too), the pcs would be collected " 149*7c3d14c8STreehugger Robot "in a buffer.") 150*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, full_address_space, false, 151*7c3d14c8STreehugger Robot "Sanitize complete address space; " 152*7c3d14c8STreehugger Robot "by default kernel area on 32-bit platforms will not be sanitized") 153*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, print_suppressions, true, 154*7c3d14c8STreehugger Robot "Print matched suppressions at exit.") 155*7c3d14c8STreehugger RobotCOMMON_FLAG( 156*7c3d14c8STreehugger Robot bool, disable_coredump, (SANITIZER_WORDSIZE == 64), 157*7c3d14c8STreehugger Robot "Disable core dumping. By default, disable_core=1 on 64-bit to avoid " 158*7c3d14c8STreehugger Robot "dumping a 16T+ core file. Ignored on OSes that don't dump core by" 159*7c3d14c8STreehugger Robot "default and for sanitizers that don't reserve lots of virtual memory.") 160*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, use_madv_dontdump, true, 161*7c3d14c8STreehugger Robot "If set, instructs kernel to not store the (huge) shadow " 162*7c3d14c8STreehugger Robot "in core file.") 163*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, symbolize_inline_frames, true, 164*7c3d14c8STreehugger Robot "Print inlined frames in stacktraces. Defaults to true.") 165*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, symbolize_vs_style, false, 166*7c3d14c8STreehugger Robot "Print file locations in Visual Studio style (e.g: " 167*7c3d14c8STreehugger Robot " file(10,42): ...") 168*7c3d14c8STreehugger RobotCOMMON_FLAG(int, dedup_token_length, 0, 169*7c3d14c8STreehugger Robot "If positive, after printing a stack trace also print a short " 170*7c3d14c8STreehugger Robot "string token based on this number of frames that will simplify " 171*7c3d14c8STreehugger Robot "deduplication of the reports. " 172*7c3d14c8STreehugger Robot "Example: 'DEDUP_TOKEN: foo-bar-main'. Default is 0.") 173*7c3d14c8STreehugger RobotCOMMON_FLAG(const char *, stack_trace_format, "DEFAULT", 174*7c3d14c8STreehugger Robot "Format string used to render stack frames. " 175*7c3d14c8STreehugger Robot "See sanitizer_stacktrace_printer.h for the format description. " 176*7c3d14c8STreehugger Robot "Use DEFAULT to get default format.") 177*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, no_huge_pages_for_shadow, true, 178*7c3d14c8STreehugger Robot "If true, the shadow is not allowed to use huge pages. ") 179*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, strict_string_checks, false, 180*7c3d14c8STreehugger Robot "If set check that string arguments are properly null-terminated") 181*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_strstr, true, 182*7c3d14c8STreehugger Robot "If set, uses custom wrappers for strstr and strcasestr functions " 183*7c3d14c8STreehugger Robot "to find more errors.") 184*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_strspn, true, 185*7c3d14c8STreehugger Robot "If set, uses custom wrappers for strspn and strcspn function " 186*7c3d14c8STreehugger Robot "to find more errors.") 187*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_strpbrk, true, 188*7c3d14c8STreehugger Robot "If set, uses custom wrappers for strpbrk function " 189*7c3d14c8STreehugger Robot "to find more errors.") 190*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_strlen, true, 191*7c3d14c8STreehugger Robot "If set, uses custom wrappers for strlen and strnlen functions " 192*7c3d14c8STreehugger Robot "to find more errors.") 193*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_strchr, true, 194*7c3d14c8STreehugger Robot "If set, uses custom wrappers for strchr, strchrnul, and strrchr " 195*7c3d14c8STreehugger Robot "functions to find more errors.") 196*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_memcmp, true, 197*7c3d14c8STreehugger Robot "If set, uses custom wrappers for memcmp function " 198*7c3d14c8STreehugger Robot "to find more errors.") 199*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, strict_memcmp, true, 200*7c3d14c8STreehugger Robot "If true, assume that memcmp(p1, p2, n) always reads n bytes before " 201*7c3d14c8STreehugger Robot "comparing p1 and p2.") 202*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_intrin, true, 203*7c3d14c8STreehugger Robot "If set, uses custom wrappers for memset/memcpy/memmove " 204*7c3d14c8STreehugger Robot "intrinsics to find more errors.") 205*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_stat, true, 206*7c3d14c8STreehugger Robot "If set, uses custom wrappers for *stat functions " 207*7c3d14c8STreehugger Robot "to find more errors.") 208*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, intercept_send, true, 209*7c3d14c8STreehugger Robot "If set, uses custom wrappers for send* functions " 210*7c3d14c8STreehugger Robot "to find more errors.") 211*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, decorate_proc_maps, false, "If set, decorate sanitizer " 212*7c3d14c8STreehugger Robot "mappings in /proc/self/maps with " 213*7c3d14c8STreehugger Robot "user-readable names") 214*7c3d14c8STreehugger RobotCOMMON_FLAG(int, exitcode, 1, "Override the program exit status if the tool " 215*7c3d14c8STreehugger Robot "found an error") 216*7c3d14c8STreehugger RobotCOMMON_FLAG( 217*7c3d14c8STreehugger Robot bool, abort_on_error, SANITIZER_ANDROID || SANITIZER_MAC, 218*7c3d14c8STreehugger Robot "If set, the tool calls abort() instead of _exit() after printing the " 219*7c3d14c8STreehugger Robot "error report.") 220*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, suppress_equal_pcs, true, 221*7c3d14c8STreehugger Robot "Deduplicate multiple reports for single source location in " 222*7c3d14c8STreehugger Robot "halt_on_error=false mode (asan only).") 223*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, print_cmdline, false, "Print command line on crash " 224*7c3d14c8STreehugger Robot "(asan only).") 225*7c3d14c8STreehugger RobotCOMMON_FLAG(bool, html_cov_report, false, "Generate html coverage report.") 226*7c3d14c8STreehugger RobotCOMMON_FLAG(const char *, sancov_path, "sancov", "Sancov tool location.") 227