[PATCH] D69546: [SanitizerCommon] Print the current value of options when printing out help.

Dan Liew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 28 19:17:30 PDT 2019


delcypher created this revision.
delcypher added reviewers: kubamracek, yln, kcc, dvyukov, vitalybuka, cryptoad, eugenis, samsonov.
Herald added projects: Sanitizers, LLVM.
Herald added a subscriber: Sanitizers.

Previously it wasn't obvious what the default value of various sanitizer
options were. A very close approximation of the "default values" for the
options are the current value of the options at the time of printing the
help output.

In the case that no other options are provided then the current values
are the default values (apart from `help`).

  ASAN_OPTIONS=help=1 ./program

This patch causes the current option values to be printed when the
`help` output is enabled. The original intention for this patch was to append
`(Default: <value>)` to an option's help text. However because this
is technically wrong (and misleading) I've opted to append
`(Current Value: <value>)` instead.

When trying to implement a way of displaying the default value of the
options I tried another solution where the default value used in `*.inc` files
were used to create compile time strings that where used when printing
the help output. This solution was not satisfactory for several reasons:

- Stringifying the default values with the preprocessor did not work very

well in several cases.  Some options contain boolean operators which no
amount of macro expansion can get rid of.

- It was much more invasive than this patch. Every sanitizer had to be changed.
- The settings of `__<sanitizer>_default_options()` are ignored.

For those reasons I opted for the solution in this patch.

rdar://problem/42567204


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69546

Files:
  compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.h
  compiler-rt/test/sanitizer_common/TestCases/options-help-current-values.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69546.226832.patch
Type: text/x-patch
Size: 5761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191029/030b356f/attachment.bin>


More information about the llvm-commits mailing list