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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 26 deletions

View File

@ -168,6 +168,8 @@ class DebuggerPrompt(Cmd):
self.debugger.eval(args)
self.stop = True
do_e = do_eval
do_print = do_eval
do_p = do_eval
def do_eval_at(self, args):
""" Evaluate JavaScript source code at a scope chain level """

View File

@ -175,12 +175,12 @@ class JerryPendingBreakpoint(object):
def __init__(self, line=None, source_name=None, function=None):
self.function = function
self.line = line
self.source_name = source_name
self.source_name = source_name or ""
self.index = -1
def __str__(self):
result = self.source_name or ""
result = self.source_name
if self.line:
result += ":%d" % (self.line)
else:
@ -761,8 +761,8 @@ class JerryDebugger(object):
result += "Frame %d: %s\n" % (frame_index, breakpoint[0])
frame_index += 1
buffer_pos += 6
buffer_size -= 6
buffer_pos += self.cp_size + 4
buffer_size -= self.cp_size + 4
if buffer_type == JERRY_DEBUGGER_BACKTRACE_END:
self.prompt = True
@ -992,7 +992,9 @@ class JerryDebugger(object):
for breakpoint_index, breakpoint in bp_list.items():
source_lines = 0
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)
break
@ -1089,8 +1091,8 @@ class JerryDebugger(object):
result += self._enable_breakpoint(function.lines[function.first_breakpoint_line])
if not result and not pending:
print("No breakpoint found, do you want to add a %spending breakpoint%s? (y or [n])" % \
(self.yellow, self.nocolor))
print("No breakpoint found, do you want to add a %spending breakpoint%s? (y or [n]) " % \
(self.yellow, self.nocolor), end='')
ans = sys.stdin.readline()
if ans in ['yes\n', 'y\n']:

View File

@ -6,8 +6,7 @@ Stopped at tests/debugger/do_delete.js:17
(jerry-debugger) b do_delete.js:17
Breakpoint 1 at tests/debugger/do_delete.js:17
(jerry-debugger) b do_delete.js:21
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
Pending breakpoint 2 at do_delete.js:21
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 2 at do_delete.js:21
(jerry-debugger) b do_delete.js:19
Breakpoint 3 at tests/debugger/do_delete.js:19
(jerry-debugger) b do_delete.js:18

View File

@ -7,11 +7,9 @@ Breakpoint 2 at tests/debugger/do_delete_all.js:18
(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)
(jerry-debugger) b do_delete_all:350
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
Pending breakpoint 4 at do_delete_all:350
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 4 at do_delete_all:350
(jerry-debugger) b do_delete_all:37
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
Pending breakpoint 5 at do_delete_all:37
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 5 at do_delete_all:37
(jerry-debugger) list
=== Active breakpoints ===
1: tests/debugger/do_delete_all.js:17

View File

@ -3,9 +3,9 @@ n
eval a
break f
n
e b
p b
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 b = 8
n

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)
(jerry-debugger) n
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
(jerry-debugger) next
Stopped at tests/debugger/do_eval.js:20 (in f() at line:17, col:1)
(jerry-debugger) e b
(jerry-debugger) print b
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
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

View File

@ -4,10 +4,10 @@ Stopped at tests/debugger/do_help.js:15
Documented commands (type help <topic>):
========================================
EOF bt dump f ms restart src
abort c e finish n s step
b continue eval help next scope throw
backtrace delete eval_at list quit scroll variables
break display exception memstats res source
EOF bt dump f ms quit scroll variables
abort c e finish n res source
b continue eval help next restart src
backtrace delete eval_at list p s step
break display exception memstats print scope throw
(jerry-debugger) quit

View File

@ -1,11 +1,9 @@
Connecting to: localhost:5001
Stopped at tests/debugger/do_pending_breakpoints.js:15
(jerry-debugger) break :1
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
Pending breakpoint 1 at :1
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 1 at :1
(jerry-debugger) break f
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
Pending breakpoint 2 at f()
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 2 at f()
(jerry-debugger) list
=== Pending breakpoints ===
1: :1 (pending)

View File

@ -67,6 +67,7 @@ def generate_jerry_core(output_dir, verbose=False):
'python', SRCMERGER,
'--base-dir', JERRY_CORE,
'--input={}/include/jerryscript.h'.format(JERRY_CORE),
'--input={}/include/jerryscript-debugger-transport.h'.format(JERRY_CORE),
'--output={}/jerryscript.h'.format(output_dir),
'--remove-include=config.h',
'--push-include=jerryscript-config.h',