| OLD | NEW |
| (Empty) | |
| 1 //===-- sanitizer/common_interface_defs.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 // Common part of the public sanitizer interface. |
| 11 //===----------------------------------------------------------------------===// |
| 12 |
| 13 #ifndef SANITIZER_COMMON_INTERFACE_DEFS_H |
| 14 #define SANITIZER_COMMON_INTERFACE_DEFS_H |
| 15 |
| 16 #include <stddef.h> |
| 17 #include <stdint.h> |
| 18 |
| 19 // GCC does not understand __has_feature. |
| 20 #if !defined(__has_feature) |
| 21 # define __has_feature(x) 0 |
| 22 #endif |
| 23 |
| 24 #ifdef __cplusplus |
| 25 extern "C" { |
| 26 #endif |
| 27 // Tell the tools to write their reports to "path.<pid>" instead of stderr. |
| 28 void __sanitizer_set_report_path(const char *path); |
| 29 |
| 30 // Notify the tools that the sandbox is going to be turned on. The reserved |
| 31 // parameter will be used in the future to hold a structure with functions |
| 32 // that the tools may call to bypass the sandbox. |
| 33 void __sanitizer_sandbox_on_notify(void *reserved); |
| 34 |
| 35 // This function is called by the tool when it has just finished reporting |
| 36 // an error. 'error_summary' is a one-line string that summarizes |
| 37 // the error message. This function can be overridden by the client. |
| 38 void __sanitizer_report_error_summary(const char *error_summary); |
| 39 |
| 40 // Some of the sanitizers (e.g. asan/tsan) may miss bugs that happen |
| 41 // in unaligned loads/stores. In order to find such bugs reliably one needs |
| 42 // to replace plain unaligned loads/stores with these calls. |
| 43 uint16_t __sanitizer_unaligned_load16(const void *p); |
| 44 uint32_t __sanitizer_unaligned_load32(const void *p); |
| 45 uint64_t __sanitizer_unaligned_load64(const void *p); |
| 46 void __sanitizer_unaligned_store16(void *p, uint16_t x); |
| 47 void __sanitizer_unaligned_store32(void *p, uint32_t x); |
| 48 void __sanitizer_unaligned_store64(void *p, uint64_t x); |
| 49 |
| 50 // Record and dump coverage info. |
| 51 void __sanitizer_cov_dump(); |
| 52 |
| 53 // Annotate the current state of a contiguous container, such as |
| 54 // std::vector, std::string or similar. |
| 55 // A contiguous container is a container that keeps all of its elements |
| 56 // in a contiguous region of memory. The container owns the region of memory |
| 57 // [beg, end); the memory [beg, mid) is used to store the current elements |
| 58 // and the memory [mid, end) is reserved for future elements; |
| 59 // beg <= mid <= end. For example, in "std::vector<> v" |
| 60 // beg = &v[0]; |
| 61 // end = beg + v.capacity() * sizeof(v[0]); |
| 62 // mid = beg + v.size() * sizeof(v[0]); |
| 63 // |
| 64 // This annotation tells the Sanitizer tool about the current state of the |
| 65 // container so that the tool can report errors when memory from [mid, end) |
| 66 // is accessed. Insert this annotation into methods like push_back/pop_back. |
| 67 // Supply the old and the new values of mid (old_mid/new_mid). |
| 68 // In the initial state mid == end and so should be the final |
| 69 // state when the container is destroyed or when it reallocates the storage. |
| 70 // |
| 71 // Use with caution and don't use for anything other than vector-like classes. |
| 72 // |
| 73 // For AddressSanitizer, 'beg' should be 8-aligned and 'end' should |
| 74 // be either 8-aligned or it should point to the end of a separate heap-, |
| 75 // stack-, or global- allocated buffer. I.e. the following will not work: |
| 76 // int64_t x[2]; // 16 bytes, 8-aligned. |
| 77 // char *beg = (char *)&x[0]; |
| 78 // char *end = beg + 12; // Not 8 aligned, not the end of the buffer. |
| 79 // This however will work fine: |
| 80 // int32_t x[3]; // 12 bytes, but 8-aligned under AddressSanitizer. |
| 81 // char *beg = (char*)&x[0]; |
| 82 // char *end = beg + 12; // Not 8-aligned, but is the end of the buffer. |
| 83 void __sanitizer_annotate_contiguous_container(const void *beg, |
| 84 const void *end, |
| 85 const void *old_mid, |
| 86 const void *new_mid); |
| 87 |
| 88 // Print the stack trace leading to this call. Useful for debugging user code. |
| 89 void __sanitizer_print_stack_trace(); |
| 90 |
| 91 #ifdef __cplusplus |
| 92 } // extern "C" |
| 93 #endif |
| 94 |
| 95 #endif // SANITIZER_COMMON_INTERFACE_DEFS_H |
| OLD | NEW |