Open zherczeg opened 4 years ago
Thank you very much for your wonderful contribution:)
Yes, we definitely have to support environment outside of Escargot engine. All your ideas looks great!
BTW I have some questions/requests as follows.
Hi,
abort
(which is not caught by try/catch(Value) C++ handlers) could work. Do you have a better suggestion?function f() {
a++;
b++;
}
If we would attach when a++
is executed, we cannot change the byte code of f
because the byte code of the function is currently executed by the vm (it has a pointer to the byte code, and an offset to the current instruction, and even worse, if computed gotos are enabled, we have a direct pointer to the instruction). Those things should be updated in some way. If you have a good solution maybe we could try to support this use case.
throw
c++ statement in the code? Or just report them when a JS catch caughts them? What would be the status?adding "kill" or "quit" option IMO detaching(finishing) the debugger would be enough.
Turning on/off the debugger during the runtime I'm wondering that this is one of common features in other JS debuggers. As you mentioned, replacing the bytecode during the code execution is extremely difficult. If we don't need to support this case, just ignore it.
Handling errors/segfaults
IMO printing each exception error message is useful for debugging (for segfault case, just finishing the debugging would be enough). When an exception occurs Escargot prints an error message with JS call stack infos. But the debugger client just quits its run. How about supporting exception messages in the debugger client too? To be specific, when an exception occur, ErrorObject with error message is generated and thrown which is then catched in SandBox::run
. Sandbox also calculates stack tracing data to provide JS call stack infos. We may deliver these exception-releated infos to the debugger as well.
Regarding on/off the debugger: the debugger can work silently. If no breakpoints are set, and no stop command is issued, the program just runs. So the IDE can simulate attach / detach / attach again events by temporariliy enabling and disabling breakpoints.
Regarding errors: am I understand correctly, that we just need to notify users, but does not need to do any actions? Sending this data is not difficult.
I missed that "quit" option was already added Regarding errors: yes, just notify the users.
"finish" option looks similar to "until" option in gdb. Is this also one of essential features in JS debugger?
"finish" is a command in gdb, and VSCode debugger has a "step-out" command which is the same: https://sourceware.org/gdb/onlinedocs/gdb/Continuing-and-Stepping.html https://code.visualstudio.com/docs/editor/debugging#_debug-actions
I don't think this is essential, so if you want it I can close #618 .
Btw the VSCode command mapping will look like this (left VSCode, right Escargot debugger):
Continue / Pause - ESCARGOT_MESSAGE_CONTINUE / ESCARGOT_MESSAGE_STEP Step Over - ESCARGOT_MESSAGE_NEXT Step Into - ESCARGOT_MESSAGE_STEP Step Out - ESCARGOT_MESSAGE_FINISH Restart - not implemented yet Stop - closing socket
Thanks for your detailed explanation. It seems that we should add "finish" command to support "Step out" in VSCode.
I think the core debugger features are completed. The list of these features follows:
Breakpoint management:
Execution control:
Other features:
Could you tell us what other features do you need? I can share some ideas. These ideas requires shell support (environment outside of Escargot engine), so porting them to other environments require some effort.
Source sending feature: instead of executing a js file, the shell enters to a "wait for source code" mode. After the debugger sends the source code, the shell executes it. This is useful for trying JS code without flashing it onto a device, and also useful for demonstration purposes.
Restarting feature: allow the debugger to restart the JavaScript code. This is a difficult feature (for the environment, not for the debugger), since the current execution must be aborted, all resources must be freed, and a new Escargot instance must be created.
Debug log support: most environments have a "print" or "console.log" native function, which displays some text. However, if the device has no screen, this output can be lost. Sending this output to the debugger is useful in this case, since it can also display this output.