forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit.py
50 lines (36 loc) · 1.15 KB
/
unit.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
"""
Set the target Unit; used implicitly by some other commands.
"""
from compatibility import *
import gdb
from gdbutils import *
#------------------------------------------------------------------------------
curunit = None
class UnitCommand(gdb.Command):
"""Set the current translation unit.
Use `unit none` to unset. Just `unit` displays the current Unit.
"""
def __init__(self):
super(UnitCommand, self).__init__('unit', gdb.COMMAND_DATA,
gdb.COMPLETE_NONE, True)
@errorwrap
def invoke(self, args, from_tty):
argv = gdb.string_to_argv(args)
global curunit
if len(argv) == 0:
if curunit is None:
print('unit: No Unit set.')
else:
gdbprint(curunit)
return
if len(argv) > 1:
print('Usage: unit [Unit*|none]')
return
if argv[0] == 'none':
curunit = None
return
else:
unit_type = T('HPHP::Unit').const().pointer()
curunit = gdb.parse_and_eval(argv[0]).cast(unit_type)
gdbprint(curunit)
UnitCommand()