Path: blob/main/contrib/llvm-project/compiler-rt/lib/gwp_asan/options.h
35236 views
//===-- options.h -----------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef GWP_ASAN_OPTIONS_H_9#define GWP_ASAN_OPTIONS_H_1011#include <stddef.h>12#include <stdint.h>1314namespace gwp_asan {15namespace options {16// ================================ Requirements ===============================17// This function is required to be either implemented by the supporting18// allocator, or one of the two provided implementations may be used19// (RTGwpAsanBacktraceLibc or RTGwpAsanBacktraceSanitizerCommon).20// ================================ Description ================================21// This function shall collect the backtrace for the calling thread and place22// the result in `TraceBuffer`. This function should elide itself and all frames23// below itself from `TraceBuffer`, i.e. the caller's frame should be in24// TraceBuffer[0], and subsequent frames 1..n into TraceBuffer[1..n], where a25// maximum of `Size` frames are stored. Returns the number of frames stored into26// `TraceBuffer`, and zero on failure. If the return value of this function is27// equal to `Size`, it may indicate that the backtrace is truncated.28// =================================== Notes ===================================29// This function may directly or indirectly call malloc(), as the30// GuardedPoolAllocator contains a reentrancy barrier to prevent infinite31// recursion. Any allocation made inside this function will be served by the32// supporting allocator, and will not have GWP-ASan protections.33typedef size_t (*Backtrace_t)(uintptr_t *TraceBuffer, size_t Size);3435struct Options {36Backtrace_t Backtrace = nullptr;3738// Read the options from the included definitions file.39#define GWP_ASAN_OPTION(Type, Name, DefaultValue, Description) \40Type Name = DefaultValue;41#include "gwp_asan/options.inc"42#undef GWP_ASAN_OPTION4344void setDefaults() {45#define GWP_ASAN_OPTION(Type, Name, DefaultValue, Description) \46Name = DefaultValue;47#include "gwp_asan/options.inc"48#undef GWP_ASAN_OPTION4950Backtrace = nullptr;51}52};53} // namespace options54} // namespace gwp_asan5556#endif // GWP_ASAN_OPTIONS_H_575859