[PATCH] D63179: [sanitizer-common] Reduce ANSI color sequences that have no effect.

Aaron Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 17:16:25 PDT 2019


aarongreen created this revision.
aarongreen added reviewers: mcgrathr, jakehehrlich.
aarongreen added a project: Sanitizers.
Herald added subscribers: llvm-commits, Sanitizers, mgorny, kubamracek.
Herald added a project: LLVM.

sanitizer_common's consumers use SanitizerCommonDecorator to color their output in various cases. In some cases they end up emitting several escape sequences in a row that don't end up having any effect, e.g. PrintShadowBytes will transition to bold+color, print a byte, transition to default, transition back to bold+color, etc. This extra transitions end up being passed to the RawWrite call in sanitizer_printf.cc. If the implementation of RawWrite has a fixed buffer size (e.g. as in sanitizer_fuchsia.cc), this can cause the buffer to be consumed unnecessary and even end up breaking the line in the middle of an escape sequence.

This change attempts to mitigate that problem by providing SanitizerCommonDecorator::Compact, which removes sequences that would simply be overwritten by subsequent sequences.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D63179

Files:
  compiler-rt/lib/sanitizer_common/CMakeLists.txt
  compiler-rt/lib/sanitizer_common/sanitizer_printf.cc
  compiler-rt/lib/sanitizer_common/sanitizer_report_decorator.cc
  compiler-rt/lib/sanitizer_common/sanitizer_report_decorator.h
  compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63179.204195.patch
Type: text/x-patch
Size: 10769 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190612/60b8be17/attachment.bin>


More information about the llvm-commits mailing list