| 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 c86a3c2b010c23ea0f6c8eae44e90fdcb317ee45..4aee0cf4ec7eea1b8d34af05d245b2237b275784 100644
|
| --- a/third_party/tcmalloc/chromium/src/heap-profiler.cc
|
| +++ b/third_party/tcmalloc/chromium/src/heap-profiler.cc
|
| @@ -272,7 +272,9 @@ static void NewHook(const void* ptr, size_t size);
|
| static void DeleteHook(const void* ptr);
|
|
|
| // Helper for HeapProfilerDump.
|
| -static void DumpProfileLocked(const char* reason) {
|
| +static void DumpProfileLocked(const char* reason,
|
| + char* filename_buffer,
|
| + size_t filename_buffer_length) {
|
| RAW_DCHECK(heap_lock.IsHeld(), "");
|
| RAW_DCHECK(is_on, "");
|
| RAW_DCHECK(!dumping, "");
|
| @@ -282,18 +284,17 @@ static void DumpProfileLocked(const char* reason) {
|
| dumping = true;
|
|
|
| // Make file name
|
| - char file_name[1000];
|
| dump_count++;
|
| - snprintf(file_name, sizeof(file_name), "%s.%05d.%04d%s",
|
| + snprintf(filename_buffer, filename_buffer_length, "%s.%05d.%04d%s",
|
| filename_prefix, getpid(), dump_count, HeapProfileTable::kFileExt);
|
|
|
| // Dump the profile
|
| - RAW_VLOG(0, "Dumping heap profile to %s (%s)", file_name, reason);
|
| + RAW_VLOG(0, "Dumping heap profile to %s (%s)", filename_buffer, reason);
|
| // We must use file routines that don't access memory, since we hold
|
| // a memory lock now.
|
| - RawFD fd = RawOpenForWriting(file_name);
|
| + RawFD fd = RawOpenForWriting(filename_buffer);
|
| if (fd == kIllegalRawFD) {
|
| - RAW_LOG(ERROR, "Failed dumping heap profile to %s", file_name);
|
| + RAW_LOG(ERROR, "Failed dumping heap profile to %s", filename_buffer);
|
| dumping = false;
|
| return;
|
| }
|
| @@ -312,10 +313,10 @@ static void DumpProfileLocked(const char* reason) {
|
|
|
| #if defined(TYPE_PROFILING)
|
| if (FLAGS_heap_profile_type_statistics) {
|
| - snprintf(file_name, sizeof(file_name), "%s.%05d.%04d.type",
|
| + snprintf(filename_buffer, filename_buffer_length, "%s.%05d.%04d.type",
|
| filename_prefix, getpid(), dump_count);
|
| - RAW_VLOG(0, "Dumping type statistics to %s", file_name);
|
| - heap_profile->DumpTypeStatistics(file_name);
|
| + RAW_VLOG(0, "Dumping type statistics to %s", filename_buffer);
|
| + heap_profile->DumpTypeStatistics(filename_buffer);
|
| }
|
| #endif // defined(TYPE_PROFILING)
|
|
|
| @@ -364,7 +365,8 @@ static void MaybeDumpProfileLocked() {
|
| last_dump_time = current_time;
|
| }
|
| if (need_to_dump) {
|
| - DumpProfileLocked(buf);
|
| + char filename_buffer[1000];
|
| + DumpProfileLocked(buf, filename_buffer, sizeof(filename_buffer));
|
|
|
| last_dump_alloc = total.alloc_size;
|
| last_dump_free = total.free_size;
|
| @@ -619,7 +621,17 @@ extern "C" void HeapProfilerStop() {
|
| extern "C" void HeapProfilerDump(const char* reason) {
|
| SpinLockHolder l(&heap_lock);
|
| if (is_on && !dumping) {
|
| - DumpProfileLocked(reason);
|
| + char filename_buffer[1000];
|
| + DumpProfileLocked(reason, filename_buffer, sizeof(filename_buffer));
|
| + }
|
| +}
|
| +
|
| +extern "C" void HeapProfilerDumpWithFileName(const char* reason,
|
| + char* dumped_filename_buffer,
|
| + int filename_buffer_length) {
|
| + SpinLockHolder l(&heap_lock);
|
| + if (is_on && !dumping) {
|
| + DumpProfileLocked(reason, dumped_filename_buffer, filename_buffer_length);
|
| }
|
| }
|
|
|
|
|