10b57cec5SDimitry Andric//===-- options.inc ---------------------------------------------*- C++ -*-===// 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric#ifndef GWP_ASAN_OPTION 100b57cec5SDimitry Andric#error "Define GWP_ASAN_OPTION prior to including this file!" 110b57cec5SDimitry Andric#endif 120b57cec5SDimitry Andric 130b57cec5SDimitry AndricGWP_ASAN_OPTION(bool, Enabled, true, "Is GWP-ASan enabled? Defaults to true.") 140b57cec5SDimitry Andric 150b57cec5SDimitry AndricGWP_ASAN_OPTION( 160b57cec5SDimitry Andric bool, PerfectlyRightAlign, false, 170b57cec5SDimitry Andric "When allocations are right-aligned, should we perfectly align them up to " 180b57cec5SDimitry Andric "the page boundary? By default (false), we round up allocation size to the " 190b57cec5SDimitry Andric "nearest power of two (1, 2, 4, 8, 16) up to a maximum of 16-byte " 20*5ffd83dbSDimitry Andric "alignment for performance reasons. For Bionic, we use 8-byte alignment by " 21*5ffd83dbSDimitry Andric "default. Setting this to true can find single byte buffer-overflows for " 22*5ffd83dbSDimitry Andric "multibyte allocations at the cost of performance, and may be incompatible " 23*5ffd83dbSDimitry Andric "with some architectures.") 240b57cec5SDimitry Andric 2568d75effSDimitry AndricGWP_ASAN_OPTION(int, MaxSimultaneousAllocations, 16, 2668d75effSDimitry Andric "Number of simultaneously-guarded allocations available in the " 2768d75effSDimitry Andric "pool. Defaults to 16.") 280b57cec5SDimitry Andric 290b57cec5SDimitry AndricGWP_ASAN_OPTION(int, SampleRate, 5000, 300b57cec5SDimitry Andric "The probability (1 / SampleRate) that an allocation is " 310b57cec5SDimitry Andric "selected for GWP-ASan sampling. Default is 5000. Sample rates " 320b57cec5SDimitry Andric "up to (2^31 - 1) are supported.") 330b57cec5SDimitry Andric 34*5ffd83dbSDimitry Andric// Developer note - This option is not actually processed by GWP-ASan itself. It 35*5ffd83dbSDimitry Andric// is included here so that a user can specify whether they want signal handlers 36*5ffd83dbSDimitry Andric// or not. The supporting allocator should inspect this value to see whether 37*5ffd83dbSDimitry Andric// signal handlers need to be installed, and then use 38*5ffd83dbSDimitry Andric// crash_handler::installSignalHandlers() in order to install the handlers. Note 39*5ffd83dbSDimitry Andric// that in order to support signal handlers, you will need to link against the 40*5ffd83dbSDimitry Andric// optional crash_handler component. 410b57cec5SDimitry AndricGWP_ASAN_OPTION( 420b57cec5SDimitry Andric bool, InstallSignalHandlers, true, 430b57cec5SDimitry Andric "Install GWP-ASan signal handlers for SIGSEGV during dynamic loading. This " 440b57cec5SDimitry Andric "allows better error reports by providing stack traces for allocation and " 450b57cec5SDimitry Andric "deallocation when reporting a memory error. GWP-ASan's signal handler " 460b57cec5SDimitry Andric "will forward the signal to any previously-installed handler, and user " 470b57cec5SDimitry Andric "programs that install further signal handlers should make sure they do " 480b57cec5SDimitry Andric "the same. Note, if the previously installed SIGSEGV handler is SIG_IGN, " 490b57cec5SDimitry Andric "we terminate the process after dumping the error report.") 50*5ffd83dbSDimitry Andric 51*5ffd83dbSDimitry AndricGWP_ASAN_OPTION(bool, InstallForkHandlers, true, 52*5ffd83dbSDimitry Andric "Install GWP-ASan atfork handlers to acquire internal locks " 53*5ffd83dbSDimitry Andric "before fork and release them after.") 54