3 _usertaskdebugging_availabe
= False
5 from usertaskdebugging
import userprocess
6 from usertaskdebugging
import gdbserver
7 _usertaskdebugging_availabe
= True
11 def setupLogging(debug_level
):
12 log_level
= debug_level
13 log_filename
= "/tmp/kdbserver.log"
14 logging
.basicConfig(level
=log_level
,
15 format
='%(asctime)s %(module)s %(levelname)s: %(message)s',
16 datefmt
='%Y-%m-%d %H:%M:%S')
19 @lldb_command('beginusertaskdebugging', 'DW')
20 def DoUserTaskDebuggingServer(cmd_args
= [], cmd_options
={}):
21 """ starts a gdb protocol server that is backed by <task_t> in kernel debugging session.
22 Usage: (lldb) beginusertaskdebugging <task_t>
23 options: -D for debug level logging
24 -W for warning level logging.
25 default is error level logging
27 if not _usertaskdebugging_availabe
:
28 print "You do not have the usertask debugging files available. "
30 log_level
= logging
.ERROR
31 if '-D' in cmd_options
:
32 log_level
= logging
.DEBUG
33 elif '-W' in cmd_options
:
34 log_level
= logging
.WARNING
36 setupLogging(debug_level
=log_level
)
38 raise ArgumentError("Please provide valid task argument.")
40 t
= kern
.GetValueFromAddress(cmd_args
[0], 'task_t')
42 up
= userprocess
.UserProcess(t
)
43 gbs
= gdbserver
.GDBServer(up
)
44 print "Starting debug session for %s at localhost:%d." % (GetProcNameForTask(t
), gbs
.portnum
)
46 print "stopped the debug session"