@@ -50,10 +50,11 @@ def __sub__(self, other):
50
50
if isinstance (other , int ):
51
51
return self .__add__ (- other )
52
52
else :
53
- return int ((self .value .unsigned - other .value .unsigned ) / sizeof (self .normal_type .__name__ ))
53
+ return int ((self .value .unsigned - other .value .unsigned )
54
+ / sizeof (self .normal_type .__name__ ))
54
55
55
56
def __eq__ (self , other ):
56
- assert isinstance (other , Ptr ) or ( isinstance (other , int ) and other >= 0 )
57
+ assert isinstance (other , Ptr ) or isinstance (other , int ) and other >= 0
57
58
if isinstance (other , Ptr ):
58
59
return self .value .unsigned == other .value .unsigned
59
60
else :
@@ -126,19 +127,22 @@ def addr(self):
126
127
127
128
c_structs = {
128
129
'MRef' : [
129
- (property (lambda self : self ['ptr64' ].unsigned if LJ_GC64 else self ['ptr32' ].unsigned ), 'ptr' )
130
+ (property (lambda self : self ['ptr64' ].unsigned if LJ_GC64
131
+ else self ['ptr32' ].unsigned ), 'ptr' )
130
132
],
131
133
'GCRef' : [
132
- (property (lambda self : self ['gcptr64' ].unsigned if LJ_GC64 else self ['gcptr32' ].unsigned ), 'gcptr' )
134
+ (property (lambda self : self ['gcptr64' ].unsigned if LJ_GC64
135
+ else self ['gcptr32' ].unsigned ), 'gcptr' )
133
136
],
134
137
'TValue' : [
135
138
('GCRef' , 'gcr' ),
136
139
('uint' , 'it' ),
137
140
('uint' , 'i' ),
138
141
('int' , 'it64' ),
139
142
('string' , 'n' ),
140
- (property (lambda self : self ['ftsz' ].signed if LJ_GC64 else None ), 'ftsz' ),
141
- (property (lambda self : FR (self ['fr' ]) if not LJ_GC64 else None ), 'fr' )
143
+ (property (lambda self : FR (self ['fr' ]) if not LJ_GC64 else None ), 'fr' ),
144
+ (property (lambda self : self ['ftsz' ].signed if LJ_GC64 else None ),
145
+ 'ftsz' )
142
146
],
143
147
'GCState' : [
144
148
('GCRef' , 'root' ),
@@ -223,16 +227,10 @@ def addr(self):
223
227
for cls in Struct .__subclasses__ ():
224
228
ptr_name = cls .__name__ + 'Ptr'
225
229
226
- def make_ptr_init (nm , cls ):
227
- return type (
228
- nm ,
229
- (Ptr ,),
230
- {
231
- '__init__' : lambda self , value : super (type (self ), self ).__init__ (value , cls )
232
- }
233
- )
234
-
235
- globals ()[ptr_name ] = make_ptr_init (ptr_name , cls )
230
+ globals ()[ptr_name ] = type (ptr_name , (Ptr ,), {
231
+ '__init__' :
232
+ lambda self , value : super (type (self ), self ).__init__ (value , cls )
233
+ })
236
234
237
235
238
236
class Command (object ):
@@ -590,9 +588,9 @@ def dump_lj_tfunc(tv):
590
588
591
589
if ffid == 0 :
592
590
pt = funcproto (func )
593
- return 'Lua function @ {addr}, {nupvals } upvalues, {chunk}:{line}' .format (
591
+ return 'Lua function @ {addr}, {nups } upvalues, {chunk}:{line}' .format (
594
592
addr = strx64 (func ),
595
- nupvals = func .nupvalues ,
593
+ nups = func .nupvalues ,
596
594
chunk = strdata (cast (GCstrPtr , gcval (pt .chunkname ))),
597
595
line = pt .firstline
598
596
)
@@ -737,7 +735,8 @@ def frame_prevl(framelink):
737
735
# a struct member of 32-bit type to 64-bit type without getting onto
738
736
# the next property bits, despite the fact that it's an actual value, not
739
737
# a pointer to it.
740
- return framelink - (1 + LJ_FR2 + bc_a (vtou64 (dbg_eval ('((BCIns *)' + str (frame_pc (framelink )) + ')[-1]' ))))
738
+ bcins = vtou64 (dbg_eval ('((BCIns *)' + str (frame_pc (framelink )) + ')[-1]' ))
739
+ return framelink - (1 + LJ_FR2 + bc_a (bcins ))
741
740
742
741
743
742
def frame_ispcall (framelink ):
@@ -852,10 +851,15 @@ def dump_stack(L, base=None, top=None):
852
851
nstackslots = int ((maxstack - stack ) >> 3 ),
853
852
),
854
853
dump_stack_slot (L , maxstack , base , top ),
855
- '{start:{padding}}:{end:{padding}} [ ] {nfreeslots} slots: Free stack slots' .format (
856
- start = strx64 (top + 1 ),
857
- end = strx64 (maxstack - 1 ),
858
- padding = len (PADDING ),
854
+ '{start}:{end} [ ] {nfreeslots} slots: Free stack slots' .format (
855
+ start = '{address:{padding}}' .format (
856
+ address = strx64 (top + 1 ),
857
+ padding = len (PADDING ),
858
+ ),
859
+ end = '{address:{padding}}' .format (
860
+ address = strx64 (maxstack - 1 ),
861
+ padding = len (PADDING ),
862
+ ),
859
863
nfreeslots = int ((maxstack - top - 8 ) >> 3 ),
860
864
),
861
865
])
@@ -1075,9 +1079,10 @@ def register_commands(debugger, commands):
1075
1079
for command , cls in commands .items ():
1076
1080
cls .command = command
1077
1081
debugger .HandleCommand (
1078
- 'command script add --overwrite --class luajit_lldb.{cls} {command}' .format (
1082
+ 'command script add --overwrite --class luajit_lldb.{cls} {cmd}'
1083
+ .format (
1079
1084
cls = cls .__name__ ,
1080
- command = cls .command ,
1085
+ cmd = cls .command ,
1081
1086
)
1082
1087
)
1083
1088
print ('{cmd} command intialized' .format (cmd = cls .command ))
0 commit comments