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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« 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