xref: /freebsd/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h (revision 6be3386466ab79a84b48429ae66244f21526d3df)
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 
20 #include "sanitizer_internal_defs.h"
21 
22 extern "C" {
23   // Tell the tools to write their reports to "path.<pid>" instead of stderr.
24   // The special values are "stdout" and "stderr".
25   SANITIZER_INTERFACE_ATTRIBUTE
26   void __sanitizer_set_report_path(const char *path);
27   // Tell the tools to write their reports to the provided file descriptor
28   // (casted to void *).
29   SANITIZER_INTERFACE_ATTRIBUTE
30   void __sanitizer_set_report_fd(void *fd);
31 
32   typedef struct {
33       int coverage_sandboxed;
34       __sanitizer::sptr coverage_fd;
35       unsigned int coverage_max_block_size;
36   } __sanitizer_sandbox_arguments;
37 
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 
42   // This function is called by the tool when it has just finished reporting
43   // an error. 'error_summary' is a one-line string that summarizes
44   // the error message. This function can be overridden by the client.
45   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
46   void __sanitizer_report_error_summary(const char *error_summary);
47 
48   SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_dump();
49   SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage(
50       const __sanitizer::uptr *pcs, const __sanitizer::uptr len);
51   SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_trace_pc_guard_coverage();
52 
53   SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov(__sanitizer::u32 *guard);
54 
55   // Returns 1 on the first call, then returns 0 thereafter.  Called by the tool
56   // to ensure only one report is printed when multiple errors occur
57   // simultaneously.
58   SANITIZER_INTERFACE_ATTRIBUTE int __sanitizer_acquire_crash_state();
59 
60   SANITIZER_INTERFACE_ATTRIBUTE
61   void __sanitizer_annotate_contiguous_container(const void *beg,
62                                                  const void *end,
63                                                  const void *old_mid,
64                                                  const void *new_mid);
65   SANITIZER_INTERFACE_ATTRIBUTE
66   int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
67                                               const void *end);
68   SANITIZER_INTERFACE_ATTRIBUTE
69   const void *__sanitizer_contiguous_container_find_bad_address(
70       const void *beg, const void *mid, const void *end);
71 
72   SANITIZER_INTERFACE_ATTRIBUTE
73   int __sanitizer_get_module_and_offset_for_pc(
74       __sanitizer::uptr pc, char *module_path,
75       __sanitizer::uptr module_path_len, __sanitizer::uptr *pc_offset);
76 
77   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
78   void __sanitizer_cov_trace_cmp();
79   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
80   void __sanitizer_cov_trace_cmp1();
81   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
82   void __sanitizer_cov_trace_cmp2();
83   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
84   void __sanitizer_cov_trace_cmp4();
85   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
86   void __sanitizer_cov_trace_cmp8();
87   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
88   void __sanitizer_cov_trace_const_cmp1();
89   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
90   void __sanitizer_cov_trace_const_cmp2();
91   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
92   void __sanitizer_cov_trace_const_cmp4();
93   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
94   void __sanitizer_cov_trace_const_cmp8();
95   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
96   void __sanitizer_cov_trace_switch();
97   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
98   void __sanitizer_cov_trace_div4();
99   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
100   void __sanitizer_cov_trace_div8();
101   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
102   void __sanitizer_cov_trace_gep();
103   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
104   void __sanitizer_cov_trace_pc_indir();
105   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
106   void __sanitizer_cov_trace_pc_guard(__sanitizer::u32*);
107   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
108   void __sanitizer_cov_trace_pc_guard_init(__sanitizer::u32*,
109                                            __sanitizer::u32*);
110   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
111   void __sanitizer_cov_8bit_counters_init();
112   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
113   __sanitizer_cov_bool_flag_init();
114   SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
115   __sanitizer_cov_pcs_init();
116 } // extern "C"
117 
118 #endif  // SANITIZER_INTERFACE_INTERNAL_H
119