def _visualize(target): target = '(' + target + ')' if fb.evaluateBooleanExpression('(unsigned long)CFGetTypeID((CFTypeRef)' + target + ') == (unsigned long)CGImageGetTypeID()'): _showImage('(id)[UIImage imageWithCGImage:' + target + ']') else: if objectHelpers.isKindOfClass(target, 'UIImage'): _showImage(target) elif objectHelpers.isKindOfClass(target, 'UIView'): _showLayer('[(id)' + target + ' layer]') elif objectHelpers.isKindOfClass(target, 'CALayer'): _showLayer(target) elif objectHelpers.isKindOfClass(target, 'NSData'): if _dataIsImage(target): _showImage('(id)[UIImage imageWithData:' + target + ']') elif _dataIsString(target): lldb.debugger.HandleCommand( 'po (NSString*)[[NSString alloc] initWithData:' + target + ' encoding:4]') else: print 'Data isn\'t an image and isn\'t a string.' else: print '{} isn\'t supported. You can visualize UIImage, CGImageRef, UIView, CALayer or NSData.'.format( objectHelpers.className(target))
def _copy(target, preferredFilename, noOpen): target = '(' + target + ')' if objectHelpers.isKindOfClass(target, 'NSURL'): _copyFromURL(target, preferredFilename, noOpen) elif objectHelpers.isKindOfClass(target, 'NSData'): _copyFromData( target, time.strftime("%Y-%m-%d-%H-%M-%S", time.gmtime()) + ".data", preferredFilename, noOpen) else: print('{} isn\'t supported. You can copy an NSURL or NSData.'.format( objectHelpers.className(target)))
def _visualize(target): target = '(' + target + ')' if fb.evaluateBooleanExpression('(unsigned long)CFGetTypeID((CFTypeRef)' + target + ') == (unsigned long)CGImageGetTypeID()'): _showImage('(id)[UIImage imageWithCGImage:' + target + ']') else: if objectHelpers.isKindOfClass(target, 'UIImage'): _showImage(target) elif objectHelpers.isKindOfClass(target, 'UIView'): _showLayer('[(id)' + target + ' layer]') elif objectHelpers.isKindOfClass(target, 'CALayer'): _showLayer(target) else: print '{} is not supported. You can visualize UIImage, CGImageRef, UIView, or CALayer.'.format(objectHelpers.className(target))
def _showColor(color): color = '(' + color + ')' colorToUse = color isCF = _colorIsCGColorRef(color) if isCF: colorToUse = '[[UIColor alloc] initWithCGColor:(CGColorRef){}]'.format( color) else: isCI = objectHelpers.isKindOfClass(color, 'CIColor') if isCI: colorToUse = '[UIColor colorWithCIColor:(CIColor *){}]'.format( color) imageSize = 58 fb.evaluateEffect( 'UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)' .format(imageSize=imageSize)) fb.evaluateEffect('[(id){} setFill]'.format(colorToUse)) fb.evaluateEffect( 'UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))'. format(imageSize=imageSize)) result = fb.evaluateExpressionValue( '(UIImage *)UIGraphicsGetImageFromCurrentImageContext()') if result.GetError() is not None and str(result.GetError()) != 'success': print("got error {}".format(result)) print(result.GetError()) else: image = result.GetValue() _showImage(image) fb.evaluateEffect('UIGraphicsEndImageContext()')
def _showColor(color): color = '(' + color + ')' colorToUse = color isCF = _colorIsCGColorRef(color) if isCF: colorToUse = '[[UIColor alloc] initWithCGColor:(CGColorRef){}]'.format(color) else: isCI = objectHelpers.isKindOfClass(color, 'CIColor') if isCI: colorToUse = '[UIColor colorWithCIColor:(CIColor *){}]'.format(color) imageSize = 58 lldb.debugger.HandleCommand('eobjc (void)UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)'.format(imageSize=imageSize)) lldb.debugger.HandleCommand('eobjc (void)[(id){} setFill]'.format(colorToUse)) lldb.debugger.HandleCommand('eobjc (void)UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))'.format(imageSize=imageSize)) frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame() result = frame.EvaluateExpression('(UIImage *)UIGraphicsGetImageFromCurrentImageContext()') if result.GetError() is not None and str(result.GetError()) != 'success': print("got error {}".format(result)) print(result.GetError()) else: image = result.GetValue() _showImage(image) lldb.debugger.HandleCommand('eobjc (void)UIGraphicsEndImageContext()')
def _showColor(color): color = '(' + color + ')' colorToUse = color isCF = _colorIsCGColorRef(color) if isCF: colorToUse = '[[UIColor alloc] initWithCGColor:(CGColorRef){}]'.format(color) else: isCI = objectHelpers.isKindOfClass(color, 'CIColor') if isCI: colorToUse = '[UIColor colorWithCIColor:(CIColor *){}]'.format(color) imageSize = 58 lldb.debugger.HandleCommand('expr (void)UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)'.format(imageSize=imageSize)) lldb.debugger.HandleCommand('expr (void)[(id){} setFill]'.format(colorToUse)) lldb.debugger.HandleCommand('expr (void)UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))'.format(imageSize=imageSize)) frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame() result = frame.EvaluateExpression('(UIImage *)UIGraphicsGetImageFromCurrentImageContext()') if result.GetError() is not None and str(result.GetError()) != 'success': print "got error {}".format(result) print result.GetError() else: image = result.GetValue() _showImage(image) lldb.debugger.HandleCommand('expr (void)UIGraphicsEndImageContext()')
def _visualize(target): target = '(' + target + ')' if fb.evaluateBooleanExpression('(unsigned long)CFGetTypeID((CFTypeRef)' + target + ') == (unsigned long)CGImageGetTypeID()'): _showImage('(id)[UIImage imageWithCGImage:' + target + ']') else: if objectHelpers.isKindOfClass(target, 'UIImage'): _showImage(target) elif objectHelpers.isKindOfClass(target, 'UIView'): _showLayer('[(id)' + target + ' layer]') elif objectHelpers.isKindOfClass(target, 'CALayer'): _showLayer(target) elif objectHelpers.isKindOfClass(target, 'NSData'): if _dataIsImage(target): _showImage('(id)[UIImage imageWithData:' + target + ']'); elif _dataIsString(target): lldb.debugger.HandleCommand('po (NSString*)[[NSString alloc] initWithData:' + target + ' encoding:4]') else: print 'Data isn\'t an image and isn\'t a string'; else: print '{} is not supported. You can visualize UIImage, CGImageRef, UIView, CALayer or NSData.'.format(objectHelpers.className(target))
def _visualize(target): target = fb.evaluateInputExpression(target) if fb.evaluateBooleanExpression('(unsigned long)CFGetTypeID((CFTypeRef)' + target + ') == (unsigned long)CGImageGetTypeID()'): _showImage('(id)[UIImage imageWithCGImage:' + target + ']') else: if objectHelpers.isKindOfClass(target, 'UIImage'): _showImage(target) elif objectHelpers.isKindOfClass(target, 'UIView'): _showLayer('[(id)' + target + ' layer]') elif objectHelpers.isKindOfClass(target, 'CALayer'): _showLayer(target) elif objectHelpers.isKindOfClass( target, 'UIColor') or objectHelpers.isKindOfClass( target, 'CIColor') or _colorIsCGColorRef(target): _showColor(target) elif objectHelpers.isKindOfClass(target, 'NSData'): if _dataIsImage(target): _showImage('(id)[UIImage imageWithData:' + target + ']') elif _dataIsString(target): print( fb.describeObject('[[NSString alloc] initWithData:' + target + ' encoding:4]')) else: print('Data isn\'t an image and isn\'t a string.') else: print( '{} isn\'t supported. You can visualize UIImage, CGImageRef, UIView, CALayer, NSData, UIColor, CIColor, or CGColorRef.' .format(objectHelpers.className(target)))
def _visualize(target): target = fb.evaluateInputExpression(target) if fb.evaluateBooleanExpression("(unsigned long)CFGetTypeID((CFTypeRef)" + target + ") == (unsigned long)CGImageGetTypeID()"): _showImage("(id)[UIImage imageWithCGImage:" + target + "]") else: if objectHelpers.isKindOfClass(target, "UIImage"): _showImage(target) elif objectHelpers.isKindOfClass(target, "UIView"): _showLayer("[(id)" + target + " layer]") elif objectHelpers.isKindOfClass(target, "CALayer"): _showLayer(target) elif (objectHelpers.isKindOfClass(target, "UIColor") or objectHelpers.isKindOfClass(target, "CIColor") or _colorIsCGColorRef(target)): _showColor(target) elif objectHelpers.isKindOfClass(target, "NSData"): if _dataIsImage(target): _showImage("(id)[UIImage imageWithData:" + target + "]") elif _dataIsString(target): print( fb.describeObject("[[NSString alloc] initWithData:" + target + " encoding:4]")) else: print("Data isn't an image and isn't a string.") else: print( "{} isn't supported. You can visualize UIImage, CGImageRef, UIView, CALayer, NSData, UIColor, CIColor, or CGColorRef." .format( # noqa B950 objectHelpers.className(target)))
def _visualize(target): target = '(' + target + ')' if fb.evaluateBooleanExpression('(unsigned long)CFGetTypeID((CFTypeRef)' + target + ') == (unsigned long)CGImageGetTypeID()'): _showImage('(id)[UIImage imageWithCGImage:' + target + ']') else: if objectHelpers.isKindOfClass(target, 'UIImage'): _showImage(target) elif objectHelpers.isKindOfClass(target, 'UIView'): _showLayer('[(id)' + target + ' layer]') elif objectHelpers.isKindOfClass(target, 'CALayer'): _showLayer(target) elif objectHelpers.isKindOfClass(target, 'UIColor') or objectHelpers.isKindOfClass(target, 'CIColor') or _colorIsCGColorRef(target): _showColor(target) elif objectHelpers.isKindOfClass(target, 'NSData'): if _dataIsImage(target): _showImage('(id)[UIImage imageWithData:' + target + ']') elif _dataIsString(target): print fb.describeObject('[[NSString alloc] initWithData:' + target + ' encoding:4]') else: print 'Data isn\'t an image and isn\'t a string.' else: print '{} isn\'t supported. You can visualize UIImage, CGImageRef, UIView, CALayer, NSData, UIColor, CIColor, or CGColorRef.'.format(objectHelpers.className(target))