forked from OSchip/llvm-project
tsan: be silent if verbosity=0
Currently tests fail with: Check failed: 'AAA' == 'AAA ==26017==Could not detach from thread 361395 (errno 3).' llvm-svn: 192711
This commit is contained in:
parent
dd6dc8276f
commit
21e99319f4
|
@ -18,7 +18,6 @@
|
||||||
namespace __sanitizer {
|
namespace __sanitizer {
|
||||||
|
|
||||||
const char *SanitizerToolName = "SanitizerTool";
|
const char *SanitizerToolName = "SanitizerTool";
|
||||||
uptr SanitizerVerbosity = 0;
|
|
||||||
|
|
||||||
uptr GetPageSizeCached() {
|
uptr GetPageSizeCached() {
|
||||||
static uptr PageSize;
|
static uptr PageSize;
|
||||||
|
|
|
@ -36,7 +36,6 @@ const uptr kCacheLineSize = 64;
|
||||||
const uptr kMaxPathLength = 512;
|
const uptr kMaxPathLength = 512;
|
||||||
|
|
||||||
extern const char *SanitizerToolName; // Can be changed by the tool.
|
extern const char *SanitizerToolName; // Can be changed by the tool.
|
||||||
extern uptr SanitizerVerbosity;
|
|
||||||
|
|
||||||
uptr GetPageSize();
|
uptr GetPageSize();
|
||||||
uptr GetPageSizeCached();
|
uptr GetPageSizeCached();
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "sanitizer_common.h"
|
#include "sanitizer_common.h"
|
||||||
|
#include "sanitizer_flags.h"
|
||||||
#include "sanitizer_libc.h"
|
#include "sanitizer_libc.h"
|
||||||
#include "sanitizer_linux.h"
|
#include "sanitizer_linux.h"
|
||||||
#include "sanitizer_mutex.h"
|
#include "sanitizer_mutex.h"
|
||||||
|
@ -99,10 +100,11 @@ bool ThreadSuspender::SuspendThread(SuspendedThreadID thread_id) {
|
||||||
&pterrno)) {
|
&pterrno)) {
|
||||||
// Either the thread is dead, or something prevented us from attaching.
|
// Either the thread is dead, or something prevented us from attaching.
|
||||||
// Log this event and move on.
|
// Log this event and move on.
|
||||||
Report("Could not attach to thread %d (errno %d).\n", thread_id, pterrno);
|
if (common_flags()->verbosity)
|
||||||
|
Report("Could not attach to thread %d (errno %d).\n", thread_id, pterrno);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (SanitizerVerbosity > 0)
|
if (common_flags()->verbosity)
|
||||||
Report("Attached to thread %d.\n", thread_id);
|
Report("Attached to thread %d.\n", thread_id);
|
||||||
// The thread is not guaranteed to stop before ptrace returns, so we must
|
// The thread is not guaranteed to stop before ptrace returns, so we must
|
||||||
// wait on it.
|
// wait on it.
|
||||||
|
@ -112,8 +114,9 @@ bool ThreadSuspender::SuspendThread(SuspendedThreadID thread_id) {
|
||||||
if (internal_iserror(waitpid_status, &wperrno)) {
|
if (internal_iserror(waitpid_status, &wperrno)) {
|
||||||
// Got a ECHILD error. I don't think this situation is possible, but it
|
// Got a ECHILD error. I don't think this situation is possible, but it
|
||||||
// doesn't hurt to report it.
|
// doesn't hurt to report it.
|
||||||
Report("Waiting on thread %d failed, detaching (errno %d).\n", thread_id,
|
if (common_flags()->verbosity)
|
||||||
wperrno);
|
Report("Waiting on thread %d failed, detaching (errno %d).\n",
|
||||||
|
thread_id, wperrno);
|
||||||
internal_ptrace(PTRACE_DETACH, thread_id, NULL, NULL);
|
internal_ptrace(PTRACE_DETACH, thread_id, NULL, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -128,13 +131,14 @@ void ThreadSuspender::ResumeAllThreads() {
|
||||||
int pterrno;
|
int pterrno;
|
||||||
if (!internal_iserror(internal_ptrace(PTRACE_DETACH, tid, NULL, NULL),
|
if (!internal_iserror(internal_ptrace(PTRACE_DETACH, tid, NULL, NULL),
|
||||||
&pterrno)) {
|
&pterrno)) {
|
||||||
if (SanitizerVerbosity > 0)
|
if (common_flags()->verbosity)
|
||||||
Report("Detached from thread %d.\n", tid);
|
Report("Detached from thread %d.\n", tid);
|
||||||
} else {
|
} else {
|
||||||
// Either the thread is dead, or we are already detached.
|
// Either the thread is dead, or we are already detached.
|
||||||
// The latter case is possible, for instance, if this function was called
|
// The latter case is possible, for instance, if this function was called
|
||||||
// from a signal handler.
|
// from a signal handler.
|
||||||
Report("Could not detach from thread %d (errno %d).\n", tid, pterrno);
|
if (common_flags()->verbosity)
|
||||||
|
Report("Could not detach from thread %d (errno %d).\n", tid, pterrno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +260,8 @@ static int TracerThread(void* argument) {
|
||||||
|
|
||||||
int exit_code = 0;
|
int exit_code = 0;
|
||||||
if (!thread_suspender.SuspendAllThreads()) {
|
if (!thread_suspender.SuspendAllThreads()) {
|
||||||
Report("Failed suspending threads.\n");
|
if (common_flags()->verbosity)
|
||||||
|
Report("Failed suspending threads.\n");
|
||||||
exit_code = 3;
|
exit_code = 3;
|
||||||
} else {
|
} else {
|
||||||
tracer_thread_argument->callback(thread_suspender.suspended_threads_list(),
|
tracer_thread_argument->callback(thread_suspender.suspended_threads_list(),
|
||||||
|
@ -370,7 +375,8 @@ void StopTheWorld(StopTheWorldCallback callback, void *argument) {
|
||||||
/* child_tidptr */);
|
/* child_tidptr */);
|
||||||
int local_errno = 0;
|
int local_errno = 0;
|
||||||
if (internal_iserror(tracer_pid, &local_errno)) {
|
if (internal_iserror(tracer_pid, &local_errno)) {
|
||||||
Report("Failed spawning a tracer thread (errno %d).\n", local_errno);
|
if (common_flags()->verbosity)
|
||||||
|
Report("Failed spawning a tracer thread (errno %d).\n", local_errno);
|
||||||
tracer_thread_argument.mutex.Unlock();
|
tracer_thread_argument.mutex.Unlock();
|
||||||
} else {
|
} else {
|
||||||
// On some systems we have to explicitly declare that we want to be traced
|
// On some systems we have to explicitly declare that we want to be traced
|
||||||
|
@ -385,8 +391,11 @@ void StopTheWorld(StopTheWorldCallback callback, void *argument) {
|
||||||
// At this point, any signal will either be blocked or kill us, so waitpid
|
// At this point, any signal will either be blocked or kill us, so waitpid
|
||||||
// should never return (and set errno) while the tracer thread is alive.
|
// should never return (and set errno) while the tracer thread is alive.
|
||||||
uptr waitpid_status = internal_waitpid(tracer_pid, NULL, __WALL);
|
uptr waitpid_status = internal_waitpid(tracer_pid, NULL, __WALL);
|
||||||
if (internal_iserror(waitpid_status, &local_errno))
|
if (internal_iserror(waitpid_status, &local_errno)) {
|
||||||
Report("Waiting on the tracer thread failed (errno %d).\n", local_errno);
|
if (common_flags()->verbosity)
|
||||||
|
Report("Waiting on the tracer thread failed (errno %d).\n",
|
||||||
|
local_errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +436,8 @@ int SuspendedThreadsList::GetRegistersAndSP(uptr index,
|
||||||
int pterrno;
|
int pterrno;
|
||||||
if (internal_iserror(internal_ptrace(PTRACE_GETREGS, tid, NULL, ®s),
|
if (internal_iserror(internal_ptrace(PTRACE_GETREGS, tid, NULL, ®s),
|
||||||
&pterrno)) {
|
&pterrno)) {
|
||||||
Report("Could not get registers from thread %d (errno %d).\n",
|
if (common_flags()->verbosity)
|
||||||
|
Report("Could not get registers from thread %d (errno %d).\n",
|
||||||
tid, pterrno);
|
tid, pterrno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue