Chromium Code Reviews| Index: base/trace_event/process_memory_dump.cc |
| diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc |
| index 0ec007e2ee46f5140bf83ee5580a7f5c1ee221f4..36a317d00deb45dcec8300812ffdee1483ecfc3a 100644 |
| --- a/base/trace_event/process_memory_dump.cc |
| +++ b/base/trace_event/process_memory_dump.cc |
| @@ -51,14 +51,32 @@ size_t ProcessMemoryDump::CountResidentBytes(void* start_address, |
| #if defined(OS_MACOSX) || defined(OS_IOS) |
| std::vector<char> vec(page_count + 1); |
| + // mincore in MAC does not fail with EAGAIN. |
| int res = mincore(chunk_start, chunk_size, vector_as_array(&vec)); |
| DCHECK(!res); |
| + if (res) { |
| + LOG(ERROR) |
| + << "Mincore call failed. The resident size may not be accurate"; |
|
Primiano Tucci (use gerrit)
2015/10/15 11:20:18
nit: s/Mincore/mincore()/
also, if you continue he
ssid
2015/10/15 11:23:43
The call to mincore failed only once. The next set
|
| + continue; |
| + } |
| + |
| for (size_t i = 0; i < page_count; i++) |
| resident_page_count += vec[i] & MINCORE_INCORE ? 1 : 0; |
| #else // defined(OS_MACOSX) || defined(OS_IOS) |
| std::vector<unsigned char> vec(page_count + 1); |
| - int res = mincore(chunk_start, chunk_size, vector_as_array(&vec)); |
| + int error_counter = 0; |
| + int res = 0; |
| + // HANDLE_EINTR tries for 100 times. So following the same pattern. |
| + do { |
| + res = mincore(chunk_start, chunk_size, vector_as_array(&vec)); |
| + } while (res == -1 && errno == EAGAIN && error_counter++ < 100); |
| DCHECK(!res); |
| + if (res) { |
| + LOG(ERROR) |
| + << "Mincore call failed. The resident size may not be accurate"; |
|
Primiano Tucci (use gerrit)
2015/10/15 11:20:18
can we avoid duplicating this and above?
ssid
2015/10/15 11:23:43
I would have to add 3 extra #if defined. that is w
Primiano Tucci (use gerrit)
2015/10/15 11:27:13
??
how about you just add this to before line 87:
ssid
2015/10/15 11:39:30
Yes, sounds good.
|
| + continue; |
| + } |
| + |
| for (size_t i = 0; i < page_count; i++) |
| resident_page_count += vec[i]; |
| #endif // defined(OS_MACOSX) || defined(OS_IOS) |