1 //===-- options.h -----------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef GWP_ASAN_OPTIONS_H_
10 #define GWP_ASAN_OPTIONS_H_
17 // The function pointer type for printf(). Follows the standard format from the
18 // sanitizers library. If the supported allocator exposes printing via a
19 // different function signature, please provide a wrapper which has this
20 // printf() signature, and pass the wrapper instead.
21 typedef void (*Printf_t)(const char *Format, ...);
23 // The function pointer type for backtrace information. Required to be
24 // implemented by the supporting allocator. The callee should elide itself and
25 // all frames below itself from TraceBuffer, i.e. the caller's frame should be
26 // in TraceBuffer[0], and subsequent frames 1..n into TraceBuffer[1..n], where a
27 // maximum of `MaximumDepth - 1` frames are stored. TraceBuffer should be
28 // nullptr-terminated (i.e. if there are 5 frames; TraceBuffer[5] == nullptr).
29 // If the allocator cannot supply backtrace information, it should set
30 // TraceBuffer[0] == nullptr.
31 typedef void (*Backtrace_t)(uintptr_t *TraceBuffer, size_t Size);
32 typedef void (*PrintBacktrace_t)(uintptr_t *TraceBuffer, Printf_t Print);
35 Printf_t Printf = nullptr;
36 Backtrace_t Backtrace = nullptr;
37 PrintBacktrace_t PrintBacktrace = nullptr;
39 // Read the options from the included definitions file.
40 #define GWP_ASAN_OPTION(Type, Name, DefaultValue, Description) \
41 Type Name = DefaultValue;
42 #include "gwp_asan/options.inc"
43 #undef GWP_ASAN_OPTION
46 #define GWP_ASAN_OPTION(Type, Name, DefaultValue, Description) \
48 #include "gwp_asan/options.inc"
49 #undef GWP_ASAN_OPTION
53 PrintBacktrace = nullptr;
56 } // namespace options
57 } // namespace gwp_asan
59 #endif // GWP_ASAN_OPTIONS_H_