mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Add correct debugging to .mjs files
Add breakpoint on the start of the first source code line so that module file imports can be debugged. Also extend debugger test script since Escargot uses realpaths with modules. Signed-off-by: Ádám László Kulcsár <kuladam@inf.u-szeged.hu>
This commit is contained in:
parent
ab7a13e089
commit
0ac274d1fc
6 changed files with 46 additions and 0 deletions
|
|
@ -1124,6 +1124,10 @@ Script::ModuleExecutionResult Script::moduleExecute(ExecutionState& state, Optio
|
|||
|
||||
if (LIKELY(!m_topCodeBlock->isAsync())) {
|
||||
try {
|
||||
#ifdef ESCARGOT_DEBUGGER
|
||||
// set the next(first) breakpoint to be stopped in a newer script execution
|
||||
context()->setAsAlwaysStopState();
|
||||
#endif
|
||||
Interpreter::interpret(newState, byteCodeBlock, reinterpret_cast<size_t>(byteCodeBlock->m_code.data()), registerFile);
|
||||
} catch (const Value& e) {
|
||||
resultValue = e;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ RESULT_TEMP=`mktemp ${TEST_CASE}.out.XXXXXXXXXX`
|
|||
if [[ $IS_CLIENT_SOURCE == 0 ]] && [[ $TEST_CASE != *"tools/debugger/tests/client_source_multiple"* ]]; then
|
||||
if [[ $TEST_CASE == *"tools/debugger/tests/do_wait_exit2"* ]]; then
|
||||
${ESCARGOT} --start-debug-server --wait-before-exit ${TEST_CASE}.js &
|
||||
elif [[ $TEST_CASE == *"tools/debugger/tests/module_debug"* ]]; then
|
||||
${ESCARGOT} --module --start-debug-server ${TEST_CASE}_1.mjs &
|
||||
else
|
||||
${ESCARGOT} --start-debug-server ${TEST_CASE}.js &
|
||||
fi
|
||||
|
|
@ -19,7 +21,16 @@ if [[ $IS_CLIENT_SOURCE == 0 ]] && [[ $TEST_CASE != *"tools/debugger/tests/clie
|
|||
else
|
||||
(cat "${TEST_CASE}.cmd" | ${DEBUGGER_CLIENT} --non-interactive) >${RESULT_TEMP} 2>&1
|
||||
fi
|
||||
|
||||
if [[ $TEST_CASE == *"tools/debugger/tests/module_debug"* ]]; then
|
||||
EXPECTED_PATH=$(realpath ./tools/debugger/tests/)
|
||||
sed -i '3i\Stopped at '$EXPECTED_PATH"/module_debug_2.mjs:1" $EXPECTED_PATH"/module_debug.expected"
|
||||
fi
|
||||
diff -u ${TEST_CASE}.expected ${RESULT_TEMP}
|
||||
|
||||
if [[ $TEST_CASE == *"tools/debugger/tests/module_debug"* ]]; then
|
||||
sed -i '3d' $EXPECTED_PATH"/module_debug.expected"
|
||||
fi
|
||||
elif [[ $IS_CLIENT_SOURCE == 1 ]]; then
|
||||
if [[ $TEST_CASE == *"tools/debugger/tests/do_wait_exit2"* ]]; then
|
||||
${ESCARGOT} --start-debug-server --debugger-wait-source --wait-before-exit &
|
||||
|
|
@ -33,10 +44,21 @@ elif [[ $IS_CLIENT_SOURCE == 1 ]]; then
|
|||
(cat "${TEST_CASE}.cmd" | ${DEBUGGER_CLIENT} --client-source ${TEST_CASE}.js --non-interactive --command "b do_command.js:2;c;e i;c") >${RESULT_TEMP} 2>&1
|
||||
elif [[ $TEST_CASE == *"tools/debugger/tests/do_wait_exit1"* ]]; then
|
||||
(cat "${TEST_CASE}.cmd" | ${DEBUGGER_CLIENT} --client-source ${TEST_CASE}.js --non-interactive --wait-before-exit 1) >${RESULT_TEMP} 2>&1
|
||||
elif [[ $TEST_CASE == *"tools/debugger/tests/module_debug"* ]]; then
|
||||
(cat "${TEST_CASE}.cmd" | ${DEBUGGER_CLIENT} --client-source ${TEST_CASE}_1.mjs --non-interactive) >${RESULT_TEMP} 2>&1
|
||||
else
|
||||
(cat "${TEST_CASE}.cmd" | ${DEBUGGER_CLIENT} --client-source ${TEST_CASE}.js --non-interactive) >${RESULT_TEMP} 2>&1
|
||||
fi
|
||||
|
||||
if [[ $TEST_CASE == *"tools/debugger/tests/module_debug"* ]]; then
|
||||
EXPECTED_PATH=$(realpath ./tools/debugger/tests/)
|
||||
sed -i '3i\Stopped at '$EXPECTED_PATH"/module_debug_2.mjs:1" $EXPECTED_PATH"/module_debug.expected"
|
||||
fi
|
||||
diff -u ${TEST_CASE}.expected ${RESULT_TEMP}
|
||||
|
||||
if [[ $TEST_CASE == *"tools/debugger/tests/module_debug"* ]]; then
|
||||
sed -i '3d' $EXPECTED_PATH"/module_debug.expected"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
|
|
|||
3
tools/debugger/tests/module_debug.cmd
Normal file
3
tools/debugger/tests/module_debug.cmd
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
n
|
||||
n
|
||||
n
|
||||
10
tools/debugger/tests/module_debug.expected
Normal file
10
tools/debugger/tests/module_debug.expected
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Connecting to: localhost:6501
|
||||
Connection created!!!
|
||||
(escargot-debugger) n
|
||||
Stopped at tools/debugger/tests/module_debug_1.mjs:3
|
||||
(escargot-debugger) n
|
||||
Print: hello from module_debug_1.mjs!
|
||||
Stopped at tools/debugger/tests/module_debug_1.mjs:4
|
||||
(escargot-debugger) n
|
||||
Print: hello from module_debug_2!
|
||||
Connection closed.
|
||||
4
tools/debugger/tests/module_debug_1.mjs
Normal file
4
tools/debugger/tests/module_debug_1.mjs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { hello_module2 } from "./module_debug_2.mjs";
|
||||
|
||||
print("hello from module_debug_1.mjs!");
|
||||
hello_module2();
|
||||
3
tools/debugger/tests/module_debug_2.mjs
Normal file
3
tools/debugger/tests/module_debug_2.mjs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export function hello_module2() {
|
||||
print("hello from module_debug_2!")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue