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