xref: /freebsd/contrib/llvm-project/compiler-rt/lib/ubsan/ubsan_monitor.h (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1 //===-- ubsan_monitor.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 // Hooks which allow a monitor process to inspect UBSan's diagnostics.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef UBSAN_MONITOR_H
14 #define UBSAN_MONITOR_H
15 
16 #include "ubsan_diag.h"
17 #include "ubsan_value.h"
18 
19 namespace __ubsan {
20 
21 struct UndefinedBehaviorReport {
22   const char *IssueKind;
23   Location &Loc;
24   InternalScopedString Buffer;
25 
26   UndefinedBehaviorReport(const char *IssueKind, Location &Loc,
27                           InternalScopedString &Msg);
28 };
29 
30 SANITIZER_INTERFACE_ATTRIBUTE void
31 RegisterUndefinedBehaviorReport(UndefinedBehaviorReport *UBR);
32 
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);
36 
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);
45 
46 } // end namespace __ubsan
47 
48 #endif // UBSAN_MONITOR_H
49