Initial version of JerryScript debugger (#1557)

The debugger supports setting breakpoints, execution control (step, next, continue)
and getting backtrace. The communication is WebSocket-based, so a browser can
communicate with JerryScript without any intermediate application.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
This commit is contained in:
Levente Orban
2017-02-14 15:03:01 +01:00
committed by Tilmann Scheller
parent 453066fcf1
commit 025a99ccbb
39 changed files with 4166 additions and 5 deletions
+2
View File
@@ -56,6 +56,7 @@ def get_arguments():
parser.add_argument('-j', '--jobs', metavar='N', action='store', type=int, default=multiprocessing.cpu_count() + 1, help='Allowed N build jobs at once (default: %(default)s)')
parser.add_argument('--jerry-cmdline', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build jerry command line tool (%(choices)s; default: %(default)s)')
parser.add_argument('--jerry-cmdline-minimal', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='build minimal version of the jerry command line tool (%(choices)s; default: %(default)s)')
parser.add_argument('--jerry-debugger', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable the jerry debugger (%(choices)s; default: %(default)s)')
parser.add_argument('--jerry-libc', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build and use jerry-libc (%(choices)s; default: %(default)s)')
parser.add_argument('--jerry-libm', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build and use jerry-libm (%(choices)s; default: %(default)s)')
parser.add_argument('--js-parser', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable js-parser (%(choices)s; default: %(default)s)')
@@ -117,6 +118,7 @@ def generate_build_options(arguments):
build_options.append('-DFEATURE_PROFILE=%s' % PROFILE)
build_options.append('-DFEATURE_DEBUGGER=%s' % arguments.jerry_debugger)
build_options.append('-DFEATURE_SNAPSHOT_EXEC=%s' % arguments.snapshot_exec)
build_options.append('-DFEATURE_SNAPSHOT_SAVE=%s' % arguments.snapshot_save)
build_options.append('-DFEATURE_SYSTEM_ALLOCATOR=%s' % arguments.system_allocator)
+33
View File
@@ -34,6 +34,7 @@ parser.add_argument('--check-doxygen', action='store_true', default=False, help=
parser.add_argument('--check-vera', action='store_true', default=False, help='Run vera check')
parser.add_argument('--check-license', action='store_true', default=False, help='Run license check')
parser.add_argument('--buildoption-test', action='store_true', default=False, help='Run buildoption-test')
parser.add_argument('--jerry-debugger', action='store_true', default=False, help='Run jerry-debugger tests')
parser.add_argument('--jerry-tests', action='store_true', default=False, help='Run jerry-tests')
parser.add_argument('--jerry-test-suite', action='store_true', default=False, help='Run jerry-test-suite')
parser.add_argument('--unittests', action='store_true', default=False, help='Run unittests')
@@ -96,6 +97,11 @@ test262_test_suite_options = [
Options('test262_tests'),
]
# Test options for jerry-debugger
debugger_test_options = [
Options('jerry_debugger_tests', ['--debug', '--jerry-debugger=on', '--jerry-libc=off']),
]
# Test options for buildoption-test
jerry_buildoptions = [
Options('buildoption_test-lto', ['--lto=on']),
@@ -145,6 +151,30 @@ def run_check(runnable):
return ret
def run_jerry_debugger_tests():
ret_build = ret_test = 0
for job in debugger_test_options:
ret_build = create_binary(job.build_args)
if ret_build:
break
for file in os.listdir(DEBUGGER_TESTS_DIR):
if file.endswith(".js"):
test_case, _ = os.path.splitext(file)
test_case_path = os.path.join (DEBUGGER_TESTS_DIR, test_case)
test_cmd = [
DEBUGGER_TEST_RUNNER_SCRIPT,
get_binary_path(job.out_dir),
DEBUGGER_CLIENT_SCRIPT,
os.path.relpath (test_case_path, PROJECT_DIR),
]
if job.test_args:
test_cmd.extend(job.test_args)
ret_test |= run_check(test_cmd)
return ret_build | ret_test
def run_jerry_tests():
ret_build = ret_test = 0
for job in jerry_tests_options:
@@ -242,6 +272,9 @@ def main():
if not ret and (script_args.all or script_args.check_license):
ret = run_check([LICENSE_SCRIPT])
if not ret and (script_args.all or script_args.jerry_debugger):
ret = run_jerry_debugger_tests()
if not ret and (script_args.all or script_args.jerry_tests):
ret = run_jerry_tests()
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
# 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.
JERRY=$1
DEBUGGER_CLIENT=$2
TEST_CASE=$3
START_DEBUG_SERVER="${JERRY} ${TEST_CASE}.js --start-debug-server &"
echo "$START_DEBUG_SERVER"
eval "$START_DEBUG_SERVER"
sleep 1s
RESULT=$((cat "${TEST_CASE}.cmd" | ${DEBUGGER_CLIENT}) 2>&1)
DIFF=$(diff -u0 ${TEST_CASE}.expected <(echo "$RESULT"))
if [ -n "$DIFF" ]
then
echo "$DIFF"
echo "${TEST_CASE} failed"
exit 1
fi
echo "${TEST_CASE} passed"
exit 0
+3
View File
@@ -18,6 +18,7 @@ from os import path
TOOLS_DIR = path.dirname(path.abspath(__file__))
PROJECT_DIR = path.normpath(path.join(TOOLS_DIR, '..'))
DEBUGGER_TESTS_DIR = path.join(PROJECT_DIR, 'tests/debugger')
JERRY_TESTS_DIR = path.join(PROJECT_DIR, 'tests/jerry')
JERRY_TEST_SUITE_DIR = path.join(PROJECT_DIR, 'tests/jerry-test-suite')
JERRY_TEST_SUITE_MINIMAL_LIST = path.join(PROJECT_DIR, 'tests/jerry-test-suite/minimal-profile-list')
@@ -26,6 +27,8 @@ TEST262_TEST_SUITE_DIR = path.join(PROJECT_DIR, 'tests/test262')
BUILD_SCRIPT = path.join(TOOLS_DIR, 'build.py')
CPPCHECK_SCRIPT = path.join(TOOLS_DIR, 'check-cppcheck.sh')
DEBUGGER_CLIENT_SCRIPT = path.join(PROJECT_DIR, 'jerry-debugger/jerry-client-ws.py')
DEBUGGER_TEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-debugger-test.sh')
DOXYGEN_SCRIPT = path.join(TOOLS_DIR, 'check-doxygen.sh')
LICENSE_SCRIPT = path.join(TOOLS_DIR, 'check-license.py')
SIGNED_OFF_SCRIPT = path.join(TOOLS_DIR, 'check-signed-off.sh')