Add present bytes when recording allocations.
When an allocation is freed, add information about the total
present bytes in the allocation that can be used to tell the
usage of allocations. This also applies to realloc operations
that free the previous pointer.
Add new unit tests for this functionality.
Test: All unit tests pass.
Change-Id: Id3a253e4beb1c7342711137a2bf7ebed4e25d973
diff --git a/libc/malloc_debug/RecordData.h b/libc/malloc_debug/RecordData.h
index ce71da1..bf5cc57 100644
--- a/libc/malloc_debug/RecordData.h
+++ b/libc/malloc_debug/RecordData.h
@@ -56,6 +56,8 @@
const std::string& file() { return file_; }
pthread_key_t key() { return key_; }
+ int64_t GetPresentBytes(void* pointer, size_t size);
+
static void WriteEntriesOnExit();
private:
@@ -74,6 +76,7 @@
std::vector<memory_trace::Entry> entries_;
size_t cur_index_;
std::string file_;
+ int pagemap_fd_ = -1;
BIONIC_DISALLOW_COPY_AND_ASSIGN(RecordData);
};