Skip to content

Commit 27650a5

Browse files
committed
[NFC][Asan] Remove Debug code
Used for google/sanitizers#1193 Reviewed By: morehouse Differential Revision: https://reviews.llvm.org/D86933
1 parent c05095c commit 27650a5

5 files changed

+0
-76
lines changed

compiler-rt/lib/asan/asan_allocator.cpp

-38
Original file line numberDiff line numberDiff line change
@@ -750,26 +750,6 @@ struct Allocator {
750750
return reinterpret_cast<AsanChunk *>(alloc_beg);
751751
}
752752

753-
AsanChunk *GetAsanChunkDebug(void *alloc_beg) {
754-
if (!alloc_beg)
755-
return nullptr;
756-
if (!allocator.FromPrimary(alloc_beg)) {
757-
uptr *meta = reinterpret_cast<uptr *>(allocator.GetMetaData(alloc_beg));
758-
AsanChunk *m = reinterpret_cast<AsanChunk *>(meta[1]);
759-
Printf("GetAsanChunkDebug1 alloc_beg %p meta %p m %p\n", alloc_beg, meta,
760-
m);
761-
return m;
762-
}
763-
uptr *alloc_magic = reinterpret_cast<uptr *>(alloc_beg);
764-
Printf(
765-
"GetAsanChunkDebug2 alloc_beg %p alloc_magic %p alloc_magic[0] %p "
766-
"alloc_magic[1] %p\n",
767-
alloc_beg, alloc_magic, alloc_magic[0], alloc_magic[1]);
768-
if (alloc_magic[0] == kAllocBegMagic)
769-
return reinterpret_cast<AsanChunk *>(alloc_magic[1]);
770-
return reinterpret_cast<AsanChunk *>(alloc_beg);
771-
}
772-
773753
AsanChunk *GetAsanChunkByAddr(uptr p) {
774754
void *alloc_beg = allocator.GetBlockBegin(reinterpret_cast<void *>(p));
775755
return GetAsanChunk(alloc_beg);
@@ -782,14 +762,6 @@ struct Allocator {
782762
return GetAsanChunk(alloc_beg);
783763
}
784764

785-
AsanChunk *GetAsanChunkByAddrFastLockedDebug(uptr p) {
786-
void *alloc_beg =
787-
allocator.GetBlockBeginFastLockedDebug(reinterpret_cast<void *>(p));
788-
Printf("GetAsanChunkByAddrFastLockedDebug p %p alloc_beg %p\n", p,
789-
alloc_beg);
790-
return GetAsanChunkDebug(alloc_beg);
791-
}
792-
793765
uptr AllocationSize(uptr p) {
794766
AsanChunk *m = GetAsanChunkByAddr(p);
795767
if (!m) return 0;
@@ -1093,16 +1065,6 @@ uptr PointsIntoChunk(void* p) {
10931065
return 0;
10941066
}
10951067

1096-
// Debug code. Delete once issue #1193 is chased down.
1097-
extern "C" SANITIZER_WEAK_ATTRIBUTE const char *__lsan_current_stage;
1098-
1099-
void GetUserBeginDebug(uptr chunk) {
1100-
Printf("GetUserBeginDebug1 chunk %p\n", chunk);
1101-
__asan::AsanChunk *m =
1102-
__asan::instance.GetAsanChunkByAddrFastLockedDebug(chunk);
1103-
Printf("GetUserBeginDebug2 m %p\n", m);
1104-
}
1105-
11061068
uptr GetUserBegin(uptr chunk) {
11071069
__asan::AsanChunk *m = __asan::instance.GetAsanChunkByAddrFastLocked(chunk);
11081070
return m ? m->Beg() : 0;

compiler-rt/lib/lsan/lsan_common.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include "sanitizer_common/sanitizer_thread_registry.h"
2626
#include "sanitizer_common/sanitizer_tls_get_addr.h"
2727

28-
extern "C" const char *__lsan_current_stage = "unknown";
29-
3028
#if CAN_SANITIZE_LEAKS
3129
namespace __lsan {
3230

@@ -362,7 +360,6 @@ static void FloodFillTag(Frontier *frontier, ChunkTag tag) {
362360
// ForEachChunk callback. If the chunk is marked as leaked, marks all chunks
363361
// which are reachable from it as indirectly leaked.
364362
static void MarkIndirectlyLeakedCb(uptr chunk, void *arg) {
365-
__lsan_current_stage = "MarkIndirectlyLeakedCb";
366363
chunk = GetUserBegin(chunk);
367364
LsanMetadata m(chunk);
368365
if (m.allocated() && m.tag() != kReachable) {
@@ -375,7 +372,6 @@ static void MarkIndirectlyLeakedCb(uptr chunk, void *arg) {
375372
// frontier.
376373
static void CollectIgnoredCb(uptr chunk, void *arg) {
377374
CHECK(arg);
378-
__lsan_current_stage = "CollectIgnoredCb";
379375
chunk = GetUserBegin(chunk);
380376
LsanMetadata m(chunk);
381377
if (m.allocated() && m.tag() == kIgnored) {
@@ -405,7 +401,6 @@ struct InvalidPCParam {
405401
static void MarkInvalidPCCb(uptr chunk, void *arg) {
406402
CHECK(arg);
407403
InvalidPCParam *param = reinterpret_cast<InvalidPCParam *>(arg);
408-
__lsan_current_stage = "MarkInvalidPCCb";
409404
chunk = GetUserBegin(chunk);
410405
LsanMetadata m(chunk);
411406
if (m.allocated() && m.tag() != kReachable && m.tag() != kIgnored) {
@@ -481,7 +476,6 @@ static void ClassifyAllChunks(SuspendedThreadsList const &suspended_threads,
481476
// ForEachChunk callback. Resets the tags to pre-leak-check state.
482477
static void ResetTagsCb(uptr chunk, void *arg) {
483478
(void)arg;
484-
__lsan_current_stage = "ResetTagsCb";
485479
chunk = GetUserBegin(chunk);
486480
LsanMetadata m(chunk);
487481
if (m.allocated() && m.tag() != kIgnored)
@@ -498,7 +492,6 @@ static void PrintStackTraceById(u32 stack_trace_id) {
498492
static void CollectLeaksCb(uptr chunk, void *arg) {
499493
CHECK(arg);
500494
LeakReport *leak_report = reinterpret_cast<LeakReport *>(arg);
501-
__lsan_current_stage = "CollectLeaksCb";
502495
chunk = GetUserBegin(chunk);
503496
LsanMetadata m(chunk);
504497
if (!m.allocated()) return;

compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h

-6
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,6 @@ class CombinedAllocator {
142142
return secondary_.GetBlockBeginFastLocked(p);
143143
}
144144

145-
void *GetBlockBeginFastLockedDebug(void *p) {
146-
if (primary_.PointerIsMine(p))
147-
return primary_.GetBlockBeginDebug(p);
148-
return secondary_.GetBlockBeginFastLocked(p);
149-
}
150-
151145
uptr GetActuallyAllocatedSize(void *p) {
152146
if (primary_.PointerIsMine(p))
153147
return primary_.GetActuallyAllocatedSize(p);

compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h

-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ class SizeClassAllocator32 {
211211
uptr res = beg + (n * (u32)size);
212212
return reinterpret_cast<void*>(res);
213213
}
214-
void *GetBlockBeginDebug(const void *p) { return GetBlockBegin(p); }
215214

216215
uptr GetActuallyAllocatedSize(void *p) {
217216
CHECK(PointerIsMine(p));

compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h

-24
Original file line numberDiff line numberDiff line change
@@ -199,30 +199,6 @@ class SizeClassAllocator64 {
199199
return nullptr;
200200
}
201201

202-
void *GetBlockBeginDebug(const void *p) {
203-
uptr class_id = GetSizeClass(p);
204-
uptr size = ClassIdToSize(class_id);
205-
Printf("GetBlockBeginDebug1 p %p class_id %p size %p\n", p, class_id, size);
206-
if (!size)
207-
return nullptr;
208-
uptr chunk_idx = GetChunkIdx((uptr)p, size);
209-
uptr reg_beg = GetRegionBegin(p);
210-
uptr beg = chunk_idx * size;
211-
uptr next_beg = beg + size;
212-
Printf(
213-
"GetBlockBeginDebug2 chunk_idx %p reg_beg %p beg %p next_beg %p "
214-
"kNumClasses %p\n",
215-
chunk_idx, reg_beg, beg, next_beg, kNumClasses);
216-
if (class_id >= kNumClasses)
217-
return nullptr;
218-
const RegionInfo *region = AddressSpaceView::Load(GetRegionInfo(class_id));
219-
Printf("GetBlockBeginDebug3 region %p region->mapped_user %p\n", region,
220-
region->mapped_user);
221-
if (region->mapped_user >= next_beg)
222-
return reinterpret_cast<void *>(reg_beg + beg);
223-
return nullptr;
224-
}
225-
226202
uptr GetActuallyAllocatedSize(void *p) {
227203
CHECK(PointerIsMine(p));
228204
return ClassIdToSize(GetSizeClass(p));

0 commit comments

Comments
 (0)