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