Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(707)

Side by Side Diff: tools/android/memdump/memdump.cc

Issue 177003017: Optimize execution time of the memdump tool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add 'const' Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 return true; 194 return true;
195 } 195 }
196 196
197 // Fills |committed_pages| in with the set of committed pages contained in the 197 // Fills |committed_pages| in with the set of committed pages contained in the
198 // provided memory map. 198 // provided memory map.
199 bool GetPagesForMemoryMap(int pagemap_fd, 199 bool GetPagesForMemoryMap(int pagemap_fd,
200 const MemoryMap& memory_map, 200 const MemoryMap& memory_map,
201 std::vector<PageInfo>* committed_pages, 201 std::vector<PageInfo>* committed_pages,
202 BitSet* committed_pages_bits) { 202 BitSet* committed_pages_bits) {
203 const off64_t offset = memory_map.start_address / kPageSize;
204 if (lseek64(pagemap_fd, offset * sizeof(PageMapEntry), SEEK_SET) < 0) {
205 PLOG(ERROR) << "lseek";
206 return false;
207 }
203 for (uint addr = memory_map.start_address, page_index = 0; 208 for (uint addr = memory_map.start_address, page_index = 0;
204 addr < memory_map.end_address; 209 addr < memory_map.end_address;
205 addr += kPageSize, ++page_index) { 210 addr += kPageSize, ++page_index) {
206 DCHECK_EQ(0, addr % kPageSize); 211 DCHECK_EQ(0, addr % kPageSize);
207 PageMapEntry page_map_entry = {}; 212 PageMapEntry page_map_entry = {};
208 COMPILE_ASSERT(sizeof(PageMapEntry) == sizeof(uint64), unexpected_size); 213 COMPILE_ASSERT(sizeof(PageMapEntry) == sizeof(uint64), unexpected_size);
209 const off64_t offset = addr / kPageSize; 214 ssize_t bytes = read(pagemap_fd, &page_map_entry, sizeof(page_map_entry));
210 if (!ReadFromFileAtOffset(pagemap_fd, offset, &page_map_entry)) 215 if (bytes != sizeof(PageMapEntry) && bytes != 0) {
216 PLOG(ERROR) << "read";
211 return false; 217 return false;
218 }
212 if (page_map_entry.present) { // Ignore non-committed pages. 219 if (page_map_entry.present) { // Ignore non-committed pages.
213 if (page_map_entry.page_frame_number == 0) 220 if (page_map_entry.page_frame_number == 0)
214 continue; 221 continue;
215 PageInfo page_info = {}; 222 PageInfo page_info = {};
216 page_info.page_frame_number = page_map_entry.page_frame_number; 223 page_info.page_frame_number = page_map_entry.page_frame_number;
217 committed_pages->push_back(page_info); 224 committed_pages->push_back(page_info);
218 committed_pages_bits->set(page_index); 225 committed_pages_bits->set(page_index);
219 } 226 }
220 } 227 }
221 return true; 228 return true;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 519 }
513 } 520 }
514 521
515 ClassifyPages(&processes_memory); 522 ClassifyPages(&processes_memory);
516 if (short_output) 523 if (short_output)
517 DumpProcessesMemoryMapsInShortFormat(processes_memory); 524 DumpProcessesMemoryMapsInShortFormat(processes_memory);
518 else 525 else
519 DumpProcessesMemoryMapsInExtendedFormat(processes_memory); 526 DumpProcessesMemoryMapsInExtendedFormat(processes_memory);
520 return EXIT_SUCCESS; 527 return EXIT_SUCCESS;
521 } 528 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698