diff --git a/scripts/cdb/cmd.py b/scripts/cdb/cmd.py index 1806ae7..05c7d95 100644 --- a/scripts/cdb/cmd.py +++ b/scripts/cdb/cmd.py @@ -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: diff --git a/scripts/cdb/scriptmgr.py b/scripts/cdb/scriptmgr.py index 7a65c6e..9e30166 100644 --- a/scripts/cdb/scriptmgr.py +++ b/scripts/cdb/scriptmgr.py @@ -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']