OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # A Python library to read and store procfs (/proc) information on Linux. | 6 # A Python library to read and store procfs (/proc) information on Linux. |
7 # | 7 # |
8 # Each information storage class in this file stores original data as original | 8 # Each information storage class in this file stores original data as original |
9 # as reasonablly possible. Translation is done when requested. It is to make it | 9 # as reasonablly possible. Translation is done when requested. It is to make it |
10 # always possible to probe the original data. | 10 # always possible to probe the original data. |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 class ProcMaps(object): | 306 class ProcMaps(object): |
307 """Reads and stores information in /proc/pid/maps.""" | 307 """Reads and stores information in /proc/pid/maps.""" |
308 | 308 |
309 MAPS_PATTERN = re.compile( | 309 MAPS_PATTERN = re.compile( |
310 r'^([a-f0-9]+)-([a-f0-9]+)\s+(.)(.)(.)(.)\s+([a-f0-9]+)\s+(\S+):(\S+)\s+' | 310 r'^([a-f0-9]+)-([a-f0-9]+)\s+(.)(.)(.)(.)\s+([a-f0-9]+)\s+(\S+):(\S+)\s+' |
311 r'(\d+)\s*(.*)$', re.IGNORECASE) | 311 r'(\d+)\s*(.*)$', re.IGNORECASE) |
312 | 312 |
313 EXECUTABLE_PATTERN = re.compile( | |
314 r'\S+\.(so|dll|dylib|bundle)((\.\d+)+\w*(\.\d+){0,3})?') | |
wensheng
2014/08/30 03:29:48
Dmprof may not support content shell as the modifi
Dai Mikurube (NOT FULLTIME)
2014/09/02 15:11:15
Please take a look in prepare_symbol_info.py. It n
| |
315 | |
313 def __init__(self): | 316 def __init__(self): |
314 self._sorted_indexes = [] | 317 self._sorted_indexes = [] |
315 self._dictionary = {} | 318 self._dictionary = {} |
316 self._sorted = True | 319 self._sorted = True |
317 | 320 |
318 def iter(self, condition): | 321 def iter(self, condition): |
319 if not self._sorted: | 322 if not self._sorted: |
320 self._sorted_indexes.sort() | 323 self._sorted_indexes.sort() |
321 self._sorted = True | 324 self._sorted = True |
322 for index in self._sorted_indexes: | 325 for index in self._sorted_indexes: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 matched.group(8), # major | 369 matched.group(8), # major |
367 matched.group(9), # minor | 370 matched.group(9), # minor |
368 int(matched.group(10), 10), # inode | 371 int(matched.group(10), 10), # inode |
369 matched.group(11) # name | 372 matched.group(11) # name |
370 ) | 373 ) |
371 else: | 374 else: |
372 return None | 375 return None |
373 | 376 |
374 @staticmethod | 377 @staticmethod |
375 def constants(entry): | 378 def constants(entry): |
376 return (entry.writable == '-' and entry.executable == '-' and re.match( | 379 return entry.writable == '-' and entry.executable == '-' |
377 '\S+(\.(so|dll|dylib|bundle)|chrome)((\.\d+)+\w*(\.\d+){0,3})?', | |
378 entry.name)) | |
379 | 380 |
380 @staticmethod | 381 @staticmethod |
381 def executable(entry): | 382 def executable(entry): |
382 return (entry.executable == 'x' and re.match( | 383 return entry.executable == 'x' |
383 '\S+(\.(so|dll|dylib|bundle)|chrome)((\.\d+)+\w*(\.\d+){0,3})?', | |
384 entry.name)) | |
385 | 384 |
386 @staticmethod | 385 @staticmethod |
387 def executable_and_constants(entry): | 386 def executable_and_constants(entry): |
388 return (((entry.writable == '-' and entry.executable == '-') or | 387 return ((entry.writable == '-' and entry.executable == '-') or |
389 entry.executable == 'x') and re.match( | 388 entry.executable == 'x') |
390 '\S+(\.(so|dll|dylib|bundle)|chrome)((\.\d+)+\w*(\.\d+){0,3})?', | |
391 entry.name)) | |
392 | 389 |
393 def _append_entry(self, entry): | 390 def _append_entry(self, entry): |
394 if self._sorted_indexes and self._sorted_indexes[-1] > entry.begin: | 391 if self._sorted_indexes and self._sorted_indexes[-1] > entry.begin: |
395 self._sorted = False | 392 self._sorted = False |
396 self._sorted_indexes.append(entry.begin) | 393 self._sorted_indexes.append(entry.begin) |
397 self._dictionary[entry.begin] = entry | 394 self._dictionary[entry.begin] = entry |
398 | 395 |
399 | 396 |
400 class ProcSmaps(object): | 397 class ProcSmaps(object): |
401 """Reads and stores information in /proc/pid/smaps.""" | 398 """Reads and stores information in /proc/pid/smaps.""" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 print ' status: %d (Peak:%d)' % (procs[pid].status.vm_rss * 1024, | 738 print ' status: %d (Peak:%d)' % (procs[pid].status.vm_rss * 1024, |
742 procs[pid].status.vm_hwm * 1024) | 739 procs[pid].status.vm_hwm * 1024) |
743 print ' smaps: %d' % (procs[pid].smaps.rss * 1024) | 740 print ' smaps: %d' % (procs[pid].smaps.rss * 1024) |
744 print 'pagemap: %d' % procs[pid].pagemap.present | 741 print 'pagemap: %d' % procs[pid].pagemap.present |
745 | 742 |
746 return 0 | 743 return 0 |
747 | 744 |
748 | 745 |
749 if __name__ == '__main__': | 746 if __name__ == '__main__': |
750 sys.exit(main(sys.argv)) | 747 sys.exit(main(sys.argv)) |
OLD | NEW |