<s> import os <EOL> import re <EOL> import lldb <EOL> import fblldbbase as fb <EOL> import fblldbobjcruntimehelpers as objc <EOL> import fblldbviewcontrollerhelpers as vcHelpers <EOL> def lldbcommands ( ) : <EOL> return [ <EOL> FBFindViewControllerCommand ( ) , <EOL> FBFindViewCommand ( ) , <EOL> FBTapLoggerCommand ( ) , <EOL> ] <EOL> class FBFindViewControllerCommand ( fb . FBCommand ) : <EOL> def name ( self ) : <EOL> return '<STR_LIT>' <EOL> def description ( self ) : <EOL> return '<STR_LIT>' <EOL> def options ( self ) : <EOL> return [ <EOL> fb . FBCommandArgument ( short = '<STR_LIT>' , long = '<STR_LIT>' , arg = '<STR_LIT>' , type = '<STR_LIT:string>' , help = '<STR_LIT>' ) , <EOL> fb . FBCommandArgument ( short = '<STR_LIT>' , long = '<STR_LIT>' , arg = '<STR_LIT>' , type = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> ] <EOL> def run ( self , arguments , options ) : <EOL> if options . classNameRegex and options . view : <EOL> print ( "<STR_LIT>" ) <EOL> elif options . view : <EOL> self . findOwningViewController ( options . view ) <EOL> else : <EOL> output = vcHelpers . viewControllerRecursiveDescription ( '<STR_LIT>' ) <EOL> searchString = options . classNameRegex if options . classNameRegex else arguments [ <NUM_LIT:0> ] <EOL> printMatchesInViewOutputStringAndCopyFirstToClipboard ( searchString , output ) <EOL> def findOwningViewController ( self , object ) : <EOL> while object : <EOL> if self . isViewController ( object ) : <EOL> description = fb . evaluateExpressionValue ( object ) . GetObjectDescription ( ) <EOL> print ( "<STR_LIT>" . format ( description ) ) <EOL> cmd = '<STR_LIT>' . format ( object ) <EOL> os . system ( cmd ) <EOL> return <EOL> else : <EOL> object = self . nextResponder ( object ) <EOL> print ( "<STR_LIT>" ) <EOL> @ staticmethod <EOL> def isViewController ( object ) : <EOL> command = '<STR_LIT>' . format ( object ) <EOL> isVC = fb . evaluateBooleanExpression ( command ) <EOL> return isVC <EOL> @ staticmethod <EOL> def nextResponder ( object ) : <EOL> command = '<STR_LIT>' . format ( object ) <EOL> nextResponder = fb . evaluateObjectExpression ( command ) <EOL> try : <EOL> if int ( nextResponder , <NUM_LIT:0> ) : <EOL> return nextResponder <EOL> else : <EOL> return None <EOL> except : <EOL> return None <EOL> class FBFindViewCommand ( fb . FBCommand ) : <EOL> def name ( self ) : <EOL> return '<STR_LIT>' <EOL> def description ( self ) : <EOL> return '<STR_LIT>' <EOL> def args ( self ) : <EOL> return [ fb . FBCommandArgument ( arg = '<STR_LIT>' , type = '<STR_LIT:string>' , help = '<STR_LIT>' ) ] <EOL> def run ( self , arguments , options ) : <EOL> output = fb . evaluateExpressionValue ( '<STR_LIT>' ) . GetObjectDescription ( ) <EOL> printMatchesInViewOutputStringAndCopyFirstToClipboard ( arguments [ <NUM_LIT:0> ] , output ) <EOL> def printMatchesInViewOutputStringAndCopyFirstToClipboard ( needle , haystack ) : <EOL> first = None <EOL> for match in re . finditer ( '<STR_LIT>' + needle + '<STR_LIT>' , haystack , re . IGNORECASE ) : <EOL> view = match . groups ( ) [ - <NUM_LIT:1> ] <EOL> className = fb . evaluateExpressionValue ( '<STR_LIT>' + view + '<STR_LIT>' ) . GetObjectDescription ( ) <EOL> print ( '<STR_LIT>' . format ( view , className ) ) <EOL> if first is None : <EOL> first = view <EOL> cmd = '<STR_LIT>' % view <EOL> os . system ( cmd ) <EOL> class FBTapLoggerCommand ( fb . FBCommand ) : <EOL> def name ( self ) : <EOL> return '<STR_LIT>' <EOL> def description ( self ) : <EOL> return '<STR_LIT>' <EOL> def run ( self , arguments , options ) : <EOL> parameterExpr = objc . functionPreambleExpressionForObjectParameterAtIndex ( <NUM_LIT:0> ) <EOL> breakpoint = lldb . debugger . GetSelectedTarget ( ) . BreakpointCreateByName ( "<STR_LIT>" ) <EOL> breakpoint . SetCondition ( '<STR_LIT>' + parameterExpr + '<STR_LIT>' + parameterExpr + '<STR_LIT>' ) <EOL> breakpoint . SetOneShot ( True ) <EOL> lldb . debugger . HandleCommand ( '<STR_LIT>' + __name__ + '<STR_LIT>' + self . __class__ . __name__ + '<STR_LIT>' + str ( breakpoint . id ) ) <EOL> lldb . debugger . SetAsync ( True ) <EOL> lldb . debugger . HandleCommand ( '<STR_LIT>' ) <EOL> @ staticmethod <EOL> def taplog_callback ( frame , bp_loc , internal_dict ) : <EOL> parameterExpr = objc . functionPreambleExpressionForObjectParameterAtIndex ( <NUM_LIT:0> ) <EOL> lldb . debugger . HandleCommand ( '<STR_LIT>' % ( parameterExpr ) ) <EOL> lldb . debugger . HandleCommand ( '<STR_LIT>' ) </s>
