forked from OSchip/llvm-project
[libsanitizer] Add descriptions for the common flags.
Use new(allocator_for_flags) instead of allocator_for_flags.Allocate() Fix the description output format a bit. llvm-svn: 204484
This commit is contained in:
parent
7618632517
commit
25e204e194
|
|
@ -56,31 +56,66 @@ void SetCommonFlagsDefaults(CommonFlags *f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseCommonFlagsFromString(CommonFlags *f, const char *str) {
|
void ParseCommonFlagsFromString(CommonFlags *f, const char *str) {
|
||||||
ParseFlag(str, &f->symbolize, "symbolize", "");
|
ParseFlag(str, &f->symbolize, "symbolize",
|
||||||
ParseFlag(str, &f->external_symbolizer_path, "external_symbolizer_path", "");
|
"If set, use the online symbolizer from common sanitizer runtime to turn "
|
||||||
ParseFlag(str, &f->allow_addr2line, "allow_addr2line", "");
|
"virtual addresses to file/line locations.");
|
||||||
ParseFlag(str, &f->strip_path_prefix, "strip_path_prefix", "");
|
ParseFlag(str, &f->external_symbolizer_path, "external_symbolizer_path",
|
||||||
ParseFlag(str, &f->fast_unwind_on_fatal, "fast_unwind_on_fatal", "");
|
"Path to external symbolizer. If empty, the tool will search $PATH for "
|
||||||
ParseFlag(str, &f->fast_unwind_on_malloc, "fast_unwind_on_malloc", "");
|
"the symbolizer.");
|
||||||
ParseFlag(str, &f->handle_ioctl, "handle_ioctl", "");
|
ParseFlag(str, &f->allow_addr2line, "allow_addr2line",
|
||||||
ParseFlag(str, &f->malloc_context_size, "malloc_context_size", "");
|
"If set, allows online symbolizer to run addr2line binary to symbolize "
|
||||||
ParseFlag(str, &f->log_path, "log_path", "");
|
"stack traces (addr2line will only be used if llvm-symbolizer binary is "
|
||||||
ParseFlag(str, &f->verbosity, "verbosity", "");
|
"unavailable.");
|
||||||
ParseFlag(str, &f->detect_leaks, "detect_leaks", "");
|
ParseFlag(str, &f->strip_path_prefix, "strip_path_prefix",
|
||||||
ParseFlag(str, &f->leak_check_at_exit, "leak_check_at_exit", "");
|
"Strips this prefix from file paths in error reports.");
|
||||||
|
ParseFlag(str, &f->fast_unwind_on_fatal, "fast_unwind_on_fatal",
|
||||||
|
"If available, use the fast frame-pointer-based unwinder on fatal "
|
||||||
|
"errors.");
|
||||||
|
ParseFlag(str, &f->fast_unwind_on_malloc, "fast_unwind_on_malloc",
|
||||||
|
"If available, use the fast frame-pointer-based unwinder on "
|
||||||
|
"malloc/free.");
|
||||||
|
ParseFlag(str, &f->handle_ioctl, "handle_ioctl",
|
||||||
|
"Intercept and handle ioctl requests.");
|
||||||
|
ParseFlag(str, &f->malloc_context_size, "malloc_context_size",
|
||||||
|
"Max number of stack frames kept for each allocation/deallocation.");
|
||||||
|
ParseFlag(str, &f->log_path, "log_path",
|
||||||
|
"Write logs to \"log_path.pid\". The special values are \"stdout\" and "
|
||||||
|
"\"stderr\". The default is \"stderr\".");
|
||||||
|
ParseFlag(str, &f->verbosity, "verbosity",
|
||||||
|
"Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).");
|
||||||
|
ParseFlag(str, &f->detect_leaks, "detect_leaks",
|
||||||
|
"Enable memory leak detection.");
|
||||||
|
ParseFlag(str, &f->leak_check_at_exit, "leak_check_at_exit",
|
||||||
|
"Invoke leak checking in an atexit handler. Has no effect if "
|
||||||
|
"detect_leaks=false, or if __lsan_do_leak_check() is called before the "
|
||||||
|
"handler has a chance to run.");
|
||||||
ParseFlag(str, &f->allocator_may_return_null, "allocator_may_return_null",
|
ParseFlag(str, &f->allocator_may_return_null, "allocator_may_return_null",
|
||||||
"");
|
"If false, the allocator will crash instead of returning 0 on "
|
||||||
ParseFlag(str, &f->print_summary, "print_summary", "");
|
"out-of-memory.");
|
||||||
ParseFlag(str, &f->check_printf, "check_printf", "");
|
ParseFlag(str, &f->print_summary, "print_summary",
|
||||||
ParseFlag(str, &f->handle_segv, "handle_segv", "");
|
"If false, disable printing error summaries in addition to error "
|
||||||
ParseFlag(str, &f->allow_user_segv_handler, "allow_user_segv_handler", "");
|
"reports.");
|
||||||
ParseFlag(str, &f->use_sigaltstack, "use_sigaltstack", "");
|
ParseFlag(str, &f->check_printf, "check_printf",
|
||||||
ParseFlag(str, &f->detect_deadlocks, "detect_deadlocks", "");
|
"Check printf arguments.");
|
||||||
|
ParseFlag(str, &f->handle_segv, "handle_segv",
|
||||||
|
"If set, registers the tool's custom SEGV handler (both SIGBUS and "
|
||||||
|
"SIGSEGV on OSX).");
|
||||||
|
ParseFlag(str, &f->allow_user_segv_handler, "allow_user_segv_handler",
|
||||||
|
"If set, allows user to register a SEGV handler even if the tool "
|
||||||
|
"registers one.");
|
||||||
|
ParseFlag(str, &f->use_sigaltstack, "use_sigaltstack",
|
||||||
|
"If set, uses alternate stack for signal handling.");
|
||||||
|
ParseFlag(str, &f->detect_deadlocks, "detect_deadlocks",
|
||||||
|
"If set, deadlock detection is enabled.");
|
||||||
ParseFlag(str, &f->clear_shadow_mmap_threshold,
|
ParseFlag(str, &f->clear_shadow_mmap_threshold,
|
||||||
"clear_shadow_mmap_threshold", "");
|
"clear_shadow_mmap_threshold",
|
||||||
ParseFlag(str, &f->color, "color", "");
|
"Large shadow regions are zero-filled using mmap(NORESERVE) instead of "
|
||||||
ParseFlag(str, &f->legacy_pthread_cond, "legacy_pthread_cond", "");
|
"memset(). This is the threshold size in bytes.");
|
||||||
ParseFlag(str, &f->help, "help", "");
|
ParseFlag(str, &f->color, "color",
|
||||||
|
"Colorize reports: (always|never|auto).");
|
||||||
|
ParseFlag(str, &f->legacy_pthread_cond, "legacy_pthread_cond",
|
||||||
|
"Enables support for dynamic libraries linked with libpthread 2.2.5.");
|
||||||
|
ParseFlag(str, &f->help, "help", "Print the flag descriptions.");
|
||||||
|
|
||||||
// Do a sanity check for certain flags.
|
// Do a sanity check for certain flags.
|
||||||
if (f->malloc_context_size < 1)
|
if (f->malloc_context_size < 1)
|
||||||
|
|
@ -149,8 +184,7 @@ bool FlagInDescriptionList(const char *name) {
|
||||||
void AddFlagDescription(const char *name, const char *description) {
|
void AddFlagDescription(const char *name, const char *description) {
|
||||||
if (FlagInDescriptionList(name)) return;
|
if (FlagInDescriptionList(name)) return;
|
||||||
FlagDescription *new_description =
|
FlagDescription *new_description =
|
||||||
(FlagDescription*)allocator_for_flags.Allocate(
|
new(allocator_for_flags) FlagDescription();
|
||||||
sizeof(FlagDescription));
|
|
||||||
new_description->name = name;
|
new_description->name = name;
|
||||||
new_description->description = description;
|
new_description->description = description;
|
||||||
flag_descriptions.push_back(new_description);
|
flag_descriptions.push_back(new_description);
|
||||||
|
|
@ -162,7 +196,7 @@ void PrintFlagDescriptions() {
|
||||||
Printf("Available flags for %s:\n", SanitizerToolName);
|
Printf("Available flags for %s:\n", SanitizerToolName);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
FlagDescription *descr = it.next();
|
FlagDescription *descr = it.next();
|
||||||
Printf("\t%s - %s\n", descr->name, descr->description);
|
Printf("\t%s\n\t\t- %s\n", descr->name, descr->description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,63 +28,28 @@ void ParseFlag(const char *env, const char **flag,
|
||||||
const char *name, const char *descr);
|
const char *name, const char *descr);
|
||||||
|
|
||||||
struct CommonFlags {
|
struct CommonFlags {
|
||||||
// If set, use the online symbolizer from common sanitizer runtime to turn
|
|
||||||
// virtual addresses to file/line locations.
|
|
||||||
bool symbolize;
|
bool symbolize;
|
||||||
// Path to external symbolizer. If it is NULL, symbolizer will be looked for
|
|
||||||
// in PATH. If it is empty (or if "symbolize" is false), external symbolizer
|
|
||||||
// will not be started.
|
|
||||||
const char *external_symbolizer_path;
|
const char *external_symbolizer_path;
|
||||||
// If set, allows online symbolizer to run addr2line binary to symbolize
|
|
||||||
// stack traces (addr2line will only be used if llvm-symbolizer binary is not
|
|
||||||
// available.
|
|
||||||
bool allow_addr2line;
|
bool allow_addr2line;
|
||||||
// Strips this prefix from file paths in error reports.
|
|
||||||
const char *strip_path_prefix;
|
const char *strip_path_prefix;
|
||||||
// Use fast (frame-pointer-based) unwinder on fatal errors (if available).
|
|
||||||
bool fast_unwind_on_fatal;
|
bool fast_unwind_on_fatal;
|
||||||
// Use fast (frame-pointer-based) unwinder on malloc/free (if available).
|
|
||||||
bool fast_unwind_on_malloc;
|
bool fast_unwind_on_malloc;
|
||||||
// Intercept and handle ioctl requests.
|
|
||||||
bool handle_ioctl;
|
bool handle_ioctl;
|
||||||
// Max number of stack frames kept for each allocation/deallocation.
|
|
||||||
int malloc_context_size;
|
int malloc_context_size;
|
||||||
// Write logs to "log_path.pid".
|
|
||||||
// The special values are "stdout" and "stderr".
|
|
||||||
// The default is "stderr".
|
|
||||||
const char *log_path;
|
const char *log_path;
|
||||||
// Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).
|
|
||||||
int verbosity;
|
int verbosity;
|
||||||
// Enable memory leak detection.
|
|
||||||
bool detect_leaks;
|
bool detect_leaks;
|
||||||
// Invoke leak checking in an atexit handler. Has no effect if
|
|
||||||
// detect_leaks=false, or if __lsan_do_leak_check() is called before the
|
|
||||||
// handler has a chance to run.
|
|
||||||
bool leak_check_at_exit;
|
bool leak_check_at_exit;
|
||||||
// If false, the allocator will crash instead of returning 0 on out-of-memory.
|
|
||||||
bool allocator_may_return_null;
|
bool allocator_may_return_null;
|
||||||
// If false, disable printing error summaries in addition to error reports.
|
|
||||||
bool print_summary;
|
bool print_summary;
|
||||||
// Check printf arguments.
|
|
||||||
bool check_printf;
|
bool check_printf;
|
||||||
// If set, registers the tool's custom SEGV handler (both SIGBUS and SIGSEGV
|
|
||||||
// on OSX).
|
|
||||||
bool handle_segv;
|
bool handle_segv;
|
||||||
// If set, allows user to register a SEGV handler even if the tool registers
|
|
||||||
// one.
|
|
||||||
bool allow_user_segv_handler;
|
bool allow_user_segv_handler;
|
||||||
// If set, uses alternate stack for signal handling.
|
|
||||||
bool use_sigaltstack;
|
bool use_sigaltstack;
|
||||||
// If set, deadlock detection is enabled.
|
|
||||||
bool detect_deadlocks;
|
bool detect_deadlocks;
|
||||||
// Large shadow regions are zero-filled using mmap(NORESERVE) instead of
|
|
||||||
// memset. This is the threshold size in bytes.
|
|
||||||
uptr clear_shadow_mmap_threshold;
|
uptr clear_shadow_mmap_threshold;
|
||||||
// Colorize reports: (always|never|auto).
|
|
||||||
const char *color;
|
const char *color;
|
||||||
// Enables support for dynamic libraries linked with libpthread 2.2.5.
|
|
||||||
bool legacy_pthread_cond;
|
bool legacy_pthread_cond;
|
||||||
// Print help and exit.
|
|
||||||
bool help;
|
bool help;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue