in commands/FBDebugCommands.py [0:0]
def loadChiselIfNecessary(self):
target = lldb.debugger.GetSelectedTarget()
symbol_contexts = target.FindSymbols("PrintInstances", lldb.eSymbolTypeCode)
if any(ctx.symbol.IsValid() for ctx in symbol_contexts):
return True
path = self.chiselLibraryPath()
if not os.path.exists(path):
print("Chisel library missing: " + path)
return False
module = fb.evaluateExpressionValue('(void*)dlopen("{}", 2)'.format(path))
if module.unsigned != 0 or target.module["Chisel"]:
return True
# `errno` is a macro that expands to a call to __error(). In development,
# lldb was not getting a correct value for `errno`, so `__error()` is used.
errno = fb.evaluateExpressionValue("*(int*)__error()").value
error = fb.evaluateExpressionValue("(char*)dlerror()")
if errno == 50:
# KERN_CODESIGN_ERROR from <mach/kern_return.h>
print("Error loading Chisel: Code signing failure; Must re-run codesign")
elif error.unsigned != 0:
print("Error loading Chisel: " + error.summary)
elif errno != 0:
error = fb.evaluateExpressionValue("(char*)strerror({})".format(errno))
if error.unsigned != 0:
print("Error loading Chisel: " + error.summary)
else:
print("Error loading Chisel (errno {})".format(errno))
else:
print("Unknown error loading Chisel")
return False