| 1 | //===-- sanitizer/ubsan_interface.h -----------------------------*- C++ -*-===// |
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file is a part of UBSanitizer (UBSan). |
| 10 | // |
| 11 | // Public interface header. |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | #ifndef SANITIZER_UBSAN_INTERFACE_H |
| 14 | #define SANITIZER_UBSAN_INTERFACE_H |
| 15 | |
| 16 | #include <sanitizer/common_interface_defs.h> |
| 17 | |
| 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #endif |
| 21 | /// User-provided default option settings. |
| 22 | /// |
| 23 | /// You can provide your own implementation of this function to return a string |
| 24 | /// containing UBSan runtime options (for example, |
| 25 | /// <c>verbosity=1:halt_on_error=0</c>). |
| 26 | /// |
| 27 | /// \returns Default options string. |
| 28 | const char *SANITIZER_CDECL __ubsan_default_options(void); |
| 29 | |
| 30 | /// Set up an interval timer and install a SIGPROF signal handler that crashes |
| 31 | /// the program if it is stuck in a trap loop generated by -fsanitize-trap-loop. |
| 32 | /// |
| 33 | /// This function is only intended to be called by single-threaded programs. |
| 34 | /// Because interval timers are delivered to an arbitrary thread in the process, |
| 35 | /// it is possible that a thread in a trap loop will never have the signal |
| 36 | /// delivered to it. For multi-threaded programs, it is recommended to call |
| 37 | /// OS-specific APIs such as timer_create(CLOCK_THREAD_CPUTIME_ID) on Linux to |
| 38 | /// install a timer on each thread. |
| 39 | /// |
| 40 | /// Programs with their own signal handlers can call __ubsan_is_trap_loop from |
| 41 | /// the signal handler to implement trap loop handling. |
| 42 | /// |
| 43 | /// This function is currently only supported on Linux/x86. |
| 44 | void __ubsan_install_trap_loop_detection(void); |
| 45 | |
| 46 | /// Returns whether uc (actually a pointer to ucontext_t) indicates that the |
| 47 | /// thread is stuck in a trap loop generated by -fsanitize-trap-loop. |
| 48 | /// |
| 49 | /// This function is currently only supported on Linux/x86. |
| 50 | int __ubsan_is_trap_loop(void *uc); |
| 51 | |
| 52 | #ifdef __cplusplus |
| 53 | } // extern "C" |
| 54 | #endif |
| 55 | |
| 56 | #endif // SANITIZER_UBSAN_INTERFACE_H |
| 57 | |