summaryrefslogtreecommitdiff
path: root/include/sanitizer/common_interface_defs.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2013-11-18 14:02:05 +0000
committerKostya Serebryany <kcc@google.com>2013-11-18 14:02:05 +0000
commit2991200255098ac0739952351b2eb2b487819eec (patch)
tree23b44b10ec3658b7058034192afb39e67abe4c65 /include/sanitizer/common_interface_defs.h
parent0fbf056b4dbe12f63cefe7488c76d08cb8b26788 (diff)
[asan] introduce __sanitizer_annotate_contiguous_container
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/sanitizer/common_interface_defs.h')
-rw-r--r--include/sanitizer/common_interface_defs.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/sanitizer/common_interface_defs.h b/include/sanitizer/common_interface_defs.h
index 70a5c0cd3..4cc2aeae2 100644
--- a/include/sanitizer/common_interface_defs.h
+++ b/include/sanitizer/common_interface_defs.h
@@ -50,6 +50,30 @@ extern "C" {
// Record and dump coverage info.
void __sanitizer_cov_dump();
+ // Annotate the current state of a contiguous container, such as
+ // std::vector, std::string or similar.
+ // A contiguous container is a container that keeps all of its elements
+ // in a contiguous region of memory. The container owns the region of memory
+ // [beg, end); the memory [beg, mid) is used to store the current elements
+ // and the memory [mid, end) is reserved for future elements;
+ // end <= mid <= end. For example, in "std::vector<> v"
+ // beg = &v[0];
+ // end = beg + v.capacity() * sizeof(v[0]);
+ // mid = beg + v.size() * sizeof(v[0]);
+ //
+ // This annotation tells the Sanitizer tool about the current state of the
+ // container so that the tool can report errors when memory from [mid, end)
+ // is accessed. Insert this annotation into methods like push_back/pop_back.
+ // Supply the old and the new values of mid (old_mid/new_mid).
+ // In the initial state mid == end and so should be the final
+ // state when the container is destroyed or when it reallocates the storage.
+ //
+ // Use with caution and don't use for anything other than vector-like classes.
+ //
+ // For AddressSanitizer, 'beg' should be 8-aligned.
+ void __sanitizer_annotate_contiguous_container(void *beg, void *end,
+ void *old_mid, void *new_mid);
+
#ifdef __cplusplus
} // extern "C"
#endif