代码拉取完成,页面将自动刷新
#!/usr/bin/python
# Copyright (c) 2014, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
import lldb
import fblldbbase as fb
def objc_getClass(className):
command = '(void*)objc_getClass("{}")'.format(className)
value = fb.evaluateExpression(command)
return value
def object_getClass(object):
command = '(void*)object_getClass({})'.format(object)
value = fb.evaluateExpression(command)
return value
def class_getName(klass):
command = '(const char*)class_getName((Class){})'.format(klass)
value = fb.evaluateExpressionValue(command).GetSummary().strip('"')
return value
def class_getSuperclass(klass):
command = '(void*)class_getSuperclass((Class){})'.format(klass)
value = fb.evaluateExpression(command)
return value
def class_getInstanceMethod(klass, selector):
command = '(void*)class_getInstanceMethod((Class){}, @selector({}))'.format(klass, selector)
value = fb.evaluateExpression(command)
return value
def currentArch():
targetTriple = lldb.debugger.GetSelectedTarget().GetTriple()
arch = targetTriple.split('-')[0]
return arch
def functionPreambleExpressionForSelf():
import re
arch = currentArch()
expressionForSelf = None
if arch == 'i386':
expressionForSelf = '*(id*)($esp+4)'
elif arch == 'x86_64':
expressionForSelf = '(id)$rdi'
elif arch == 'arm64':
expressionForSelf = '(id)$x0'
elif re.match(r'^armv.*$', arch):
expressionForSelf = '(id)$r0'
return expressionForSelf
def functionPreambleExpressionForObjectParameterAtIndex(parameterIndex):
import re
arch = currentArch()
expresssion = None
if arch == 'i386':
expresssion = '*(id*)($esp + ' + str(12 + parameterIndex * 4) + ')'
elif arch == 'x86_64':
if parameterIndex > 3:
raise Exception("Current implementation can not return object at index greater than 3 for arc x86_64")
registersList = ['rdx', 'rcx', 'r8', 'r9']
expresssion = '(id)$' + registersList[parameterIndex]
elif arch == 'arm64':
if parameterIndex > 5:
raise Exception("Current implementation can not return object at index greater than 5 for arm64")
expresssion = '(id)$x' + str(parameterIndex + 2)
elif re.match(r'^armv.*$', arch):
if parameterIndex > 3:
raise Exception("Current implementation can not return object at index greater than 1 for arm32")
expresssion = '(id)$r' + str(parameterIndex + 2)
return expresssion
def isMacintoshArch():
arch = currentArch()
if not arch == 'x86_64':
return False
nsClassName = 'NSApplication'
command = '(void*)objc_getClass("{}")'.format(nsClassName)
return (fb.evaluateBooleanExpression(command + '!= nil'))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。