sanitizer_interface_internal.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 void
  45. __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, const void *end,
  57. const void *old_mid,
  58. const void *new_mid);
  59. SANITIZER_INTERFACE_ATTRIBUTE
  60. void __sanitizer_annotate_double_ended_contiguous_container(
  61. const void *storage_beg, const void *storage_end,
  62. const void *old_container_beg, const void *old_container_end,
  63. const void *new_container_beg, const void *new_container_end);
  64. SANITIZER_INTERFACE_ATTRIBUTE
  65. int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
  66. const void *end);
  67. SANITIZER_INTERFACE_ATTRIBUTE
  68. int __sanitizer_verify_double_ended_contiguous_container(
  69. const void *storage_beg, const void *container_beg,
  70. const void *container_end, const void *storage_end);
  71. SANITIZER_INTERFACE_ATTRIBUTE
  72. const void *__sanitizer_contiguous_container_find_bad_address(const void *beg,
  73. const void *mid,
  74. const void *end);
  75. SANITIZER_INTERFACE_ATTRIBUTE
  76. const void *__sanitizer_double_ended_contiguous_container_find_bad_address(
  77. const void *storage_beg, const void *container_beg,
  78. const void *container_end, const void *storage_end);
  79. SANITIZER_INTERFACE_ATTRIBUTE
  80. int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_path,
  81. __sanitizer::uptr module_path_len,
  82. void **pc_offset);
  83. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  84. __sanitizer_cov_trace_cmp();
  85. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  86. __sanitizer_cov_trace_cmp1();
  87. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  88. __sanitizer_cov_trace_cmp2();
  89. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  90. __sanitizer_cov_trace_cmp4();
  91. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  92. __sanitizer_cov_trace_cmp8();
  93. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  94. __sanitizer_cov_trace_const_cmp1();
  95. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  96. __sanitizer_cov_trace_const_cmp2();
  97. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  98. __sanitizer_cov_trace_const_cmp4();
  99. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  100. __sanitizer_cov_trace_const_cmp8();
  101. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  102. __sanitizer_cov_trace_switch();
  103. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  104. __sanitizer_cov_trace_div4();
  105. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  106. __sanitizer_cov_trace_div8();
  107. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  108. __sanitizer_cov_trace_gep();
  109. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  110. __sanitizer_cov_trace_pc_indir();
  111. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  112. __sanitizer_cov_load1();
  113. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  114. __sanitizer_cov_load2();
  115. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  116. __sanitizer_cov_load4();
  117. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  118. __sanitizer_cov_load8();
  119. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  120. __sanitizer_cov_load16();
  121. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  122. __sanitizer_cov_store1();
  123. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  124. __sanitizer_cov_store2();
  125. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  126. __sanitizer_cov_store4();
  127. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  128. __sanitizer_cov_store8();
  129. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  130. __sanitizer_cov_store16();
  131. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  132. __sanitizer_cov_trace_pc_guard(__sanitizer::u32 *);
  133. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  134. __sanitizer_cov_trace_pc_guard_init(__sanitizer::u32 *, __sanitizer::u32 *);
  135. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  136. __sanitizer_cov_8bit_counters_init(char *, char *);
  137. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  138. __sanitizer_cov_bool_flag_init();
  139. SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
  140. __sanitizer_cov_pcs_init(const __sanitizer::uptr *, const __sanitizer::uptr *);
  141. } // extern "C"
  142. #endif // SANITIZER_INTERFACE_INTERNAL_H