in commands/FBVisualizationCommands.py [0:0]
def _showImage(commandForImage):
imageDirectory = "/tmp/xcode_debug_images/"
imageName = time.strftime("%Y-%m-%d-%H-%M-%S", time.gmtime()) + ".png"
imagePath = imageDirectory + imageName
try:
os.makedirs(imageDirectory)
except OSError as e:
if e.errno == errno.EEXIST and os.path.isdir(imageDirectory):
pass
else:
raise
toPNG = "(id)UIImagePNGRepresentation((id){})".format(commandForImage)
imageDataAddress = fb.evaluateExpressionValue(toPNG, tryAllThreads=True).GetValue()
imageBytesStartAddress = fb.evaluateExpression(
"(void *)[(id)" + imageDataAddress + " bytes]"
)
imageBytesLength = fb.evaluateExpression(
"(NSUInteger)[(id)" + imageDataAddress + " length]"
)
address = int(imageBytesStartAddress, 16)
length = int(imageBytesLength)
if not (address or length):
print("Could not get image data.")
return
process = lldb.debugger.GetSelectedTarget().GetProcess()
error = lldb.SBError()
mem = process.ReadMemory(address, length, error)
if error is not None and str(error) != "success":
print(error)
else:
with open(imagePath, "wb") as imgFile:
imgFile.write(mem)
os.system("open " + imagePath)