Skip to content

Commit 6f25d6e

Browse files
authored
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 [email protected]
1 parent 3c9a791 commit 6f25d6e

File tree

9 files changed

+26
-26
lines changed

9 files changed

+26
-26
lines changed

jerry-debugger/jerry_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ def do_eval(self, args):
168168
self.debugger.eval(args)
169169
self.stop = True
170170
do_e = do_eval
171+
do_print = do_eval
172+
do_p = do_eval
171173

172174
def do_eval_at(self, args):
173175
""" Evaluate JavaScript source code at a scope chain level """

jerry-debugger/jerry_client_main.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ class JerryPendingBreakpoint(object):
175175
def __init__(self, line=None, source_name=None, function=None):
176176
self.function = function
177177
self.line = line
178-
self.source_name = source_name
178+
self.source_name = source_name or ""
179179

180180
self.index = -1
181181

182182
def __str__(self):
183-
result = self.source_name or ""
183+
result = self.source_name
184184
if self.line:
185185
result += ":%d" % (self.line)
186186
else:
@@ -761,8 +761,8 @@ def process_messages(self):
761761
result += "Frame %d: %s\n" % (frame_index, breakpoint[0])
762762

763763
frame_index += 1
764-
buffer_pos += 6
765-
buffer_size -= 6
764+
buffer_pos += self.cp_size + 4
765+
buffer_size -= self.cp_size + 4
766766

767767
if buffer_type == JERRY_DEBUGGER_BACKTRACE_END:
768768
self.prompt = True
@@ -992,7 +992,9 @@ def _parse_source(self, data):
992992
for breakpoint_index, breakpoint in bp_list.items():
993993
source_lines = 0
994994
for src in new_function_list.values():
995-
if src.source_name == breakpoint.source_name:
995+
if (src.source_name == breakpoint.source_name or
996+
src.source_name.endswith("/" + breakpoint.source_name) or
997+
src.source_name.endswith("\\" + breakpoint.source_name)):
996998
source_lines = len(src.source)
997999
break
9981000

@@ -1089,8 +1091,8 @@ def _set_breakpoint(self, string, pending):
10891091
result += self._enable_breakpoint(function.lines[function.first_breakpoint_line])
10901092

10911093
if not result and not pending:
1092-
print("No breakpoint found, do you want to add a %spending breakpoint%s? (y or [n])" % \
1093-
(self.yellow, self.nocolor))
1094+
print("No breakpoint found, do you want to add a %spending breakpoint%s? (y or [n]) " % \
1095+
(self.yellow, self.nocolor), end='')
10941096

10951097
ans = sys.stdin.readline()
10961098
if ans in ['yes\n', 'y\n']:

tests/debugger/do_delete.expected

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Stopped at tests/debugger/do_delete.js:17
66
(jerry-debugger) b do_delete.js:17
77
Breakpoint 1 at tests/debugger/do_delete.js:17
88
(jerry-debugger) b do_delete.js:21
9-
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
10-
Pending breakpoint 2 at do_delete.js:21
9+
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 2 at do_delete.js:21
1110
(jerry-debugger) b do_delete.js:19
1211
Breakpoint 3 at tests/debugger/do_delete.js:19
1312
(jerry-debugger) b do_delete.js:18

tests/debugger/do_delete_all.expected

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ Breakpoint 2 at tests/debugger/do_delete_all.js:18
77
(jerry-debugger) b do_delete_all.js:21
88
Breakpoint 3 at tests/debugger/do_delete_all.js:21 (in delete_test() at line:20, col:1)
99
(jerry-debugger) b do_delete_all:350
10-
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
11-
Pending breakpoint 4 at do_delete_all:350
10+
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 4 at do_delete_all:350
1211
(jerry-debugger) b do_delete_all:37
13-
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
14-
Pending breakpoint 5 at do_delete_all:37
12+
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 5 at do_delete_all:37
1513
(jerry-debugger) list
1614
=== Active breakpoints ===
1715
1: tests/debugger/do_delete_all.js:17

tests/debugger/do_eval.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ n
33
eval a
44
break f
55
n
6-
e b
6+
p b
77
next
8-
e b
8+
print b
99
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
1010
e b = 8
1111
n

tests/debugger/do_eval.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Stopped at tests/debugger/do_eval.js:23
1010
Breakpoint 1 at tests/debugger/do_eval.js:19 (in f() at line:17, col:1)
1111
(jerry-debugger) n
1212
Stopped at breakpoint:1 tests/debugger/do_eval.js:19 (in f() at line:17, col:1)
13-
(jerry-debugger) e b
13+
(jerry-debugger) p b
1414
undefined
1515
(jerry-debugger) next
1616
Stopped at tests/debugger/do_eval.js:20 (in f() at line:17, col:1)
17-
(jerry-debugger) e b
17+
(jerry-debugger) print b
1818
6
1919
(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
2020
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

tests/debugger/do_help.expected

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Stopped at tests/debugger/do_help.js:15
44

55
Documented commands (type help <topic>):
66
========================================
7-
EOF bt dump f ms restart src
8-
abort c e finish n s step
9-
b continue eval help next scope throw
10-
backtrace delete eval_at list quit scroll variables
11-
break display exception memstats res source
7+
EOF bt dump f ms quit scroll variables
8+
abort c e finish n res source
9+
b continue eval help next restart src
10+
backtrace delete eval_at list p s step
11+
break display exception memstats print scope throw
1212

1313
(jerry-debugger) quit

tests/debugger/do_pending_breakpoints.expected

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
Connecting to: localhost:5001
22
Stopped at tests/debugger/do_pending_breakpoints.js:15
33
(jerry-debugger) break :1
4-
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
5-
Pending breakpoint 1 at :1
4+
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 1 at :1
65
(jerry-debugger) break f
7-
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
8-
Pending breakpoint 2 at f()
6+
No breakpoint found, do you want to add a pending breakpoint? (y or [n]) Pending breakpoint 2 at f()
97
(jerry-debugger) list
108
=== Pending breakpoints ===
119
1: :1 (pending)

tools/srcgenerator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def generate_jerry_core(output_dir, verbose=False):
6767
'python', SRCMERGER,
6868
'--base-dir', JERRY_CORE,
6969
'--input={}/include/jerryscript.h'.format(JERRY_CORE),
70+
'--input={}/include/jerryscript-debugger-transport.h'.format(JERRY_CORE),
7071
'--output={}/jerryscript.h'.format(output_dir),
7172
'--remove-include=config.h',
7273
'--push-include=jerryscript-config.h',

0 commit comments

Comments
 (0)