Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | |
michael@0 | 3 | # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. |
michael@0 | 4 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | # found in the LICENSE file. |
michael@0 | 6 | |
michael@0 | 7 | """ |
michael@0 | 8 | A clone of 'pmap' utility on Linux, 'vmmap' on OSX and 'procstat -v' on BSD. |
michael@0 | 9 | Report memory map of a process. |
michael@0 | 10 | """ |
michael@0 | 11 | |
michael@0 | 12 | import sys |
michael@0 | 13 | |
michael@0 | 14 | import psutil |
michael@0 | 15 | from psutil._compat import print_ |
michael@0 | 16 | |
michael@0 | 17 | def main(): |
michael@0 | 18 | if len(sys.argv) != 2: |
michael@0 | 19 | sys.exit('usage: pmap pid') |
michael@0 | 20 | p = psutil.Process(int(sys.argv[1])) |
michael@0 | 21 | print_("pid=%s, name=%s" % (p.pid, p.name)) |
michael@0 | 22 | templ = "%-16s %10s %-7s %s" |
michael@0 | 23 | print_(templ % ("Address", "RSS", "Mode", "Mapping")) |
michael@0 | 24 | total_rss = 0 |
michael@0 | 25 | for m in p.get_memory_maps(grouped=False): |
michael@0 | 26 | total_rss += m.rss |
michael@0 | 27 | print_(templ % (m.addr.split('-')[0].zfill(16), |
michael@0 | 28 | str(m.rss / 1024) + 'K' , |
michael@0 | 29 | m.perms, |
michael@0 | 30 | m.path)) |
michael@0 | 31 | print_("-" * 33) |
michael@0 | 32 | print_(templ % ("Total", str(total_rss / 1024) + 'K', '', '')) |
michael@0 | 33 | |
michael@0 | 34 | if __name__ == '__main__': |
michael@0 | 35 | main() |