diff options
author | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-06 02:23:43 +0000 |
---|---|---|
committer | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-06 02:23:43 +0000 |
commit | b8b15608ca83df0a762a9be9d5dd3a022fa647f3 (patch) | |
tree | 208cb5b79c1561339316b99b08d95c282062574d /third_party | |
parent | 88b02be81610402a781de96ea6b2c1f2682a2573 (diff) | |
download | chromium_src-b8b15608ca83df0a762a9be9d5dd3a022fa647f3.zip chromium_src-b8b15608ca83df0a762a9be9d5dd3a022fa647f3.tar.gz chromium_src-b8b15608ca83df0a762a9be9d5dd3a022fa647f3.tar.bz2 |
Dump a list of memory regions which are not hooked by the heap-profiler.
BUG=174304
Review URL: https://chromiumcodereview.appspot.com/12207014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/tcmalloc/chromium/src/deep-heap-profile.cc | 43 | ||||
-rw-r--r-- | third_party/tcmalloc/chromium/src/deep-heap-profile.h | 6 |
2 files changed, 44 insertions, 5 deletions
diff --git a/third_party/tcmalloc/chromium/src/deep-heap-profile.cc b/third_party/tcmalloc/chromium/src/deep-heap-profile.cc index 4941f8d..895a527 100644 --- a/third_party/tcmalloc/chromium/src/deep-heap-profile.cc +++ b/third_party/tcmalloc/chromium/src/deep-heap-profile.cc @@ -38,6 +38,15 @@ static const char kProcSelfMapsHeader[] = "\nMAPPED_LIBRARIES:\n"; static const char kVirtualLabel[] = "virtual"; static const char kCommittedLabel[] = "committed"; +const char* DeepHeapProfile::kMapsRegionTypeDict[] = { + "absent", + "anonymous", + "file-exec", + "file-nonexec", + "stack", + "other", +}; + namespace { #if defined(__linux__) @@ -261,7 +270,7 @@ int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { mmap_list_[num_mmap_allocations_ - 1].last_address = 0; } - stats_.SnapshotProcMaps(memory_residence_info_getter_, NULL, 0); + stats_.SnapshotProcMaps(memory_residence_info_getter_, NULL, 0, NULL, 0); // TODO(dmikurube): Eliminate dynamic memory allocation caused by snprintf. // glibc's snprintf internally allocates memory by alloca normally, but it @@ -271,8 +280,11 @@ int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { stats_.SnapshotAllocations(this); // Check if committed bytes changed during SnapshotAllocations. - stats_.SnapshotProcMaps( - memory_residence_info_getter_, mmap_list_, mmap_list_length_); + stats_.SnapshotProcMaps(memory_residence_info_getter_, + mmap_list_, + mmap_list_length_, + filename_prefix_, + dump_count_); buffer.AppendString(kProfileHeader, 0); buffer.AppendString(kProfileVersion, 0); @@ -617,7 +629,9 @@ void DeepHeapProfile::RegionStats::Unparse(const char* name, void DeepHeapProfile::GlobalStats::SnapshotProcMaps( const MemoryResidenceInfoGetterInterface* memory_residence_info_getter, MMapListEntry* mmap_list, - int mmap_list_length) { + int mmap_list_length, + const char* prefix, + int dump_count) { ProcMapsIterator::Buffer iterator_buffer; ProcMapsIterator iterator(0, &iterator_buffer); uint64 first_address, last_address, offset; @@ -626,12 +640,20 @@ void DeepHeapProfile::GlobalStats::SnapshotProcMaps( char* filename; int mmap_list_index = 0; enum MapsRegionType type; + char unhooked_filename[100]; + RawFD unhooked_fd = kIllegalRawFD; for (int i = 0; i < NUMBER_OF_MAPS_REGION_TYPES; ++i) { all_[i].Initialize(); nonprofiled_[i].Initialize(); } + if (prefix) { + snprintf(unhooked_filename, sizeof(unhooked_filename), + "%s.%05d.%04d.unhooked", prefix, getpid(), dump_count); + unhooked_fd = RawOpenForWriting(unhooked_filename); + } + while (iterator.Next(&first_address, &last_address, &flags, &offset, &unused_inode, &filename)) { // 'last_address' should be the last inclusive address of the region. @@ -686,12 +708,25 @@ void DeepHeapProfile::GlobalStats::SnapshotProcMaps( memory_residence_info_getter, cursor, last_address_of_nonprofiled); + if (unhooked_fd != kIllegalRawFD) { + char range[128]; + int length = 0; + length = snprintf(range, sizeof(range), + "%s %"PRIxPTR"-%"PRIxPTR"\n", + kMapsRegionTypeDict[type], + cursor, last_address_of_nonprofiled); + if (length > 0) + RawWrite(unhooked_fd, range, length); + } cursor = last_address_of_nonprofiled + 1; } } while (mmap_list_index < mmap_list_length && mmap_list[mmap_list_index].last_address <= last_address); } } + + if (unhooked_fd != kIllegalRawFD) + RawClose(unhooked_fd); } void DeepHeapProfile::GlobalStats::SnapshotAllocations( diff --git a/third_party/tcmalloc/chromium/src/deep-heap-profile.h b/third_party/tcmalloc/chromium/src/deep-heap-profile.h index 121c5b8..435a061 100644 --- a/third_party/tcmalloc/chromium/src/deep-heap-profile.h +++ b/third_party/tcmalloc/chromium/src/deep-heap-profile.h @@ -116,6 +116,8 @@ class DeepHeapProfile { NUMBER_OF_MAPS_REGION_TYPES }; + static const char* kMapsRegionTypeDict[NUMBER_OF_MAPS_REGION_TYPES]; + // Manages a buffer to keep a dumped text for FillOrderedProfile and other // functions. class TextBuffer { @@ -258,7 +260,9 @@ class DeepHeapProfile { void SnapshotProcMaps( const MemoryResidenceInfoGetterInterface* memory_residence_info_getter, MMapListEntry* mmap_list, - int mmap_list_length); + int mmap_list_length, + const char* prefix, + int dump_count); // Snapshots allocations by malloc and mmap. void SnapshotAllocations(DeepHeapProfile* deep_profile); |