[PATCH] [lsan] GetUserBegin() in LSan.
Sergey Matveev
earthdok at google.com
Mon May 20 04:40:31 PDT 2013
Hi kcc, glider,
Separate the notions of user-visible chunk and allocator chunk, to facilitate
ASan integration.
http://llvm-reviews.chandlerc.com/D826
Files:
lib/lsan/lsan_allocator.cc
lib/lsan/lsan_common.cc
lib/lsan/lsan_common.h
Index: lib/lsan/lsan_allocator.cc
===================================================================
--- lib/lsan/lsan_allocator.cc
+++ lib/lsan/lsan_allocator.cc
@@ -146,6 +146,10 @@
return 0;
}
+void *GetUserBegin(void *p) {
+ return p;
+}
+
LsanMetadata::LsanMetadata(void *chunk) {
metadata_ = Metadata(chunk);
CHECK(metadata_);
Index: lib/lsan/lsan_common.cc
===================================================================
--- lib/lsan/lsan_common.cc
+++ lib/lsan/lsan_common.cc
@@ -177,6 +177,7 @@
// Mark leaked chunks which are reachable from other leaked chunks.
void MarkIndirectlyLeakedCb::operator()(void *p) const {
+ p = GetUserBegin(p);
LsanMetadata m(p);
if (m.allocated() && m.tag() != kReachable) {
ScanRangeForPointers(reinterpret_cast<uptr>(p),
@@ -205,6 +206,7 @@
}
void ClearTagCb::operator()(void *p) const {
+ p = GetUserBegin(p);
LsanMetadata m(p);
m.set_tag(kDirectlyLeaked);
}
@@ -228,6 +230,7 @@
///// Normal leak checking. /////
void CollectLeaksCb::operator()(void *p) const {
+ p = GetUserBegin(p);
LsanMetadata m(p);
if (!m.allocated()) return;
if (m.tag() != kReachable) {
@@ -249,6 +252,7 @@
}
void PrintLeakedCb::operator()(void *p) const {
+ p = GetUserBegin(p);
LsanMetadata m(p);
if (!m.allocated()) return;
if (m.tag() != kReachable) {
@@ -291,6 +295,7 @@
///// Reporting of leaked blocks' addresses (for testing). /////
void ReportLeakedCb::operator()(void *p) const {
+ p = GetUserBegin(p);
LsanMetadata m(p);
if (m.allocated() && m.tag() != kReachable)
leaked_->push_back(p);
Index: lib/lsan/lsan_common.h
===================================================================
--- lib/lsan/lsan_common.h
+++ lib/lsan/lsan_common.h
@@ -170,11 +170,14 @@
uptr *tls_begin, uptr *tls_end,
uptr *cache_begin, uptr *cache_end);
// If p points into a chunk that has been allocated to the user, return its
-// address. Otherwise, return 0.
+// user-visible address. Otherwise, return 0.
void *PointsIntoChunk(void *p);
+// Return address of user-visible chunk contained in this allocator chunk.
+void *GetUserBegin(void *p);
// Wrapper for chunk metadata operations.
class LsanMetadata {
public:
+ // Constructor accepts pointer to user-visible chunk.
explicit LsanMetadata(void *chunk);
bool allocated() const;
ChunkTag tag() const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D826.1.patch
Type: text/x-patch
Size: 2428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130520/3417e45e/attachment.bin>
More information about the llvm-commits
mailing list