(commandForImage)
| 19 | |
| 20 | |
| 21 | def _showImage(commandForImage): |
| 22 | imageDirectory = "/tmp/xcode_debug_images/" |
| 23 | |
| 24 | imageName = time.strftime("%Y-%m-%d-%H-%M-%S", time.gmtime()) + ".png" |
| 25 | imagePath = imageDirectory + imageName |
| 26 | |
| 27 | try: |
| 28 | os.makedirs(imageDirectory) |
| 29 | except OSError as e: |
| 30 | if e.errno == errno.EEXIST and os.path.isdir(imageDirectory): |
| 31 | pass |
| 32 | else: |
| 33 | raise |
| 34 | |
| 35 | toPNG = "(id)UIImagePNGRepresentation((id){})".format(commandForImage) |
| 36 | imageDataAddress = fb.evaluateExpressionValue(toPNG, tryAllThreads=True).GetValue() |
| 37 | imageBytesStartAddress = fb.evaluateExpression( |
| 38 | "(void *)[(id)" + imageDataAddress + " bytes]" |
| 39 | ) |
| 40 | imageBytesLength = fb.evaluateExpression( |
| 41 | "(NSUInteger)[(id)" + imageDataAddress + " length]" |
| 42 | ) |
| 43 | |
| 44 | address = int(imageBytesStartAddress, 16) |
| 45 | length = int(imageBytesLength) |
| 46 | |
| 47 | if not (address or length): |
| 48 | print("Could not get image data.") |
| 49 | return |
| 50 | |
| 51 | process = lldb.debugger.GetSelectedTarget().GetProcess() |
| 52 | error = lldb.SBError() |
| 53 | mem = process.ReadMemory(address, length, error) |
| 54 | |
| 55 | if error is not None and str(error) != "success": |
| 56 | print(error) |
| 57 | else: |
| 58 | with open(imagePath, "wb") as imgFile: |
| 59 | imgFile.write(mem) |
| 60 | os.system("open " + imagePath) |
| 61 | |
| 62 | |
| 63 | def _colorIsCGColorRef(color): |
no outgoing calls
no test coverage detected