OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 static const char kProfileVersion[] = "DUMP_DEEP_6"; | 34 static const char kProfileVersion[] = "DUMP_DEEP_6"; |
35 static const char kMetaInformationHeader[] = "META:\n"; | 35 static const char kMetaInformationHeader[] = "META:\n"; |
36 static const char kMMapListHeader[] = "MMAP_LIST:\n"; | 36 static const char kMMapListHeader[] = "MMAP_LIST:\n"; |
37 static const char kGlobalStatsHeader[] = "GLOBAL_STATS:\n"; | 37 static const char kGlobalStatsHeader[] = "GLOBAL_STATS:\n"; |
38 static const char kStacktraceHeader[] = "STACKTRACES:\n"; | 38 static const char kStacktraceHeader[] = "STACKTRACES:\n"; |
39 static const char kProcSelfMapsHeader[] = "\nMAPPED_LIBRARIES:\n"; | 39 static const char kProcSelfMapsHeader[] = "\nMAPPED_LIBRARIES:\n"; |
40 | 40 |
41 static const char kVirtualLabel[] = "virtual"; | 41 static const char kVirtualLabel[] = "virtual"; |
42 static const char kCommittedLabel[] = "committed"; | 42 static const char kCommittedLabel[] = "committed"; |
43 | 43 |
44 const char* DeepHeapProfile::kMapsRegionTypeDict[] = { | |
45 "absent", | |
46 "anonymous", | |
47 "file-exec", | |
48 "file-nonexec", | |
49 "stack", | |
50 "other", | |
51 }; | |
52 | |
53 namespace { | 44 namespace { |
54 | 45 |
55 #if defined(__linux__) | 46 #if defined(__linux__) |
56 | 47 |
57 // Implements MemoryResidenceInfoGetterInterface for Linux. | 48 // Implements MemoryResidenceInfoGetterInterface for Linux. |
58 class MemoryInfoGetterLinux : | 49 class MemoryInfoGetterLinux : |
59 public DeepHeapProfile::MemoryResidenceInfoGetterInterface { | 50 public DeepHeapProfile::MemoryResidenceInfoGetterInterface { |
60 public: | 51 public: |
61 MemoryInfoGetterLinux(): fd_(kIllegalRawFD) {} | 52 MemoryInfoGetterLinux(): fd_(kIllegalRawFD) {} |
62 virtual ~MemoryInfoGetterLinux() {} | 53 virtual ~MemoryInfoGetterLinux() {} |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 uint64 committed_size = unhooked_[type].Record( | 751 uint64 committed_size = unhooked_[type].Record( |
761 memory_residence_info_getter, | 752 memory_residence_info_getter, |
762 cursor, | 753 cursor, |
763 last_address_of_unhooked); | 754 last_address_of_unhooked); |
764 if (mmap_dump_buffer) { | 755 if (mmap_dump_buffer) { |
765 mmap_dump_buffer->AppendString(" ", 0); | 756 mmap_dump_buffer->AppendString(" ", 0); |
766 mmap_dump_buffer->AppendPtr(cursor, 0); | 757 mmap_dump_buffer->AppendPtr(cursor, 0); |
767 mmap_dump_buffer->AppendString(" - ", 0); | 758 mmap_dump_buffer->AppendString(" - ", 0); |
768 mmap_dump_buffer->AppendPtr(last_address_of_unhooked + 1, 0); | 759 mmap_dump_buffer->AppendPtr(last_address_of_unhooked + 1, 0); |
769 mmap_dump_buffer->AppendString(" unhooked ", 0); | 760 mmap_dump_buffer->AppendString(" unhooked ", 0); |
770 mmap_dump_buffer->AppendString(kMapsRegionTypeDict[type], 0); | |
771 mmap_dump_buffer->AppendString(" ", 0); | |
772 mmap_dump_buffer->AppendInt64(committed_size, 0); | 761 mmap_dump_buffer->AppendInt64(committed_size, 0); |
773 mmap_dump_buffer->AppendString(" / ", 0); | 762 mmap_dump_buffer->AppendString(" / ", 0); |
774 mmap_dump_buffer->AppendInt64( | 763 mmap_dump_buffer->AppendInt64( |
775 last_address_of_unhooked - cursor + 1, 0); | 764 last_address_of_unhooked - cursor + 1, 0); |
776 mmap_dump_buffer->AppendString("\n", 0); | 765 mmap_dump_buffer->AppendString("\n", 0); |
777 } | 766 } |
778 cursor = last_address_of_unhooked + 1; | 767 cursor = last_address_of_unhooked + 1; |
779 } | 768 } |
780 | 769 |
781 if (mmap_iter != MemoryRegionMap::EndRegionLocked() && | 770 if (mmap_iter != MemoryRegionMap::EndRegionLocked() && |
(...skipping 13 matching lines...) Expand all Loading... |
795 uint64 committed_size = memory_residence_info_getter->CommittedSize( | 784 uint64 committed_size = memory_residence_info_getter->CommittedSize( |
796 partial_first_address, partial_last_address); | 785 partial_first_address, partial_last_address); |
797 mmap_dump_buffer->AppendString(trailing ? " (" : " ", 0); | 786 mmap_dump_buffer->AppendString(trailing ? " (" : " ", 0); |
798 mmap_dump_buffer->AppendPtr(mmap_iter->start_addr, 0); | 787 mmap_dump_buffer->AppendPtr(mmap_iter->start_addr, 0); |
799 mmap_dump_buffer->AppendString(trailing ? ")" : " ", 0); | 788 mmap_dump_buffer->AppendString(trailing ? ")" : " ", 0); |
800 mmap_dump_buffer->AppendString("-", 0); | 789 mmap_dump_buffer->AppendString("-", 0); |
801 mmap_dump_buffer->AppendString(continued ? "(" : " ", 0); | 790 mmap_dump_buffer->AppendString(continued ? "(" : " ", 0); |
802 mmap_dump_buffer->AppendPtr(mmap_iter->end_addr, 0); | 791 mmap_dump_buffer->AppendPtr(mmap_iter->end_addr, 0); |
803 mmap_dump_buffer->AppendString(continued ? ")" : " ", 0); | 792 mmap_dump_buffer->AppendString(continued ? ")" : " ", 0); |
804 mmap_dump_buffer->AppendString(" hooked ", 0); | 793 mmap_dump_buffer->AppendString(" hooked ", 0); |
805 mmap_dump_buffer->AppendString(kMapsRegionTypeDict[type], 0); | |
806 mmap_dump_buffer->AppendString(" ", 0); | |
807 mmap_dump_buffer->AppendInt64(committed_size, 0); | 794 mmap_dump_buffer->AppendInt64(committed_size, 0); |
808 mmap_dump_buffer->AppendString(" / ", 0); | 795 mmap_dump_buffer->AppendString(" / ", 0); |
809 mmap_dump_buffer->AppendInt64( | 796 mmap_dump_buffer->AppendInt64( |
810 partial_last_address - partial_first_address + 1, 0); | 797 partial_last_address - partial_first_address + 1, 0); |
811 mmap_dump_buffer->AppendString(" @ ", 0); | 798 mmap_dump_buffer->AppendString(" @ ", 0); |
812 if (deep_bucket != NULL) { | 799 if (deep_bucket != NULL) { |
813 mmap_dump_buffer->AppendInt(deep_bucket->id, 0, false); | 800 mmap_dump_buffer->AppendInt(deep_bucket->id, 0, false); |
814 } else { | 801 } else { |
815 mmap_dump_buffer->AppendInt(0, 0, false); | 802 mmap_dump_buffer->AppendInt(0, 0, false); |
816 } | 803 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 969 } |
983 | 970 |
984 DeepHeapProfile::~DeepHeapProfile() { | 971 DeepHeapProfile::~DeepHeapProfile() { |
985 } | 972 } |
986 | 973 |
987 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { | 974 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { |
988 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size); | 975 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size); |
989 } | 976 } |
990 | 977 |
991 #endif // USE_DEEP_HEAP_PROFILE | 978 #endif // USE_DEEP_HEAP_PROFILE |
OLD | NEW |