tsan: add log_path parameter (similar to asan)

remove old log_fileno

llvm-svn: 168788
This commit is contained in:
Dmitry Vyukov 2012-11-28 12:56:52 +00:00
parent e1a7f338a3
commit 3374e3f874
3 changed files with 12 additions and 5 deletions

View File

@ -48,7 +48,7 @@ void InitializeFlags(Flags *f, const char *env) {
f->strip_path_prefix = "";
f->suppressions = "";
f->exitcode = 66;
f->log_fileno = kStderrFd;
f->log_path = "stderr";
f->atexit_sleep_ms = 1000;
f->verbosity = 0;
f->profile_memory = "";
@ -77,7 +77,7 @@ void InitializeFlags(Flags *f, const char *env) {
ParseFlag(env, &f->strip_path_prefix, "strip_path_prefix");
ParseFlag(env, &f->suppressions, "suppressions");
ParseFlag(env, &f->exitcode, "exitcode");
ParseFlag(env, &f->log_fileno, "log_fileno");
ParseFlag(env, &f->log_path, "log_path");
ParseFlag(env, &f->atexit_sleep_ms, "atexit_sleep_ms");
ParseFlag(env, &f->verbosity, "verbosity");
ParseFlag(env, &f->profile_memory, "profile_memory");

View File

@ -49,8 +49,10 @@ struct Flags {
const char *suppressions;
// Override exit status if something was reported.
int exitcode;
// Log fileno (1 - stdout, 2 - stderr).
int log_fileno;
// Write logs to "log_path.pid".
// The special values are "stdout" and "stderr".
// The default is "stderr".
const char *log_path;
// Sleep in main thread before exiting for that many ms
// (useful to catch "at exit" races).
int atexit_sleep_ms;

View File

@ -191,7 +191,12 @@ void Initialize(ThreadState *thr) {
ctx->dead_list_tail = 0;
InitializeFlags(&ctx->flags, env);
// Setup correct file descriptor for error reports.
__sanitizer_set_report_fd(flags()->log_fileno);
if (internal_strcmp(flags()->log_path, "stdout") == 0)
__sanitizer_set_report_fd(kStdoutFd);
else if (internal_strcmp(flags()->log_path, "stderr") == 0)
__sanitizer_set_report_fd(kStderrFd);
else
__sanitizer_set_report_path(flags()->log_path);
InitializeSuppressions();
#ifndef TSAN_GO
// Initialize external symbolizer before internal threads are started.