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

Side by Side Diff: third_party/tcmalloc/chromium/src/deep-heap-profile.cc

Issue 10832290: Dump /proc/<pid>/maps with every heap profile dump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/tcmalloc/chromium/src/deep-heap-profile.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // --- 5 // ---
6 // Author: Sainbayar Sukhbaatar 6 // Author: Sainbayar Sukhbaatar
7 // Dai Mikurube 7 // Dai Mikurube
8 // 8 //
9 9
10 #include "deep-heap-profile.h" 10 #include "deep-heap-profile.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 for (int i = 0; i < kHashTableSize; i++) { 85 for (int i = 0; i < kHashTableSize; i++) {
86 for (DeepBucket* deep_bucket = deep_table_[i]; 86 for (DeepBucket* deep_bucket = deep_table_[i];
87 deep_bucket != NULL; 87 deep_bucket != NULL;
88 deep_bucket = deep_bucket->next) { 88 deep_bucket = deep_bucket->next) {
89 deep_bucket->is_logged = false; 89 deep_bucket->is_logged = false;
90 } 90 }
91 } 91 }
92 92
93 // Write maps into a .maps file with using the global buffer. 93 // Write maps into a .maps file with using the global buffer.
94 WriteMapsToFile(filename_prefix_, kProfilerBufferSize, profiler_buffer_); 94 WriteMapsToFile(filename_prefix_, 0,
Alexander Potapenko 2012/08/14 08:39:57 Why is this 0? If the process didn't call exec() y
Dai Mikurube (NOT FULLTIME) 2012/08/14 09:33:26 Data in /proc/<pid>/maps is used in this dumper "d
Alexander Potapenko 2012/08/14 09:36:47 Can you please prepend a comment to "0" so that th
95 kProfilerBufferSize, profiler_buffer_);
95 } 96 }
97 WriteMapsToFile(filename_prefix_, dump_count_,
Alexander Potapenko 2012/08/14 08:39:57 Are you going to write the mappings twice if most_
Dai Mikurube (NOT FULLTIME) 2012/08/14 09:33:26 Yes, I know normally "prefix.<pid>.maps" and "pref
98 kProfilerBufferSize, profiler_buffer_);
96 99
97 // Reset committed sizes of buckets. 100 // Reset committed sizes of buckets.
98 ResetCommittedSize(deep_table_); 101 ResetCommittedSize(deep_table_);
99 102
100 // Allocate a list for mmap'ed regions. 103 // Allocate a list for mmap'ed regions.
101 num_mmap_allocations_ = 0; 104 num_mmap_allocations_ = 0;
102 heap_profile_->mmap_address_map_->Iterate(CountMMap, this); 105 heap_profile_->mmap_address_map_->Iterate(CountMMap, this);
103 mmap_list_length_ = 0; 106 mmap_list_length_ = 0;
104 mmap_list_ = reinterpret_cast<MMapListEntry*>(heap_profile_->alloc_( 107 mmap_list_ = reinterpret_cast<MMapListEntry*>(heap_profile_->alloc_(
105 sizeof(MMapListEntry) * num_mmap_allocations_)); 108 sizeof(MMapListEntry) * num_mmap_allocations_));
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 break; 319 break;
317 } 320 }
318 page_address += page_size; 321 page_address += page_size;
319 } 322 }
320 323
321 return committed_size; 324 return committed_size;
322 } 325 }
323 326
324 // static 327 // static
325 void DeepHeapProfile::WriteMapsToFile(const char* filename_prefix, 328 void DeepHeapProfile::WriteMapsToFile(const char* filename_prefix,
329 unsigned count,
326 int buffer_size, 330 int buffer_size,
327 char buffer[]) { 331 char buffer[]) {
328 char filename[100]; 332 char filename[100];
329 snprintf(filename, sizeof(filename), 333 if (count > 0) {
330 "%s.%05d.maps", filename_prefix, static_cast<int>(getpid())); 334 snprintf(filename, sizeof(filename),
335 "%s.%05d.%04d.maps", filename_prefix, static_cast<int>(getpid()),
336 count);
337 } else {
338 snprintf(filename, sizeof(filename),
339 "%s.%05d.maps", filename_prefix, static_cast<int>(getpid()));
340 }
331 341
332 RawFD maps_fd = RawOpenForWriting(filename); 342 RawFD maps_fd = RawOpenForWriting(filename);
333 RAW_DCHECK(maps_fd != kIllegalRawFD, ""); 343 RAW_DCHECK(maps_fd != kIllegalRawFD, "");
334 344
335 int map_length; 345 int map_length;
336 bool wrote_all; 346 bool wrote_all;
337 map_length = tcmalloc::FillProcSelfMaps(buffer, buffer_size, &wrote_all); 347 map_length = tcmalloc::FillProcSelfMaps(buffer, buffer_size, &wrote_all);
338 RAW_DCHECK(wrote_all, ""); 348 RAW_DCHECK(wrote_all, "");
339 RAW_DCHECK(map_length <= buffer_size, ""); 349 RAW_DCHECK(map_length <= buffer_size, "");
340 RawWrite(maps_fd, buffer, map_length); 350 RawWrite(maps_fd, buffer, map_length);
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 } 817 }
808 818
809 DeepHeapProfile::~DeepHeapProfile() { 819 DeepHeapProfile::~DeepHeapProfile() {
810 } 820 }
811 821
812 int DeepHeapProfile::FillOrderedProfile(char buffer[], int buffer_size) { 822 int DeepHeapProfile::FillOrderedProfile(char buffer[], int buffer_size) {
813 return heap_profile_->FillOrderedProfile(buffer, buffer_size); 823 return heap_profile_->FillOrderedProfile(buffer, buffer_size);
814 } 824 }
815 825
816 #endif // DEEP_HEAP_PROFILE 826 #endif // DEEP_HEAP_PROFILE
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/deep-heap-profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698