summaryrefslogtreecommitdiff
path: root/src/heap-profiler.cc
diff options
context:
space:
mode:
authorcsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2012-01-28 00:13:43 +0000
committercsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2012-01-28 00:13:43 +0000
commite0eaf5981eede6311e311ac5054489b85015c5d7 (patch)
tree7d093149f72e85add4f0a0cce9cc12df1c69b050 /src/heap-profiler.cc
parent4fa02db374683d3c69c1b36158534c011513ed31 (diff)
downloadgperftools-e0eaf5981eede6311e311ac5054489b85015c5d7.tar.gz
* PORTING: Support for patching assembly on win x86_64! (scott.fr...)
* PORTING: Work around atexit-execution-order bug on freebsd (csilvers) * PORTING: Patch _calloc_crt for windows (roger orr) * PORTING: Add C++11 compatibility method for stl allocator (jdennett) * PORTING: use MADV_FREE, not MADV_DONTNEED, on freebsd (csilvers) * PORTING: Don't use SYS_open when not supported on solaris (csilvers) * PORTING: Do not assume uname() returns 0 on success (csilvers) * LSS: Improved ARM support in linux-syscall-support (dougkwan) * LSS: Get rid of unused syscalls in linux-syscall-support (csilvers) * LSS: Fix broken mmap wrapping for ppc (markus) * LSS: Emit .cfi_adjust_cfa_offset when appropriate (ppluzhnikov) * LSS: Be more accurate in register use in __asm__ (markus) * LSS: Fix __asm__ calls to compile under clang (chandlerc) * LSS: Fix ARM inline assembly bug around r7 and swi (lcwu) * No longer log when an allocator fails (csilvers) * void* -> const void* for MallocExtension methods (llib) * Improve HEAP_PROFILE_MMAP and fix bugs with it (dmikurube) * Replace int-based abs with more correct fabs in a test (pmurin) git-svn-id: http://gperftools.googlecode.com/svn/trunk@134 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
Diffstat (limited to 'src/heap-profiler.cc')
-rw-r--r--src/heap-profiler.cc38
1 files changed, 6 insertions, 32 deletions
diff --git a/src/heap-profiler.cc b/src/heap-profiler.cc
index 32815b4..68b379d 100644
--- a/src/heap-profiler.cc
+++ b/src/heap-profiler.cc
@@ -175,29 +175,6 @@ static HeapProfileTable* heap_profile = NULL; // the heap profile table
// Profile generation
//----------------------------------------------------------------------
-enum AddOrRemove { ADD, REMOVE };
-
-// Add or remove all MMap-allocated regions to/from *heap_profile.
-// Assumes heap_lock is held.
-static void AddRemoveMMapDataLocked(AddOrRemove mode) {
- RAW_DCHECK(heap_lock.IsHeld(), "");
- if (!FLAGS_mmap_profile || !is_on) return;
- // MemoryRegionMap maintained all the data we need for all
- // mmap-like allocations, so we just use it here:
- MemoryRegionMap::LockHolder l;
- for (MemoryRegionMap::RegionIterator r = MemoryRegionMap::BeginRegionLocked();
- r != MemoryRegionMap::EndRegionLocked(); ++r) {
- if (mode == ADD) {
- heap_profile->RecordAlloc(
- reinterpret_cast<const void*>(r->start_addr),
- r->end_addr - r->start_addr,
- r->call_stack_depth, r->call_stack);
- } else {
- heap_profile->RecordFree(reinterpret_cast<void*>(r->start_addr));
- }
- }
-}
-
// Input must be a buffer of size at least 1MB.
static char* DoGetHeapProfileLocked(char* buf, int buflen) {
// We used to be smarter about estimating the required memory and
@@ -208,16 +185,13 @@ static char* DoGetHeapProfileLocked(char* buf, int buflen) {
RAW_DCHECK(heap_lock.IsHeld(), "");
int bytes_written = 0;
if (is_on) {
- HeapProfileTable::Stats const stats = heap_profile->total();
- (void)stats; // avoid an unused-variable warning in non-debug mode.
- AddRemoveMMapDataLocked(ADD);
+ if (FLAGS_mmap_profile) {
+ heap_profile->RefreshMMapData();
+ }
bytes_written = heap_profile->FillOrderedProfile(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:
- AddRemoveMMapDataLocked(REMOVE);
- RAW_DCHECK(stats.Equivalent(heap_profile->total()), "");
- // if this fails, we somehow removed by AddRemoveMMapDataLocked
- // more than we have added.
+ if (FLAGS_mmap_profile) {
+ heap_profile->ClearMMapData();
+ }
}
buf[bytes_written] = '\0';
RAW_DCHECK(bytes_written == strlen(buf), "");