本文整理匯總了Python中lldb.SBError方法的典型用法代碼示例。如果您正苦於以下問題:Python lldb.SBError方法的具體用法?Python lldb.SBError怎麽用?Python lldb.SBError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lldb
的用法示例。
在下文中一共展示了lldb.SBError方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: evaluate
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def evaluate(expr):
if not check_expr(expr):
raise Exception(
"Invalid Expression, the last expression not include a RETURN family marco"
)
command = "({" + RETURN_MACRO + "\n" + expr + "})"
ret = evaluateExpressionValue(command, printErrors=True)
if not ret.GetError().Success():
print(ret.GetError())
return None
else:
process = lldb.debugger.GetSelectedTarget().GetProcess()
error = lldb.SBError()
ret = process.ReadCStringFromMemory(int(ret.GetValue(), 16), 2 ** 20, error)
if not error.Success():
print(error)
return None
else:
ret = json.loads(ret)
return ret["return"]
示例2: read
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def read(addr, size):
i = 0
data = ''
if size<BSZ:
bs = size
else:
bs = BSZ
while i<size:
target = lldb.debugger.GetSelectedTarget()
error = lldb.SBError()
if i+bs>size:
bs = size-i
res = target.process.ReadMemory (addr+i, bs, error)
if len (res) == 0:
print(error)
#print ("READ FAIL AT 0x%x"%(addr+i))
i = i + bs
continue
if data == None:
data = res
elif res:
data = data + res
i = i + bs
return data
示例3: write
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def write(addr, buf):
i = 0
data = ''
target = lldb.debugger.GetSelectedTarget()
error = lldb.SBError()
res = target.process.WriteMemory (addr+i, buf, error)
#if not error.Success() or res != 1:
print ("RES")
print (res)
if res == 0:
print(error)
#print ("WRITE FAIL AT 0x%x"%(addr+i))
return 0
return res
#[ 99] 29886CD7-2AC8-3578-8389-7D5BEE405F53 0x08a38000 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/FaceCore.framework/FaceCore
示例4: __init__
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def __init__(self, valobj):
super(KonanStringSyntheticProvider, self).__init__(valobj)
fallback = valobj.GetValue()
buff_len = evaluate(
'(int)Konan_DebugObjectToUtf8Array({}, (char *)Konan_DebugBuffer(), (int)Konan_DebugBufferSize());'.format(
self._ptr)
).unsigned
if not buff_len:
self._representation = fallback
return
buff_addr = evaluate("(char *)Konan_DebugBuffer()").unsigned
error = lldb.SBError()
s = self._process.ReadCStringFromMemory(int(buff_addr), int(buff_len), error)
if not error.Success():
raise DebuggerException()
self._representation = s if error.Success() else fallback
self._logger = lldb.formatters.Logger.Logger()
示例5: _init_child_type_info
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def _init_child_type_info(self):
tip = self._tip
ptr = self._ptr
error = lldb.SBError()
if tip > 0 and tip in TYPES_CACHE:
return TYPES_CACHE[tip]
else:
kid_count = self.system_count_children()
children_type_info = \
[ChildMetaInfo(
self._read_string("(const char *)Konan_DebugGetFieldName({}, (int){})".format(ptr, x), error), _child_type_global(ptr, x), self._calc_offset(self._children_type_address(x))) for x in range(kid_count)]
if tip != -1:
TYPES_CACHE[tip] = children_type_info
if not error.Success():
raise DebuggerException()
return children_type_info
示例6: __init__
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def __init__(self, valobj):
self._children_count = 0
super(KonanStringSyntheticProvider, self).__init__(valobj, True)
fallback = valobj.GetValue()
buff_len = evaluate(
'(int)Konan_DebugObjectToUtf8Array({}, (char *)Konan_DebugBuffer(), (int)Konan_DebugBufferSize());'.format(
self._ptr)
).unsigned
if not buff_len:
self._representation = fallback
return
buff_addr = evaluate("(char *)Konan_DebugBuffer()").unsigned
error = lldb.SBError()
s = self._process.ReadCStringFromMemory(int(buff_addr), int(buff_len), error)
if not error.Success():
raise DebuggerException()
self._representation = s if error.Success() else fallback
self._logger = lldb.formatters.Logger.Logger()
示例7: getLazyPointersFromData
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def getLazyPointersFromData(data, section, outputCount=0):
script = generateLazyPointerScriptWithOptions(section)
target = getTarget()
indeces = []
stringList = []
descriptions = []
ptrsize = getType("void*").GetByteSize()
options = genExpressionOptions(False, True, True)
val = target.EvaluateExpression(script, options)
# for dbg'ing
# lldb.debugger.HandleCommand('exp -l objc++ -O -g -- ' + script)
# print(res)
process = target.GetProcess()
loadAddr = section.addr.GetLoadAddress(target)
for i in range(val.GetNumChildren()):
x = val.GetChildAtIndex(i)
indeces.append(i * ptrsize)
retstr = x.summary.replace("\"", "")
error = lldb.SBError()
ptr = process.ReadPointerFromMemory(loadAddr + i * ptrsize, error)
if error.success == True:
sec = target.ResolveLoadAddress(ptr).section
if sec.IsValid():
if sec.name == "__stub_helper":
descriptions.append("-")
else:
descriptions.append("+")
else:
descriptions.append(None)
stringList.append(retstr)
return (indeces, stringList, descriptions)
示例8: getStringsFromData
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def getStringsFromData(_data, outputCount=0):
indeces = []
stringList = []
target = getTarget()
# Hack, f it
if outputCount == 1:
err = lldb.SBError()
val = target.EvaluateExpression('(char *){}'.format(_data.GetAddress(err, 0)), genExpressionOptions())
print(val)
# Force conversion of "unknown" data to known of char**
t = target.GetBasicType(lldb.eBasicTypeChar).GetPointerType()
data = _data
vl = target.CreateValueFromData("__ds_unused", _data, t)
if not vl.IsValid():
print("SBValue not valid")
return (indeces, stringList)
dataArray = data.sint8
marker = 0
for index, x in enumerate(dataArray):
if outputCount != 0 and len(stringList) > outputCount:
break
if x == 0:
indeces.append(marker)
stringList.append(''.join([chr(i) for i in dataArray[marker:index]]))
marker = index + 1
if len(stringList) == 0:
stringList.append(''.join([chr(i) for i in data.sint8]))
indeces.append(0)
return (indeces, stringList)
示例9: run
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def run(self, arguments, options):
commandForObject, ivarName = arguments
objectAddress = int(fb.evaluateObjectExpression(commandForObject), 0)
ivarOffsetCommand = '(ptrdiff_t)ivar_getOffset((void*)object_getInstanceVariable((id){}, "{}", 0))'.format(
objectAddress, ivarName
)
ivarOffset = int(fb.evaluateExpression(ivarOffsetCommand), 0)
# A multi-statement command allows for variables scoped to the command,
# not permanent in the session like $variables.
ivarSizeCommand = (
"unsigned int size = 0;"
'char *typeEncoding = (char *)ivar_getTypeEncoding((void*)class_getInstanceVariable((Class)object_getClass((id){}), "{}"));'
"(char *)NSGetSizeAndAlignment(typeEncoding, &size, 0);"
"size"
).format(objectAddress, ivarName)
ivarSize = int(fb.evaluateExpression(ivarSizeCommand), 0)
error = lldb.SBError()
watchpoint = lldb.debugger.GetSelectedTarget().WatchAddress(
objectAddress + ivarOffset, ivarSize, False, True, error
)
if error.Success():
print(
"Remember to delete the watchpoint using: watchpoint delete {}".format(
watchpoint.GetID()
)
)
else:
print("Could not create the watchpoint: {}".format(error.GetCString()))
示例10: _copyFromData
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def _copyFromData(data, defaultFilename, preferredFilename, noOpen):
directory = '/tmp/chisel_copy/'
path = directory + (preferredFilename or defaultFilename)
try:
os.makedirs(directory)
except OSError as e:
if e.errno == errno.EEXIST and os.path.isdir(directory):
pass
else:
raise
startAddress = fb.evaluateExpression('(void *)[(id)' + data + ' bytes]')
length = fb.evaluateExpression('(NSUInteger)[(id)' + data + ' length]')
address = int(startAddress, 16)
length = int(length)
if not (address or length):
print('Could not get 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(path, 'wb') as file:
file.write(mem)
file.close()
print(path)
if not noOpen:
os.system('open ' + path)
示例11: _showImage
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
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)
示例12: evaluateCStringExpression
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def evaluateCStringExpression(expression, printErrors=True):
ret = evaluateExpression(expression, printErrors)
process = lldb.debugger.GetSelectedTarget().GetProcess()
error = lldb.SBError()
ret = process.ReadCStringFromMemory(int(ret, 16), 256, error)
if error.Success():
return ret
else:
if printErrors:
print(error)
return None
示例13: memWrite
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def memWrite(addr, buf):
data = ''
target = lldb.debugger.GetSelectedTarget()
error = lldb.SBError()
res = target.process.WriteMemory (addr, buf, error)
#if not error.Success() or res != 1:
if res == 0:
print(error)
print ("WRITE FAIL AT 0x%x"%(addr))
return res
示例14: _field_name
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def _field_name(self, index):
error = lldb.SBError()
name = self._read_string("(const char *)Konan_DebugGetFieldName({}, (int){})".format(self._ptr, index), error)
if not error.Success():
raise DebuggerException()
return name
示例15: __init__
# 需要導入模塊: import lldb [as 別名]
# 或者: from lldb import SBError [as 別名]
def __init__(self, valobj, type_check_result):
buff_len = (type_check_result*-1) - STRING_SIZE_OFFSET
if not buff_len:
self._representation = valobj.GetValue()
return
process = lldb.debugger.GetSelectedTarget().GetProcess()
error = lldb.SBError()
s = process.ReadCStringFromMemory(debug_string_buffer_ptr(), int(buff_len), error)
if not error.Success():
raise DebuggerException()
self._representation = s if error.Success() else valobj.GetValue()
self._logger = lldb.formatters.Logger.Logger()