Support abort in the debugger. (#2273)

Aborts are not caught by catch/finally blocks,
so it is possible to stop a script using the debugger.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-04-11 13:59:13 +02:00
committed by GitHub
parent 5c0c21b26a
commit e91471727f
12 changed files with 183 additions and 66 deletions
+5
View File
@@ -0,0 +1,5 @@
s
s
s
s
abort new Error('Fatal error :)')
+12
View File
@@ -0,0 +1,12 @@
Connecting to: localhost:5001
Stopped at tests/debugger/do_abort.js:24
(jerry-debugger) s
Stopped at tests/debugger/do_abort.js:25
(jerry-debugger) s
Stopped at tests/debugger/do_abort.js:26
(jerry-debugger) s
Stopped at tests/debugger/do_abort.js:20 (in g() at line:19, col:1)
(jerry-debugger) s
Stopped at tests/debugger/do_abort.js:16 (in f() at line:15, col:1)
(jerry-debugger) abort new Error('Fatal error :)')
err: Script Error: Error: Fatal error :)
+30
View File
@@ -0,0 +1,30 @@
// 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.
function f() {
return 32;
}
function g() {
f();
}
// In regular JS, it is not possible to escape from this loop
while (true) {
try {
g();
} catch (e) {
var s = "Don't stop here";
}
}
+4 -3
View File
@@ -4,8 +4,9 @@ Stopped at tests/debugger/do_help.js:15
Documented commands (type help <topic>):
========================================
b bt delete e f list n s src
backtrace c display eval finish memstats next scroll step
break continue dump exception help ms quit source throw
abort bt display exception list next source
b c dump f memstats quit src
backtrace continue e finish ms s step
break delete eval help n scroll throw
(jerry-debugger) quit
+8
View File
@@ -1 +1,9 @@
s
s
s
s
s
throw new Error('Escape')
throw new Error('Once upon a time there lived in a certain village a little country girl, the prettiest creature who was ever seen. Her mother was excessively fond of her; and her grandmother doted on her still more. This good woman had a little red riding hood made for her. It suited the girl so extremely well that everybody called her Little Red Riding Hood. One day her mother, having made some cakes, said to her, "Go, my dear, and see how your grandmother is doing, for I hear she has been very ill. Take her a cake, and this little pot of butter."')
eval e.message.length
throw new Error('Exit')
+18 -1
View File
@@ -1,3 +1,20 @@
Connecting to: localhost:5001
Stopped at tests/debugger/do_throw.js:19
Stopped at tests/debugger/do_throw.js:23
(jerry-debugger) s
Stopped at tests/debugger/do_throw.js:24
(jerry-debugger) s
Stopped at tests/debugger/do_throw.js:26
(jerry-debugger) s
Stopped at tests/debugger/do_throw.js:27
(jerry-debugger) s
Stopped at tests/debugger/do_throw.js:20 (in g() at line:19, col:1)
(jerry-debugger) s
Stopped at tests/debugger/do_throw.js:16 (in f() at line:15, col:1)
(jerry-debugger) throw new Error('Escape')
Stopped at tests/debugger/do_throw.js:31
(jerry-debugger) throw new Error('Once upon a time there lived in a certain village a little country girl, the prettiest creature who was ever seen. Her mother was excessively fond of her; and her grandmother doted on her still more. This good woman had a little red riding hood made for her. It suited the girl so extremely well that everybody called her Little Red Riding Hood. One day her mother, having made some cakes, said to her, "Go, my dear, and see how your grandmother is doing, for I hear she has been very ill. Take her a cake, and this little pot of butter."')
Stopped at tests/debugger/do_throw.js:34
(jerry-debugger) eval e.message.length
538
(jerry-debugger) throw new Error('Exit')
err: Script Error: Error: Exit
+19 -3
View File
@@ -12,8 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
function inevitable() {
print("An error will be thrown.");
function f() {
return 32;
}
inevitable();
function g() {
f();
}
try {
try {
while (true) {
g();
}
} catch (e) {
var s = "Stop here";
}
} catch (e) {
var s = "Stop here again";
}