Without this it's possible for the following to happen:
- The debug transport gets broken by e.g. a syntax error during message
handling.
- The detached_cb is called when marking transport bad. The detached
callback immediately reattaches.
- The debug command processing continues, potentially reading from and
writing to the *new connection* which causes the connection to go
out of sync.
Delaying the detached_cb call to the message loop, right after one message
has been fully processed, avoids this issue and keeps the connections
cleanly separated.
The solution is a bit awkward: duk_debug_do_detach() is split into two.
Outside callers (duk_debugger_detach(), duk_heap_free()) still have a single
function helper to hide the split.
This should make it easier to allow a detached callback to reattach
immediately without leaving the debugger state inconsistent.
Requires careful handling of the detach/reattach sequence:
- Both the detached callback and its udata must be stashed, state cleared,
and only then the detached callback can be called.
- When the Detach command has been handled, must avoid skipping to EOM
because that would happen in a potentially new connection which would
cause that connection to be out of sync. Returning to the message loop
is fine, and since duk_debugger_attach() marks the state dirty, a Status
will be immediately sent (followed by the handshake line, sent inline by
duk_debugger_attach()).
GetLocals, GetVar, PutVar, and Eval will now accept an optional negative
callstack offset specifying the function activation to operate on. This
offset has the same semantics as the argument of Duktape.act(): -1 is
the topmost activation, -2 is its caller, etc.
- Fix string intern test case ("intern match"), which didn't keep a
reference to the string so that the string was actually not already
in the string table.
- Add character length computation performance test cases for both
pure ASCII and non-ASCII strings.
- Add character length computation correctness test case, which exercises
different string lengths and random string bytes.
- Change duk__debug_process_message() to store/restore value stack top
for message handlers. This is more robust than requiring that every
debug message handler code path always manages the value stack 100%
correctly.
- Change existing message handlers so that trivial value stack cleanups
are not done in the message handler. Value stack popping is still
necessary for loops where the value stack might grow without bound.
Add internal duk_push_tval_readable() which summarizes a duk_tval into a human
readable, limited length sanitized string without side effects. It is useful
for summarizing values safely in e.g. error messages. The internal call is a
candidate for the public API later on (in a slightly different form).
Forcing tm_isdst to 0 before mktime() and removing a previous DST check
after mktime() seems to work on Linux and should (potentially) fix a
RISC OS issue.
- Bug testcase for GH-413
- Testcase for removing octal autodetection in parseInt()
Fix expect string of numconv parseInt() testcase to match E5.1 behavior.