Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: third_party/tcmalloc/chromium/src/heap-profile-table.cc

Issue 10541026: Add support for dump allocations created in a certain time window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/heap-profile-table.cc
diff --git a/third_party/tcmalloc/chromium/src/heap-profile-table.cc b/third_party/tcmalloc/chromium/src/heap-profile-table.cc
index 696f41e0b9cedbbaf36f43fd71e36605eb0e8117..dc7fc9c167fd289bbdf0cdc2c66d0565d48e0401 100644
--- a/third_party/tcmalloc/chromium/src/heap-profile-table.cc
+++ b/third_party/tcmalloc/chromium/src/heap-profile-table.cc
@@ -290,6 +290,16 @@ void HeapProfileTable::MarkAsIgnored(const void* ptr) {
}
}
+void HeapProfileTable::MarkCurrentAllocations(AllocationMark mark) {
+ const MarkArgs args(mark, true);
+ alloc_address_map_->Iterate<const MarkArgs&>(MarkIterator, args);
+}
+
+void HeapProfileTable::MarkUnmarkedAllocations(AllocationMark mark) {
+ const MarkArgs args(mark, true);
+ alloc_address_map_->Iterate<const MarkArgs&>(MarkIterator, args);
+}
+
// We'd be happier using snprintfer, but we don't to reduce dependencies.
int HeapProfileTable::UnparseBucket(const Bucket& b,
char* buf, int buflen, int bufsize,
@@ -396,6 +406,18 @@ void HeapProfileTable::ClearMMapData() {
mmap_address_map_ = NULL;
}
+void HeapProfileTable::DumpMarkedObjects(AllocationMark mark,
+ const char* file_name) {
+ RawFD fd = RawOpenForWriting(file_name);
+ if (fd == kIllegalRawFD) {
+ RAW_LOG(ERROR, "Failed dumping live objects to %s", file_name);
+ return;
+ }
+ const DumpMarkedArgs args(fd, mark);
+ alloc_address_map_->Iterate<const DumpMarkedArgs&>(DumpMarkedIterator, args);
+ RawClose(fd);
+}
+
void HeapProfileTable::IterateOrderedAllocContexts(
AllocContextIterator callback) const {
Bucket** list = MakeSortedBucketList();
@@ -474,6 +496,32 @@ void HeapProfileTable::DumpNonLiveIterator(const void* ptr, AllocValue* v,
RawWrite(args.fd, buf, len);
}
+inline
+void HeapProfileTable::DumpMarkedIterator(const void* ptr, AllocValue* v,
+ const DumpMarkedArgs& args) {
+ if (v->mark() != args.mark)
+ return;
+ Bucket b;
+ memset(&b, 0, sizeof(b));
+ b.allocs = 1;
+ b.alloc_size = v->bytes;
+ b.depth = v->bucket()->depth;
+ b.stack = v->bucket()->stack;
+ char addr[16];
+ snprintf(addr, 16, "0x%08" PRIxPTR, ptr);
+ char buf[1024];
+ int len = UnparseBucket(b, buf, 0, sizeof(buf), addr, NULL);
+ RawWrite(args.fd, buf, len);
+}
+
+inline
+void HeapProfileTable::MarkIterator(const void* ptr, AllocValue* v,
+ const MarkArgs& args) {
+ if (!args.mark_all && v->mark() != UNMARKED)
+ return;
+ v->set_mark(args.mark);
+}
+
inline void HeapProfileTable::ZeroBucketCountsIterator(
const void* ptr, AllocValue* v, HeapProfileTable* heap_profile) {
Bucket* b = v->bucket();
« no previous file with comments | « third_party/tcmalloc/chromium/src/heap-profile-table.h ('k') | third_party/tcmalloc/chromium/src/heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698