]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libsanitizer/tsan/tsan_printf.cc
1 //===-- tsan_printf.cc ----------------------------------------------------===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of ThreadSanitizer (TSan), a race detector.
10 //===----------------------------------------------------------------------===//
12 #include "sanitizer_common/sanitizer_common.h"
13 #include "sanitizer_common/sanitizer_libc.h"
14 #include "tsan_defs.h"
15 #include "tsan_mman.h"
16 #include "tsan_platform.h"
18 #include <stdarg.h> // va_list
20 namespace __sanitizer
{
21 int VSNPrintf(char *buff
, int buff_length
, const char *format
, va_list args
);
22 } // namespace __sanitizer
26 void TsanPrintf(const char *format
, ...) {
28 const uptr kMaxLen
= 16 * 1024;
29 InternalScopedBuffer
<char> buffer(kMaxLen
);
31 va_start(args
, format
);
32 uptr len
= VSNPrintf(buffer
.data(), buffer
.size(), format
, args
);
34 internal_write(CTX() ? flags()->log_fileno
: 2,
35 buffer
.data(), len
< buffer
.size() ? len
: buffer
.size() - 1);