sanitizer_interface_internal.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //===-- sanitizer_interface_internal.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. // This file is shared between run-time libraries of sanitizers.
  10. //
  11. // This header declares the sanitizer runtime interface functions.
  12. // The runtime library has to define these functions so the instrumented program
  13. // could call them.
  14. //
  15. // See also include/sanitizer/common_interface_defs.h
  16. //===----------------------------------------------------------------------===//
  17. #ifndef SANITIZER_INTERFACE_INTERNAL_H
  18. #define SANITIZER_INTERFACE_INTERNAL_H
  19. #include "sanitizer_internal_defs.h"
  20. extern "C" {
  21. // Tell the tools to write their reports to "path.<pid>" instead of stderr.
  22. // The special values are "stdout" and "stderr".
  23. SANITIZER_INTERFACE_ATTRIBUTE
  24. void __sanitizer_set_report_path(const char *path);
  25. // Tell the tools to write their reports to the provided file descriptor
  26. // (casted to void *).
  27. SANITIZER_INTERFACE_ATTRIBUTE
  28. void __sanitizer_set_report_fd(void *fd);
  29. // Get the current full report file path, if a path was specified by
  30. // an earlier call to __sanitizer_set_report_path. Returns null otherwise.
  31. SANITIZER_INTERFACE_ATTRIBUTE
  32. const char *__sanitizer_get_report_path();
  33. typedef struct {
  34. int coverage_sandboxed;
  35. __sanitizer::sptr coverage_fd;
  36. unsigned int coverage_max_block_size;
  37. } __sanitizer_sandbox_arguments;
  38. // Notify the tools that the sandbox is going to be turned on.
  39. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  40. __sanitizer_sandbox_on_notify(__sanitizer_sandbox_arguments *args);
  41. // This function is called by the tool when it has just finished reporting
  42. // an error. 'error_summary' is a one-line string that summarizes
  43. // the error message. This function can be overridden by the client.
  44. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  45. void __sanitizer_report_error_summary(const char *error_summary);
  46. SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_dump();
  47. SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage(
  48. const __sanitizer::uptr *pcs, const __sanitizer::uptr len);
  49. SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_trace_pc_guard_coverage();
  50. SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov(__sanitizer::u32 *guard);
  51. // Returns 1 on the first call, then returns 0 thereafter. Called by the tool
  52. // to ensure only one report is printed when multiple errors occur
  53. // simultaneously.
  54. SANITIZER_INTERFACE_ATTRIBUTE int __sanitizer_acquire_crash_state();
  55. SANITIZER_INTERFACE_ATTRIBUTE
  56. void __sanitizer_annotate_contiguous_container(const void *beg,
  57. const void *end,
  58. const void *old_mid,
  59. const void *new_mid);
  60. SANITIZER_INTERFACE_ATTRIBUTE
  61. int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
  62. const void *end);
  63. SANITIZER_INTERFACE_ATTRIBUTE
  64. const void *__sanitizer_contiguous_container_find_bad_address(
  65. const void *beg, const void *mid, const void *end);
  66. SANITIZER_INTERFACE_ATTRIBUTE
  67. int __sanitizer_get_module_and_offset_for_pc(
  68. __sanitizer::uptr pc, char *module_path,
  69. __sanitizer::uptr module_path_len, __sanitizer::uptr *pc_offset);
  70. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  71. void __sanitizer_cov_trace_cmp();
  72. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  73. void __sanitizer_cov_trace_cmp1();
  74. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  75. void __sanitizer_cov_trace_cmp2();
  76. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  77. void __sanitizer_cov_trace_cmp4();
  78. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  79. void __sanitizer_cov_trace_cmp8();
  80. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  81. void __sanitizer_cov_trace_const_cmp1();
  82. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  83. void __sanitizer_cov_trace_const_cmp2();
  84. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  85. void __sanitizer_cov_trace_const_cmp4();
  86. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  87. void __sanitizer_cov_trace_const_cmp8();
  88. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  89. void __sanitizer_cov_trace_switch();
  90. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  91. void __sanitizer_cov_trace_div4();
  92. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  93. void __sanitizer_cov_trace_div8();
  94. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  95. void __sanitizer_cov_trace_gep();
  96. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  97. void __sanitizer_cov_trace_pc_indir();
  98. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  99. void __sanitizer_cov_trace_pc_guard(__sanitizer::u32*);
  100. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
  101. void __sanitizer_cov_trace_pc_guard_init(__sanitizer::u32*,
  102. __sanitizer::u32*);
  103. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  104. __sanitizer_cov_8bit_counters_init(char *, char *);
  105. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  106. __sanitizer_cov_bool_flag_init();
  107. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  108. __sanitizer_cov_pcs_init(const __sanitizer::uptr *,
  109. const __sanitizer::uptr *);
  110. } // extern "C"
  111. #endif // SANITIZER_INTERFACE_INTERNAL_H