Chromium Code Reviews| Index: tools/memory_inspector/memory_inspector/backends/android/memdump_parser.py |
| diff --git a/tools/memory_inspector/memory_inspector/backends/android/memdump_parser.py b/tools/memory_inspector/memory_inspector/backends/android/memdump_parser.py |
| index 0bb7004a54ac321a298287ce89620a871531377b..5c5e0a1360b35b492f5ac197192d52af9cff8d79 100644 |
| --- a/tools/memory_inspector/memory_inspector/backends/android/memdump_parser.py |
| +++ b/tools/memory_inspector/memory_inspector/backends/android/memdump_parser.py |
| @@ -42,7 +42,8 @@ def Parse(lines): |
| An instance of |memory_map.Map|. |
| """ |
| RE = (r'^([0-9a-f]+)-([0-9a-f]+)\s+' |
| - r'([rwxps-]{4})\s*.*?' |
| + r'([rwxps-]{4})\s+' |
| + r'([0-9a-f]+)\s+' |
| r'private_unevictable=(\d+) private=(\d+) ' |
| r'shared_app=(.*?) ' |
| r'shared_other_unevictable=(\d+) shared_other=(\d+) ' |
| @@ -64,20 +65,21 @@ def Parse(lines): |
| logging.warning('Skipping unrecognized memdump line "%s"' % line) |
| continue |
| - # TODO(primiano): proper offset handling requires a change in memdump. In |
| - # the meanwhile, it should pretty safe assuming zero-offset for libs (for |
| - # symbolization). Also, offsets for other mappings don't really matter. |
| + start = int(m.group(1), 16) |
| + end = int(m.group(2), 16) - 1 # end addr is inclusive in memdump output. |
| + if (start > end): |
| + continue # Sadly, this happened. Probably a kernel bug, see b/17402069. |
|
Sami
2014/09/09 10:44:26
Should we log a warning?
Primiano Tucci (use gerrit)
2014/09/09 11:11:38
Yeah, probably it's a good idea.
|
| entry = memory_map.MapEntry( |
| - start=int(m.group(1), 16), |
| - end=int(m.group(2), 16) - 1, # end addr is inclusive in memdump output. |
| + start=start, |
| + end=end, |
| prot_flags=m.group(3), |
| - mapped_file=m.group(9), |
| - mapped_offset=0) |
| - entry.priv_dirty_bytes = int(m.group(4)) |
| - entry.priv_clean_bytes = int(m.group(5)) - entry.priv_dirty_bytes |
| - entry.shared_dirty_bytes = int(m.group(7)) |
| - entry.shared_clean_bytes = int(m.group(8)) - entry.shared_dirty_bytes |
| - entry.resident_pages = [ord(c) for c in base64.b64decode(m.group(10))] |
| + mapped_file=m.group(10), |
| + mapped_offset=int(m.group(4), 16)) |
| + entry.priv_dirty_bytes = int(m.group(5)) |
| + entry.priv_clean_bytes = int(m.group(6)) - entry.priv_dirty_bytes |
| + entry.shared_dirty_bytes = int(m.group(8)) |
| + entry.shared_clean_bytes = int(m.group(9)) - entry.shared_dirty_bytes |
| + entry.resident_pages = [ord(c) for c in base64.b64decode(m.group(11))] |
|
Sami
2014/09/09 10:44:26
Having 11 groups in a regex is probably an argumen
Primiano Tucci (use gerrit)
2014/09/09 11:11:39
Hmm suggestions for alternatives? I can't simply t
Sami
2014/09/09 11:16:20
Maybe shlex?
|
| maps.Add(entry) |
| return maps |