Improve breakpoint generator of the debugger. (#1652)

Now the debugger generates a breakpoint for each function before
its first executable statement. This allows inspecting the function
arguments. Position (line and column) info is also added which
simplifies finding of anonymus functions. Several tests were
update to check more corner cases.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2017-03-13 11:36:34 +01:00
committed by GitHub
parent 57ea06782b
commit 679500b327
30 changed files with 409 additions and 226 deletions
+4 -1
View File
@@ -3,7 +3,10 @@ n
next
step
next
n
s
bt
n
n
s
backtrace
c
+12 -6
View File
@@ -3,12 +3,18 @@ Stopped at tests/debugger/do_backtrace.js:15
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:28
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:37
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:40
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:30 (in test)
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:32 (in test)
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:33 (in test)
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:21 (in foo)
(jerry-debugger) Frame 0: tests/debugger/do_backtrace.js:21 (in foo)
Frame 1: tests/debugger/do_backtrace.js:33 (in test)
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:32 (in test() at line:30, col:1)
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:33 (in test() at line:30, col:1)
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
(jerry-debugger) Frame 0: tests/debugger/do_backtrace.js:23 (in foo() at line:21, col:1)
Frame 1: tests/debugger/do_backtrace.js:33 (in test() at line:30, col:1)
Frame 2: tests/debugger/do_backtrace.js:40
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:24 (in foo() at line:21, col:1)
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:25 (in foo() at line:21, col:1)
(jerry-debugger) Stopped at tests/debugger/do_backtrace.js:18 (in f4() at line:17, col:1)
(jerry-debugger) Frame 0: tests/debugger/do_backtrace.js:18 (in f4() at line:17, col:1)
Frame 1: tests/debugger/do_backtrace.js:25 (in foo() at line:21, col:1)
Frame 2: tests/debugger/do_backtrace.js:33 (in test() at line:30, col:1)
Frame 3: tests/debugger/do_backtrace.js:40
(jerry-debugger) Press enter to stop JavaScript execution.
Connection closed.
+8 -5
View File
@@ -1,7 +1,10 @@
break do_break.js:24
b do_break.js:27
b do_break.js:17
break do_break.js:51
b do_break.js:36
break f
list
delete 2
next
c
delete 1
list
c
continue
c
+17 -7
View File
@@ -1,11 +1,21 @@
Connecting to: localhost:5001
Stopped at tests/debugger/do_break.js:15
(jerry-debugger) Breakpoint 1 at tests/debugger/do_break.js:24 (in test)
(jerry-debugger) Breakpoint 2 at tests/debugger/do_break.js:27 (in test)
(jerry-debugger) Breakpoint 3 at tests/debugger/do_break.js:17
(jerry-debugger) 1: tests/debugger/do_break.js:24 (in test)
2: tests/debugger/do_break.js:27 (in test)
3: tests/debugger/do_break.js:17
(jerry-debugger) (jerry-debugger) Stopped at breakpoint:3 tests/debugger/do_break.js:17
(jerry-debugger) Breakpoint 1 at tests/debugger/do_break.js:51
(jerry-debugger) Breakpoint 2 at tests/debugger/do_break.js:36 (in test() at line:20, col:1)
(jerry-debugger) Breakpoint 3 at tests/debugger/do_break.js:33 (in f() at line:31, col:3)
Breakpoint 4 at tests/debugger/do_break.js:45 (in f() at line:43, col:1)
(jerry-debugger) 1: tests/debugger/do_break.js:51
2: tests/debugger/do_break.js:36 (in test() at line:20, col:1)
3: tests/debugger/do_break.js:33 (in f() at line:31, col:3)
4: tests/debugger/do_break.js:45 (in f() at line:43, col:1)
(jerry-debugger) Press enter to stop JavaScript execution.
Stopped at breakpoint:1 tests/debugger/do_break.js:51
(jerry-debugger) (jerry-debugger) 2: tests/debugger/do_break.js:36 (in test() at line:20, col:1)
3: tests/debugger/do_break.js:33 (in f() at line:31, col:3)
4: tests/debugger/do_break.js:45 (in f() at line:43, col:1)
(jerry-debugger) Press enter to stop JavaScript execution.
Stopped at breakpoint:2 tests/debugger/do_break.js:36 (in test() at line:20, col:1)
(jerry-debugger) Press enter to stop JavaScript execution.
Stopped at breakpoint:3 tests/debugger/do_break.js:33 (in f() at line:31, col:3)
(jerry-debugger) Press enter to stop JavaScript execution.
Connection closed.
+28 -10
View File
@@ -17,17 +17,35 @@ print("break test");
print ("var cat");
var cat = 'cat';
function test()
function test(x)
{
print("function test");
foo();
var a = 3;
var b = 5;
var c = a + b;
global_var = c;
return c;
function f() {
return 0;
}
function f() {
/* Again. */
return 1;
}
function f() {
/* And again. */
return 2;
}
print("function test");
var a = 3;
var b = 5, c = a + b;
global_var = f();
return c;
}
function f() {
/* And again. */
}
var
x =
1;
x =
1;
test(x);
+1
View File
@@ -0,0 +1 @@
continue
+3
View File
@@ -0,0 +1,3 @@
Connecting to: localhost:5001
Stopped at tests/debugger/do_continue.js:16
(jerry-debugger) Press enter to stop JavaScript execution.
+15
View File
@@ -0,0 +1,15 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/* Empty file. */
+2 -2
View File
@@ -2,10 +2,10 @@ Connecting to: localhost:5001
Stopped at tests/debugger/do_delete_all.js:15
(jerry-debugger) Breakpoint 1 at tests/debugger/do_delete_all.js:17
(jerry-debugger) Breakpoint 2 at tests/debugger/do_delete_all.js:18
(jerry-debugger) Breakpoint 3 at tests/debugger/do_delete_all.js:21 (in delete_test)
(jerry-debugger) Breakpoint 3 at tests/debugger/do_delete_all.js:21 (in delete_test() at line:20, col:1)
(jerry-debugger) 1: tests/debugger/do_delete_all.js:17
2: tests/debugger/do_delete_all.js:18
3: tests/debugger/do_delete_all.js:21 (in delete_test)
3: tests/debugger/do_delete_all.js:21 (in delete_test() at line:20, col:1)
(jerry-debugger) (jerry-debugger) Stopped at tests/debugger/do_delete_all.js:16
(jerry-debugger) Press enter to stop JavaScript execution.
Connection closed.
-1
View File
@@ -1,3 +1,2 @@
step
dump
c
+7 -8
View File
@@ -1,12 +1,11 @@
Connecting to: localhost:5001
Stopped at tests/debugger/do_dump.js:15
(jerry-debugger) Stopped at tests/debugger/do_dump.js:42
(jerry-debugger) {68: Function(byte_code_cp:0x44, source_name:"tests/debugger/do_dump.js", name:"f4", { Breakpoint(line:32, offset:17, active_index:-1),Breakpoint(line:31, offset:16, active_index:-1) }),
79: Function(byte_code_cp:0x4f, source_name:"tests/debugger/do_dump.js", name:"f1", { Breakpoint(line:17, offset:21, active_index:-1),Breakpoint(line:27, offset:22, active_index:-1) }),
102: Function(byte_code_cp:0x66, source_name:"tests/debugger/do_dump.js", name:"f2", { Breakpoint(line:19, offset:14, active_index:-1),Breakpoint(line:21, offset:15, active_index:-1) }),
105: Function(byte_code_cp:0x69, source_name:"tests/debugger/do_dump.js", name:"foo", { Breakpoint(line:35, offset:22, active_index:-1),Breakpoint(line:37, offset:23, active_index:-1),Breakpoint(line:38, offset:28, active_index:-1),Breakpoint(line:39, offset:33, active_index:-1) }),
125: Function(byte_code_cp:0x7d, source_name:"tests/debugger/do_dump.js", name:"f3", { Breakpoint(line:22, offset:25, active_index:-1),Breakpoint(line:23, offset:30, active_index:-1) }),
131: Function(byte_code_cp:0x83, source_name:"tests/debugger/do_dump.js", name:"", { Breakpoint(line:57, offset:63, active_index:-1),Breakpoint(line:42, offset:54, active_index:-1),Breakpoint(line:43, offset:59, active_index:-1),Breakpoint(line:60, offset:68, active_index:-1),Breakpoint(line:15, offset:49, active_index:-1) }),
154: Function(byte_code_cp:0x9a, source_name:"tests/debugger/do_dump.js", name:"test", { Breakpoint(line:45, offset:28, active_index:-1),Breakpoint(line:47, offset:29, active_index:-1),Breakpoint(line:48, offset:34, active_index:-1),Breakpoint(line:49, offset:38, active_index:-1),Breakpoint(line:50, offset:43, active_index:-1),Breakpoint(line:51, offset:48, active_index:-1),Breakpoint(line:52, offset:54, active_index:-1),Breakpoint(line:53, offset:58, active_index:-1) })}
(jerry-debugger) {60: Function(byte_code_cp:0x3c, source_name:"tests/debugger/do_dump.js", name:"", line:54, column: 8 { Breakpoint(line:58, offset:12, active_index:-1) }),
64: Function(byte_code_cp:0x40, source_name:"tests/debugger/do_dump.js", name:"func", line:34, column: 1 { Breakpoint(line:36, offset:16, active_index:-1) }),
79: Function(byte_code_cp:0x4f, source_name:"tests/debugger/do_dump.js", name:"f1", line:17, column: 1 { Breakpoint(line:30, offset:23, active_index:-1) }),
100: Function(byte_code_cp:0x64, source_name:"tests/debugger/do_dump.js", name:"g2", line:26, column: 5 { Breakpoint(line:26, offset:12, active_index:-1) }),
102: Function(byte_code_cp:0x66, source_name:"tests/debugger/do_dump.js", name:"f2", line:19, column: 3 { Breakpoint(line:27, offset:26, active_index:-1) }),
109: Function(byte_code_cp:0x6d, source_name:"tests/debugger/do_dump.js", name:"g1", line:21, column: 5 { Breakpoint(line:22, offset:18, active_index:-1),Breakpoint(line:23, offset:23, active_index:-1) }),
128: Function(byte_code_cp:0x80, source_name:"tests/debugger/do_dump.js", name:"", line:1, column: 1 { Breakpoint(line:41, offset:47, active_index:-1),Breakpoint(line:51, offset:57, active_index:-1),Breakpoint(line:49, offset:52, active_index:-1),Breakpoint(line:54, offset:62, active_index:-1),Breakpoint(line:15, offset:42, active_index:-1) })}
(jerry-debugger) Press enter to stop JavaScript execution.
Connection closed.
+29 -31
View File
@@ -16,45 +16,43 @@ print("first line of code");
function f1()
{
function f2()
{
return function f3() {
a = 4;
print("funciton f3");
};
}
function f2()
{
function g1() {
a = 4;
return print("funciton f3");
}
x =
6;
function g2() { }
}
var
x =
6;
}
function f4() {
print("function f4");
function func() {
'use strict';
'use stri' + 'ct';
}
function foo()
{
print("function foo");
var tmp = 4;
f4();
{
print("Y");
}
}
print ("var cat");
var cat = 'cat';
function test()
{
print("function test");
foo();
var a = 3;
var b = 5;
var c = a + b;
global_var = c;
return c;
}
;
;
var
x =
1;
x =
1,
y =
2
test();
test = function
(
)
{
}
+3 -1
View File
@@ -7,5 +7,7 @@ e b
next
e 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
next
e b = 8
n
e a
c
+7 -5
View File
@@ -3,12 +3,14 @@ Stopped at tests/debugger/do_eval.js:15
(jerry-debugger) undefined
(jerry-debugger) Stopped at tests/debugger/do_eval.js:23
(jerry-debugger) 5
(jerry-debugger) Breakpoint 1 at tests/debugger/do_eval.js:17 (in f)
(jerry-debugger) Stopped at breakpoint:1 tests/debugger/do_eval.js:17 (in f)
(jerry-debugger) undefined
(jerry-debugger) Stopped at tests/debugger/do_eval.js:19 (in f)
(jerry-debugger) Breakpoint 1 at tests/debugger/do_eval.js:19 (in f() at line:17, col:1)
(jerry-debugger) Stopped at breakpoint:1 tests/debugger/do_eval.js:19 (in f() at line:17, col:1)
(jerry-debugger) undefined
(jerry-debugger) Stopped at tests/debugger/do_eval.js:20 (in f() at line:17, col:1)
(jerry-debugger) 6
(jerry-debugger) 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) Stopped at tests/debugger/do_eval.js:20 (in f)
(jerry-debugger) 8
(jerry-debugger) Stopped at tests/debugger/do_eval.js:24
(jerry-debugger) 11.3
(jerry-debugger) Press enter to stop JavaScript execution.
Connection closed.
+2 -1
View File
@@ -20,4 +20,5 @@ function f(a)
return a + b;
}
f(3.3)
a = f(3.3);
null;
-1
View File
@@ -1,7 +1,6 @@
b f
n
next
n
s
src
n
+3 -4
View File
@@ -1,14 +1,13 @@
Connecting to: localhost:5001
Stopped at tests/debugger/do_src.js:19
(jerry-debugger) Breakpoint 1 at tests/debugger/do_src.js:15 (in f)
(jerry-debugger) Stopped at breakpoint:1 tests/debugger/do_src.js:15 (in f)
(jerry-debugger) Stopped at tests/debugger/do_src.js:16 (in f)
(jerry-debugger) Breakpoint 1 at tests/debugger/do_src.js:16 (in f() at line:15, col:1)
(jerry-debugger) Stopped at breakpoint:1 tests/debugger/do_src.js:16 (in f() at line:15, col:1)
(jerry-debugger) Stopped at tests/debugger/do_src.js:20
(jerry-debugger) Stopped at <unknown>:1
(jerry-debugger) f = function f() {
print('F2') }
(jerry-debugger) Stopped at tests/debugger/do_src.js:21
(jerry-debugger) Stopped at <unknown>:2 (in f)
(jerry-debugger) Stopped at <unknown>:2 (in f() at line:1, col:5)
(jerry-debugger) f = function f() {
print('F2') }
(jerry-debugger) Press enter to stop JavaScript execution.
-1
View File
@@ -19,4 +19,3 @@ function f() {
f();
eval("f = function f() {\nprint('F2') }");
f();
f();
+5 -3
View File
@@ -1,8 +1,10 @@
break do_step.js:25
step
step
backtrace
b do_step.js:26
next
next
bt
next
s
n
bt
c
+14 -9
View File
@@ -1,12 +1,17 @@
Connecting to: localhost:5001
Stopped at tests/debugger/do_step.js:25
(jerry-debugger) Breakpoint 1 at tests/debugger/do_step.js:25
(jerry-debugger) Stopped at tests/debugger/do_step.js:15 (in f1)
(jerry-debugger) Frame 0: tests/debugger/do_step.js:15 (in f1)
Frame 1: tests/debugger/do_step.js:25
(jerry-debugger) Breakpoint 2 at tests/debugger/do_step.js:26
(jerry-debugger) Stopped at tests/debugger/do_step.js:17 (in f1)
(jerry-debugger) Stopped at breakpoint:2 tests/debugger/do_step.js:26
(jerry-debugger) Frame 0: tests/debugger/do_step.js:26
Stopped at tests/debugger/do_step.js:32
(jerry-debugger) Stopped at tests/debugger/do_step.js:22 (in f1() at line:15, col:1)
(jerry-debugger) Stopped at tests/debugger/do_step.js:19 (in g() at line:17, col:3)
(jerry-debugger) Frame 0: tests/debugger/do_step.js:19 (in g() at line:17, col:3)
Frame 1: tests/debugger/do_step.js:22 (in f1() at line:15, col:1)
Frame 2: tests/debugger/do_step.js:32
(jerry-debugger) Stopped at tests/debugger/do_step.js:23 (in f1() at line:15, col:1)
(jerry-debugger) Frame 0: tests/debugger/do_step.js:23 (in f1() at line:15, col:1)
Frame 1: tests/debugger/do_step.js:32
(jerry-debugger) Stopped at tests/debugger/do_step.js:33
(jerry-debugger) Stopped at tests/debugger/do_step.js:28 (in f2() at line:26, col:1)
(jerry-debugger) Stopped at tests/debugger/do_step.js:29 (in f2() at line:26, col:1)
(jerry-debugger) Frame 0: tests/debugger/do_step.js:29 (in f2() at line:26, col:1)
Frame 1: tests/debugger/do_step.js:33
(jerry-debugger) Press enter to stop JavaScript execution.
Connection closed.
+9 -2
View File
@@ -14,12 +14,19 @@
function f1()
{
var i = 1;
function g()
{
return 6;
}
var i = g();
g();
}
function f2()
{
var y = 2;
f1();
return 7;
}
f1();