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

Side by Side Diff: tools/find_runtime_symbols/proc_maps.py

Issue 10825075: Classify memory usage by allocated type in Deep Memory Profiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # 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
4 # found in the LICENSE file. 3 # found in the LICENSE file.
5 4
6 import re 5 import re
7 import sys 6 import sys
8 7
9 8
10 _MAPS_PATTERN = re.compile( 9 _MAPS_PATTERN = re.compile(
11 '^([a-f0-9]+)-([a-f0-9]+)\s+(.)(.)(.)(.)\s+([a-f0-9]+)\s+(\S+):(\S+)\s+' 10 '^([a-f0-9]+)-([a-f0-9]+)\s+(.)(.)(.)(.)\s+([a-f0-9]+)\s+(\S+):(\S+)\s+'
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 if not condition or condition(self._dictionary[index]): 52 if not condition or condition(self._dictionary[index]):
54 yield self._dictionary[index] 53 yield self._dictionary[index]
55 54
56 def __iter__(self): 55 def __iter__(self):
57 if not self._sorted: 56 if not self._sorted:
58 self._sorted_indexes.sort() 57 self._sorted_indexes.sort()
59 self._sorted = True 58 self._sorted = True
60 for index in self._sorted_indexes: 59 for index in self._sorted_indexes:
61 yield self._dictionary[index] 60 yield self._dictionary[index]
62 61
62 @staticmethod
63 def load(f):
64 table = ProcMaps()
65 for line in f:
66 matched = _MAPS_PATTERN.match(line)
67 if matched:
68 table.append(ProcMapsEntry(
69 int(matched.group(1), 16), # begin
70 int(matched.group(2), 16), # end
71 matched.group(3), # readable
72 matched.group(4), # writable
73 matched.group(5), # executable
74 matched.group(6), # private
75 int(matched.group(7), 16), # offset
76 matched.group(8), # major
77 matched.group(9), # minor
78 int(matched.group(10), 10), # inode
79 matched.group(11) # name
80 ))
63 81
64 def parse_proc_maps(f): 82 return table
65 table = ProcMaps()
66 for line in f:
67 matched = _MAPS_PATTERN.match(line)
68 if matched:
69 table.append(ProcMapsEntry(
70 int(matched.group(1), 16), # begin
71 int(matched.group(2), 16), # end
72 matched.group(3), # readable
73 matched.group(4), # writable
74 matched.group(5), # executable
75 matched.group(6), # private
76 int(matched.group(7), 16), # offset
77 matched.group(8), # major
78 matched.group(9), # minor
79 int(matched.group(10), 10), # inode
80 matched.group(11) # name
81 ))
82 83
83 return table 84 @staticmethod
85 def constants(entry):
86 return (entry.writable == '-' and entry.executable == '-' and re.match(
87 '\S+(\.(so|dll|dylib|bundle)|chrome)((\.\d+)+\w*(\.\d+){0,3})?',
88 entry.name))
84 89
90 @staticmethod
91 def executable(entry):
92 return (entry.executable == 'x' and re.match(
93 '\S+(\.(so|dll|dylib|bundle)|chrome)((\.\d+)+\w*(\.\d+){0,3})?',
94 entry.name))
85 95
86 def main(): 96 @staticmethod
87 if len(sys.argv) < 2: 97 def executable_and_constants(entry):
88 sys.stderr.write("""Usage: 98 return (((entry.writable == '-' and entry.executable == '-') or
89 %s /path/to/maps 99 entry.executable == 'x') and re.match(
90 """ % sys.argv[0]) 100 '\S+(\.(so|dll|dylib|bundle)|chrome)((\.\d+)+\w*(\.\d+){0,3})?',
91 return 1 101 entry.name))
92
93 with open(sys.argv[1], mode='r') as f:
94 maps = parse_proc_maps(f)
95
96 for entry in maps:
97 print "%016x-%016x +%06x %s" % (
98 entry.begin, entry.end, entry.offset, entry.name)
99
100 return 0
101
102
103 if __name__ == '__main__':
104 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/find_runtime_symbols/prepare_symbol_info.py ('k') | tools/find_runtime_symbols/static_symbols.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698