[llvm-commits] [compiler-rt] r158058 - in /compiler-rt/trunk/lib/tsan: rtl/tsan_interceptors.cc rtl/tsan_interface_ann.cc rtl/tsan_mman.cc rtl/tsan_mutex.cc rtl/tsan_platform_linux.cc rtl/tsan_printf.cc rtl/tsan_report.cc rtl/tsan_rtl.cc rtl/tsan_rtl.h rtl/tsan_rtl_mutex.cc rtl/tsan_rtl_report.cc rtl/tsan_rtl_thread.cc rtl/tsan_stat.cc rtl/tsan_suppressions.cc rtl/tsan_symbolize_addr2line_linux.cc unit_tests/tsan_printf_test.cc
Alexey Samsonov
samsonov at google.com
Wed Jun 6 03:13:28 PDT 2012
Author: samsonov
Date: Wed Jun 6 05:13:27 2012
New Revision: 158058
URL: http://llvm.org/viewvc/llvm-project?rev=158058&view=rev
Log:
[TSan] run some renaming as a preparation for factoring out Printf implementation.
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
compiler-rt/trunk/lib/tsan/unit_tests/tsan_printf_test.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Wed Jun 6 05:13:27 2012
@@ -238,13 +238,13 @@
TSAN_INTERCEPTOR(void, longjmp, void *env, int val) {
SCOPED_TSAN_INTERCEPTOR(longjmp, env, val);
- Printf("ThreadSanitizer: longjmp() is not supported\n");
+ TsanPrintf("ThreadSanitizer: longjmp() is not supported\n");
Die();
}
TSAN_INTERCEPTOR(void, siglongjmp, void *env, int val) {
SCOPED_TSAN_INTERCEPTOR(siglongjmp, env, val);
- Printf("ThreadSanitizer: siglongjmp() is not supported\n");
+ TsanPrintf("ThreadSanitizer: siglongjmp() is not supported\n");
Die();
}
@@ -620,7 +620,7 @@
uptr iter = (uptr)v;
if (iter > 1) {
if (pthread_setspecific(g_thread_finalize_key, (void*)(iter - 1))) {
- Printf("ThreadSanitizer: failed to set thread key\n");
+ TsanPrintf("ThreadSanitizer: failed to set thread key\n");
Die();
}
return;
@@ -647,7 +647,7 @@
ThreadState *thr = cur_thread();
ScopedInRtl in_rtl;
if (pthread_setspecific(g_thread_finalize_key, (void*)4)) {
- Printf("ThreadSanitizer: failed to set thread key\n");
+ TsanPrintf("ThreadSanitizer: failed to set thread key\n");
Die();
}
while ((tid = atomic_load(&p->tid, memory_order_acquire)) == 0)
@@ -1511,12 +1511,12 @@
AtExitContext();
if (__cxa_atexit(&finalize, 0, 0)) {
- Printf("ThreadSanitizer: failed to setup atexit callback\n");
+ TsanPrintf("ThreadSanitizer: failed to setup atexit callback\n");
Die();
}
if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
- Printf("ThreadSanitizer: failed to create thread key\n");
+ TsanPrintf("ThreadSanitizer: failed to create thread key\n");
Die();
}
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interface_ann.cc Wed Jun 6 05:13:27 2012
@@ -215,11 +215,11 @@
}
static void ReportMissedExpectedRace(ExpectRace *race) {
- Printf("==================\n");
- Printf("WARNING: ThreadSanitizer: missed expected data race\n");
- Printf(" %s addr=%lx %s:%d\n",
+ TsanPrintf("==================\n");
+ TsanPrintf("WARNING: ThreadSanitizer: missed expected data race\n");
+ TsanPrintf(" %s addr=%lx %s:%d\n",
race->desc, race->addr, race->file, race->line);
- Printf("==================\n");
+ TsanPrintf("==================\n");
}
void AnnotateFlushExpectedRaces(char *f, int l) {
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc Wed Jun 6 05:13:27 2012
@@ -92,7 +92,7 @@
MBlock *b = (MBlock*)AllocBlock(p);
// FIXME: Output a warning, it's a user error.
if (p < (char*)(b + 1) || p > (char*)(b + 1) + b->size) {
- Printf("user_mblock p=%p b=%p size=%lu beg=%p end=%p\n",
+ TsanPrintf("user_mblock p=%p b=%p size=%lu beg=%p end=%p\n",
p, b, b->size, (char*)(b + 1), (char*)(b + 1) + b->size);
CHECK_GE(p, (char*)(b + 1));
CHECK_LE(p, (char*)(b + 1) + b->size);
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc Wed Jun 6 05:13:27 2012
@@ -91,25 +91,25 @@
}
}
#if 0
- Printf("Can lock graph:\n");
+ TsanPrintf("Can lock graph:\n");
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
- Printf("%d ", CanLockAdj[i][j]);
+ TsanPrintf("%d ", CanLockAdj[i][j]);
}
- Printf("\n");
+ TsanPrintf("\n");
}
- Printf("Can lock graph closure:\n");
+ TsanPrintf("Can lock graph closure:\n");
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
- Printf("%d ", CanLockAdj2[i][j]);
+ TsanPrintf("%d ", CanLockAdj2[i][j]);
}
- Printf("\n");
+ TsanPrintf("\n");
}
#endif
// Verify that the graph is acyclic.
for (int i = 0; i < N; i++) {
if (CanLockAdj2[i][i]) {
- Printf("Mutex %d participates in a cycle\n", i);
+ TsanPrintf("Mutex %d participates in a cycle\n", i);
Die();
}
}
@@ -120,7 +120,7 @@
}
void DeadlockDetector::Lock(MutexType t) {
- // Printf("LOCK %d @%llu\n", t, seq_ + 1);
+ // TsanPrintf("LOCK %d @%llu\n", t, seq_ + 1);
u64 max_seq = 0;
u64 max_idx = MutexTypeInvalid;
for (int i = 0; i != MutexTypeCount; i++) {
@@ -135,16 +135,16 @@
locked_[t] = ++seq_;
if (max_idx == MutexTypeInvalid)
return;
- // Printf(" last %d @%llu\n", max_idx, max_seq);
+ // TsanPrintf(" last %d @%llu\n", max_idx, max_seq);
if (!CanLockAdj[max_idx][t]) {
- Printf("ThreadSanitizer: internal deadlock detected\n");
- Printf("ThreadSanitizer: can't lock %d while under %llu\n", t, max_idx);
+ TsanPrintf("ThreadSanitizer: internal deadlock detected\n");
+ TsanPrintf("ThreadSanitizer: can't lock %d while under %llu\n", t, max_idx);
Die();
}
}
void DeadlockDetector::Unlock(MutexType t) {
- // Printf("UNLO %d @%llu #%llu\n", t, seq_, locked_[t]);
+ // TsanPrintf("UNLO %d @%llu #%llu\n", t, seq_, locked_[t]);
CHECK(locked_[t]);
locked_[t] = 0;
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Wed Jun 6 05:13:27 2012
@@ -96,8 +96,8 @@
PROT_NONE,
MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
-1, 0)) {
- Printf("FATAL: ThreadSanitizer can not protect [%lx,%lx]\n", beg, end);
- Printf("FATAL: Make sure you are not using unlimited stack\n");
+ TsanPrintf("FATAL: ThreadSanitizer can not protect [%lx,%lx]\n", beg, end);
+ TsanPrintf("FATAL: Make sure you are not using unlimited stack\n");
Die();
}
}
@@ -113,8 +113,9 @@
MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
-1, 0);
if (shadow != kLinuxShadowBeg) {
- Printf("FATAL: ThreadSanitizer can not mmap the shadow memory\n");
- Printf("FATAL: Make sure to compile with -fPIE and to link with -pie.\n");
+ TsanPrintf("FATAL: ThreadSanitizer can not mmap the shadow memory\n");
+ TsanPrintf("FATAL: Make sure to compile with -fPIE and "
+ "to link with -pie.\n");
Die();
}
ProtectRange(kClosedLowBeg, kClosedLowEnd);
@@ -142,10 +143,10 @@
buf[sizeof(buf) - 1] = 0;
u64 addr = strtoll(buf, 0, 16);
if ((u64)addr < kLinuxAppMemBeg) {
- Printf("FATAL: ThreadSanitizer can not mmap the shadow memory ("
+ TsanPrintf("FATAL: ThreadSanitizer can not mmap the shadow memory ("
"something is mapped at 0x%llx < 0x%lx)\n",
addr, kLinuxAppMemBeg);
- Printf("FATAL: Make sure to compile with -fPIE"
+ TsanPrintf("FATAL: Make sure to compile with -fPIE"
" and to link with -pie.\n");
Die();
}
@@ -209,7 +210,7 @@
MAP_PRIVATE | MAP_ANON, -1, 0);
fd_t maps = internal_open("/proc/self/maps", false);
if (maps == kInvalidFd) {
- Printf("Failed to open /proc/self/maps\n");
+ TsanPrintf("Failed to open /proc/self/maps\n");
Die();
}
char *end = buf;
@@ -222,18 +223,18 @@
end[0] = 0;
end = (char*)internal_strstr(buf, "[stack]");
if (end == 0) {
- Printf("Can't find [stack] in /proc/self/maps\n");
+ TsanPrintf("Can't find [stack] in /proc/self/maps\n");
Die();
}
end[0] = 0;
char *pos = (char*)internal_strrchr(buf, '\n');
if (pos == 0) {
- Printf("Can't find [stack] in /proc/self/maps\n");
+ TsanPrintf("Can't find [stack] in /proc/self/maps\n");
Die();
}
pos = (char*)internal_strchr(pos, '-');
if (pos == 0) {
- Printf("Can't find [stack] in /proc/self/maps\n");
+ TsanPrintf("Can't find [stack] in /proc/self/maps\n");
Die();
}
uptr stack = 0;
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_printf.cc Wed Jun 6 05:13:27 2012
@@ -78,8 +78,8 @@
return result;
}
-static uptr VSNPrintf(char *buff, int buff_length,
- const char *format, va_list args) {
+uptr VSNPrintf(char *buff, int buff_length,
+ const char *format, va_list args) {
const char *buff_end = &buff[buff_length - 1];
const char *cur = format;
int result = 0;
@@ -126,7 +126,7 @@
return result;
}
-void Printf(const char *format, ...) {
+void TsanPrintf(const char *format, ...) {
ScopedInRtl in_rtl;
const uptr kMaxLen = 16 * 1024;
InternalScopedBuf<char> buffer(kMaxLen);
@@ -138,11 +138,12 @@
buffer, len < buffer.Size() ? len : buffer.Size() - 1);
}
-uptr Snprintf(char *buffer, uptr length, const char *format, ...) {
+uptr SNPrintf(char *buffer, uptr length, const char *format, ...) {
va_list args;
va_start(args, format);
uptr len = VSNPrintf(buffer, length, format, args);
va_end(args);
return len;
}
-}
+
+} // namespace __tsan
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc Wed Jun 6 05:13:27 2012
@@ -28,81 +28,81 @@
}
static void PrintHeader(ReportType typ) {
- Printf("WARNING: ThreadSanitizer: ");
+ TsanPrintf("WARNING: ThreadSanitizer: ");
if (typ == ReportTypeRace)
- Printf("data race");
+ TsanPrintf("data race");
else if (typ == ReportTypeUseAfterFree)
- Printf("heap-use-after-free");
+ TsanPrintf("heap-use-after-free");
else if (typ == ReportTypeThreadLeak)
- Printf("thread leak");
+ TsanPrintf("thread leak");
else if (typ == ReportTypeMutexDestroyLocked)
- Printf("destroy of a locked mutex");
+ TsanPrintf("destroy of a locked mutex");
else if (typ == ReportTypeSignalUnsafe)
- Printf("signal-unsafe call inside of a signal");
+ TsanPrintf("signal-unsafe call inside of a signal");
- Printf(" (pid=%d)\n", GetPid());
+ TsanPrintf(" (pid=%d)\n", GetPid());
}
static void PrintStack(const ReportStack *ent) {
for (int i = 0; ent; ent = ent->next, i++) {
- Printf(" #%d %s %s:%d", i, ent->func, ent->file, ent->line);
+ TsanPrintf(" #%d %s %s:%d", i, ent->func, ent->file, ent->line);
if (ent->col)
- Printf(":%d", ent->col);
+ TsanPrintf(":%d", ent->col);
if (ent->module && ent->offset)
- Printf(" (%s+%p)\n", ent->module, (void*)ent->offset);
+ TsanPrintf(" (%s+%p)\n", ent->module, (void*)ent->offset);
else
- Printf(" (%p)\n", (void*)ent->pc);
+ TsanPrintf(" (%p)\n", (void*)ent->pc);
}
}
static void PrintMop(const ReportMop *mop, bool first) {
- Printf(" %s of size %d at %p",
+ TsanPrintf(" %s of size %d at %p",
(first ? (mop->write ? "Write" : "Read")
: (mop->write ? "Previous write" : "Previous read")),
mop->size, (void*)mop->addr);
if (mop->tid == 0)
- Printf(" by main thread:\n");
+ TsanPrintf(" by main thread:\n");
else
- Printf(" by thread %d:\n", mop->tid);
+ TsanPrintf(" by thread %d:\n", mop->tid);
PrintStack(mop->stack);
}
static void PrintLocation(const ReportLocation *loc) {
if (loc->type == ReportLocationGlobal) {
- Printf(" Location is global '%s' of size %lu at %lx %s:%d\n",
- loc->name, loc->size, loc->addr, loc->file, loc->line);
+ TsanPrintf(" Location is global '%s' of size %lu at %lx %s:%d\n",
+ loc->name, loc->size, loc->addr, loc->file, loc->line);
} else if (loc->type == ReportLocationHeap) {
- Printf(" Location is heap of size %lu at %lx allocated by thread %d:\n",
- loc->size, loc->addr, loc->tid);
+ TsanPrintf(" Location is heap of size %lu at %lx allocated "
+ "by thread %d:\n", loc->size, loc->addr, loc->tid);
PrintStack(loc->stack);
} else if (loc->type == ReportLocationStack) {
- Printf(" Location is stack of thread %d:\n", loc->tid);
+ TsanPrintf(" Location is stack of thread %d:\n", loc->tid);
}
}
static void PrintMutex(const ReportMutex *rm) {
if (rm->stack == 0)
return;
- Printf(" Mutex %d created at:\n", rm->id);
+ TsanPrintf(" Mutex %d created at:\n", rm->id);
PrintStack(rm->stack);
}
static void PrintThread(const ReportThread *rt) {
if (rt->id == 0) // Little sense in describing the main thread.
return;
- Printf(" Thread %d", rt->id);
+ TsanPrintf(" Thread %d", rt->id);
if (rt->name)
- Printf(" '%s'", rt->name);
- Printf(" (%s)", rt->running ? "running" : "finished");
+ TsanPrintf(" '%s'", rt->name);
+ TsanPrintf(" (%s)", rt->running ? "running" : "finished");
if (rt->stack)
- Printf(" created at:");
- Printf("\n");
+ TsanPrintf(" created at:");
+ TsanPrintf("\n");
PrintStack(rt->stack);
}
void PrintReport(const ReportDesc *rep) {
- Printf("==================\n");
+ TsanPrintf("==================\n");
PrintHeader(rep->typ);
for (uptr i = 0; i < rep->stacks.Size(); i++)
@@ -120,7 +120,7 @@
for (uptr i = 0; i < rep->threads.Size(); i++)
PrintThread(rep->threads[i]);
- Printf("==================\n");
+ TsanPrintf("==================\n");
}
} // namespace __tsan
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Wed Jun 6 05:13:27 2012
@@ -104,7 +104,7 @@
uptr nsync = 0;
uptr syncmem = CTX()->synctab.GetMemoryConsumption(&nsync);
- Snprintf(buf, buf_size, "%d: shadow=%luMB"
+ SNPrintf(buf, buf_size, "%d: shadow=%luMB"
" thread=%luMB(total=%d/live=%d)"
" sync=%luMB(cnt=%lu)\n",
num,
@@ -128,11 +128,11 @@
if (flags()->profile_memory == 0 || flags()->profile_memory[0] == 0)
return;
InternalScopedBuf<char> filename(4096);
- Snprintf(filename.Ptr(), filename.Size(), "%s.%d",
+ SNPrintf(filename.Ptr(), filename.Size(), "%s.%d",
flags()->profile_memory, GetPid());
fd_t fd = internal_open(filename.Ptr(), true);
if (fd == kInvalidFd) {
- Printf("Failed to open memory profile file '%s'\n", &filename[0]);
+ TsanPrintf("Failed to open memory profile file '%s'\n", &filename[0]);
Die();
}
internal_start_thread(&MemoryProfileThread, (void*)(uptr)fd);
@@ -177,7 +177,8 @@
InitializeMemoryFlush();
if (ctx->flags.verbosity)
- Printf("***** Running under ThreadSanitizer v2 (pid %d) *****\n", GetPid());
+ TsanPrintf("***** Running under ThreadSanitizer v2 (pid %d) *****\n",
+ GetPid());
// Initialize thread 0.
ctx->thread_seq = 0;
@@ -188,7 +189,7 @@
ctx->initialized = true;
if (flags()->stop_on_start) {
- Printf("ThreadSanitizer is suspended at startup (pid %d)."
+ TsanPrintf("ThreadSanitizer is suspended at startup (pid %d)."
" Call __tsan_resume().\n",
GetPid());
while (__tsan_resumed == 0);
@@ -204,12 +205,12 @@
if (ctx->nreported) {
failed = true;
- Printf("ThreadSanitizer: reported %d warnings\n", ctx->nreported);
+ TsanPrintf("ThreadSanitizer: reported %d warnings\n", ctx->nreported);
}
if (ctx->nmissed_expected) {
failed = true;
- Printf("ThreadSanitizer: missed %d expected races\n",
+ TsanPrintf("ThreadSanitizer: missed %d expected races\n",
ctx->nmissed_expected);
}
@@ -364,11 +365,11 @@
shadow_mem[0], shadow_mem[1], shadow_mem[2], shadow_mem[3]);
#if TSAN_DEBUG
if (!IsAppMem(addr)) {
- Printf("Access to non app mem %lx\n", addr);
+ TsanPrintf("Access to non app mem %lx\n", addr);
DCHECK(IsAppMem(addr));
}
if (!IsShadowMem((uptr)shadow_mem)) {
- Printf("Bad shadow addr %p (%lx)\n", shadow_mem, addr);
+ TsanPrintf("Bad shadow addr %p (%lx)\n", shadow_mem, addr);
DCHECK(IsShadowMem((uptr)shadow_mem));
}
#endif
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Wed Jun 6 05:13:27 2012
@@ -37,8 +37,8 @@
namespace __tsan {
-void Printf(const char *format, ...) FORMAT(1, 2);
-uptr Snprintf(char *buffer, uptr length, const char *format, ...) FORMAT(3, 4);
+void TsanPrintf(const char *format, ...) FORMAT(1, 2);
+uptr SNPrintf(char *buffer, uptr length, const char *format, ...) FORMAT(3, 4);
// FastState (from most significant bit):
// unused : 1
@@ -398,13 +398,13 @@
bool IsExpectedReport(uptr addr, uptr size);
#if defined(TSAN_DEBUG_OUTPUT) && TSAN_DEBUG_OUTPUT >= 1
-# define DPrintf Printf
+# define DPrintf TsanPrintf
#else
# define DPrintf(...)
#endif
#if defined(TSAN_DEBUG_OUTPUT) && TSAN_DEBUG_OUTPUT >= 2
-# define DPrintf2 Printf
+# define DPrintf2 TsanPrintf
#else
# define DPrintf2(...)
#endif
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc Wed Jun 6 05:13:27 2012
@@ -63,7 +63,7 @@
} else if (s->owner_tid == thr->tid) {
CHECK_GT(s->recursion, 0);
} else {
- Printf("ThreadSanitizer WARNING: double lock\n");
+ TsanPrintf("ThreadSanitizer WARNING: double lock\n");
}
if (s->recursion == 0) {
StatInc(thr, StatMutexLock);
@@ -89,12 +89,12 @@
if (s->recursion == 0) {
if (!s->is_broken) {
s->is_broken = true;
- Printf("ThreadSanitizer WARNING: unlock of unlocked mutex\n");
+ TsanPrintf("ThreadSanitizer WARNING: unlock of unlocked mutex\n");
}
} else if (s->owner_tid != thr->tid) {
if (!s->is_broken) {
s->is_broken = true;
- Printf("ThreadSanitizer WARNING: mutex unlock by another thread\n");
+ TsanPrintf("ThreadSanitizer WARNING: mutex unlock by another thread\n");
}
} else {
s->recursion--;
@@ -121,7 +121,7 @@
TraceAddEvent(thr, thr->fast_state.epoch(), EventTypeRLock, addr);
SyncVar *s = CTX()->synctab.GetAndLock(thr, pc, addr, false);
if (s->owner_tid != SyncVar::kInvalidTid)
- Printf("ThreadSanitizer WARNING: read lock of a write locked mutex\n");
+ TsanPrintf("ThreadSanitizer WARNING: read lock of a write locked mutex\n");
thr->clock.set(thr->tid, thr->fast_state.epoch());
thr->clock.acquire(&s->clock);
StatInc(thr, StatSyncAcquire);
@@ -137,7 +137,8 @@
TraceAddEvent(thr, thr->fast_state.epoch(), EventTypeRUnlock, addr);
SyncVar *s = CTX()->synctab.GetAndLock(thr, pc, addr, true);
if (s->owner_tid != SyncVar::kInvalidTid)
- Printf("ThreadSanitizer WARNING: read unlock of a write locked mutex\n");
+ TsanPrintf("ThreadSanitizer WARNING: read unlock of a write "
+ "locked mutex\n");
thr->clock.set(thr->tid, thr->fast_state.epoch());
thr->fast_synch_epoch = thr->fast_state.epoch();
thr->clock.release(&s->read_clock);
@@ -181,7 +182,7 @@
}
} else if (!s->is_broken) {
s->is_broken = true;
- Printf("ThreadSanitizer WARNING: mutex unlock by another thread\n");
+ TsanPrintf("ThreadSanitizer WARNING: mutex unlock by another thread\n");
}
s->mtx.Unlock();
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Wed Jun 6 05:13:27 2012
@@ -68,7 +68,7 @@
// can actually happen if we do not instrument some code,
// so it's only a DCHECK. However we must try hard to not miss it
// due to our fault.
- Printf("Bottom stack frame of stack %lx is missed\n", stack->pc);
+ TsanPrintf("Bottom stack frame of stack %lx is missed\n", stack->pc);
}
}
@@ -349,7 +349,7 @@
void CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2) {
ScopedInRtl in_rtl;
- Printf("FATAL: ThreadSanitizer CHECK failed: %s:%d \"%s\" (%llx, %llx)\n",
+ TsanPrintf("FATAL: ThreadSanitizer CHECK failed: %s:%d \"%s\" (%llx, %llx)\n",
file, line, cond, v1, v2);
Die();
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Wed Jun 6 05:13:27 2012
@@ -78,7 +78,8 @@
if (ctx->dead_list_size > kThreadQuarantineSize
|| ctx->thread_seq >= kMaxTid) {
if (ctx->dead_list_size == 0) {
- Printf("ThreadSanitizer: %d thread limit exceeded. Dying.\n", kMaxTid);
+ TsanPrintf("ThreadSanitizer: %d thread limit exceeded. Dying.\n",
+ kMaxTid);
Die();
}
StatInc(thr, StatThreadReuse);
@@ -251,7 +252,7 @@
Lock l(&ctx->thread_mtx);
ThreadContext *tctx = ctx->threads[tid];
if (tctx->status == ThreadStatusInvalid) {
- Printf("ThreadSanitizer: join of non-existent thread\n");
+ TsanPrintf("ThreadSanitizer: join of non-existent thread\n");
return;
}
CHECK_EQ(tctx->detached, false);
@@ -269,7 +270,7 @@
Lock l(&ctx->thread_mtx);
ThreadContext *tctx = ctx->threads[tid];
if (tctx->status == ThreadStatusInvalid) {
- Printf("ThreadSanitizer: detach of non-existent thread\n");
+ TsanPrintf("ThreadSanitizer: detach of non-existent thread\n");
return;
}
if (tctx->status == ThreadStatusFinished) {
@@ -291,19 +292,19 @@
#if TSAN_DEBUG
if (!IsAppMem(addr)) {
- Printf("Access to non app mem %lx\n", addr);
+ TsanPrintf("Access to non app mem %lx\n", addr);
DCHECK(IsAppMem(addr));
}
if (!IsAppMem(addr + size - 1)) {
- Printf("Access to non app mem %lx\n", addr + size - 1);
+ TsanPrintf("Access to non app mem %lx\n", addr + size - 1);
DCHECK(IsAppMem(addr + size - 1));
}
if (!IsShadowMem((uptr)shadow_mem)) {
- Printf("Bad shadow addr %p (%lx)\n", shadow_mem, addr);
+ TsanPrintf("Bad shadow addr %p (%lx)\n", shadow_mem, addr);
DCHECK(IsShadowMem((uptr)shadow_mem));
}
if (!IsShadowMem((uptr)(shadow_mem + size * kShadowCnt / 8 - 1))) {
- Printf("Bad shadow addr %p (%lx)\n",
+ TsanPrintf("Bad shadow addr %p (%lx)\n",
shadow_mem + size * kShadowCnt / 8 - 1, addr + size - 1);
DCHECK(IsShadowMem((uptr)(shadow_mem + size * kShadowCnt / 8 - 1)));
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc Wed Jun 6 05:13:27 2012
@@ -241,9 +241,9 @@
name[StatMtxAtExit] = " Atexit ";
name[StatMtxAnnotations] = " Annotations ";
- Printf("Statistics:\n");
+ TsanPrintf("Statistics:\n");
for (int i = 0; i < StatCnt; i++)
- Printf("%s: %llu\n", name[i], stat[i]);
+ TsanPrintf("%s: %llu\n", name[i], stat[i]);
}
} // namespace __tsan
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc Wed Jun 6 05:13:27 2012
@@ -27,24 +27,24 @@
return 0;
InternalScopedBuf<char> tmp(4*1024);
if (filename[0] == '/')
- Snprintf(tmp, tmp.Size(), "%s", filename);
+ SNPrintf(tmp, tmp.Size(), "%s", filename);
else
- Snprintf(tmp, tmp.Size(), "%s/%s", internal_getpwd(), filename);
+ SNPrintf(tmp, tmp.Size(), "%s/%s", internal_getpwd(), filename);
fd_t fd = internal_open(tmp, false);
if (fd == kInvalidFd) {
- Printf("ThreadSanitizer: failed to open suppressions file '%s'\n",
+ TsanPrintf("ThreadSanitizer: failed to open suppressions file '%s'\n",
tmp.Ptr());
Die();
}
const uptr fsize = internal_filesize(fd);
if (fsize == (uptr)-1) {
- Printf("ThreadSanitizer: failed to stat suppressions file '%s'\n",
+ TsanPrintf("ThreadSanitizer: failed to stat suppressions file '%s'\n",
tmp.Ptr());
Die();
}
char *buf = (char*)internal_alloc(MBlockSuppression, fsize + 1);
if (fsize != internal_read(fd, buf, fsize)) {
- Printf("ThreadSanitizer: failed to read suppressions file '%s'\n",
+ TsanPrintf("ThreadSanitizer: failed to read suppressions file '%s'\n",
tmp.Ptr());
Die();
}
@@ -109,7 +109,7 @@
stype = SuppressionSignal;
line += sizeof("signal:") - 1;
} else {
- Printf("ThreadSanitizer: failed to parse suppressions file\n");
+ TsanPrintf("ThreadSanitizer: failed to parse suppressions file\n");
Die();
}
Suppression *s = (Suppression*)internal_alloc(MBlockSuppression,
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc Wed Jun 6 05:13:27 2012
@@ -50,12 +50,12 @@
static void NOINLINE InitModule(ModuleDesc *m) {
int outfd[2] = {};
if (pipe(&outfd[0])) {
- Printf("ThreadSanitizer: outfd pipe() failed (%d)\n", errno);
+ TsanPrintf("ThreadSanitizer: outfd pipe() failed (%d)\n", errno);
Die();
}
int infd[2] = {};
if (pipe(&infd[0])) {
- Printf("ThreadSanitizer: infd pipe() failed (%d)\n", errno);
+ TsanPrintf("ThreadSanitizer: infd pipe() failed (%d)\n", errno);
Die();
}
int pid = fork();
@@ -72,7 +72,7 @@
execl("/usr/bin/addr2line", "/usr/bin/addr2line", "-Cfe", m->fullname, 0);
_exit(0);
} else if (pid < 0) {
- Printf("ThreadSanitizer: failed to fork symbolizer\n");
+ TsanPrintf("ThreadSanitizer: failed to fork symbolizer\n");
Die();
}
internal_close(outfd[0]);
@@ -85,7 +85,7 @@
DlIteratePhdrCtx *ctx = (DlIteratePhdrCtx*)arg;
InternalScopedBuf<char> tmp(128);
if (ctx->is_first) {
- Snprintf(tmp.Ptr(), tmp.Size(), "/proc/%d/exe", GetPid());
+ SNPrintf(tmp.Ptr(), tmp.Size(), "/proc/%d/exe", GetPid());
info->dlpi_name = tmp.Ptr();
}
ctx->is_first = false;
@@ -158,16 +158,16 @@
ModuleDesc *m = s->module;
uptr offset = addr - m->base;
char addrstr[32];
- Snprintf(addrstr, sizeof(addrstr), "%p\n", (void*)offset);
+ SNPrintf(addrstr, sizeof(addrstr), "%p\n", (void*)offset);
if (0 >= internal_write(m->out_fd, addrstr, internal_strlen(addrstr))) {
- Printf("ThreadSanitizer: can't write from symbolizer (%d, %d)\n",
+ TsanPrintf("ThreadSanitizer: can't write from symbolizer (%d, %d)\n",
m->out_fd, errno);
Die();
}
InternalScopedBuf<char> func(1024);
ssize_t len = internal_read(m->inp_fd, func, func.Size() - 1);
if (len <= 0) {
- Printf("ThreadSanitizer: can't read from symbolizer (%d, %d)\n",
+ TsanPrintf("ThreadSanitizer: can't read from symbolizer (%d, %d)\n",
m->inp_fd, errno);
Die();
}
@@ -198,7 +198,7 @@
base = GetImageBase();
int res = 0;
InternalScopedBuf<char> cmd(1024);
- Snprintf(cmd, cmd.Size(),
+ SNPrintf(cmd, cmd.Size(),
"nm -alC %s|grep \"%lx\"|awk '{printf(\"%%s\\n%%s\", $3, $4)}' > tsan.tmp2",
exe, (addr - base));
if (system(cmd))
Modified: compiler-rt/trunk/lib/tsan/unit_tests/tsan_printf_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/unit_tests/tsan_printf_test.cc?rev=158058&r1=158057&r2=158058&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/unit_tests/tsan_printf_test.cc (original)
+++ compiler-rt/trunk/lib/tsan/unit_tests/tsan_printf_test.cc Wed Jun 6 05:13:27 2012
@@ -20,7 +20,7 @@
TEST(Printf, Basic) {
char buf[1024];
- uptr len = Snprintf(buf, sizeof(buf),
+ uptr len = SNPrintf(buf, sizeof(buf),
"a%db%ldc%lldd%ue%luf%llug%xh%lxq%llxw%pe%sr",
(int)-1, (long)-2, (long long)-3, // NOLINT
(unsigned)-4, (unsigned long)5, (unsigned long long)6, // NOLINT
@@ -33,7 +33,7 @@
TEST(Printf, OverflowStr) {
char buf[] = "123456789";
- uptr len = Snprintf(buf, 4, "%s", "abcdef");
+ uptr len = SNPrintf(buf, 4, "%s", "abcdef");
EXPECT_EQ(len, (uptr)6);
EXPECT_EQ(0, strcmp(buf, "abc"));
EXPECT_EQ(buf[3], 0);
@@ -47,7 +47,7 @@
TEST(Printf, OverflowInt) {
char buf[] = "123456789";
- Snprintf(buf, 4, "%d", -123456789);
+ SNPrintf(buf, 4, "%d", -123456789);
EXPECT_EQ(0, strcmp(buf, "-12"));
EXPECT_EQ(buf[3], 0);
EXPECT_EQ(buf[4], '5');
@@ -60,7 +60,7 @@
TEST(Printf, OverflowUint) {
char buf[] = "123456789";
- Snprintf(buf, 4, "a%llx", (long long)0x123456789); // NOLINT
+ SNPrintf(buf, 4, "a%llx", (long long)0x123456789); // NOLINT
EXPECT_EQ(0, strcmp(buf, "a12"));
EXPECT_EQ(buf[3], 0);
EXPECT_EQ(buf[4], '5');
@@ -73,7 +73,7 @@
TEST(Printf, OverflowPtr) {
char buf[] = "123456789";
- Snprintf(buf, 4, "%p", (void*)0x123456789);
+ SNPrintf(buf, 4, "%p", (void*)0x123456789);
EXPECT_EQ(0, strcmp(buf, "0x0"));
EXPECT_EQ(buf[3], 0);
EXPECT_EQ(buf[4], '5');
@@ -87,7 +87,7 @@
template<typename T>
static void TestMinMax(const char *fmt, T min, T max) {
char buf[1024];
- uptr len = Snprintf(buf, sizeof(buf), fmt, min, max);
+ uptr len = SNPrintf(buf, sizeof(buf), fmt, min, max);
char buf2[1024];
snprintf(buf2, sizeof(buf2), fmt, min, max);
EXPECT_EQ(len, strlen(buf));
More information about the llvm-commits
mailing list