summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/sanitizer_common to .cppNico Weber2019-07-311-358/+0
| | | | | | | | | | | See https://reviews.llvm.org/D58620 for discussion, and for the commands I ran. In addition I also ran for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done and manually updated (many) references to renamed files found by that. llvm-svn: 367463
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [Sanitizer] Internal Printf string width + left-justify.Alex Shlyapnikov2018-04-231-11/+27
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Example: Printf("%-5s", "123"); should yield: '123 ' In case Printf's requested string field width is larger than the string argument length, the resulting string should be padded up to the requested width. For the simplicity sake, implementing left-justified (right padding) only. Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45906 llvm-svn: 330643
* Revert "[Sanitizer] Internal Printf string precision argument + padding."Alex Shlyapnikov2018-04-201-2/+0
| | | | | | | | | This reverts commit r330458. There are existing code using string precision as 'max len', need more work. llvm-svn: 330476
* [Sanitizer] Internal Printf string precision argument + padding.Alex Shlyapnikov2018-04-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: Example: Printf("%.*s", 5, "123"); should yield: '123 ' In case Printf's requested string precision is larger than the string argument, the resulting string should be padded up to the requested precision. For the simplicity sake, implementing right padding only. Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45844 llvm-svn: 330458
* [sanitizer] Move CommonSanitizerReportMutex from _print.cc to _common.ccVitaly Buka2017-09-221-2/+0
| | | | llvm-svn: 314006
* [sanitizer_common] Fuchsia OS support codeVitaly Buka2017-08-011-1/+3
| | | | | | | | | | | | | | | | 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 llvm-svn: 309756
* Revert "[compiler-rt] Include thread ID into sanitizers logs"Vitaly Buka2017-07-251-4/+4
| | | | | | | | This improvement introduce additional dependencies on sandboxed environments. This reverts commit r308637. llvm-svn: 308984
* [compiler-rt] Use NOINLE to shrink stack framesVitaly Buka2017-07-201-5/+7
| | | | llvm-svn: 308654
* [compiler-rt] Reorder functions to shrink stack framesVitaly Buka2017-07-201-8/+14
| | | | llvm-svn: 308652
* Revert "[compiler-rt] Reorder functions to have smaller stack frames"Vitaly Buka2017-07-201-10/+4
| | | | | | | | Does not compile. This reverts commit r308650. llvm-svn: 308651
* [compiler-rt] Reorder functions to have smaller stack framesVitaly Buka2017-07-201-4/+10
| | | | llvm-svn: 308650
* [compiler-rt] Include thread ID into sanitizers logsVitaly Buka2017-07-201-5/+4
| | | | | | | | | | Reviewers: kcc, alekseyshl Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D35654 llvm-svn: 308637
* General definition for weak functionsMarcos Pividori2017-01-291-8/+4
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 293419
* [sanitizer] Add a 'print_module_map' flag which prints modules with UUIDs on ↵Kuba Mracek2017-01-061-11/+17
| | | | | | | | | | 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 llvm-svn: 291277
* tsan: always define SANITIZER_GODmitry Vyukov2016-10-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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" llvm-svn: 285443
* [sanitizers] Log all output to CrashReport on OS XAnna Zaks2016-01-061-2/+5
| | | | | | | | | | | 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 llvm-svn: 256988
* Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-11-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.) llvm-svn: 253688
* Revert "Reapply: [asan] On OS X, log reports to syslog and os_trace"Juergen Ributzka2015-11-041-1/+1
| | | | | | | 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/). llvm-svn: 252076
* Reapply: [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-10-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.) llvm-svn: 251577
* Revert "[asan] On OS X, log reports to syslog and os_trace"Anna Zaks2015-10-271-1/+1
| | | | | | | | This reverts commit 251447. (Which caused failures on a Linux bot.) llvm-svn: 251467
* [asan] On OS X, log reports to syslog and os_traceAnna Zaks2015-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 251447
* [sanitizer_common] Apply modernize-use-nullptr, other minor fixesVedant Kumar2015-09-301-3/+2
| | | | | | | | | | | | - 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 llvm-svn: 248964
* [asan] Read process name from /proc/self/cmdline on Linux.Evgeniy Stepanov2015-07-281-1/+1
| | | | | | | | | | 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. llvm-svn: 243473
* [sanitizer] Implement logging to syslog.Evgeniy Stepanov2015-07-231-1/+2
| | | | | | | | | | | | | | | | | 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). llvm-svn: 243051
* Revert r242975.Evgeniy Stepanov2015-07-231-2/+1
| | | | | | Breaks Mac build. llvm-svn: 242978
* [sanitizer] Implement logging to syslog.Evgeniy Stepanov2015-07-221-1/+2
| | | | | | | | | | | | | 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. llvm-svn: 242975
* [ASan] Add process basename to log name and error message toYury Gribov2015-06-051-12/+18
| | | | | | | | simplify analysis of sanitized systems logs. Differential Revision: http://reviews.llvm.org/D7333 llvm-svn: 239134
* Removed r221896, it seems to break build in various ways.Yury Gribov2014-11-131-4/+2
| | | | llvm-svn: 221912
* [ASan] Add process basename to log name and error message to simplify ↵Yury Gribov2014-11-131-2/+4
| | | | | | | | analysis of sanitized systems logs. Reviewed at http://reviews.llvm.org/D5724 llvm-svn: 221896
* [asan] [mips] added support of asan for mips64/mips64el, patch by Kumar SukhaniKostya Serebryany2014-11-121-1/+1
| | | | llvm-svn: 221800
* sanitizer_printf.cc: guard the va_copy hack on _MSC_VERHans Wennborg2014-08-181-1/+2
| | | | llvm-svn: 215932
* Revert "[ASan/Win] Remove a hack that seems not to be required with VS2013 ↵Hans Wennborg2014-08-181-0/+4
| | | | | | | | anymore" (r215708) This is still needed for VS2012. llvm-svn: 215930
* [ASan/Win] Remove a hack that seems not to be required with VS2013 anymoreTimur Iskhodzhanov2014-08-151-4/+0
| | | | llvm-svn: 215708
* [asan] Android logging.Evgeniy Stepanov2014-01-231-0/+1
| | | | | | This change duplicates all ASan output to system log on Android. llvm-svn: 199887
* [sanitizer] Add a sanity check.Evgeniy Stepanov2014-01-231-0/+1
| | | | llvm-svn: 199880
* [sanitizer] Add printf format attributes.Evgeniy Stepanov2014-01-231-0/+4
| | | | | | These were lost in a refactoring a long time ago. llvm-svn: 199874
* [Sanitizer] Support %.*s in internal printf implementation. Patch by Yuri ↵Alexey Samsonov2014-01-211-4/+15
| | | | | | Gribov. llvm-svn: 199724
* [sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.Sergey Matveev2013-12-051-0/+1
| | | | | | Instead of "if (common_flags()->verbosity) Report(...)" we now have macros. llvm-svn: 196497
* [Sanitizer] Print symbolized stack frame using a single Printf() call.Alexey Samsonov2013-11-141-0/+9
| | | | | | | | 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. llvm-svn: 194686
* tsan: allow to override OnPrint() callback in Go runtimeDmitry Vyukov2013-10-141-5/+10
| | | | llvm-svn: 192576
* Define SANITIZER_INTERFACE_ATTRIBUTE on Windows and fix all the places where ↵Timur Iskhodzhanov2013-08-131-1/+1
| | | | | | SANITIZER_INTERFACE_ATTRIBUTE or SANITIZER_ATTRIBUTE_WEAK are used llvm-svn: 188261
* [sanitizer] Support padding with spaces in Printf.Sergey Matveev2013-06-271-26/+42
| | | | llvm-svn: 185082
* tsan: fix windows mingw buildDmitry Vyukov2013-06-101-1/+1
| | | | llvm-svn: 183644
* Fix MSVC W3 compiler warningsTimur Iskhodzhanov2013-05-291-1/+1
| | | | llvm-svn: 182857
* [nolibc] Move all platforms to internal_getpid.Peter Collingbourne2013-05-171-1/+1
| | | | | | | | | | 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. llvm-svn: 182132
* asan: fix windows buildDmitry Vyukov2013-04-301-0/+4
| | | | llvm-svn: 180788
* asan/tsan: fix printf(), on the second pass it prints garbage and crashes on ↵Dmitry Vyukov2013-04-301-0/+5
| | | | | | random pointer dereference llvm-svn: 180784
* [Sanitizer] Rework r176802: share code between Printf and Report and ↵Alexey Samsonov2013-04-181-55/+55
| | | | | | simplify it a bit llvm-svn: 179755
* [Sanitizer] Use a common mutex to prevent mixing reports from different ↵Alexey Samsonov2013-04-051-0/+2
| | | | | | sanitizers. This fixes PR15516 llvm-svn: 178853
OpenPOWER on IntegriCloud