Introducing debugger modes (run, breakpoint). (#1645)
This makes the code more robust and error prone, since certain messages cannot be received in certain situations, e.g. an eval command during garbage collection. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -894,10 +894,43 @@ function DebuggerClient(address)
|
||||
}
|
||||
}
|
||||
|
||||
this.sendResumeExec = function(command)
|
||||
{
|
||||
if (!lastBreakpointHit)
|
||||
{
|
||||
appendLog("This command is allowed only if JavaScript execution is stopped at a breakpoint.");
|
||||
return;
|
||||
}
|
||||
|
||||
encodeMessage("B", [ command ]);
|
||||
|
||||
lastBreakpointHit = null;
|
||||
}
|
||||
|
||||
this.sendGetBacktrace = function(depth)
|
||||
{
|
||||
if (!lastBreakpointHit)
|
||||
{
|
||||
appendLog("This command is allowed only if JavaScript execution is stopped at a breakpoint.");
|
||||
return;
|
||||
}
|
||||
|
||||
encodeMessage("BI", [ JERRY_DEBUGGER_GET_BACKTRACE, max_depth ]);
|
||||
|
||||
appendLog("Backtrace:");
|
||||
}
|
||||
|
||||
this.sendEval = function(str)
|
||||
{
|
||||
if (!lastBreakpointHit)
|
||||
{
|
||||
appendLog("This command is allowed only if JavaScript execution is stopped at a breakpoint.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (str == "")
|
||||
{
|
||||
appendLog("Argument required");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1054,23 +1087,24 @@ function debuggerCommand(event)
|
||||
debuggerObj.deleteBreakpoint(args[2]);
|
||||
break;
|
||||
|
||||
case "st":
|
||||
case "stop":
|
||||
debuggerObj.encodeMessage("B", [ JERRY_DEBUGGER_STOP ]);
|
||||
break;
|
||||
|
||||
case "c":
|
||||
case "continue":
|
||||
debuggerObj.encodeMessage("B", [ JERRY_DEBUGGER_CONTINUE ]);
|
||||
debuggerObj.sendResumeExec(JERRY_DEBUGGER_CONTINUE);
|
||||
break;
|
||||
|
||||
case "s":
|
||||
case "step":
|
||||
debuggerObj.encodeMessage("B", [ JERRY_DEBUGGER_STEP ]);
|
||||
debuggerObj.sendResumeExec(JERRY_DEBUGGER_STEP);
|
||||
break;
|
||||
|
||||
case "n":
|
||||
case "next":
|
||||
debuggerObj.encodeMessage("B", [ JERRY_DEBUGGER_NEXT ]);
|
||||
debuggerObj.sendResumeExec(JERRY_DEBUGGER_NEXT);
|
||||
break;
|
||||
|
||||
case "e":
|
||||
@@ -1095,9 +1129,7 @@ function debuggerCommand(event)
|
||||
}
|
||||
}
|
||||
|
||||
appendLog("Backtrace:");
|
||||
|
||||
debuggerObj.encodeMessage("BI", [ JERRY_DEBUGGER_GET_BACKTRACE, max_depth ]);
|
||||
debuggerObj.sendGetBacktrace(max_depth);
|
||||
break;
|
||||
|
||||
case "src":
|
||||
|
||||
@@ -68,6 +68,7 @@ def arguments_parse():
|
||||
|
||||
parser.add_argument("address", action="store", nargs="?", default="localhost:5001", help="specify a unique network address for connection (default: %(default)s)")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", default=False, help="increase verbosity (default: %(default)s)")
|
||||
parser.add_argument("--non-interactive", action="store_true", default=False, help="disable stop when newline is pressed (default: %(default)s)")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -140,7 +141,7 @@ class DebuggerPrompt(Cmd):
|
||||
self.debugger = debugger
|
||||
self.stop = False
|
||||
self.quit = False
|
||||
self.cont = False
|
||||
self.cont = True
|
||||
|
||||
def precmd(self, line):
|
||||
self.stop = False
|
||||
@@ -188,12 +189,14 @@ class DebuggerPrompt(Cmd):
|
||||
def do_step(self, args):
|
||||
""" Next breakpoint, step into functions """
|
||||
self.exec_command(args, JERRY_DEBUGGER_STEP)
|
||||
self.cont = True
|
||||
|
||||
do_s = do_step
|
||||
|
||||
def do_next(self, args):
|
||||
""" Next breakpoint in the same context """
|
||||
self.exec_command(args, JERRY_DEBUGGER_NEXT)
|
||||
self.cont = True
|
||||
|
||||
do_n = do_next
|
||||
|
||||
@@ -669,13 +672,15 @@ def main():
|
||||
|
||||
debugger = JerryDebugger(args.address)
|
||||
|
||||
non_interactive = args.non_interactive
|
||||
|
||||
logging.debug("Connected to JerryScript on %d port" % (debugger.port))
|
||||
|
||||
prompt = DebuggerPrompt(debugger)
|
||||
prompt.prompt = "(jerry-debugger) "
|
||||
|
||||
while True:
|
||||
if prompt.cont:
|
||||
if not non_interactive and prompt.cont:
|
||||
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
|
||||
sys.stdin.readline()
|
||||
prompt.cont = False
|
||||
|
||||
Reference in New Issue
Block a user