1
This commit is contained in:
parent
014ae40f07
commit
10de601297
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import time
|
||||||
import pychrome
|
import pychrome
|
||||||
|
|
||||||
import cmd
|
import cmd
|
||||||
@ -25,5 +26,11 @@ tab.start()
|
|||||||
initTab(tab)
|
initTab(tab)
|
||||||
tab.call_method("Page.navigate", url="http://localhost:7456/", _timeout=5)
|
tab.call_method("Page.navigate", url="http://localhost:7456/", _timeout=5)
|
||||||
|
|
||||||
|
time.sleep(3)
|
||||||
|
cmd.processCmd(browser, tab, scriptmgr, 'b jcmatchvs.js:102')
|
||||||
while True:
|
while True:
|
||||||
cmd.processCmd(browser, tab, scriptmgr)
|
cmdline= input('(cdb)').strip()
|
||||||
|
try:
|
||||||
|
cmd.processCmd(browser, tab, scriptmgr, cmdline)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
@ -4,7 +4,7 @@ def _b_cmd(browser, tab, scriptmgr, params):
|
|||||||
line = int(params[0].split(':')[1])
|
line = int(params[0].split(':')[1])
|
||||||
url = scriptmgr.getUrl(filename)
|
url = scriptmgr.getUrl(filename)
|
||||||
print(params, url)
|
print(params, url)
|
||||||
tab.debug = True
|
# tab.debug = True
|
||||||
tab.call_method("Debugger.setBreakpointByUrl",
|
tab.call_method("Debugger.setBreakpointByUrl",
|
||||||
lineNumber=line,
|
lineNumber=line,
|
||||||
url=url,
|
url=url,
|
||||||
@ -12,6 +12,9 @@ def _b_cmd(browser, tab, scriptmgr, params):
|
|||||||
condition=''
|
condition=''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _bt_cmd(browser, tab, scriptmgr, params):
|
||||||
|
scriptmgr.dumpStack()
|
||||||
|
|
||||||
def _p_cmd(browser, tab, scriptmgr, params):
|
def _p_cmd(browser, tab, scriptmgr, params):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -21,6 +24,7 @@ def _processCdbCmd(cmd_str, browser, tab, scriptmgr):
|
|||||||
return
|
return
|
||||||
cmd_hash = {
|
cmd_hash = {
|
||||||
'b': _b_cmd,
|
'b': _b_cmd,
|
||||||
|
'bt': _bt_cmd,
|
||||||
'p': None,
|
'p': None,
|
||||||
}
|
}
|
||||||
print(cmdlist)
|
print(cmdlist)
|
||||||
@ -29,8 +33,7 @@ def _processCdbCmd(cmd_str, browser, tab, scriptmgr):
|
|||||||
else:
|
else:
|
||||||
print('not found %s cmd' % cmdlist[0])
|
print('not found %s cmd' % cmdlist[0])
|
||||||
|
|
||||||
def processCmd(browser, tab, scriptmgr):
|
def processCmd(browser, tab, scriptmgr, cmdline):
|
||||||
cmdline= input('').strip()
|
|
||||||
try:
|
try:
|
||||||
if len(cmdline) > 0 :
|
if len(cmdline) > 0 :
|
||||||
if cmdline[0] == '!':
|
if cmdline[0] == '!':
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
def getShortUrl(url):
|
||||||
|
return url.replace('http://localhost:7456/', '')
|
||||||
|
|
||||||
class ScriptMgr:
|
class ScriptMgr:
|
||||||
|
|
||||||
def __init__(self, tab):
|
def __init__(self, tab):
|
||||||
|
self.frames = []
|
||||||
self.scripts = []
|
self.scripts = []
|
||||||
self.tab = tab
|
self.tab = tab
|
||||||
self.tab.set_listener('Debugger.scriptParsed', self.onScriptParsed)
|
self.tab.set_listener('Debugger.scriptParsed', self.onScriptParsed)
|
||||||
@ -18,6 +24,9 @@ class ScriptMgr:
|
|||||||
|
|
||||||
def onPaused(self, **kwargs):
|
def onPaused(self, **kwargs):
|
||||||
print('onPaused')
|
print('onPaused')
|
||||||
|
self.frames = []
|
||||||
|
for frame in kwargs['callFrames']:
|
||||||
|
self.frames.append(frame)
|
||||||
|
|
||||||
def onResumed(self, **kwargs):
|
def onResumed(self, **kwargs):
|
||||||
print('onResumed')
|
print('onResumed')
|
||||||
@ -30,3 +39,15 @@ class ScriptMgr:
|
|||||||
if filename in script['url']:
|
if filename in script['url']:
|
||||||
return script['url']
|
return script['url']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def dumpStack(self):
|
||||||
|
for frame in self.frames:
|
||||||
|
print('%30s %s:%d' %
|
||||||
|
(
|
||||||
|
frame['functionName'] + ':' +
|
||||||
|
str(json.loads(frame['callFrameId'])['ordinal']) + ':' +
|
||||||
|
str(json.loads(frame['callFrameId'])['injectedScriptId']),
|
||||||
|
getShortUrl(frame['url']),
|
||||||
|
frame['functionLocation']['lineNumber'],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user