tools/scripts/cdb/cmd.py
aozhiwei 10de601297 1
2019-10-12 15:08:42 +08:00

46 lines
1.2 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 _processCdbCmd(cmd_str, browser, tab, scriptmgr):
cmdlist = cmd_str.split(' ')
if len(cmdlist) < 1:
return
cmd_hash = {
'b': _b_cmd,
'bt': _bt_cmd,
'p': None,
}
print(cmdlist)
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)