1*0b57cec5SDimitry Andric //===-- ubsan_monitor.h -----------------------------------------*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric // 9*0b57cec5SDimitry Andric // Hooks which allow a monitor process to inspect UBSan's diagnostics. 10*0b57cec5SDimitry Andric // 11*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 12*0b57cec5SDimitry Andric 13*0b57cec5SDimitry Andric #ifndef UBSAN_MONITOR_H 14*0b57cec5SDimitry Andric #define UBSAN_MONITOR_H 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric #include "ubsan_diag.h" 17*0b57cec5SDimitry Andric #include "ubsan_value.h" 18*0b57cec5SDimitry Andric 19*0b57cec5SDimitry Andric namespace __ubsan { 20*0b57cec5SDimitry Andric 21*0b57cec5SDimitry Andric struct UndefinedBehaviorReport { 22*0b57cec5SDimitry Andric const char *IssueKind; 23*0b57cec5SDimitry Andric Location &Loc; 24*0b57cec5SDimitry Andric InternalScopedString Buffer; 25*0b57cec5SDimitry Andric 26*0b57cec5SDimitry Andric UndefinedBehaviorReport(const char *IssueKind, Location &Loc, 27*0b57cec5SDimitry Andric InternalScopedString &Msg); 28*0b57cec5SDimitry Andric }; 29*0b57cec5SDimitry Andric 30*0b57cec5SDimitry Andric SANITIZER_INTERFACE_ATTRIBUTE void 31*0b57cec5SDimitry Andric RegisterUndefinedBehaviorReport(UndefinedBehaviorReport *UBR); 32*0b57cec5SDimitry Andric 33*0b57cec5SDimitry Andric /// Called after a report is prepared. This serves to alert monitor processes 34*0b57cec5SDimitry Andric /// that a UB report is available. 35*0b57cec5SDimitry Andric extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __ubsan_on_report(void); 36*0b57cec5SDimitry Andric 37*0b57cec5SDimitry Andric /// Used by the monitor process to extract information from a UB report. The 38*0b57cec5SDimitry Andric /// data is only available until the next time __ubsan_on_report is called. The 39*0b57cec5SDimitry Andric /// caller is responsible for copying and preserving the data if needed. 40*0b57cec5SDimitry Andric extern "C" SANITIZER_INTERFACE_ATTRIBUTE void 41*0b57cec5SDimitry Andric __ubsan_get_current_report_data(const char **OutIssueKind, 42*0b57cec5SDimitry Andric const char **OutMessage, 43*0b57cec5SDimitry Andric const char **OutFilename, unsigned *OutLine, 44*0b57cec5SDimitry Andric unsigned *OutCol, char **OutMemoryAddr); 45*0b57cec5SDimitry Andric 46*0b57cec5SDimitry Andric } // end namespace __ubsan 47*0b57cec5SDimitry Andric 48*0b57cec5SDimitry Andric #endif // UBSAN_MONITOR_H 49