]>
git.saurik.com Git - apple/xnu.git/blob - tools/lldbmacros/plugins/speedtracer.py
1 import json
, urllib
, urllib2
2 from urllib2
import Request
, urlopen
, HTTPError
5 def plugin_init ( kernel_target
, config
, lldb_obj
, isConnected
):
6 """ initialize the common data as required by plugin """
8 kern_version
= str ( kernel_target
. version
)
10 def plugin_execute ( command_name
, result_output
):
11 """ The xnu framework will call this function with output of a command.
12 The options for returning are as follows
13 returns: (status, outstr, further_cmds)
14 status: Boolean - specifying whether plugin execution succeeded(True) or failed. If failed then xnu will stop doing any further work with this command.
15 outstr: str - string output for user to be printed at the prompt
16 further_cmds: [] of str - this holds set of commands to execute at the lldb prompt. Empty array if nothing is required.
22 submitvars
[ 'log_content' ]= result_output
24 submiturl
= "https://speedtracer.apple.com/api/v2/trace"
25 encoded_data
= urllib
. urlencode ( submitvars
)
26 request
= urllib2
. Request ( submiturl
, encoded_data
)
27 request
. add_header ( "Accept" , "application/json" )
28 request
. add_header ( "X-ST-GroupName" , "core-os" )
30 response
= urllib2
. urlopen ( request
)
31 response_str
= response
. read ()
32 j
= json
. loads ( response_str
)
33 outstr
+= " \n speedtracer output: \n\n "
34 stacks
= j
. get ( "symbolicated_log" )
38 outstr
+= json
. dumps ( j
)
39 except HTTPError
as e
:
40 outstr
+= "speedtracer replied with \n " + str ( e
. info ())
43 return ( status
, outstr
, further_cmds
)
46 """ A cleanup call from xnu which is a signal to wrap up any open file descriptors etc. """