This commit is contained in:
aozhiwei 2019-10-12 16:42:54 +08:00
parent 76da7be959
commit 060f97653b
2 changed files with 19 additions and 3 deletions

View File

@ -1,10 +1,14 @@
g_cmdstr = ''
def _getCmdParam():
return g_cmdstr[1:]
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,
@ -16,7 +20,13 @@ def _bt_cmd(browser, tab, scriptmgr, params):
scriptmgr.dumpStack()
def _p_cmd(browser, tab, scriptmgr, params):
pass
tab.call_method("Debugger.evaluateOnCallFrame",
callFrameId=scriptmgr.getFrameId(),
expression='console.log(' + _getCmdParam() + ')'
)
def _f_cmd(browser, tab, scriptmgr, params):
scriptmgr.curr_frame = int(params[0])
def _debugon_cmd(browser, tab, scriptmgr, params):
tab.debug = True
@ -31,6 +41,8 @@ def _exit_cmd(browser, tab, scriptmgr, params):
exit(0)
def _processCdbCmd(cmd_str, browser, tab, scriptmgr):
global g_cmdstr
g_cmdstr = cmd_str
cmdlist = cmd_str.split(' ')
if len(cmdlist) < 1:
return
@ -38,9 +50,9 @@ def _processCdbCmd(cmd_str, browser, tab, scriptmgr):
'b': _b_cmd,
'bt': _bt_cmd,
'p': _p_cmd,
'f': _f_cmd,
'debugon': _debugon_cmd,
'debugoff': _debugoff_cmd,
'exit': _exit_cmd,
'q': _exit_cmd,
}
if cmdlist[0] in cmd_hash:

View File

@ -7,6 +7,7 @@ def getShortUrl(url):
class ScriptMgr:
def __init__(self, tab):
self.curr_frame = 0
self.frames = []
self.scripts = []
self.tab = tab
@ -51,3 +52,6 @@ class ScriptMgr:
frame['functionLocation']['lineNumber'],
)
)
def getFrameId(self):
return self.frames[self.curr_frame]['callFrameId']