Improve JerryScript debugger (#4299)

- Support print (p) as alias to eval (e)
- Fix backtrace processing (incorrect increment when cpointer is 4 byte long)
- Support partial names for pending breakpoints (similar to normal breakpoints)
- Don't print newline after pending breakpoint dialog text
- Add jerryscript-debugger-transport.h to all-in-one build

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2020-10-19 15:26:19 +02:00
committed by GitHub
parent 3c9a7915e1
commit 6f25d6ed31
9 changed files with 26 additions and 26 deletions
+2
View File
@@ -168,6 +168,8 @@ class DebuggerPrompt(Cmd):
self.debugger.eval(args) self.debugger.eval(args)
self.stop = True self.stop = True
do_e = do_eval do_e = do_eval
do_print = do_eval
do_p = do_eval
def do_eval_at(self, args): def do_eval_at(self, args):
""" Evaluate JavaScript source code at a scope chain level """ """ Evaluate JavaScript source code at a scope chain level """
+9 -7
View File
@@ -175,12 +175,12 @@ class JerryPendingBreakpoint(object):
def __init__(self, line=None, source_name=None, function=None): def __init__(self, line=None, source_name=None, function=None):
self.function = function self.function = function
self.line = line self.line = line
self.source_name = source_name self.source_name = source_name or ""
self.index = -1 self.index = -1
def __str__(self): def __str__(self):
result = self.source_name or "" result = self.source_name
if self.line: if self.line:
result += ":%d" % (self.line) result += ":%d" % (self.line)
else: else:
@@ -761,8 +761,8 @@ class JerryDebugger(object):
result += "Frame %d: %s\n" % (frame_index, breakpoint[0]) result += "Frame %d: %s\n" % (frame_index, breakpoint[0])
frame_index += 1 frame_index += 1
buffer_pos += 6 buffer_pos += self.cp_size + 4
buffer_size -= 6 buffer_size -= self.cp_size + 4
if buffer_type == JERRY_DEBUGGER_BACKTRACE_END: if buffer_type == JERRY_DEBUGGER_BACKTRACE_END:
self.prompt = True self.prompt = True
@@ -992,7 +992,9 @@ class JerryDebugger(object):
for breakpoint_index, breakpoint in bp_list.items(): for breakpoint_index, breakpoint in bp_list.items():
source_lines = 0 source_lines = 0
for src in new_function_list.values(): for src in new_function_list.values():
if src.source_name == breakpoint.source_name: if (src.source_name == breakpoint.source_name or
src.source_name.endswith("/" + breakpoint.source_name) or
src.source_name.endswith("\\" + breakpoint.source_name)):
source_lines = len(src.source) source_lines = len(src.source)
break break
@@ -1089,8 +1091,8 @@ class JerryDebugger(object):
result += self._enable_breakpoint(function.lines[function.first_breakpoint_line]) result += self._enable_breakpoint(function.lines[function.first_breakpoint_line])
if not result and not pending: if not result and not pending:
print("No breakpoint found, do you want to add a %spending breakpoint%s? (y or [n])" % \ print("No breakpoint found, do you want to add a %spending breakpoint%s? (y or [n]) " % \
(self.yellow, self.nocolor)) (self.yellow, self.nocolor), end='')
ans = sys.stdin.readline() ans = sys.stdin.readline()
if ans in ['yes\n', 'y\n']: if ans in ['yes\n', 'y\n']:
+1 -2
View File
@@ -6,8 +6,7 @@ Stopped at tests/debugger/do_delete.js:17
(jerry-debugger) b do_delete.js:17 (jerry-debugger) b do_delete.js:17
Breakpoint 1 at tests/debugger/do_delete.js:17 Breakpoint 1 at tests/debugger/do_delete.js:17
(jerry-debugger) b do_delete.js:21 (jerry-debugger) b do_delete.js:21
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 2 at do_delete.js:21
Pending breakpoint 2 at do_delete.js:21
(jerry-debugger) b do_delete.js:19 (jerry-debugger) b do_delete.js:19
Breakpoint 3 at tests/debugger/do_delete.js:19 Breakpoint 3 at tests/debugger/do_delete.js:19
(jerry-debugger) b do_delete.js:18 (jerry-debugger) b do_delete.js:18
+2 -4
View File
@@ -7,11 +7,9 @@ Breakpoint 2 at tests/debugger/do_delete_all.js:18
(jerry-debugger) b do_delete_all.js:21 (jerry-debugger) b do_delete_all.js:21
Breakpoint 3 at tests/debugger/do_delete_all.js:21 (in delete_test() at line:20, col:1) Breakpoint 3 at tests/debugger/do_delete_all.js:21 (in delete_test() at line:20, col:1)
(jerry-debugger) b do_delete_all:350 (jerry-debugger) b do_delete_all:350
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 4 at do_delete_all:350
Pending breakpoint 4 at do_delete_all:350
(jerry-debugger) b do_delete_all:37 (jerry-debugger) b do_delete_all:37
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 5 at do_delete_all:37
Pending breakpoint 5 at do_delete_all:37
(jerry-debugger) list (jerry-debugger) list
=== Active breakpoints === === Active breakpoints ===
1: tests/debugger/do_delete_all.js:17 1: tests/debugger/do_delete_all.js:17
+2 -2
View File
@@ -3,9 +3,9 @@ n
eval a eval a
break f break f
n n
e b p b
next next
e b print b
e "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 XXX 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 YYY 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 ZZZ " + 123 e "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 XXX 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 YYY 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 ZZZ " + 123
e b = 8 e b = 8
n n
+2 -2
View File
@@ -10,11 +10,11 @@ Stopped at tests/debugger/do_eval.js:23
Breakpoint 1 at tests/debugger/do_eval.js:19 (in f() at line:17, col:1) Breakpoint 1 at tests/debugger/do_eval.js:19 (in f() at line:17, col:1)
(jerry-debugger) n (jerry-debugger) n
Stopped at breakpoint:1 tests/debugger/do_eval.js:19 (in f() at line:17, col:1) Stopped at breakpoint:1 tests/debugger/do_eval.js:19 (in f() at line:17, col:1)
(jerry-debugger) e b (jerry-debugger) p b
undefined undefined
(jerry-debugger) next (jerry-debugger) next
Stopped at tests/debugger/do_eval.js:20 (in f() at line:17, col:1) Stopped at tests/debugger/do_eval.js:20 (in f() at line:17, col:1)
(jerry-debugger) e b (jerry-debugger) print b
6 6
(jerry-debugger) e "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 XXX 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 YYY 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 ZZZ " + 123 (jerry-debugger) e "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 XXX 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 YYY 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 ZZZ " + 123
1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 XXX 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 YYY 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 ZZZ 123 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 XXX 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 YYY 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 ZZZ 123
+5 -5
View File
@@ -4,10 +4,10 @@ Stopped at tests/debugger/do_help.js:15
Documented commands (type help <topic>): Documented commands (type help <topic>):
======================================== ========================================
EOF bt dump f ms restart src EOF bt dump f ms quit scroll variables
abort c e finish n s step abort c e finish n res source
b continue eval help next scope throw b continue eval help next restart src
backtrace delete eval_at list quit scroll variables backtrace delete eval_at list p s step
break display exception memstats res source break display exception memstats print scope throw
(jerry-debugger) quit (jerry-debugger) quit
@@ -1,11 +1,9 @@
Connecting to: localhost:5001 Connecting to: localhost:5001
Stopped at tests/debugger/do_pending_breakpoints.js:15 Stopped at tests/debugger/do_pending_breakpoints.js:15
(jerry-debugger) break :1 (jerry-debugger) break :1
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 1 at :1
Pending breakpoint 1 at :1
(jerry-debugger) break f (jerry-debugger) break f
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 2 at f()
Pending breakpoint 2 at f()
(jerry-debugger) list (jerry-debugger) list
=== Pending breakpoints === === Pending breakpoints ===
1: :1 (pending) 1: :1 (pending)
+1
View File
@@ -67,6 +67,7 @@ def generate_jerry_core(output_dir, verbose=False):
'python', SRCMERGER, 'python', SRCMERGER,
'--base-dir', JERRY_CORE, '--base-dir', JERRY_CORE,
'--input={}/include/jerryscript.h'.format(JERRY_CORE), '--input={}/include/jerryscript.h'.format(JERRY_CORE),
'--input={}/include/jerryscript-debugger-transport.h'.format(JERRY_CORE),
'--output={}/jerryscript.h'.format(output_dir), '--output={}/jerryscript.h'.format(output_dir),
'--remove-include=config.h', '--remove-include=config.h',
'--push-include=jerryscript-config.h', '--push-include=jerryscript-config.h',