tools/scripts/cdb/cmd.py
aozhiwei 76da7be959 1
2019-10-12 15:50:07 +08:00

61 lines
1.5 KiB
Python

def _b_cmd(browser, tab, scriptmgr, params):
filename = params[0].split(':')[0]
line = int(params[0].split(':')[1])
url = scriptmgr.getUrl(filename)
print(params, url)
# tab.debug = True
tab.call_method("Debugger.setBreakpointByUrl",
lineNumber=line,
url=url,
columnNumber=0,
condition=''
)
def _bt_cmd(browser, tab, scriptmgr, params):
scriptmgr.dumpStack()
def _p_cmd(browser, tab, scriptmgr, params):
pass
def _debugon_cmd(browser, tab, scriptmgr, params):
tab.debug = True
print('debug on')
def _debugoff_cmd(browser, tab, scriptmgr, params):
tab.debug = False
print('debug off')
def _exit_cmd(browser, tab, scriptmgr, params):
print('quit')
exit(0)
def _processCdbCmd(cmd_str, browser, tab, scriptmgr):
cmdlist = cmd_str.split(' ')
if len(cmdlist) < 1:
return
cmd_hash = {
'b': _b_cmd,
'bt': _bt_cmd,
'p': _p_cmd,
'debugon': _debugon_cmd,
'debugoff': _debugoff_cmd,
'exit': _exit_cmd,
'q': _exit_cmd,
}
if cmdlist[0] in cmd_hash:
cmd_hash[cmdlist[0]](browser, tab, scriptmgr, cmdlist[1:])
else:
print('not found %s cmd' % cmdlist[0])
def processCmd(browser, tab, scriptmgr, cmdline):
try:
if len(cmdline) > 0 :
if cmdline[0] == '!':
msg = eval(cmdline[1:])
else:
_processCdbCmd(cmdline, browser, tab, scriptmgr)
except Exception as e:
print(e)