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