diff options
author | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-08-30 16:12:58 +0000 |
---|---|---|
committer | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-08-30 16:12:58 +0000 |
commit | 9e46467d67ba5ff4a10318b505879dcb15418636 (patch) | |
tree | 23d42aa647cb7a2de96792b724ecaaddee3423fa /libsanitizer/sanitizer_common | |
parent | 95bf5b605b129d86d39ac9a10338bbaaab32d631 (diff) | |
download | gcc-9e46467d67ba5ff4a10318b505879dcb15418636.tar.gz |
Merge ubsan into trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202113 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libsanitizer/sanitizer_common')
-rw-r--r-- | libsanitizer/sanitizer_common/sanitizer_common.h | 3 | ||||
-rw-r--r-- | libsanitizer/sanitizer_common/sanitizer_printf.cc | 2 | ||||
-rw-r--r-- | libsanitizer/sanitizer_common/sanitizer_report_decorator.h | 26 |
3 files changed, 19 insertions, 12 deletions
diff --git a/libsanitizer/sanitizer_common/sanitizer_common.h b/libsanitizer/sanitizer_common/sanitizer_common.h index 302dc742769..d2782b6c9dc 100644 --- a/libsanitizer/sanitizer_common/sanitizer_common.h +++ b/libsanitizer/sanitizer_common/sanitizer_common.h @@ -15,6 +15,7 @@ #define SANITIZER_COMMON_H #include "sanitizer_internal_defs.h" +#include "sanitizer_mutex.h" namespace __sanitizer { struct StackTrace; @@ -105,6 +106,8 @@ bool PrintsToTty(); void Printf(const char *format, ...); void Report(const char *format, ...); void SetPrintfAndReportCallback(void (*callback)(const char *)); +// Can be used to prevent mixing error reports from different sanitizers. +extern StaticSpinMutex CommonSanitizerReportMutex; fd_t OpenFile(const char *filename, bool write); // Opens the file 'file_name" and reads up to 'max_len' bytes. diff --git a/libsanitizer/sanitizer_common/sanitizer_printf.cc b/libsanitizer/sanitizer_common/sanitizer_printf.cc index 7771e1d34a1..8298f12bd7b 100644 --- a/libsanitizer/sanitizer_common/sanitizer_printf.cc +++ b/libsanitizer/sanitizer_common/sanitizer_printf.cc @@ -21,6 +21,8 @@ namespace __sanitizer { +StaticSpinMutex CommonSanitizerReportMutex; + static int AppendChar(char **buff, const char *buff_end, char c) { if (*buff < buff_end) { **buff = c; diff --git a/libsanitizer/sanitizer_common/sanitizer_report_decorator.h b/libsanitizer/sanitizer_common/sanitizer_report_decorator.h index 17f0b2edd2f..cabf08e6082 100644 --- a/libsanitizer/sanitizer_common/sanitizer_report_decorator.h +++ b/libsanitizer/sanitizer_common/sanitizer_report_decorator.h @@ -12,24 +12,26 @@ // //===----------------------------------------------------------------------===// -#ifndef SANITIZER_ALLOCATOR_H -#define SANITIZER_ALLOCATOR_H +#ifndef SANITIZER_REPORT_DECORATOR_H +#define SANITIZER_REPORT_DECORATOR_H namespace __sanitizer { class AnsiColorDecorator { public: explicit AnsiColorDecorator(bool use_ansi_colors) : ansi_(use_ansi_colors) { } - const char *Black() { return ansi_ ? "\033[1m\033[30m" : ""; } - const char *Red() { return ansi_ ? "\033[1m\033[31m" : ""; } - const char *Green() { return ansi_ ? "\033[1m\033[32m" : ""; } - const char *Yellow() { return ansi_ ? "\033[1m\033[33m" : ""; } - const char *Blue() { return ansi_ ? "\033[1m\033[34m" : ""; } - const char *Magenta() { return ansi_ ? "\033[1m\033[35m" : ""; } - const char *Cyan() { return ansi_ ? "\033[1m\033[36m" : ""; } - const char *White() { return ansi_ ? "\033[1m\033[37m" : ""; } - const char *Default() { return ansi_ ? "\033[1m\033[0m" : ""; } + const char *Bold() const { return ansi_ ? "\033[1m" : ""; } + const char *Black() const { return ansi_ ? "\033[1m\033[30m" : ""; } + const char *Red() const { return ansi_ ? "\033[1m\033[31m" : ""; } + const char *Green() const { return ansi_ ? "\033[1m\033[32m" : ""; } + const char *Yellow() const { return ansi_ ? "\033[1m\033[33m" : ""; } + const char *Blue() const { return ansi_ ? "\033[1m\033[34m" : ""; } + const char *Magenta() const { return ansi_ ? "\033[1m\033[35m" : ""; } + const char *Cyan() const { return ansi_ ? "\033[1m\033[36m" : ""; } + const char *White() const { return ansi_ ? "\033[1m\033[37m" : ""; } + const char *Default() const { return ansi_ ? "\033[1m\033[0m" : ""; } private: bool ansi_; }; } // namespace __sanitizer -#endif // SANITIZER_ALLOCATOR_H + +#endif // SANITIZER_REPORT_DECORATOR_H |