49 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// Hooks which allow a monitor process to inspect UBSan's diagnostics.10//11//===----------------------------------------------------------------------===//12 13#ifndef UBSAN_MONITOR_H14#define UBSAN_MONITOR_H15 16#include "ubsan_diag.h"17#include "ubsan_value.h"18 19namespace __ubsan {20 21struct UndefinedBehaviorReport {22 const char *IssueKind;23 Location &Loc;24 InternalScopedString Buffer;25 26 UndefinedBehaviorReport(const char *IssueKind, Location &Loc,27 InternalScopedString &Msg);28};29 30SANITIZER_INTERFACE_ATTRIBUTE void31RegisterUndefinedBehaviorReport(UndefinedBehaviorReport *UBR);32 33/// Called after a report is prepared. This serves to alert monitor processes34/// that a UB report is available.35extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __ubsan_on_report(void);36 37/// Used by the monitor process to extract information from a UB report. The38/// data is only available until the next time __ubsan_on_report is called. The39/// caller is responsible for copying and preserving the data if needed.40extern "C" SANITIZER_INTERFACE_ATTRIBUTE void41__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 __ubsan47 48#endif // UBSAN_MONITOR_H49