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