Index: third_party/tcmalloc/chromium/src/heap-profiler.cc |
diff --git a/third_party/tcmalloc/chromium/src/heap-profiler.cc b/third_party/tcmalloc/chromium/src/heap-profiler.cc |
index 67cb31e464d286fa30f228a9abac955fe8360f62..aa331fa974345c886ac9bad471e74c4d0a1917f7 100644 |
--- a/third_party/tcmalloc/chromium/src/heap-profiler.cc |
+++ b/third_party/tcmalloc/chromium/src/heap-profiler.cc |
@@ -220,6 +220,9 @@ static int64 last_dump_time = 0; // The time of the last dump |
static HeapProfileTable* heap_profile = NULL; // the heap profile table |
static DeepHeapProfile* deep_profile = NULL; // deep memory profiler |
+// Callback an appplication can use to generate its own "stacks". |
+static PseudoStackGenerator pseudo_stack_generator = NULL; |
+ |
//---------------------------------------------------------------------- |
// Profile generation |
//---------------------------------------------------------------------- |
@@ -239,7 +242,8 @@ static char* DoGetHeapProfileLocked(char* buf, int buflen) { |
if (deep_profile) { |
bytes_written = deep_profile->FillOrderedProfile(buf, buflen - 1); |
} else { |
- bytes_written = heap_profile->FillOrderedProfile(buf, buflen - 1); |
+// bytes_written = heap_profile->FillOrderedProfile(buf, buflen - 1); |
+ bytes_written = heap_profile->FillOrderedProfile2(buf, buflen - 1); |
} |
// FillOrderedProfile should not reduce the set of active mmap-ed regions, |
// hence MemoryRegionMap will let us remove everything we've added above: |
@@ -371,7 +375,15 @@ static void MaybeDumpProfileLocked() { |
static void RecordAlloc(const void* ptr, size_t bytes, int skip_count) { |
// Take the stack trace outside the critical section. |
void* stack[HeapProfileTable::kMaxStackDepth]; |
- int depth = HeapProfileTable::GetCallerStackTrace(skip_count + 1, stack); |
+ //JAMESDEBUG this is the wrong place to do this, look deeper |
+ int depth; |
+ if (pseudo_stack_generator) { |
+ depth = (*pseudo_stack_generator)(stack); |
+ } else { |
+ stack[0] = NULL; |
+ depth = 1; |
+ } |
+// int depth = HeapProfileTable::GetCallerStackTrace(skip_count + 1, stack); |
SpinLockHolder l(&heap_lock); |
if (is_on) { |
heap_profile->RecordAlloc(ptr, bytes, depth, stack); |
@@ -638,6 +650,11 @@ extern "C" void HeapProfilerDumpAliveObjects(const char* filename) { |
heap_profile->DumpMarkedObjects(HeapProfileTable::MARK_TWO, filename); |
} |
+extern "C" void SetPseudoStackGenerator(PseudoStackGenerator callback) { |
+ SpinLockHolder l(&heap_lock); |
+ pseudo_stack_generator = callback; |
+} |
+ |
//---------------------------------------------------------------------- |
// Initialization/finalization code |
//---------------------------------------------------------------------- |