Index: tools/android/memdump/memdump.cc |
diff --git a/tools/android/memdump/memdump.cc b/tools/android/memdump/memdump.cc |
index 50a5914e1e76b9df99f08bb17a5c6f4b640e65f3..20684f69f820e6357661d5832da3b78a64b0300d 100644 |
--- a/tools/android/memdump/memdump.cc |
+++ b/tools/android/memdump/memdump.cc |
@@ -200,15 +200,22 @@ bool GetPagesForMemoryMap(int pagemap_fd, |
const MemoryMap& memory_map, |
std::vector<PageInfo>* committed_pages, |
BitSet* committed_pages_bits) { |
+ const off64_t offset = memory_map.start_address / kPageSize; |
+ if (lseek64(pagemap_fd, offset * sizeof(PageMapEntry), SEEK_SET) < 0) { |
+ PLOG(ERROR) << "lseek"; |
+ return false; |
+ } |
for (uint addr = memory_map.start_address, page_index = 0; |
addr < memory_map.end_address; |
addr += kPageSize, ++page_index) { |
DCHECK_EQ(0, addr % kPageSize); |
PageMapEntry page_map_entry = {}; |
COMPILE_ASSERT(sizeof(PageMapEntry) == sizeof(uint64), unexpected_size); |
- const off64_t offset = addr / kPageSize; |
- if (!ReadFromFileAtOffset(pagemap_fd, offset, &page_map_entry)) |
+ ssize_t bytes = read(pagemap_fd, &page_map_entry, sizeof(page_map_entry)); |
+ if (bytes != sizeof(PageMapEntry) && bytes != 0) { |
+ PLOG(ERROR) << "read"; |
return false; |
+ } |
if (page_map_entry.present) { // Ignore non-committed pages. |
if (page_map_entry.page_frame_number == 0) |
continue; |