<s> import re <EOL> import lldb <EOL> import fblldbbase as fb <EOL> def lldbcommands ( ) : <EOL> return [ <EOL> FBPrintInvocation ( ) , <EOL> ] <EOL> class FBPrintInvocation ( 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:all>' , default = False , boolean = True , help = '<STR_LIT>' ) , <EOL> ] <EOL> def run ( self , arguments , options ) : <EOL> target = lldb . debugger . GetSelectedTarget ( ) <EOL> if not re . match ( r'<STR_LIT>' , target . GetTriple ( ) ) : <EOL> print '<STR_LIT>' <EOL> return <EOL> thread = target . GetProcess ( ) . GetSelectedThread ( ) <EOL> if options . all : <EOL> for frame in thread : <EOL> printInvocationForFrame ( frame ) <EOL> print '<STR_LIT>' <EOL> else : <EOL> frame = thread . GetSelectedFrame ( ) <EOL> printInvocationForFrame ( frame ) <EOL> def printInvocationForFrame ( frame ) : <EOL> print frame <EOL> symbolName = frame . GetSymbol ( ) . GetName ( ) <EOL> if not re . match ( r'<STR_LIT>' , symbolName ) : <EOL> return <EOL> self = findArgAtIndexFromStackFrame ( frame , <NUM_LIT:0> ) <EOL> cmd = findArgAtIndexFromStackFrame ( frame , <NUM_LIT:1> ) <EOL> commandForSignature = '<STR_LIT>' + self + '<STR_LIT>' + cmd + '<STR_LIT>' <EOL> signatureValue = fb . evaluateExpressionValue ( '<STR_LIT>' + commandForSignature ) <EOL> if signatureValue . GetError ( ) is not None and str ( signatureValue . GetError ( ) ) != '<STR_LIT:success>' : <EOL> print "<STR_LIT>" <EOL> return <EOL> signature = signatureValue . GetValue ( ) <EOL> arg0 = stackStartAddressInSelectedFrame ( frame ) <EOL> commandForInvocation = '<STR_LIT>' + signature + '<STR_LIT>' + str ( arg0 ) + '<STR_LIT>' <EOL> invocation = fb . evaluateExpression ( '<STR_LIT>' + commandForInvocation ) <EOL> if invocation : <EOL> prettyPrintInvocation ( frame , invocation ) <EOL> else : <EOL> print frame <EOL> def stackStartAddressInSelectedFrame ( frame ) : <EOL> frameSymbol = frame . GetSymbolContext ( <NUM_LIT:0> ) . GetSymbol ( ) <EOL> frameStartAddress = frameSymbol . GetStartAddress ( ) . GetLoadAddress ( lldb . debugger . GetSelectedTarget ( ) ) <EOL> currentPC = frame . GetPC ( ) <EOL> offset = currentPC - frameStartAddress <EOL> if offset == <NUM_LIT:0> : <EOL> return int ( frame . EvaluateExpression ( '<STR_LIT>' ) . GetValue ( ) ) <EOL> elif offset == <NUM_LIT:1> : <EOL> return int ( frame . EvaluateExpression ( '<STR_LIT>' ) . GetValue ( ) ) <EOL> else : <EOL> return int ( frame . EvaluateExpression ( '<STR_LIT>' ) . GetValue ( ) ) <EOL> def findArgAtIndexFromStackFrame ( frame , index ) : <EOL> return fb . evaluateExpression ( '<STR_LIT>' + str ( findArgAdressAtIndexFromStackFrame ( frame , index ) ) ) <EOL> def findArgAdressAtIndexFromStackFrame ( frame , index ) : <EOL> arg0 = stackStartAddressInSelectedFrame ( frame ) <EOL> arg = arg0 + <NUM_LIT:4> * index <EOL> return arg <EOL> def prettyPrintInvocation ( frame , invocation ) : <EOL> object = fb . evaluateExpression ( '<STR_LIT>' + invocation + '<STR_LIT>' ) <EOL> description = fb . evaluateExpressionValue ( '<STR_LIT>' + invocation ) . GetObjectDescription ( ) <EOL> argDescriptions = description . splitlines ( True ) [ <NUM_LIT:4> : ] <EOL> print '<STR_LIT>' + invocation <EOL> print '<STR_LIT>' + fb . evaluateExpression ( '<STR_LIT>' + object ) <EOL> if len ( argDescriptions ) > <NUM_LIT:0> : <EOL> print '<STR_LIT:\n>' + str ( len ( argDescriptions ) ) + '<STR_LIT>' if len ( argDescriptions ) > <NUM_LIT:1> else '<STR_LIT>' <EOL> index = <NUM_LIT:2> <EOL> for argDescription in argDescriptions : <EOL> s = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , argDescription ) <EOL> lldb . debugger . HandleCommand ( '<STR_LIT>' ) <EOL> lldb . debugger . HandleCommand ( '<STR_LIT>' + invocation + '<STR_LIT>' + str ( index ) + '<STR_LIT:]>' ) <EOL> address = findArgAdressAtIndexFromStackFrame ( frame , index ) <EOL> encoding = s . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] <EOL> description = '<STR_LIT:U+0020>' . join ( s . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:1> : ] ) <EOL> readableString = argumentAsString ( frame , address , encoding ) <EOL> if readableString : <EOL> print readableString <EOL> else : <EOL> if encoding [ <NUM_LIT:0> ] == '<STR_LIT:{>' : <EOL> encoding = encoding [ <NUM_LIT:1> : ] <EOL> print ( hex ( address ) + '<STR_LIT>' + encoding + '<STR_LIT:U+0020>' + description ) . strip ( ) <EOL> index += <NUM_LIT:1> <EOL> def argumentAsString ( frame , address , encoding ) : <EOL> if encoding [ <NUM_LIT:0> ] == '<STR_LIT:{>' : <EOL> encoding = encoding [ <NUM_LIT:1> : ] <EOL> encodingMap = { <EOL> '<STR_LIT:c>' : '<STR_LIT>' , <EOL> '<STR_LIT:i>' : '<STR_LIT:int>' , <EOL> '<STR_LIT:s>' : '<STR_LIT>' , <EOL> '<STR_LIT:l>' : '<STR_LIT>' , <EOL> '<STR_LIT:q>' : '<STR_LIT>' , <EOL> '<STR_LIT:C>' : '<STR_LIT>' , <EOL> '<STR_LIT:I>' : '<STR_LIT>' , <EOL> '<STR_LIT:S>' : '<STR_LIT>' , <EOL> '<STR_LIT:L>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:f>' : '<STR_LIT:float>' , <EOL> '<STR_LIT:d>' : '<STR_LIT>' , <EOL> '<STR_LIT:B>' : '<STR_LIT:bool>' , <EOL> '<STR_LIT:v>' : '<STR_LIT>' , <EOL> '<STR_LIT:*>' : '<STR_LIT>' , <EOL> '<STR_LIT:@>' : '<STR_LIT:id>' , <EOL> '<STR_LIT:#>' : '<STR_LIT>' , <EOL> '<STR_LIT::>' : '<STR_LIT>' , <EOL> } <EOL> pointers = '<STR_LIT>' <EOL> while encoding [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> pointers += '<STR_LIT:*>' <EOL> encoding = encoding [ <NUM_LIT:1> : ] <EOL> type = None <EOL> if encoding in encodingMap : <EOL> type = encodingMap [ encoding ] <EOL> if type and pointers : <EOL> type = type + '<STR_LIT:U+0020>' + pointers <EOL> if not type : <EOL> if encoding [ <NUM_LIT:0> ] == '<STR_LIT:{>' : <EOL> encoding = encoding [ <NUM_LIT:1> : ] <EOL> type = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , encoding ) <EOL> if pointers : <EOL> type += '<STR_LIT:U+0020>' + pointers <EOL> if type : <EOL> value = frame . EvaluateExpression ( '<STR_LIT>' + type + '<STR_LIT>' + str ( address ) ) <EOL> if value . GetError ( ) is None or str ( value . GetError ( ) ) == '<STR_LIT:success>' : <EOL> description = None <EOL> if encoding == '<STR_LIT:@>' : <EOL> description = value . GetObjectDescription ( ) <EOL> if not description : <EOL> description = value . GetValue ( ) <EOL> if not description : <EOL> description = value . GetSummary ( ) <EOL> if description : <EOL> return type + '<STR_LIT>' + description <EOL> return None </s>
