Multiple nexts with one command (#2207)

Make a next command more gdb like.
If an argument is given `next 10`, it does 10 nexts.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
This commit is contained in:
Daniel Balla
2018-03-08 10:46:03 +01:00
committed by László Langó
parent 29b337d159
commit 685af74a10
+24 -2
View File
@@ -25,6 +25,7 @@ import socket
import struct import struct
import sys import sys
import math import math
import time
# Expected debugger protocol version. # Expected debugger protocol version.
JERRY_DEBUGGER_VERSION = 1 JERRY_DEBUGGER_VERSION = 1
@@ -265,7 +266,22 @@ class DebuggerPrompt(Cmd):
def do_next(self, args): def do_next(self, args):
""" Next breakpoint in the same context """ """ Next breakpoint in the same context """
self._exec_command(args, JERRY_DEBUGGER_NEXT) if not args:
args = 0
else:
try:
args = int(args)
if args <= 0:
raise ValueError(args)
except ValueError as val_errno:
print("Error: expected a positive integer: %s" % val_errno)
return
args = min(args, len(self.debugger.last_breakpoint_hit.function.lines) -
self.debugger.last_breakpoint_hit.function.line) - 1
self.debugger.repeats_remain = args
self._exec_command("", JERRY_DEBUGGER_NEXT)
self.cont = True self.cont = True
do_n = do_next do_n = do_next
@@ -561,6 +577,7 @@ class JerryDebugger(object):
self.src_offset_diff = 0 self.src_offset_diff = 0
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.client_socket.connect((self.host, self.port)) self.client_socket.connect((self.host, self.port))
self.repeats_remain = 0
self.send_message(b"GET /jerry-debugger HTTP/1.1\r\n" + self.send_message(b"GET /jerry-debugger HTTP/1.1\r\n" +
b"Upgrade: websocket\r\n" + b"Upgrade: websocket\r\n" +
@@ -1141,7 +1158,12 @@ def main():
if debugger.display: if debugger.display:
print_source(prompt.debugger, debugger.display, 0) print_source(prompt.debugger, debugger.display, 0)
prompt.cmdloop() if debugger.repeats_remain:
prompt.do_next(debugger.repeats_remain)
time.sleep(0.1)
else:
prompt.cmdloop()
if prompt.quit: if prompt.quit:
break break