5
5
# This source code is licensed under the MIT license found in the
6
6
# LICENSE file in the root directory of this source tree.
7
7
8
+ # Can be removed when Python 2 support is removed.
9
+ from __future__ import print_function
10
+
8
11
import lldb
9
12
import fblldbbase as fb
10
13
import fblldbobjcruntimehelpers as objc
@@ -58,9 +61,9 @@ def run(self, arguments, options):
58
61
watchpoint = lldb .debugger .GetSelectedTarget ().WatchAddress (objectAddress + ivarOffset , ivarSize , False , True , error )
59
62
60
63
if error .Success ():
61
- print 'Remember to delete the watchpoint using: watchpoint delete {}' .format (watchpoint .GetID ())
64
+ print ( 'Remember to delete the watchpoint using: watchpoint delete {}' .format (watchpoint .GetID () ))
62
65
else :
63
- print 'Could not create the watchpoint: {}' .format (error .GetCString ())
66
+ print ( 'Could not create the watchpoint: {}' .format (error .GetCString () ))
64
67
65
68
class FBFrameworkAddressBreakpointCommand (fb .FBCommand ):
66
69
def name (self ):
@@ -108,12 +111,12 @@ def run(self, arguments, options):
108
111
match = methodPattern .match (expression )
109
112
110
113
if not match :
111
- print 'Failed to parse expression. Do you even Objective-C?!'
114
+ print ( 'Failed to parse expression. Do you even Objective-C?!' )
112
115
return
113
116
114
117
expressionForSelf = objc .functionPreambleExpressionForSelf ()
115
118
if not expressionForSelf :
116
- print 'Your architecture, {}, is truly fantastic. However, I don\' t currently support it.' .format (arch )
119
+ print ( 'Your architecture, {}, is truly fantastic. However, I don\' t currently support it.' .format (arch ) )
117
120
return
118
121
119
122
methodTypeCharacter = match .group ('scope' )
@@ -139,7 +142,7 @@ def run(self, arguments, options):
139
142
targetClass = fb .evaluateObjectExpression ('[{} class]' .format (targetObject ), False )
140
143
141
144
if not targetClass or int (targetClass , 0 ) == 0 :
142
- print 'Couldn\' t find a class from the expression "{}". Did you typo?' .format (classNameOrExpression )
145
+ print ( 'Couldn\' t find a class from the expression "{}". Did you typo?' .format (classNameOrExpression ) )
143
146
return
144
147
145
148
if methodIsClassMethod :
@@ -155,7 +158,7 @@ def run(self, arguments, options):
155
158
nextClass = objc .class_getSuperclass (nextClass )
156
159
157
160
if not found :
158
- print 'There doesn\' t seem to be an implementation of {} in the class hierarchy. Made a boo boo with the selector name?' .format (selector )
161
+ print ( 'There doesn\' t seem to be an implementation of {} in the class hierarchy. Made a boo boo with the selector name?' .format (selector ) )
159
162
return
160
163
161
164
breakpointClassName = objc .class_getName (nextClass )
@@ -167,7 +170,7 @@ def run(self, arguments, options):
167
170
else :
168
171
breakpointCondition = '(void*){} == {}' .format (expressionForSelf , targetObject )
169
172
170
- print 'Setting a breakpoint at {} with condition {}' .format (breakpointFullName , breakpointCondition )
173
+ print ( 'Setting a breakpoint at {} with condition {}' .format (breakpointFullName , breakpointCondition ) )
171
174
172
175
if category :
173
176
lldb .debugger .HandleCommand ('breakpoint set --skip-prologue false --fullname "{}" --condition "{}"' .format (breakpointFullName , breakpointCondition ))
@@ -205,11 +208,11 @@ def switchBreakpointState(expression,on):
205
208
target = lldb .debugger .GetSelectedTarget ()
206
209
for breakpoint in target .breakpoint_iter ():
207
210
if breakpoint .IsEnabled () != on and (expression_pattern .search (str (breakpoint ))):
208
- print str (breakpoint )
211
+ print ( str (breakpoint ) )
209
212
breakpoint .SetEnabled (on )
210
213
for location in breakpoint :
211
214
if location .IsEnabled () != on and (expression_pattern .search (str (location )) or expression == hex (location .GetAddress ()) ):
212
- print str (location )
215
+ print ( str (location ) )
213
216
location .SetEnabled (on )
214
217
215
218
class FBMethodBreakpointEnableCommand (fb .FBCommand ):
@@ -330,7 +333,7 @@ def run(self, arguments, options):
330
333
return
331
334
332
335
if len (arguments ) == 0 or not arguments [0 ].strip ():
333
- print 'Usage: findinstances <classOrProtocol> [<predicate>]; Run `help findinstances`'
336
+ print ( 'Usage: findinstances <classOrProtocol> [<predicate>]; Run `help findinstances`' )
334
337
return
335
338
336
339
query = arguments [0 ]
@@ -348,7 +351,7 @@ def loadChiselIfNecessary(self):
348
351
349
352
path = self .chiselLibraryPath ()
350
353
if not os .path .exists (path ):
351
- print 'Chisel library missing: ' + path
354
+ print ( 'Chisel library missing: ' + path )
352
355
return False
353
356
354
357
module = fb .evaluateExpressionValue ('(void*)dlopen("{}", 2)' .format (path ))
@@ -361,17 +364,17 @@ def loadChiselIfNecessary(self):
361
364
error = fb .evaluateExpressionValue ('(char*)dlerror()' )
362
365
if errno == 50 :
363
366
# KERN_CODESIGN_ERROR from <mach/kern_return.h>
364
- print 'Error loading Chisel: Code signing failure; Must re-run codesign'
367
+ print ( 'Error loading Chisel: Code signing failure; Must re-run codesign' )
365
368
elif error .unsigned != 0 :
366
- print 'Error loading Chisel: ' + error .summary
369
+ print ( 'Error loading Chisel: ' + error .summary )
367
370
elif errno != 0 :
368
371
error = fb .evaluateExpressionValue ('(char*)strerror({})' .format (errno ))
369
372
if error .unsigned != 0 :
370
- print 'Error loading Chisel: ' + error .summary
373
+ print ( 'Error loading Chisel: ' + error .summary )
371
374
else :
372
- print 'Error loading Chisel (errno {})' .format (errno )
375
+ print ( 'Error loading Chisel (errno {})' .format (errno ) )
373
376
else :
374
- print 'Unknown error loading Chisel'
377
+ print ( 'Unknown error loading Chisel' )
375
378
376
379
return False
377
380
@@ -428,9 +431,9 @@ def isHeap(addr):
428
431
429
432
allocations = (addr for addr in pointers if isHeap (addr ))
430
433
for addr in allocations :
431
- print >> self . result , '0x{addr:x} {path}' .format (addr = addr , path = pointers [addr ])
434
+ print ( '0x{addr:x} {path}' .format (addr = addr , path = pointers [addr ]), file = self . result )
432
435
if not allocations :
433
- print >> self . result , "No heap addresses found"
436
+ print ( "No heap addresses found" , file = self . result )
434
437
435
438
436
439
class FBSequenceCommand (fb .FBCommand ):
@@ -453,17 +456,17 @@ def run(self, arguments, options):
453
456
454
457
# Complete one command before running the next one in the sequence. Disable
455
458
# async to do this. Also, save the current async value to restore it later.
456
- async = lldb .debugger .GetAsync ()
459
+ asyncFlag = lldb .debugger .GetAsync ()
457
460
lldb .debugger .SetAsync (False )
458
461
459
462
for command in commands [:- 1 ]:
460
463
success = self .run_command (interpreter , command )
461
464
if not success :
462
- lldb .debugger .SetAsync (async )
465
+ lldb .debugger .SetAsync (asyncFlag )
463
466
return
464
467
465
468
# Restore original async value.
466
- lldb .debugger .SetAsync (async )
469
+ lldb .debugger .SetAsync (asyncFlag )
467
470
468
471
# If the last command is `continue`, call Continue() on the process
469
472
# instead. This is done because HandleCommand('continue') has strange
@@ -478,7 +481,7 @@ def run_command(self, interpreter, command):
478
481
ret = lldb .SBCommandReturnObject ()
479
482
interpreter .HandleCommand (command , ret )
480
483
if ret .GetOutput ():
481
- print >> self . result , ret .GetOutput ().strip ()
484
+ print ( ret .GetOutput ().strip (), file = self . result )
482
485
483
486
if ret .Succeeded ():
484
487
return True
0 commit comments