1*c54f35caSApple OSS Distributions# Feed user stacks to ios/speedtracer 2*c54f35caSApple OSS Distributions 3*c54f35caSApple OSS Distributionsdef plugin_init(kernel_target, config, lldb_obj, isConnected): 4*c54f35caSApple OSS Distributions """ initialize the common data as required by plugin """ 5*c54f35caSApple OSS Distributions return None 6*c54f35caSApple OSS Distributions 7*c54f35caSApple OSS Distributionsdef plugin_execute(command_name, result_output): 8*c54f35caSApple OSS Distributions """ The xnu framework will call this function with output of a command. 9*c54f35caSApple OSS Distributions The options for returning are as follows 10*c54f35caSApple OSS Distributions returns: (status, outstr, further_cmds) 11*c54f35caSApple OSS Distributions status: Boolean - specifying whether plugin execution succeeded(True) or failed. If failed then xnu will stop doing any further work with this command. 12*c54f35caSApple OSS Distributions outstr: str - string output for user to be printed at the prompt 13*c54f35caSApple OSS Distributions further_cmds: [] of str - this holds set of commands to execute at the lldb prompt. Empty array if nothing is required. 14*c54f35caSApple OSS Distributions """ 15*c54f35caSApple OSS Distributions import subprocess,os 16*c54f35caSApple OSS Distributions status = True 17*c54f35caSApple OSS Distributions outstr = '' 18*c54f35caSApple OSS Distributions further_cmds = [] 19*c54f35caSApple OSS Distributions 20*c54f35caSApple OSS Distributions if command_name != 'showtaskuserstacks' : 21*c54f35caSApple OSS Distributions status = False 22*c54f35caSApple OSS Distributions else: 23*c54f35caSApple OSS Distributions ios_process = subprocess.Popen([os.path.join(os.path.dirname(os.path.abspath(__file__)), "iosspeedtracer.sh")], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 24*c54f35caSApple OSS Distributions 25*c54f35caSApple OSS Distributions outstr += ios_process.communicate(input=result_output)[0] 26*c54f35caSApple OSS Distributions 27*c54f35caSApple OSS Distributions return (status, outstr, further_cmds) 28*c54f35caSApple OSS Distributions 29*c54f35caSApple OSS Distributionsdef plugin_cleanup(): 30*c54f35caSApple OSS Distributions """ A cleanup call from xnu which is a signal to wrap up any open file descriptors etc. """ 31*c54f35caSApple OSS Distributions return None 32*c54f35caSApple OSS Distributions 33*c54f35caSApple OSS Distributions 34