1 //===-- sanitizer_flags.h ---------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of ThreadSanitizer/AddressSanitizer runtime.
9 //
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef SANITIZER_FLAGS_H
13 #define SANITIZER_FLAGS_H
14 
15 #include "sanitizer_internal_defs.h"
16 
17 namespace __sanitizer {
18 
19 void ParseFlag(const char *env, bool *flag, const char *name);
20 void ParseFlag(const char *env, int *flag, const char *name);
21 void ParseFlag(const char *env, const char **flag, const char *name);
22 
23 struct CommonFlags {
24   // If set, use the online symbolizer from common sanitizer runtime.
25   bool symbolize;
26   // Path to external symbolizer. If it is NULL, symbolizer will be looked for
27   // in PATH. If it is empty, external symbolizer will not be started.
28   const char *external_symbolizer_path;
29   // Strips this prefix from file paths in error reports.
30   const char *strip_path_prefix;
31   // Use fast (frame-pointer-based) unwinder on fatal errors (if available).
32   bool fast_unwind_on_fatal;
33   // Use fast (frame-pointer-based) unwinder on malloc/free (if available).
34   bool fast_unwind_on_malloc;
35   // Intercept and handle ioctl requests.
36   bool handle_ioctl;
37   // Max number of stack frames kept for each allocation/deallocation.
38   int malloc_context_size;
39   // Write logs to "log_path.pid".
40   // The special values are "stdout" and "stderr".
41   // The default is "stderr".
42   const char *log_path;
43   // Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).
44   int  verbosity;
45   // Enable memory leak detection.
46   bool detect_leaks;
47   // Invoke leak checking in an atexit handler. Has no effect if
48   // detect_leaks=false, or if __lsan_do_leak_check() is called before the
49   // handler has a chance to run.
50   bool leak_check_at_exit;
51   // If false, the allocator will crash instead of returning 0 on out-of-memory.
52   bool allocator_may_return_null;
53   // If false, disable printing error summaries in addition to error reports.
54   bool print_summary;
55 };
56 
common_flags()57 inline CommonFlags *common_flags() {
58   static CommonFlags f;
59   return &f;
60 }
61 
62 void SetCommonFlagsDefaults(CommonFlags *f);
63 void ParseCommonFlagsFromString(CommonFlags *f, const char *str);
64 
65 }  // namespace __sanitizer
66 
67 #endif  // SANITIZER_FLAGS_H
68