OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include <fcntl.h> | 5 #include <fcntl.h> |
6 #include <signal.h> | 6 #include <signal.h> |
7 #include <sys/types.h> | 7 #include <sys/types.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 const off64_t offset = memory_map.start_address / kPageSize; | 211 const off64_t offset = memory_map.start_address / kPageSize; |
212 if (lseek64(pagemap_fd, offset * sizeof(PageMapEntry), SEEK_SET) < 0) { | 212 if (lseek64(pagemap_fd, offset * sizeof(PageMapEntry), SEEK_SET) < 0) { |
213 PLOG(ERROR) << "lseek"; | 213 PLOG(ERROR) << "lseek"; |
214 return false; | 214 return false; |
215 } | 215 } |
216 for (uint64 addr = memory_map.start_address, page_index = 0; | 216 for (uint64 addr = memory_map.start_address, page_index = 0; |
217 addr < memory_map.end_address; | 217 addr < memory_map.end_address; |
218 addr += kPageSize, ++page_index) { | 218 addr += kPageSize, ++page_index) { |
219 DCHECK_EQ(0, addr % kPageSize); | 219 DCHECK_EQ(0, addr % kPageSize); |
220 PageMapEntry page_map_entry = {}; | 220 PageMapEntry page_map_entry = {}; |
221 COMPILE_ASSERT(sizeof(PageMapEntry) == sizeof(uint64), unexpected_size); | 221 static_assert(sizeof(PageMapEntry) == sizeof(uint64), "unexpected size"); |
222 ssize_t bytes = read(pagemap_fd, &page_map_entry, sizeof(page_map_entry)); | 222 ssize_t bytes = read(pagemap_fd, &page_map_entry, sizeof(page_map_entry)); |
223 if (bytes != sizeof(PageMapEntry) && bytes != 0) { | 223 if (bytes != sizeof(PageMapEntry) && bytes != 0) { |
224 PLOG(ERROR) << "read"; | 224 PLOG(ERROR) << "read"; |
225 return false; | 225 return false; |
226 } | 226 } |
227 if (page_map_entry.present) { // Ignore non-committed pages. | 227 if (page_map_entry.present) { // Ignore non-committed pages. |
228 if (page_map_entry.page_frame_number == 0) | 228 if (page_map_entry.page_frame_number == 0) |
229 continue; | 229 continue; |
230 PageInfo page_info = {}; | 230 PageInfo page_info = {}; |
231 page_info.page_frame_number = page_map_entry.page_frame_number; | 231 page_info.page_frame_number = page_map_entry.page_frame_number; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 } | 525 } |
526 } | 526 } |
527 | 527 |
528 ClassifyPages(&processes_memory); | 528 ClassifyPages(&processes_memory); |
529 if (short_output) | 529 if (short_output) |
530 DumpProcessesMemoryMapsInShortFormat(processes_memory); | 530 DumpProcessesMemoryMapsInShortFormat(processes_memory); |
531 else | 531 else |
532 DumpProcessesMemoryMapsInExtendedFormat(processes_memory); | 532 DumpProcessesMemoryMapsInExtendedFormat(processes_memory); |
533 return EXIT_SUCCESS; | 533 return EXIT_SUCCESS; |
534 } | 534 } |
OLD | NEW |