summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_printf.cc
AgeCommit message (Collapse)Author
2017-09-22[sanitizer] Move CommonSanitizerReportMutex from _print.cc to _common.ccVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314006 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-01[sanitizer_common] Fuchsia OS support codeVitaly Buka
Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc Reviewed By: vitalybuka Subscribers: cryptoad, srhines, kubamracek, mgorny, phosek, filcab, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36031 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309756 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-25Revert "[compiler-rt] Include thread ID into sanitizers logs"Vitaly Buka
This improvement introduce additional dependencies on sandboxed environments. This reverts commit r308637. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308984 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20[compiler-rt] Use NOINLE to shrink stack framesVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308654 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20[compiler-rt] Reorder functions to shrink stack framesVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308652 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20Revert "[compiler-rt] Reorder functions to have smaller stack frames"Vitaly Buka
Does not compile. This reverts commit r308650. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308651 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20[compiler-rt] Reorder functions to have smaller stack framesVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308650 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20[compiler-rt] Include thread ID into sanitizers logsVitaly Buka
Reviewers: kcc, alekseyshl Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D35654 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308637 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-29General definition for weak functionsMarcos Pividori
In this diff, I define a general macro for defining weak functions with a default implementation: "SANITIZER_INTERFACE_WEAK_DEF()". This way, we simplify the implementation for different platforms. For example, we cannot define weak functions on Windows, but we can use linker pragmas to create an alias to a default implementation. All of these implementation details are hidden in the new macro. Also, as I modify the name for exported weak symbols on Windows, I needed to temporarily disable "dll_host" test for asan, which checks the list of functions included in asan_win_dll_thunk. Differential Revision: https://reviews.llvm.org/D28596 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293419 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06[sanitizer] Add a 'print_module_map' flag which prints modules with UUIDs on ↵Kuba Mracek
Darwin This patch add a new sanitizer flag, print_module_map, which enables printing a module map when the process exits, or after each report (for TSan). The output format is very similar to what Crash Reporter produces on Darwin (e.g. the format of module UUIDs). This enables users to use the existing symbol servers to offline symbolicate and aggregate reports. Differential Revision: https://reviews.llvm.org/D27400 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291277 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-28tsan: always define SANITIZER_GODmitry Vyukov
Currently we either define SANITIZER_GO for Go or don't define it at all for C++. This works fine with preprocessor (ifdef/ifndef/defined), but does not work for C++ if statements (e.g. if (SANITIZER_GO) {...}). Also this is different from majority of SANITIZER_FOO macros which are always defined to either 0 or 1. Always define SANITIZER_GO to either 0 or 1. This allows to use SANITIZER_GO in expressions and in flag default values. Also remove kGoMode and kCppMode, which were meant to be used in expressions, but they are not defined in sanitizer_common code, so SANITIZER_GO become prevalent. Also convert some preprocessor checks to C++ if's or ternary expressions. Majority of this change is done mechanically with: sed "s#ifdef SANITIZER_GO#if SANITIZER_GO#g" sed "s#ifndef SANITIZER_GO#if \!SANITIZER_GO#g" sed "s#defined(SANITIZER_GO)#SANITIZER_GO#g" git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@285443 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-06[sanitizers] Log all output to CrashReport on OS XAnna Zaks
Log all of sanitizers' output (not just ASan bug reports) to CrashReport, which simplifies diagnosing failed checks as well as other errors. This also allows to strip the color sequences early from the printed buffer, which is more efficient than what we had perviously. Differential Revision: http://reviews.llvm.org/D15396 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256988 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks
When ASan currently detects a bug, by default it will only print out the text of the report to stderr. This patch changes this behavior and writes the full text of the report to syslog before we terminate the process. It also calls os_trace (Activity Tracing available on OS X and iOS) with a message saying that the report is available in syslog. This is useful, because this message will be shown in the crash log. For this to work, the patch makes sure we store the full report into error_message_buffer unconditionally, and it also strips out ANSI escape sequences from the report (they are used when producing colored reports). I've initially tried to log to syslog during printing, which is done on Android right now. The advantage is that if we crash during error reporting or the produced error does not go through ScopedInErrorReport, we would still get a (partial) message in the syslog. However, that solution is very problematic on OS X. One issue is that the logging routine uses GCD, which may spawn a new thread on its behalf. In many cases, the reporting logic locks threadRegistry, which leads to deadlocks. Reviewed at http://reviews.llvm.org/D13452 (In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid build failures on Linux.) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253688 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-04Revert "Reapply: [asan] On OS X, log reports to syslog and os_trace"Juergen Ributzka
Looks like this commit is deadlocking the ASAN tests on the green dragon bot (http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA/). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252076 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks
When ASan currently detects a bug, by default it will only print out the text of the report to stderr. This patch changes this behavior and writes the full text of the report to syslog before we terminate the process. It also calls os_trace (Activity Tracing available on OS X and iOS) with a message saying that the report is available in syslog. This is useful, because this message will be shown in the crash log. For this to work, the patch makes sure we store the full report into error_message_buffer unconditionally, and it also strips out ANSI escape sequences from the report (they are used when producing colored reports). I've initially tried to log to syslog during printing, which is done on Android right now. The advantage is that if we crash during error reporting or the produced error does not go through ScopedInErrorReport, we would still get a (partial) message in the syslog. However, that solution is very problematic on OS X. One issue is that the logging routine uses GCD, which may spawn a new thread on its behalf. In many cases, the reporting logic locks threadRegistry, which leads to deadlocks. Reviewed at http://reviews.llvm.org/D13452 (In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid build failures on Linux.) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251577 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-27Revert "[asan] On OS X, log reports to syslog and os_trace"Anna Zaks
This reverts commit 251447. (Which caused failures on a Linux bot.) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251467 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-27[asan] On OS X, log reports to syslog and os_traceAnna Zaks
When ASan currently detects a bug, by default it will only print out the text of the report to stderr. This patch changes this behavior and writes the full text of the report to syslog before we terminate the process. It also calls os_trace (Activity Tracing available on OS X and iOS) with a message saying that the report is available in syslog. This is useful, because this message will be shown in the crash log. For this to work, the patch makes sure we store the full report into error_message_buffer unconditionally, and it also strips out ANSI escape sequences from the report (they are used when producing colored reports). I've initially tried to log to syslog during printing, which is done on Android right now. The advantage is that if we crash during error reporting or the produced error does not go through ScopedInErrorReport, we would still get a (partial) message in the syslog. However, that solution is very problematic on OS X. One issue is that the logging routine uses GCD, which may spawn a new thread on its behalf. In many cases, the reporting logic locks threadRegistry, which leads to deadlocks. Reviewed at http://reviews.llvm.org/D13452 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251447 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30[sanitizer_common] Apply modernize-use-nullptr, other minor fixesVedant Kumar
- Trim spaces. - Use nullptr in place of 0 for pointer variables. - Use '!p' in place of 'p == 0' for null pointer checks. Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13310 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248964 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-23[sanitizer] Implement logging to syslog.Evgeniy Stepanov
Previously, Android target had a logic of duplicating all sanitizer output to logcat. This change extends it to all posix platforms via the use of syslog, controlled by log_to_syslog flag. Enabled by default on Android, off everywhere else. A bit of cmake magic is required to allow Printf() to call a libc function. I'm adding a stub implementation to support no-libc builds like dfsan and safestack. This is a second attempt. I believe I've fixed all the issues that prompted the revert: Mac build, and all kinds of non-CMake builds (there are 3 of those). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243051 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23Revert r242975.Evgeniy Stepanov
Breaks Mac build. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242978 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22[sanitizer] Implement logging to syslog.Evgeniy Stepanov
Previously, Android target had a logic of duplicating all sanitizer output to logcat. This change extends it to all posix platforms via the use of syslog, controlled by log_to_syslog flag. Enabled by default on Android, off everywhere else. A bit of cmake magic is required to allow Printf() to call a libc function. I'm adding a stub implementation to support no-libc builds like dfsan and safestack. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242975 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-05[ASan] Add process basename to log name and error message toYury Gribov
simplify analysis of sanitized systems logs. Differential Revision: http://reviews.llvm.org/D7333 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@239134 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-12[asan] [mips] added support of asan for mips64/mips64el, patch by Kumar SukhaniKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221800 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-18sanitizer_printf.cc: guard the va_copy hack on _MSC_VERHans Wennborg
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215932 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-18Revert "[ASan/Win] Remove a hack that seems not to be required with VS2013 ↵Hans Wennborg
anymore" (r215708) This is still needed for VS2012. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215930 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15[ASan/Win] Remove a hack that seems not to be required with VS2013 anymoreTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215708 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23[asan] Android logging.Evgeniy Stepanov
This change duplicates all ASan output to system log on Android. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199887 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23[sanitizer] Add a sanity check.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199880 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-23[sanitizer] Add printf format attributes.Evgeniy Stepanov
These were lost in a refactoring a long time ago. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199874 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-21[Sanitizer] Support %.*s in internal printf implementation. Patch by Yuri ↵Alexey Samsonov
Gribov. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199724 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05[sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.Sergey Matveev
Instead of "if (common_flags()->verbosity) Report(...)" we now have macros. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196497 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-14[Sanitizer] Print symbolized stack frame using a single Printf() call.Alexey Samsonov
This reduces the number of "write" syscalls performed to print a single stack frame description, and makes sanitizer output less intermixed with program output. Also, add a number of unit tests. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194686 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-14tsan: allow to override OnPrint() callback in Go runtimeDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192576 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13Define SANITIZER_INTERFACE_ATTRIBUTE on Windows and fix all the places where ↵Timur Iskhodzhanov
SANITIZER_INTERFACE_ATTRIBUTE or SANITIZER_ATTRIBUTE_WEAK are used git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188261 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-27[sanitizer] Support padding with spaces in Printf.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@185082 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-10tsan: fix windows mingw buildDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@183644 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-29Fix MSVC W3 compiler warningsTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182857 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-17[nolibc] Move all platforms to internal_getpid.Peter Collingbourne
Before, we had an unused internal_getpid function for Linux, and a platform-independent GetPid function. To make the naming conventions consistent for syscall-like functions, the GetPid syscall wrapper in sanitizer_posix.cc is moved to sanitizer_mac.cc, and GetPid is renamed to internal_getpid, bringing the Linux variant into use. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182132 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-30asan: fix windows buildDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@180788 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-30asan/tsan: fix printf(), on the second pass it prints garbage and crashes on ↵Dmitry Vyukov
random pointer dereference git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@180784 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-18[Sanitizer] Rework r176802: share code between Printf and Report and ↵Alexey Samsonov
simplify it a bit git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@179755 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-05[Sanitizer] Use a common mutex to prevent mixing reports from different ↵Alexey Samsonov
sanitizers. This fixes PR15516 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178853 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03[Sanitizer] Fix OnPrint weak hook. Disable weak hooks for gotsan.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178640 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-26asan/tsan: change SANITIZER_GO to more general SANITIZER_SUPPORTS_WEAK_HOOKSDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178009 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-25asan/tsan: add Printf/Report hookDmitry Vyukov
The hook can be overriden in frontend to print to e.g. a file. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177864 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-13Break a >80 char line.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176937 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-11[ASan] Reduce the local buffer size in Report() not to fail the check ↵Alexander Potapenko
enforced when building TSan runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176804 91177308-0d34-0410-b5e6-96231b3b80d8