xref: /netbsd-src/external/gpl3/gcc.old/dist/libsanitizer/ubsan/ubsan_monitor.h (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
1 //===-- ubsan_monitor.h -----------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Hooks which allow a monitor process to inspect UBSan's diagnostics.
9 //
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef UBSAN_MONITOR_H
13 #define UBSAN_MONITOR_H
14 
15 #include "ubsan_diag.h"
16 #include "ubsan_value.h"
17 
18 namespace __ubsan {
19 
20 struct UndefinedBehaviorReport {
21   const char *IssueKind;
22   Location &Loc;
23   InternalScopedString Buffer;
24 
25   UndefinedBehaviorReport(const char *IssueKind, Location &Loc,
26                           InternalScopedString &Msg);
27 };
28 
29 SANITIZER_INTERFACE_ATTRIBUTE void
30 RegisterUndefinedBehaviorReport(UndefinedBehaviorReport *UBR);
31 
32 /// Called after a report is prepared. This serves to alert monitor processes
33 /// that a UB report is available.
34 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __ubsan_on_report(void);
35 
36 /// Used by the monitor process to extract information from a UB report. The
37 /// data is only available until the next time __ubsan_on_report is called. The
38 /// caller is responsible for copying and preserving the data if needed.
39 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
40 __ubsan_get_current_report_data(const char **OutIssueKind,
41                                 const char **OutMessage,
42                                 const char **OutFilename, unsigned *OutLine,
43                                 unsigned *OutCol, char **OutMemoryAddr);
44 
45 } // end namespace __ubsan
46 
47 #endif // UBSAN_MONITOR_H
48