1 //===-- ubsan_monitor.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 // Hooks which allow a monitor process to inspect UBSan's diagnostics.
11 //===----------------------------------------------------------------------===//
13 #ifndef UBSAN_MONITOR_H
14 #define UBSAN_MONITOR_H
16 #include "ubsan_diag.h"
17 #include "ubsan_value.h"
21 struct UndefinedBehaviorReport
{
22 const char *IssueKind
;
24 InternalScopedString Buffer
;
26 UndefinedBehaviorReport(const char *IssueKind
, Location
&Loc
,
27 InternalScopedString
&Msg
);
30 SANITIZER_INTERFACE_ATTRIBUTE
void
31 RegisterUndefinedBehaviorReport(UndefinedBehaviorReport
*UBR
);
33 /// Called after a report is prepared. This serves to alert monitor processes
34 /// that a UB report is available.
35 extern "C" SANITIZER_INTERFACE_ATTRIBUTE
void __ubsan_on_report(void);
37 /// Used by the monitor process to extract information from a UB report. The
38 /// data is only available until the next time __ubsan_on_report is called. The
39 /// caller is responsible for copying and preserving the data if needed.
40 extern "C" SANITIZER_INTERFACE_ATTRIBUTE
void
41 __ubsan_get_current_report_data(const char **OutIssueKind
,
42 const char **OutMessage
,
43 const char **OutFilename
, unsigned *OutLine
,
44 unsigned *OutCol
, char **OutMemoryAddr
);
46 } // end namespace __ubsan
48 #endif // UBSAN_MONITOR_H