1336817Sdim//===-- ubsan_monitor.h -----------------------------------------*- C++ -*-===//
2336817Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6336817Sdim//
7336817Sdim//===----------------------------------------------------------------------===//
8336817Sdim//
9336817Sdim// Hooks which allow a monitor process to inspect UBSan's diagnostics.
10336817Sdim//
11336817Sdim//===----------------------------------------------------------------------===//
12336817Sdim
13336817Sdim#ifndef UBSAN_MONITOR_H
14336817Sdim#define UBSAN_MONITOR_H
15336817Sdim
16336817Sdim#include "ubsan_diag.h"
17336817Sdim#include "ubsan_value.h"
18336817Sdim
19336817Sdimnamespace __ubsan {
20336817Sdim
21336817Sdimstruct UndefinedBehaviorReport {
22336817Sdim  const char *IssueKind;
23336817Sdim  Location &Loc;
24336817Sdim  InternalScopedString Buffer;
25336817Sdim
26336817Sdim  UndefinedBehaviorReport(const char *IssueKind, Location &Loc,
27336817Sdim                          InternalScopedString &Msg);
28336817Sdim};
29336817Sdim
30336817SdimSANITIZER_INTERFACE_ATTRIBUTE void
31336817SdimRegisterUndefinedBehaviorReport(UndefinedBehaviorReport *UBR);
32336817Sdim
33336817Sdim/// Called after a report is prepared. This serves to alert monitor processes
34336817Sdim/// that a UB report is available.
35336817Sdimextern "C" SANITIZER_INTERFACE_ATTRIBUTE void __ubsan_on_report(void);
36336817Sdim
37336817Sdim/// Used by the monitor process to extract information from a UB report. The
38336817Sdim/// data is only available until the next time __ubsan_on_report is called. The
39336817Sdim/// caller is responsible for copying and preserving the data if needed.
40336817Sdimextern "C" SANITIZER_INTERFACE_ATTRIBUTE void
41336817Sdim__ubsan_get_current_report_data(const char **OutIssueKind,
42336817Sdim                                const char **OutMessage,
43336817Sdim                                const char **OutFilename, unsigned *OutLine,
44336817Sdim                                unsigned *OutCol, char **OutMemoryAddr);
45336817Sdim
46336817Sdim} // end namespace __ubsan
47336817Sdim
48336817Sdim#endif // UBSAN_MONITOR_H
49