1*1031c584SApple OSS Distributions# A basic Plugin that creates performance reports from zprint output 2*1031c584SApple OSS Distributionskern_version = None 3*1031c584SApple OSS Distributions 4*1031c584SApple OSS Distributionsdef plugin_init(kernel_target, config, lldb_obj, isConnected): 5*1031c584SApple OSS Distributions """ initialize the common data as required by plugin """ 6*1031c584SApple OSS Distributions global kern_version 7*1031c584SApple OSS Distributions kern_version = str(kernel_target.version) 8*1031c584SApple OSS Distributions 9*1031c584SApple OSS Distributionsdef plugin_execute(command_name, result_output): 10*1031c584SApple OSS Distributions """ The xnu framework will call this function with output of a command. 11*1031c584SApple OSS Distributions The options for returning are as follows 12*1031c584SApple OSS Distributions returns: (status, outstr, further_cmds) 13*1031c584SApple 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. 14*1031c584SApple OSS Distributions outstr: str - string output for user to be printed at the prompt 15*1031c584SApple OSS Distributions further_cmds: [] of str - this holds set of commands to execute at the lldb prompt. Empty array if nothing is required. 16*1031c584SApple OSS Distributions """ 17*1031c584SApple OSS Distributions status = True 18*1031c584SApple OSS Distributions outstr = 'Nothing to be done here' 19*1031c584SApple OSS Distributions further_cmds = [] 20*1031c584SApple OSS Distributions further_cmds.append("memstats -- --plugin zprint_perf_log ") 21*1031c584SApple OSS Distributions 22*1031c584SApple OSS Distributions if command_name != 'zprint' : 23*1031c584SApple OSS Distributions status = False 24*1031c584SApple OSS Distributions else: 25*1031c584SApple OSS Distributions num_zones = len(result_output.split("\n")) -1 26*1031c584SApple OSS Distributions outstr += "Num of zones analyzed =" + str(num_zones) + "\n" 27*1031c584SApple OSS Distributions return (status, outstr, further_cmds) 28*1031c584SApple OSS Distributions 29*1031c584SApple OSS Distributionsdef plugin_cleanup(): 30*1031c584SApple OSS Distributions """ A cleanup call from xnu which is a signal to wrap up any open file descriptors etc. """ 31*1031c584SApple OSS Distributions return None 32