summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_flags.cc
AgeCommit message (Collapse)Author
2016-08-03[ASan] Report illegal instruction exceptions in ASanReid Kleckner
Summary: Respect the handle_sigill common flag and handle_segv flags while we're at it. We still handle signals/exceptions differently on Unix and Windows. The installation process is tricky on Windows, and difficult to push down into sanitizer_common without concerning it with the different static/dynamic CRT models on Windows. Reviewers: kcc, etienneb Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23098 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277621 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-18[sancov] common flags initialization.Mike Aizatsky
Summary: Introducing InitializeCommonFlags accross all sanitizers to simplify common flags management. Setting coverage=1 when html_cov_report is requested. Differential Revision: http://reviews.llvm.org/D18273 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263820 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-16Introduce stats and stats_client libraries.Peter Collingbourne
This is part of a new statistics gathering feature for the sanitizers. See clang/docs/SanitizerStats.rst for further info and docs. Differential Revision: http://reviews.llvm.org/D16176 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257972 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28[asan] Read process name from /proc/self/cmdline on Linux.Evgeniy Stepanov
Rename getBinaryBasename() to getProcessName() and, on Linux, read it from /proc/self/cmdline instead of /proc/self/exe. The former can be modified by the process. The main motivation is Android, where application processes re-write cmdline to a package name. This lets us setup per-application ASAN_OPTIONS through include=/some/path/%b. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243473 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21[sanitizer] Implement include_if_exists with process name substitution.Evgeniy Stepanov
include_if_exists=/path/to/sanitizer/options reads flags from the file if it is present. "%b" in the include file path (for both variants of the flag) is replaced with the basename of the main executable. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242853 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-17[Sanitizer] Teach ReadFileToBuffer to distinguish empty file from ↵Alexey Samsonov
inaccessible file. Summary: This fixes https://code.google.com/p/address-sanitizer/issues/detail?id=399 (sanitizers crash with empty suppression files). Reviewers: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11284 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242594 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use error_t rather than int in a couple of places where we handle filesTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234491 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-18tsan: add -Wno-maybe-uninitialized to mingw gcc build flagsDmitry Vyukov
As per discussion with David Blaikie here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150216/260289.html git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229657 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-16tsan: fix compiler warningDmitry Vyukov
mingw gcc complains: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized] Printf("Failed to read options from '%s': error %d\n", value, err); git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229392 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-12[Sanitizer] Add "final" specifier to FlagHandlerBase::Parse overrides. NFC.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228893 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20[asan] Warn if unsupported flags are used at activation.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226563 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19[sanitizer] Switch flag parsing to LowLevelAlloc.Evgeniy Stepanov
InternalAlloc is quite complex and its behavior may depend on the values of flags. As such, it should not be used while parsing flags. Sadly, LowLevelAlloc does not support deallocation of memory. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226453 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-17[sanitizer] Adjust max read size in FlagHandlerIncludeHal Finkel
Setting the maximum read size in FlagHandlerInclude to 2^15 might be a good default, but causes the read to fail on systems with a page size larger than that (ReadFileToBuffer(...) will fail if the maximum allowed size is less than the value returned by GetPageSizeCached()). For example, on my PPC64/Linux system, GetPageSizeCached() returns 2^16. In case the page size is larger, use that instead. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226368 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16[sanitizer] Additional error checking.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226279 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15[sanitizer] Implement include= option.Evgeniy Stepanov
Allows loading sanitizer options from file. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226175 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15[sanitizer] Flag parser rewrite.Evgeniy Stepanov
The new parser is a lot stricter about syntax, reports unrecognized flags, and will make it easier to implemented some of the planned features. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226169 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-06[Sanitizer] Use COMMON_FLAG macro to describe common runtime flags.Alexey Samsonov
Summary: Introduce a single place where we specify flag type, name, default value, and description. This removes a large amount of boilerplate and ensures we won't leave flags uninitialized. Test Plan: regression test suite Reviewers: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6851 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225239 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-02Revert "Revert r224736: "[Sanitizer] Make CommonFlags immutable after ↵Alexey Samsonov
initialization."" Fix test failures by introducing CommonFlags::CopyFrom() to make sure compiler doesn't insert memcpy() calls into runtime code. Original commit message: Protect CommonFlags singleton by adding const qualifier to common_flags() accessor. The only ways to modify the flags are SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and OverrideCommonFlags() functions, which are only supposed to be called during initialization. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225088 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-30[asan] add flag coverage_pcs. When false, the coverage is not dumped as PCs. ↵Kostya Serebryany
Useful e.g. if the user only needs coverage is bitset git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225002 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-26[sanitizer] Treat \r, \n, \t as flag separators.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224858 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-23[asan] change the coverage collection scheme so that we can easily emit ↵Kostya Serebryany
coverage for the entire process as a single bit set, and if coverage_bitset=1 actually emit that bitset git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224789 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19[sanitizer] initialize two flas in SetCommonFlagsDefaultsKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224645 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19[Sanitizer] Refactor CommonFlags interface. NFC.Alexey Samsonov
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224617 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16[asan] new flag: hard_rss_limit_mbKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224353 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13Removed r221896, it seems to break build in various ways.Yury Gribov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221912 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13[ASan] Add process basename to log name and error message to simplify ↵Yury Gribov
analysis of sanitized systems logs. Reviewed at http://reviews.llvm.org/D5724 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221896 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-06[Sanitizer] Introduce "stack_trace_format" runtime flag.Alexey Samsonov
This flag can be used to specify the format of stack frames - user can now provide a string with placeholders, which should be printed for each stack frame with placeholders replaced with actual data. For example "%p" will be replaced by PC, "%s" will be replaced by the source file name etc. "DEFAULT" value enforces default stack trace format currently used in all the sanitizers except TSan. This change also implements __sanitizer_print_stack_trace interface function in TSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221469 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-24Add runtime flag 'symbolize_inline_frames' to disable symbolization of ↵Alexey Samsonov
inlined frames done in llvm-symbolizer git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@220582 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-14[asan] Add fast_unwind_on_check flag.Evgeniy Stepanov
Allows to specify the unwinder to use for CHECK failures. Previous behaviour was to use the "fatal" unwinder. As compiler-rt is built without frame pointers, only the slow unwinder really makes sense here, and it is the default. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@219677 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-12Revert r217616. Problems and complexity it introduces negate its benefitAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217652 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11[UBSan] Parse common flags from UBSAN_OPTIONS runtime variable even ifAlexey Samsonov
UBSan is combined with ASan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217616 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-12[Sanitizer] Make disable_coredump a common flag and use it in TSanAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215479 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-30[Sanitizer] Make "suppressions" and "print_suppressions" common runtime flags.Alexey Samsonov
No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214343 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-09[Sanitizer] Remove SANITIZER_NEEDS_SEGV from shared sanitizer_common headers.Alexey Samsonov
Otherwise, it can be accidentally redefined when we build specific sanitizer runtime. This definition should be provided only once - when we build sanitizer_common library. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212663 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-02[asan] Default to memory-mapped coverage on Android.Evgeniy Stepanov
The alternative (writing coverage at process exit) is nearly useless there. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210024 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29[sanitizer] Add coverage_dir flag.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209815 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29[sanitizer] Require that options end with '='.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209814 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-27[asancov] Write coverage directly to a memory-mapped file.Evgeniy Stepanov
This way does not require a __sanitizer_cov_dump() call. That's important on Android, where apps can be killed at arbitrary time. We write raw PCs to disk instead of module offsets; we also write memory layout to a separate file. This increases dump size by the factor of 2 on 64-bit systems. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209653 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-14[asan] Respect personality in kernel area detector, patch by Yuri GribovKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208760 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-12[asan] Move the "coverage" flag to common flags.Sergey Matveev
The implementation lives in sanitizer_common and will need to access that flag. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208566 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-24[asan] enable use_sigaltstack by default (this will provide verbose reports ↵Kostya Serebryany
on stack-overflow instead of silently crashing with SEGV) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@207099 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-22[asan] enable LeakSanitizer (LSan) by default in asan. This only affects ↵Kostya Serebryany
Linux x86_64. LSan has been used in various projects for more than half a year and we now consider it quite stable to be on by default. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206896 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-22[sanitizer] enable check_printf by default for asan and tsan. We've been ↵Kostya Serebryany
using this flag for a while and it seems to be stable enough for the rest of the world. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206872 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-14[asan] added internal flag mmap_limit_mbKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206178 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-04[asan] fix a leak in __tls_get_addr handler; introduce a run-time flag to ↵Kostya Serebryany
disable this handler completely; remove a workaround for a bug fixed in glibc git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205617 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-24Fix a VS compile-time warningTimur Iskhodzhanov
warning C4345: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204597 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-21[libsanitizer] Add descriptions for the common flags.Alexander Potapenko
Use new(allocator_for_flags) instead of allocator_for_flags.Allocate() Fix the description output format a bit. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204484 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-20[libsanitizer] Implement IntrusiveList<T>::Iterator, use IntrusiveList in ↵Alexander Potapenko
sanitizer_flags.cc git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204342 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-20[libsanitizer] Introduce flag descriptions.Alexander Potapenko
Extend ParseFlag to accept the |description| parameter, add dummy values for all existing flags. As the flags are parsed their descriptions are stored in a global linked list. The tool can later call __sanitizer::PrintFlagDescriptions() to dump all the flag names and their descriptions. Add the 'help' flag and make ASan, TSan and MSan print the flags if 'help' is set to 1. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204339 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-17tsan: yet another attempt to fix pthread_cond interceptorsDmitry Vyukov
Make behavior introduced in r202820 conditional (under legacy_pthread_cond flag). The new issue that we've hit with the satellite pthread_cond_t struct is that pthread_condattr_getpshared does not work (satellite data is not shared between processes). The idea is that most processes do not use pthread 2.2.5. The rare ones that use (2.2.5 is dated by 2002) must specify legacy_pthread_cond=1 on their own risk. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204032 91177308-0d34-0410-b5e6-96231b3b80d8