[compiler-rt] r182256 - [lsan] GetUserBegin() in LSan.
Sergey Matveev
earthdok at google.com
Mon May 20 06:08:23 PDT 2013
Author: smatveev
Date: Mon May 20 08:08:23 2013
New Revision: 182256
URL: http://llvm.org/viewvc/llvm-project?rev=182256&view=rev
Log:
[lsan] GetUserBegin() in LSan.
Separate the notions of user-visible chunk and allocator chunk, to facilitate
ASan integration.
Modified:
compiler-rt/trunk/lib/lsan/lsan_allocator.cc
compiler-rt/trunk/lib/lsan/lsan_common.cc
compiler-rt/trunk/lib/lsan/lsan_common.h
Modified: compiler-rt/trunk/lib/lsan/lsan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_allocator.cc?rev=182256&r1=182255&r2=182256&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_allocator.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_allocator.cc Mon May 20 08:08:23 2013
@@ -146,6 +146,10 @@ void *PointsIntoChunk(void* p) {
return 0;
}
+void *GetUserBegin(void *p) {
+ return p;
+}
+
LsanMetadata::LsanMetadata(void *chunk) {
metadata_ = Metadata(chunk);
CHECK(metadata_);
Modified: compiler-rt/trunk/lib/lsan/lsan_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.cc?rev=182256&r1=182255&r2=182256&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common.cc Mon May 20 08:08:23 2013
@@ -177,6 +177,7 @@ static void FloodFillReachable(InternalV
// 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 @@ static void ClassifyAllChunks(SuspendedT
}
void ClearTagCb::operator()(void *p) const {
+ p = GetUserBegin(p);
LsanMetadata m(p);
m.set_tag(kDirectlyLeaked);
}
@@ -228,6 +230,7 @@ static void LockAndSuspendThreads(StopTh
///// 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 @@ static void CollectLeaks(LeakReport *lea
}
void PrintLeakedCb::operator()(void *p) const {
+ p = GetUserBegin(p);
LsanMetadata m(p);
if (!m.allocated()) return;
if (m.tag() != kReachable) {
@@ -291,6 +295,7 @@ void DoLeakCheck() {
///// 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);
Modified: compiler-rt/trunk/lib/lsan/lsan_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.h?rev=182256&r1=182255&r2=182256&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common.h (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common.h Mon May 20 08:08:23 2013
@@ -170,11 +170,14 @@ bool GetThreadRangesLocked(uptr os_id, u
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;
More information about the llvm-commits
mailing list