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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 uint64 committed_size = unhooked_[type].Record( | 727 uint64 committed_size = unhooked_[type].Record( |
737 memory_residence_info_getter, | 728 memory_residence_info_getter, |
738 cursor, | 729 cursor, |
739 last_address_of_unhooked); | 730 last_address_of_unhooked); |
740 if (mmap_dump_buffer) { | 731 if (mmap_dump_buffer) { |
741 mmap_dump_buffer->AppendString(" ", 0); | 732 mmap_dump_buffer->AppendString(" ", 0); |
742 mmap_dump_buffer->AppendPtr(cursor, 0); | 733 mmap_dump_buffer->AppendPtr(cursor, 0); |
743 mmap_dump_buffer->AppendString(" - ", 0); | 734 mmap_dump_buffer->AppendString(" - ", 0); |
744 mmap_dump_buffer->AppendPtr(last_address_of_unhooked + 1, 0); | 735 mmap_dump_buffer->AppendPtr(last_address_of_unhooked + 1, 0); |
745 mmap_dump_buffer->AppendString(" unhooked ", 0); | 736 mmap_dump_buffer->AppendString(" unhooked ", 0); |
746 mmap_dump_buffer->AppendString(kMapsRegionTypeDict[type], 0); | |
747 mmap_dump_buffer->AppendString(" ", 0); | |
748 mmap_dump_buffer->AppendInt64(committed_size, 0); | 737 mmap_dump_buffer->AppendInt64(committed_size, 0); |
749 mmap_dump_buffer->AppendString(" / ", 0); | 738 mmap_dump_buffer->AppendString(" / ", 0); |
750 mmap_dump_buffer->AppendInt64( | 739 mmap_dump_buffer->AppendInt64( |
751 last_address_of_unhooked - cursor + 1, 0); | 740 last_address_of_unhooked - cursor + 1, 0); |
752 mmap_dump_buffer->AppendString("\n", 0); | 741 mmap_dump_buffer->AppendString("\n", 0); |
753 } | 742 } |
754 cursor = last_address_of_unhooked + 1; | 743 cursor = last_address_of_unhooked + 1; |
755 } | 744 } |
756 | 745 |
757 if (mmap_iter != MemoryRegionMap::EndRegionLocked() && | 746 if (mmap_iter != MemoryRegionMap::EndRegionLocked() && |
(...skipping 13 matching lines...) Expand all Loading... |
771 uint64 committed_size = memory_residence_info_getter->CommittedSize( | 760 uint64 committed_size = memory_residence_info_getter->CommittedSize( |
772 partial_first_address, partial_last_address); | 761 partial_first_address, partial_last_address); |
773 mmap_dump_buffer->AppendString(trailing ? " (" : " ", 0); | 762 mmap_dump_buffer->AppendString(trailing ? " (" : " ", 0); |
774 mmap_dump_buffer->AppendPtr(mmap_iter->start_addr, 0); | 763 mmap_dump_buffer->AppendPtr(mmap_iter->start_addr, 0); |
775 mmap_dump_buffer->AppendString(trailing ? ")" : " ", 0); | 764 mmap_dump_buffer->AppendString(trailing ? ")" : " ", 0); |
776 mmap_dump_buffer->AppendString("-", 0); | 765 mmap_dump_buffer->AppendString("-", 0); |
777 mmap_dump_buffer->AppendString(continued ? "(" : " ", 0); | 766 mmap_dump_buffer->AppendString(continued ? "(" : " ", 0); |
778 mmap_dump_buffer->AppendPtr(mmap_iter->end_addr, 0); | 767 mmap_dump_buffer->AppendPtr(mmap_iter->end_addr, 0); |
779 mmap_dump_buffer->AppendString(continued ? ")" : " ", 0); | 768 mmap_dump_buffer->AppendString(continued ? ")" : " ", 0); |
780 mmap_dump_buffer->AppendString(" hooked ", 0); | 769 mmap_dump_buffer->AppendString(" hooked ", 0); |
781 mmap_dump_buffer->AppendString(kMapsRegionTypeDict[type], 0); | |
782 mmap_dump_buffer->AppendString(" ", 0); | |
783 mmap_dump_buffer->AppendInt64(committed_size, 0); | 770 mmap_dump_buffer->AppendInt64(committed_size, 0); |
784 mmap_dump_buffer->AppendString(" / ", 0); | 771 mmap_dump_buffer->AppendString(" / ", 0); |
785 mmap_dump_buffer->AppendInt64( | 772 mmap_dump_buffer->AppendInt64( |
786 partial_last_address - partial_first_address + 1, 0); | 773 partial_last_address - partial_first_address + 1, 0); |
787 mmap_dump_buffer->AppendString(" @ ", 0); | 774 mmap_dump_buffer->AppendString(" @ ", 0); |
788 if (deep_bucket != NULL) { | 775 if (deep_bucket != NULL) { |
789 mmap_dump_buffer->AppendInt(deep_bucket->id, 0, false); | 776 mmap_dump_buffer->AppendInt(deep_bucket->id, 0, false); |
790 } else { | 777 } else { |
791 mmap_dump_buffer->AppendInt(0, 0, false); | 778 mmap_dump_buffer->AppendInt(0, 0, false); |
792 } | 779 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 } | 945 } |
959 | 946 |
960 DeepHeapProfile::~DeepHeapProfile() { | 947 DeepHeapProfile::~DeepHeapProfile() { |
961 } | 948 } |
962 | 949 |
963 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { | 950 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { |
964 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size); | 951 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size); |
965 } | 952 } |
966 | 953 |
967 #endif // USE_DEEP_HEAP_PROFILE | 954 #endif // USE_DEEP_HEAP_PROFILE |
OLD | NEW |