================
@@ -177,6 +177,43 @@ For more information on leak detector in AddressSanitizer, 
see
 and can be enabled using `ASAN_OPTIONS=detect_leaks=1` on macOS;
 however, it is not yet supported on other platforms.
 
+## Flags and Options
+
+Runtime flags can be passed to AddressSanitizer via the `ASAN_OPTIONS` 
environment
+variable:
+
+```console
+$ ASAN_OPTIONS="verbosity=1:detect_stack_use_after_return=1" ./a.out
+```
+
+To see the full list of available flags, run an instrumented binary with
+`ASAN_OPTIONS="help=1"`.
+
+Flags passed via the `ASAN_OPTIONS` environment variable take precedence over
+compile-time default options.
+
+### Compile-time Default Options
+
+Default options can be specified at compile/link time by defining
+the `__asan_default_options` function in your source code:
+
+```c++
+#include <sanitizer/asan_interface.h>
+
+extern "C" const char *__asan_default_options() {
+  return "verbosity=1:detect_stack_use_after_return=1";
+}
+```
+
+### Options Evaluation with Integrated Sanitizers
+
+When running AddressSanitizer with integrated {doc}`LeakSanitizer` or 
{doc}`UndefinedBehaviorSanitizer`:
+
+- `__asan_default_options()`, `__lsan_default_options()`, and 
`__ubsan_default_options()` are all evaluated independently by the runtime.
+- The environment variables `ASAN_OPTIONS`, `LSAN_OPTIONS`, and 
`UBSAN_OPTIONS` are also parsed independently.
+
+LSan and UBSan flags should be passed via their own environment variables 
(`LSAN_OPTIONS`, `UBSAN_OPTIONS`) or default option hooks 
(`__lsan_default_options()`, `__ubsan_default_options()`) rather than packed 
into `ASAN_OPTIONS`.
----------------
thurstond wrote:

Nit: for completeness, mention `__asan_default_options()`.

https://github.com/llvm/llvm-project/pull/218793
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to