-
Notifications
You must be signed in to change notification settings - Fork 261
Do not treat outOfBandRecords as responses #478
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
Conversation
|
Sounds like a serious problem and thanks for submitting this PR. I have a few questions though -- marked in the review. |
|
For changes like this can you also try other gdb-servers like OpenOCD. What testing have you done so far? |
Just to make sure I didn't miss anything - is this project using an external review tool I'm not aware of? This comment does not have any additional review comments attached to it in GitHub. I have tested this on various nRF52832 DK boards with both JLink and OpenOCD. Both issue these out of band records when we call {"token":7,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
{"token":7,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
<repeated 26 more times>
{"token":7,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["address","0x1d730"],["load-size","279921"],["transfer-rate","521872"],["write-rate","7565"]]}}JLink's output: {"token":9,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
{"token":9,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
{"token":9,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
{"token":9,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
{"token":9,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
{"token":9,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["address","0x1d730"],["load-size","279936"],["transfer-rate","373248000"],["write-rate","12724"]]}}This change is backed by the GDB documentation, which states:
This doc page also states that passing a token for
As far as I can tell, this issue doesn't impact the actual debug behavior in most cases. The client isn't enabling |
Checks incoming MI messages for resultRecords before treating them as
responses. In some cases, the server may issue outOfBandRecords with a
token, but no resultRecords. This can for instance happen when the
server wants to report progress on an event before it's finished.
JLink's target-download command does this, and without this extra check,
we'll go straight to `target halt` before the download is actually
finished.
JLink's target-download events look like this:
{"token":8,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
Note the token (which matches the target-download command's token), and
the lack of a resultRecord. For my 250kB image, this event is issue 5
times before the resultRecord is issued.
e17dc40 to
0e3d2cb
Compare
|
Yes, looks better now. I have not read/written this code. Did have to fix a couple of things over time. I have a question. At line 143, shouldn't there be an "else { Internal error of some sort }". In other words, we have a token with results but no handler. Defensive programming is okay but can that happen? It can happen for instance getting more than one response, but can that happen? I am not saying add the internal error but maybe a comment or if you have the inclination can you look into it? Adding an error could cause a lot of failures once we release the extension if we are wrong. Logging it might be a tradeoff. |
Good question. If it doesn't contain any I can add it though, if you think it's worthwhile |
|
Thank you @trond-snekvik I wanted your opinion. I will add something to log if it ever happens. Merging now. |
Checks incoming MI messages for resultRecords before treating them as
responses. In some cases, the server may issue outOfBandRecords with a
token, but no resultRecords. This can for instance happen when the
server wants to report progress on an event before it's finished.
JLink's target-download command does this, and without this extra check,
we'll go straight to `target halt` before the download is actually
finished.
JLink's target-download events look like this:
{"token":8,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
Note the token (which matches the target-download command's token), and
the lack of a resultRecord. For my 250kB image, this event is issue 5
times before the resultRecord is issued.
Checks incoming MI messages for resultRecords before treating them as
responses. In some cases, the server may issue outOfBandRecords with a
token, but no resultRecords. This can for instance happen when the
server wants to report progress on an event before it's finished.
JLink's target-download command does this, and without this extra check,
we'll go straight to
monitor resetbefore the download is actuallyfinished.
JLink's target-download events look like this:
Note the token (which matches the target-download command's token), and
the lack of a resultRecord. For my 250kB image, this event is issued 5
times before the resultRecord is issued.