ubsan_monitor.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef UBSAN_MONITOR_H
  13. #define UBSAN_MONITOR_H
  14. #include "ubsan_diag.h"
  15. #include "ubsan_value.h"
  16. namespace __ubsan {
  17. struct UndefinedBehaviorReport {
  18. const char *IssueKind;
  19. Location &Loc;
  20. InternalScopedString Buffer;
  21. UndefinedBehaviorReport(const char *IssueKind, Location &Loc,
  22. InternalScopedString &Msg);
  23. };
  24. SANITIZER_INTERFACE_ATTRIBUTE void
  25. RegisterUndefinedBehaviorReport(UndefinedBehaviorReport *UBR);
  26. /// Called after a report is prepared. This serves to alert monitor processes
  27. /// that a UB report is available.
  28. extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __ubsan_on_report(void);
  29. /// Used by the monitor process to extract information from a UB report. The
  30. /// data is only available until the next time __ubsan_on_report is called. The
  31. /// caller is responsible for copying and preserving the data if needed.
  32. extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
  33. __ubsan_get_current_report_data(const char **OutIssueKind,
  34. const char **OutMessage,
  35. const char **OutFilename, unsigned *OutLine,
  36. unsigned *OutCol, char **OutMemoryAddr);
  37. } // end namespace __ubsan
  38. #endif // UBSAN_MONITOR_H