[compiler-rt] r204339 - [libsanitizer] Introduce flag descriptions.
Alexander Potapenko
glider at google.com
Thu Mar 20 05:52:52 PDT 2014
Author: glider
Date: Thu Mar 20 07:52:52 2014
New Revision: 204339
URL: http://llvm.org/viewvc/llvm-project?rev=204339&view=rev
Log:
[libsanitizer] Introduce flag descriptions.
Extend ParseFlag to accept the |description| parameter, add dummy values for all existing flags.
As the flags are parsed their descriptions are stored in a global linked list.
The tool can later call __sanitizer::PrintFlagDescriptions() to dump all the flag names and their descriptions.
Add the 'help' flag and make ASan, TSan and MSan print the flags if 'help' is set to 1.
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/dfsan/dfsan.cc
compiler-rt/trunk/lib/lsan/lsan_common.cc
compiler-rt/trunk/lib/msan/msan.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc
compiler-rt/trunk/lib/tsan/dd/dd_rtl.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=204339&r1=204338&r2=204339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Thu Mar 20 07:52:52 2014
@@ -95,50 +95,52 @@ static void ParseFlagsFromString(Flags *
ParseCommonFlagsFromString(cf, str);
CHECK((uptr)cf->malloc_context_size <= kStackTraceMax);
- ParseFlag(str, &f->quarantine_size, "quarantine_size");
- ParseFlag(str, &f->redzone, "redzone");
- ParseFlag(str, &f->max_redzone, "max_redzone");
+ ParseFlag(str, &f->quarantine_size, "quarantine_size", "");
+ ParseFlag(str, &f->redzone, "redzone", "");
+ ParseFlag(str, &f->max_redzone, "max_redzone", "");
CHECK_GE(f->redzone, 16);
CHECK_GE(f->max_redzone, f->redzone);
CHECK_LE(f->max_redzone, 2048);
CHECK(IsPowerOfTwo(f->redzone));
CHECK(IsPowerOfTwo(f->max_redzone));
- ParseFlag(str, &f->debug, "debug");
- ParseFlag(str, &f->report_globals, "report_globals");
- ParseFlag(str, &f->check_initialization_order, "check_initialization_order");
-
- ParseFlag(str, &f->replace_str, "replace_str");
- ParseFlag(str, &f->replace_intrin, "replace_intrin");
- ParseFlag(str, &f->mac_ignore_invalid_free, "mac_ignore_invalid_free");
+ ParseFlag(str, &f->debug, "debug", "");
+ ParseFlag(str, &f->report_globals, "report_globals", "");
+ ParseFlag(str, &f->check_initialization_order,
+ "check_initialization_order", "");
+
+ ParseFlag(str, &f->replace_str, "replace_str", "");
+ ParseFlag(str, &f->replace_intrin, "replace_intrin", "");
+ ParseFlag(str, &f->mac_ignore_invalid_free, "mac_ignore_invalid_free", "");
ParseFlag(str, &f->detect_stack_use_after_return,
- "detect_stack_use_after_return");
- ParseFlag(str, &f->min_uar_stack_size_log, "min_uar_stack_size_log");
- ParseFlag(str, &f->max_uar_stack_size_log, "max_uar_stack_size_log");
- ParseFlag(str, &f->uar_noreserve, "uar_noreserve");
- ParseFlag(str, &f->max_malloc_fill_size, "max_malloc_fill_size");
- ParseFlag(str, &f->malloc_fill_byte, "malloc_fill_byte");
- ParseFlag(str, &f->exitcode, "exitcode");
- ParseFlag(str, &f->allow_user_poisoning, "allow_user_poisoning");
- ParseFlag(str, &f->sleep_before_dying, "sleep_before_dying");
- ParseFlag(str, &f->check_malloc_usable_size, "check_malloc_usable_size");
- ParseFlag(str, &f->unmap_shadow_on_exit, "unmap_shadow_on_exit");
- ParseFlag(str, &f->abort_on_error, "abort_on_error");
- ParseFlag(str, &f->print_stats, "print_stats");
- ParseFlag(str, &f->print_legend, "print_legend");
- ParseFlag(str, &f->atexit, "atexit");
- ParseFlag(str, &f->coverage, "coverage");
- ParseFlag(str, &f->disable_core, "disable_core");
- ParseFlag(str, &f->allow_reexec, "allow_reexec");
- ParseFlag(str, &f->print_full_thread_history, "print_full_thread_history");
- ParseFlag(str, &f->poison_heap, "poison_heap");
- ParseFlag(str, &f->poison_partial, "poison_partial");
- ParseFlag(str, &f->alloc_dealloc_mismatch, "alloc_dealloc_mismatch");
- ParseFlag(str, &f->strict_memcmp, "strict_memcmp");
- ParseFlag(str, &f->strict_init_order, "strict_init_order");
- ParseFlag(str, &f->start_deactivated, "start_deactivated");
+ "detect_stack_use_after_return", "");
+ ParseFlag(str, &f->min_uar_stack_size_log, "min_uar_stack_size_log", "");
+ ParseFlag(str, &f->max_uar_stack_size_log, "max_uar_stack_size_log", "");
+ ParseFlag(str, &f->uar_noreserve, "uar_noreserve", "");
+ ParseFlag(str, &f->max_malloc_fill_size, "max_malloc_fill_size", "");
+ ParseFlag(str, &f->malloc_fill_byte, "malloc_fill_byte", "");
+ ParseFlag(str, &f->exitcode, "exitcode", "");
+ ParseFlag(str, &f->allow_user_poisoning, "allow_user_poisoning", "");
+ ParseFlag(str, &f->sleep_before_dying, "sleep_before_dying", "");
+ ParseFlag(str, &f->check_malloc_usable_size, "check_malloc_usable_size", "");
+ ParseFlag(str, &f->unmap_shadow_on_exit, "unmap_shadow_on_exit", "");
+ ParseFlag(str, &f->abort_on_error, "abort_on_error", "");
+ ParseFlag(str, &f->print_stats, "print_stats", "");
+ ParseFlag(str, &f->print_legend, "print_legend", "");
+ ParseFlag(str, &f->atexit, "atexit", "");
+ ParseFlag(str, &f->coverage, "coverage", "");
+ ParseFlag(str, &f->disable_core, "disable_core", "");
+ ParseFlag(str, &f->allow_reexec, "allow_reexec", "");
+ ParseFlag(str, &f->print_full_thread_history,
+ "print_full_thread_history", "");
+ ParseFlag(str, &f->poison_heap, "poison_heap", "");
+ ParseFlag(str, &f->poison_partial, "poison_partial", "");
+ ParseFlag(str, &f->alloc_dealloc_mismatch, "alloc_dealloc_mismatch", "");
+ ParseFlag(str, &f->strict_memcmp, "strict_memcmp", "");
+ ParseFlag(str, &f->strict_init_order, "strict_init_order", "");
+ ParseFlag(str, &f->start_deactivated, "start_deactivated", "");
ParseFlag(str, &f->detect_invalid_pointer_pairs,
- "detect_invalid_pointer_pairs");
+ "detect_invalid_pointer_pairs", "");
}
void InitializeFlags(Flags *f, const char *env) {
@@ -196,6 +198,9 @@ void InitializeFlags(Flags *f, const cha
// Override from command line.
ParseFlagsFromString(f, env);
+ if (common_flags()->help) {
+ PrintFlagDescriptions();
+ }
#if !CAN_SANITIZE_LEAKS
if (cf->detect_leaks) {
Modified: compiler-rt/trunk/lib/dfsan/dfsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan.cc?rev=204339&r1=204338&r2=204339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/dfsan.cc (original)
+++ compiler-rt/trunk/lib/dfsan/dfsan.cc Thu Mar 20 07:52:52 2014
@@ -235,9 +235,9 @@ static void InitializeFlags(Flags &f, co
f.warn_nonzero_labels = false;
f.strict_data_dependencies = true;
- ParseFlag(env, &f.warn_unimplemented, "warn_unimplemented");
- ParseFlag(env, &f.warn_nonzero_labels, "warn_nonzero_labels");
- ParseFlag(env, &f.strict_data_dependencies, "strict_data_dependencies");
+ ParseFlag(env, &f.warn_unimplemented, "warn_unimplemented", "");
+ ParseFlag(env, &f.warn_nonzero_labels, "warn_nonzero_labels", "");
+ ParseFlag(env, &f.strict_data_dependencies, "strict_data_dependencies", "");
}
#ifdef DFSAN_NOLIBC
Modified: compiler-rt/trunk/lib/lsan/lsan_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.cc?rev=204339&r1=204338&r2=204339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common.cc Thu Mar 20 07:52:52 2014
@@ -57,23 +57,23 @@ static void InitializeFlags() {
const char *options = GetEnv("LSAN_OPTIONS");
if (options) {
- ParseFlag(options, &f->use_registers, "use_registers");
- ParseFlag(options, &f->use_globals, "use_globals");
- ParseFlag(options, &f->use_stacks, "use_stacks");
- ParseFlag(options, &f->use_tls, "use_tls");
- ParseFlag(options, &f->use_root_regions, "use_root_regions");
- ParseFlag(options, &f->use_unaligned, "use_unaligned");
- ParseFlag(options, &f->use_poisoned, "use_poisoned");
- ParseFlag(options, &f->report_objects, "report_objects");
- ParseFlag(options, &f->resolution, "resolution");
+ ParseFlag(options, &f->use_registers, "use_registers", "");
+ ParseFlag(options, &f->use_globals, "use_globals", "");
+ ParseFlag(options, &f->use_stacks, "use_stacks", "");
+ ParseFlag(options, &f->use_tls, "use_tls", "");
+ ParseFlag(options, &f->use_root_regions, "use_root_regions", "");
+ ParseFlag(options, &f->use_unaligned, "use_unaligned", "");
+ ParseFlag(options, &f->use_poisoned, "use_poisoned", "");
+ ParseFlag(options, &f->report_objects, "report_objects", "");
+ ParseFlag(options, &f->resolution, "resolution", "");
CHECK_GE(&f->resolution, 0);
- ParseFlag(options, &f->max_leaks, "max_leaks");
+ ParseFlag(options, &f->max_leaks, "max_leaks", "");
CHECK_GE(&f->max_leaks, 0);
- ParseFlag(options, &f->log_pointers, "log_pointers");
- ParseFlag(options, &f->log_threads, "log_threads");
- ParseFlag(options, &f->exitcode, "exitcode");
- ParseFlag(options, &f->print_suppressions, "print_suppressions");
- ParseFlag(options, &f->suppressions, "suppressions");
+ ParseFlag(options, &f->log_pointers, "log_pointers", "");
+ ParseFlag(options, &f->log_threads, "log_threads", "");
+ ParseFlag(options, &f->exitcode, "exitcode", "");
+ ParseFlag(options, &f->print_suppressions, "print_suppressions", "");
+ ParseFlag(options, &f->suppressions, "suppressions", "");
}
}
Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=204339&r1=204338&r2=204339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Thu Mar 20 07:52:52 2014
@@ -107,24 +107,24 @@ static atomic_uint32_t NumStackOriginDes
static void ParseFlagsFromString(Flags *f, const char *str) {
CommonFlags *cf = common_flags();
ParseCommonFlagsFromString(cf, str);
- ParseFlag(str, &f->poison_heap_with_zeroes, "poison_heap_with_zeroes");
- ParseFlag(str, &f->poison_stack_with_zeroes, "poison_stack_with_zeroes");
- ParseFlag(str, &f->poison_in_malloc, "poison_in_malloc");
- ParseFlag(str, &f->poison_in_free, "poison_in_free");
- ParseFlag(str, &f->exit_code, "exit_code");
+ ParseFlag(str, &f->poison_heap_with_zeroes, "poison_heap_with_zeroes", "");
+ ParseFlag(str, &f->poison_stack_with_zeroes, "poison_stack_with_zeroes", "");
+ ParseFlag(str, &f->poison_in_malloc, "poison_in_malloc", "");
+ ParseFlag(str, &f->poison_in_free, "poison_in_free", "");
+ ParseFlag(str, &f->exit_code, "exit_code", "");
if (f->exit_code < 0 || f->exit_code > 127) {
Printf("Exit code not in [0, 128) range: %d\n", f->exit_code);
Die();
}
- ParseFlag(str, &f->report_umrs, "report_umrs");
- ParseFlag(str, &f->wrap_signals, "wrap_signals");
+ ParseFlag(str, &f->report_umrs, "report_umrs", "");
+ ParseFlag(str, &f->wrap_signals, "wrap_signals", "");
// keep_going is an old name for halt_on_error,
// and it has inverse meaning.
f->halt_on_error = !f->halt_on_error;
- ParseFlag(str, &f->halt_on_error, "keep_going");
+ ParseFlag(str, &f->halt_on_error, "keep_going", "");
f->halt_on_error = !f->halt_on_error;
- ParseFlag(str, &f->halt_on_error, "halt_on_error");
+ ParseFlag(str, &f->halt_on_error, "halt_on_error", "");
}
static void InitializeFlags(Flags *f, const char *options) {
@@ -277,6 +277,7 @@ void __msan_init() {
const char *msan_options = GetEnv("MSAN_OPTIONS");
InitializeFlags(&msan_flags, msan_options);
+ if (common_flags()->help) PrintFlagDescriptions();
__sanitizer_set_report_path(common_flags()->log_path);
InitializeInterceptors();
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc?rev=204339&r1=204338&r2=204339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc Thu Mar 20 07:52:52 2014
@@ -20,6 +20,14 @@ namespace __sanitizer {
CommonFlags common_flags_dont_use;
+struct FlagDescriptionList {
+ const char *name;
+ const char *description;
+ FlagDescriptionList *next;
+};
+
+FlagDescriptionList *flag_descriptions = 0, *last_flag_description = 0;
+
void SetCommonFlagsDefaults(CommonFlags *f) {
f->symbolize = true;
f->external_symbolizer_path = 0;
@@ -47,29 +55,31 @@ void SetCommonFlagsDefaults(CommonFlags
}
void ParseCommonFlagsFromString(CommonFlags *f, const char *str) {
- ParseFlag(str, &f->symbolize, "symbolize");
- ParseFlag(str, &f->external_symbolizer_path, "external_symbolizer_path");
- ParseFlag(str, &f->allow_addr2line, "allow_addr2line");
- ParseFlag(str, &f->strip_path_prefix, "strip_path_prefix");
- ParseFlag(str, &f->fast_unwind_on_fatal, "fast_unwind_on_fatal");
- ParseFlag(str, &f->fast_unwind_on_malloc, "fast_unwind_on_malloc");
- ParseFlag(str, &f->handle_ioctl, "handle_ioctl");
- ParseFlag(str, &f->malloc_context_size, "malloc_context_size");
- ParseFlag(str, &f->log_path, "log_path");
- ParseFlag(str, &f->verbosity, "verbosity");
- ParseFlag(str, &f->detect_leaks, "detect_leaks");
- ParseFlag(str, &f->leak_check_at_exit, "leak_check_at_exit");
- ParseFlag(str, &f->allocator_may_return_null, "allocator_may_return_null");
- ParseFlag(str, &f->print_summary, "print_summary");
- ParseFlag(str, &f->check_printf, "check_printf");
- ParseFlag(str, &f->handle_segv, "handle_segv");
- ParseFlag(str, &f->allow_user_segv_handler, "allow_user_segv_handler");
- ParseFlag(str, &f->use_sigaltstack, "use_sigaltstack");
- ParseFlag(str, &f->detect_deadlocks, "detect_deadlocks");
+ ParseFlag(str, &f->symbolize, "symbolize", "");
+ ParseFlag(str, &f->external_symbolizer_path, "external_symbolizer_path", "");
+ ParseFlag(str, &f->allow_addr2line, "allow_addr2line", "");
+ ParseFlag(str, &f->strip_path_prefix, "strip_path_prefix", "");
+ ParseFlag(str, &f->fast_unwind_on_fatal, "fast_unwind_on_fatal", "");
+ ParseFlag(str, &f->fast_unwind_on_malloc, "fast_unwind_on_malloc", "");
+ ParseFlag(str, &f->handle_ioctl, "handle_ioctl", "");
+ ParseFlag(str, &f->malloc_context_size, "malloc_context_size", "");
+ ParseFlag(str, &f->log_path, "log_path", "");
+ ParseFlag(str, &f->verbosity, "verbosity", "");
+ ParseFlag(str, &f->detect_leaks, "detect_leaks", "");
+ ParseFlag(str, &f->leak_check_at_exit, "leak_check_at_exit", "");
+ ParseFlag(str, &f->allocator_may_return_null, "allocator_may_return_null",
+ "");
+ ParseFlag(str, &f->print_summary, "print_summary", "");
+ ParseFlag(str, &f->check_printf, "check_printf", "");
+ ParseFlag(str, &f->handle_segv, "handle_segv", "");
+ ParseFlag(str, &f->allow_user_segv_handler, "allow_user_segv_handler", "");
+ ParseFlag(str, &f->use_sigaltstack, "use_sigaltstack", "");
+ ParseFlag(str, &f->detect_deadlocks, "detect_deadlocks", "");
ParseFlag(str, &f->clear_shadow_mmap_threshold,
- "clear_shadow_mmap_threshold");
- ParseFlag(str, &f->color, "color");
- ParseFlag(str, &f->legacy_pthread_cond, "legacy_pthread_cond");
+ "clear_shadow_mmap_threshold", "");
+ ParseFlag(str, &f->color, "color", "");
+ ParseFlag(str, &f->legacy_pthread_cond, "legacy_pthread_cond", "");
+ ParseFlag(str, &f->help, "help", "");
// Do a sanity check for certain flags.
if (f->malloc_context_size < 1)
@@ -124,9 +134,49 @@ static bool StartsWith(const char *flag,
(0 == internal_strncmp(flag, value, value_length));
}
-void ParseFlag(const char *env, bool *flag, const char *name) {
+static LowLevelAllocator allocator_for_flags;
+
+// The linear scan is suboptimal, but the number of flags is relatively small.
+bool FlagInDescriptionList(const char *name) {
+ FlagDescriptionList *descr = flag_descriptions;
+ while (descr) {
+ if (!internal_strcmp(descr->name, name)) return true;
+ descr = descr->next;
+ }
+ return false;
+}
+
+void AddFlagDescription(const char *name, const char *description) {
+ if (FlagInDescriptionList(name)) return;
+ FlagDescriptionList *new_description =
+ (FlagDescriptionList*)allocator_for_flags.Allocate(
+ sizeof(FlagDescriptionList));
+ if (!last_flag_description) {
+ flag_descriptions = new_description;
+ } else {
+ last_flag_description->next = new_description;
+ }
+ new_description->name = name;
+ new_description->description = description;
+ new_description->next = 0;
+ last_flag_description = new_description;
+}
+
+// TODO(glider): put the descriptions inside CommonFlags.
+void PrintFlagDescriptions() {
+ FlagDescriptionList *descr = flag_descriptions;
+ Printf("Available flags for %s:\n", SanitizerToolName);
+ while (descr) {
+ Printf("\t%s - %s\n", descr->name, descr->description);
+ descr = descr->next;
+ }
+}
+
+void ParseFlag(const char *env, bool *flag,
+ const char *name, const char *descr) {
const char *value;
int value_length;
+ AddFlagDescription(name, descr);
if (!GetFlagValue(env, name, &value, &value_length))
return;
if (StartsWith(value, value_length, "0") ||
@@ -139,27 +189,31 @@ void ParseFlag(const char *env, bool *fl
*flag = true;
}
-void ParseFlag(const char *env, int *flag, const char *name) {
+void ParseFlag(const char *env, int *flag,
+ const char *name, const char *descr) {
const char *value;
int value_length;
+ AddFlagDescription(name, descr);
if (!GetFlagValue(env, name, &value, &value_length))
return;
*flag = static_cast<int>(internal_atoll(value));
}
-void ParseFlag(const char *env, uptr *flag, const char *name) {
+void ParseFlag(const char *env, uptr *flag,
+ const char *name, const char *descr) {
const char *value;
int value_length;
+ AddFlagDescription(name, descr);
if (!GetFlagValue(env, name, &value, &value_length))
return;
*flag = static_cast<uptr>(internal_atoll(value));
}
-static LowLevelAllocator allocator_for_flags;
-
-void ParseFlag(const char *env, const char **flag, const char *name) {
+void ParseFlag(const char *env, const char **flag,
+ const char *name, const char *descr) {
const char *value;
int value_length;
+ AddFlagDescription(name, descr);
if (!GetFlagValue(env, name, &value, &value_length))
return;
// Copy the flag value. Don't use locks here, as flags are parsed at
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h?rev=204339&r1=204338&r2=204339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h Thu Mar 20 07:52:52 2014
@@ -18,10 +18,14 @@
namespace __sanitizer {
-void ParseFlag(const char *env, bool *flag, const char *name);
-void ParseFlag(const char *env, int *flag, const char *name);
-void ParseFlag(const char *env, uptr *flag, const char *name);
-void ParseFlag(const char *env, const char **flag, const char *name);
+void ParseFlag(const char *env, bool *flag,
+ const char *name, const char *descr);
+void ParseFlag(const char *env, int *flag,
+ const char *name, const char *descr);
+void ParseFlag(const char *env, uptr *flag,
+ const char *name, const char *descr);
+void ParseFlag(const char *env, const char **flag,
+ const char *name, const char *descr);
struct CommonFlags {
// If set, use the online symbolizer from common sanitizer runtime to turn
@@ -80,6 +84,8 @@ struct CommonFlags {
const char *color;
// Enables support for dynamic libraries linked with libpthread 2.2.5.
bool legacy_pthread_cond;
+ // Print help and exit.
+ bool help;
};
inline CommonFlags *common_flags() {
@@ -89,6 +95,7 @@ inline CommonFlags *common_flags() {
void SetCommonFlagsDefaults(CommonFlags *f);
void ParseCommonFlagsFromString(CommonFlags *f, const char *str);
+void PrintFlagDescriptions();
} // namespace __sanitizer
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc?rev=204339&r1=204338&r2=204339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc Thu Mar 20 07:52:52 2014
@@ -24,14 +24,14 @@ static const char kFlagName[] = "flag_na
template <typename T>
static void TestFlag(T start_value, const char *env, T final_value) {
T flag = start_value;
- ParseFlag(env, &flag, kFlagName);
+ ParseFlag(env, &flag, kFlagName, "flag description");
EXPECT_EQ(final_value, flag);
}
static void TestStrFlag(const char *start_value, const char *env,
const char *final_value) {
const char *flag = start_value;
- ParseFlag(env, &flag, kFlagName);
+ ParseFlag(env, &flag, kFlagName, "flag description");
EXPECT_EQ(0, internal_strcmp(final_value, flag));
}
@@ -70,8 +70,8 @@ static void TestTwoFlags(const char *env
const char *expected_flag2) {
bool flag1 = !expected_flag1;
const char *flag2 = "";
- ParseFlag(env, &flag1, "flag1");
- ParseFlag(env, &flag2, "flag2");
+ ParseFlag(env, &flag1, "flag1", "flag1 description");
+ ParseFlag(env, &flag2, "flag2", "flag2 description");
EXPECT_EQ(expected_flag1, flag1);
EXPECT_EQ(0, internal_strcmp(flag2, expected_flag2));
}
Modified: compiler-rt/trunk/lib/tsan/dd/dd_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/dd/dd_rtl.cc?rev=204339&r1=204338&r2=204339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/dd/dd_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/dd/dd_rtl.cc Thu Mar 20 07:52:52 2014
@@ -76,7 +76,7 @@ void InitializeFlags(Flags *f, const cha
f->allow_addr2line = true;
// Override from command line.
- ParseFlag(env, &f->second_deadlock_stack, "second_deadlock_stack");
+ ParseFlag(env, &f->second_deadlock_stack, "second_deadlock_stack", "");
ParseCommonFlagsFromString(f, env);
// Copy back to common flags.
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc?rev=204339&r1=204338&r2=204339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc Thu Mar 20 07:52:52 2014
@@ -34,34 +34,34 @@ const char *WEAK __tsan_default_options(
#endif
static void ParseFlags(Flags *f, const char *env) {
- ParseFlag(env, &f->enable_annotations, "enable_annotations");
- ParseFlag(env, &f->suppress_equal_stacks, "suppress_equal_stacks");
- ParseFlag(env, &f->suppress_equal_addresses, "suppress_equal_addresses");
- ParseFlag(env, &f->suppress_java, "suppress_java");
- ParseFlag(env, &f->report_bugs, "report_bugs");
- ParseFlag(env, &f->report_thread_leaks, "report_thread_leaks");
- ParseFlag(env, &f->report_destroy_locked, "report_destroy_locked");
- ParseFlag(env, &f->report_signal_unsafe, "report_signal_unsafe");
- ParseFlag(env, &f->report_atomic_races, "report_atomic_races");
- ParseFlag(env, &f->force_seq_cst_atomics, "force_seq_cst_atomics");
- ParseFlag(env, &f->suppressions, "suppressions");
- ParseFlag(env, &f->print_suppressions, "print_suppressions");
- ParseFlag(env, &f->print_benign, "print_benign");
- ParseFlag(env, &f->exitcode, "exitcode");
- ParseFlag(env, &f->halt_on_error, "halt_on_error");
- ParseFlag(env, &f->atexit_sleep_ms, "atexit_sleep_ms");
- ParseFlag(env, &f->profile_memory, "profile_memory");
- ParseFlag(env, &f->flush_memory_ms, "flush_memory_ms");
- ParseFlag(env, &f->flush_symbolizer_ms, "flush_symbolizer_ms");
- ParseFlag(env, &f->memory_limit_mb, "memory_limit_mb");
- ParseFlag(env, &f->stop_on_start, "stop_on_start");
- ParseFlag(env, &f->running_on_valgrind, "running_on_valgrind");
- ParseFlag(env, &f->history_size, "history_size");
- ParseFlag(env, &f->io_sync, "io_sync");
- ParseFlag(env, &f->die_after_fork, "die_after_fork");
+ ParseFlag(env, &f->enable_annotations, "enable_annotations", "");
+ ParseFlag(env, &f->suppress_equal_stacks, "suppress_equal_stacks", "");
+ ParseFlag(env, &f->suppress_equal_addresses, "suppress_equal_addresses", "");
+ ParseFlag(env, &f->suppress_java, "suppress_java", "");
+ ParseFlag(env, &f->report_bugs, "report_bugs", "");
+ ParseFlag(env, &f->report_thread_leaks, "report_thread_leaks", "");
+ ParseFlag(env, &f->report_destroy_locked, "report_destroy_locked", "");
+ ParseFlag(env, &f->report_signal_unsafe, "report_signal_unsafe", "");
+ ParseFlag(env, &f->report_atomic_races, "report_atomic_races", "");
+ ParseFlag(env, &f->force_seq_cst_atomics, "force_seq_cst_atomics", "");
+ ParseFlag(env, &f->suppressions, "suppressions", "");
+ ParseFlag(env, &f->print_suppressions, "print_suppressions", "");
+ ParseFlag(env, &f->print_benign, "print_benign", "");
+ ParseFlag(env, &f->exitcode, "exitcode", "");
+ ParseFlag(env, &f->halt_on_error, "halt_on_error", "");
+ ParseFlag(env, &f->atexit_sleep_ms, "atexit_sleep_ms", "");
+ ParseFlag(env, &f->profile_memory, "profile_memory", "");
+ ParseFlag(env, &f->flush_memory_ms, "flush_memory_ms", "");
+ ParseFlag(env, &f->flush_symbolizer_ms, "flush_symbolizer_ms", "");
+ ParseFlag(env, &f->memory_limit_mb, "memory_limit_mb", "");
+ ParseFlag(env, &f->stop_on_start, "stop_on_start", "");
+ ParseFlag(env, &f->running_on_valgrind, "running_on_valgrind", "");
+ ParseFlag(env, &f->history_size, "history_size", "");
+ ParseFlag(env, &f->io_sync, "io_sync", "");
+ ParseFlag(env, &f->die_after_fork, "die_after_fork", "");
// DDFlags
- ParseFlag(env, &f->second_deadlock_stack, "second_deadlock_stack");
+ ParseFlag(env, &f->second_deadlock_stack, "second_deadlock_stack", "");
}
void InitializeFlags(Flags *f, const char *env) {
@@ -118,6 +118,8 @@ void InitializeFlags(Flags *f, const cha
f->report_signal_unsafe = false;
}
+ if (f->help) PrintFlagDescriptions();
+
if (f->history_size < 0 || f->history_size > 7) {
Printf("ThreadSanitizer: incorrect value for history_size"
" (must be [0..7])\n");
More information about the llvm-commits
mailing list