文章40 | 阅读 18249 | 点赞0
command alias views expression -l objc -O -- [[[UIApplication sharedApplication] keyWindow] recursiveDescription]
command alias flush expression -l objc -- (void)[CATransaction flush]
command regex change_color 's/(.+) (.+)/e (void)[(id)%1 setBackgroundColor:[UIColor %2]]/'
def command_function(debugger, command, result, internal_dict):
# Your code goes here
def __lldb_init_module(debugger, internal_dict):
# Command Initialization code goes here
debugger.HandleCommand('command script add -f filter.filter_button_by_label filter_button_by_label')
import lldb
import commands
import optparse
import shlex
import re
def create_options():
usage = "usage: filter_button_by_label [options]"
description='''
This command is used to find a UIButton with a label matching the option provided as option
'''
parser = optparse.OptionParser(description=description, prog='filter_button_by_label', usage=usage)
parser.add_option('-n', '--needle', type='string', dest='needle', help='Text to search on UIButton labels.')
return parser
def filter_button_by_label(debugger, command, result, internal_dict):
target = debugger.GetSelectedTarget()
process = target.GetProcess()
mainThread = process.GetThreadAtIndex(0)
currentFrame = mainThread.GetSelectedFrame()
# Parse arguments and options
command_args = shlex.split(command)
parser = create_options()
try:
(options, args) = parser.parse_args(command_args)
# if needle is not provided
if not options.needle:
parser.print_help()
return
except:
return
view_hierarchy_command = '(id)[[[UIApplication sharedApplication] keyWindow] recursiveDescription]'
view_hierarchy = currentFrame.EvaluateExpression(view_hierarchy_command).GetObjectDescription()
for match in re.finditer('.*<UIButton: (0x[0-9a-fA-F]*);.*', view_hierarchy, re.IGNORECASE):
view = match.groups()[-1]
created_command = '(NSString *)[ (id)' + view + ' currentTitle]'
title = currentFrame.EvaluateExpression(created_command).GetObjectDescription()
if title == options.needle:
print >>result, view
else:
print >>result, "Not Found"
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('command script add -f ' + __name__ + '.filter_button_by_label filter_button_by_label')
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/Forever_wj/article/details/121937061
内容来源于网络,如有侵权,请联系作者删除!