-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugger stops sending messages #244
Comments
Could you enable Duktape debug output and see what that outputs around the time of the problem? Also if you could debug log from your transport callbacks, that might help pinpoint the problem. |
Interesting. Upon performing a Step Over at the above-mentioned line, an excerpt of the output from my transport callbacks:
A Step Over request is 3 bytes, REQ 15h (0x95) EOM. But Duktape appears to be actually performing the step after receiving REQ 15h, and starts sending stuff out before it reads the EOM. Now this technically shouldn't be an issue since TCP is a full-duplex protocol, but it intrigues me that Duktape is interleaving reading and writing like this. I would have expected it to read until EOM before doing anything else. In any case, single-step continues to work after this, but the client doesn't highlight anything. So it may be a bug in the client and not Duktape. I will have to investigate further. |
That's actually intentional: message handlers will read whatever dvalues they need, and then skip to EOM ignoring the rest (which is a good default for extensibility): https://github.com/svaarala/duktape/blob/master/src/duk_debugger.c#L1620 As a side effect, once all the dvalues a command handler wants to know about have been received, the command will be executed and EOM read only when the command is done. This would be the case with all commands at present - but like you said it shouldn't matter for the client. |
Okay, after running my debugger through the debugger... :) It turns out Duktape is sending line number 0 in all further NFYs after the offending |
Would it be possible to reproduce the problem using the duk command line tool and web UI debugger? |
I would first have to try to come up with a test case that doesn't require the entirety of the minisphere API. And what do I need to do to use the web UI? |
Small followup that might help narrow things down: The notifications with a state of 0 (Running) appear to include the correct line number. It's only the ones with status 1 (Paused) that are being sent with line 0. |
Here's the basic usage: https://github.com/svaarala/duktape/blob/master/debugger/README.rst#using-the-debugger-web-ui |
Further tests reveal that Duktape is always sending a PC value of 0. Is that normal? |
Okay, I figured it out. It was a bug in the client after all, specifically an operator precedence issue regarding bitshifts. Here's how I was decoding network-order ints: return bytes[0] << 24 + bytes[1] << 16 + bytes[2] << 8 + bytes[3]; Well, it turns out that, in C# at least, Everything was alright as long as all ints were encoded in one byte, so up to line number 63 displayed fine. 64+ requires 2 or more bytes to encode, and I wasn't decoding it properly. The random disconnects were the same thing: String length decoding had the same bug, which knocked the whole stream out of sync to the point of the client being unable to recover. |
Same thing with C - that shift precedence thing has bitten me more times than I can count ;) |
Sometimes upon performing a step, I won't receive any more notifications afterward, even though execution remains paused. What's odd is that it always happens at the same line(s), notably a seemingly benign
if
statement:if (!DBG_SHOW_TITLE_SCREEN)
When executing a step at that line, my client never highlights the next line and eventually the debug connection is dropped (the target reports a TCP reset).
The text was updated successfully, but these errors were encountered: