-
Notifications
You must be signed in to change notification settings - Fork 20
/
HeapInspect.py
executable file
·56 lines (53 loc) · 1.38 KB
/
HeapInspect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import argparse
from heapinspect.core import *
if __name__ == '__main__':
parser = argparse.ArgumentParser(
prog='HeapInspect.py',
description='''Inspect your heap by a given pid.
Author:matrix1001
Github:https://github.com/matrix1001/heapinspect''')
parser.add_argument(
'--raw',
action='store_true',
help='show more detailed chunk info'
)
parser.add_argument(
'--rela',
action='store_true',
help='show relative detailed chunk info'
)
parser.add_argument(
'pid',
type=int,
help='pid of the process'
)
parser.add_argument(
'-x',
action='store_false',
help='''ignore: heapchunks'''
)
args = parser.parse_args()
pid = args.pid
hi = HeapInspector(pid)
if args.rela:
hs = HeapShower(hi)
hs.relative = True
if args.x:
print(hs.heap_chunks)
print(hs.fastbins)
print(hs.unsortedbins)
print(hs.smallbins)
print(hs.largebins)
print(hs.tcache_chunks)
elif args.raw:
hs = HeapShower(hi)
if args.x:
print(hs.heap_chunks)
print(hs.fastbins)
print(hs.unsortedbins)
print(hs.smallbins)
print(hs.largebins)
print(hs.tcache_chunks)
else:
pp = PrettyPrinter(hi)
print(pp.all)