Skip to content

Commit

Permalink
DEBUGGING, print all allocations when PrintOnAllocation is set
Browse files Browse the repository at this point in the history
  • Loading branch information
rgal committed Jan 21, 2021
1 parent 3f77db7 commit c3caba8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler-rt/lib/scudo/scudo_allocator.cpp
Expand Up @@ -34,6 +34,7 @@

#include <errno.h>
#include <string.h>
#include <cstdio>

namespace __scudo {

Expand Down Expand Up @@ -707,7 +708,11 @@ void *scudoAllocate(uptr Size, uptr Alignment, AllocType Type) {
return nullptr;
reportAllocationAlignmentNotPowerOfTwo(Alignment);
}
return SetErrnoOnNull(Instance.allocate(Size, Alignment, Type));
void * mem = SetErrnoOnNull(Instance.allocate(Size, Alignment, Type));
if (getFlags()->PrintOnAllocation) {
printf("Allocating memory at %p, size %d\n", mem, Size);
}
return mem;
}

void scudoDeallocate(void *Ptr, uptr Size, uptr Alignment, AllocType Type) {
Expand Down
3 changes: 3 additions & 0 deletions compiler-rt/lib/scudo/scudo_flags.inc
Expand Up @@ -46,3 +46,6 @@ SCUDO_FLAG(bool, DeleteSizeMismatch, true,

SCUDO_FLAG(bool, ZeroContents, false,
"Zero chunk contents on allocation and deallocation.")

SCUDO_FLAG(bool, PrintOnAllocation, false,
"Print out pointer and size when allocating")

0 comments on commit c3caba8

Please sign in to comment.