Change uart_write() to return size when under control of GDBStub - #9326
Open
tomvaneyck wants to merge 1 commit into
Open
tomvaneyck wants to merge 1 commit into
tomvaneyck wants to merge 1 commit into
Conversation
Change return value from 0 to size when gdbstub is active to follow function contract.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When GDBStub has UART ISR control,
uart_write()forwards the buffer togdbstub_write(), which transmits all of it, but then returns0:As a result,
Serial.write(buf, size)reports that nothing was written even though every byte was sent.Impact
Plain
Serial.print()usage is unaffected because it ignores the return value. Code that relies on the return value breaks, notablyStream::SendGenericPeekBuffer(), which is used byStream::sendAll()andHTTPClient::writeToStream(). Becausewrite()returns0, the loop never callspeekConsume()and never resets its timeout. It sends the same bytes from the start of the source buffer again on every iteration until the timeout expires. The serial output fills with repeated copies of the first few bytes, andHTTPClient::writeToStream(&Serial)fails withHTTPC_ERROR_READ_TIMEOUT(-11).Reproduction
Fix
if(gdbstub_has_uart_isr_control() && uart->uart_nr == UART0) { gdbstub_write(buf, size); - return 0; + return size; }Disclaimer: I found the issue using claude, but checked the solution myself.