Skip to content

Monitor: skip a stop reply that arrives before an ack - #58

Merged
JohnAmadis merged 1 commit into
masterfrom
claude/zealous-ramanujan-nnsy9w
Oct 5, 2026
Merged

JohnAmadis merged 1 commit into
masterfrom
claude/zealous-ramanujan-nnsy9w

Conversation

@JohnAmadis

Copy link
Copy Markdown
Contributor

Problem

The Renode test in dmod-boot fails intermittently at step 4 (monitor-gdb). The master run after #117 failed this way:

[WARN] Unexpected GDB response: $
[ERROR] Failed to read dmlog ring buffer from target
[ERROR] Failed to connect to monitor

While connecting, the monitor sends c, then Ctrl-C after 1 s. Renode sometimes sends a late extra stop reply ($S02#b5) after the next command (m…) has already gone out, but before its +. gdb_wait_for_ack() read that packet's leading $ as the response, treated it as an error and failed the memory read. The read path (is_stop_reply + retry) only handles a stop reply that arrives after the ack, not before it.

Fix

gdb_wait_for_ack() now receives, acknowledges and skips such a packet and keeps waiting for +. It skips at most 8 packets, so it cannot loop forever. Packet body reading moved from gdb_receive_packet() into gdb_receive_packet_body(), so both paths share it.

Verification

I used a fake GDB server that, for the m command, sends $S02#b5 before + and the data. The test program links gdb.c directly and calls gdb_connect() + gdb_read_memory():

stop reply before ack normal order
old gdb.c Unexpected GDB response: $, read = -1 (the CI error) OK
new gdb.c Skipped packet 'S02' …, read = 0, data correct OK

dmlog_monitor builds with -DDMLOG_BUILD_TOOLS=ON without warnings.

dmod-boot builds the monitor from its lib/dmlog submodule, so once this is merged the submodule there needs bumping.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SVi4u4Lf8HPw1emy5uyGSB


Generated by Claude Code

Renode sometimes sends a late stop reply ("S02") to the interrupt the
monitor sends while connecting, after the next command has gone out but
before its '+'. gdb_wait_for_ack() read the reply's leading '$' as the
ack, logged "Unexpected GDB response: $" and failed the memory read - the
Renode test in dmod-boot then found no boot logs at all.

Receive, acknowledge and skip such packets (at most 8) and keep waiting
for the ack. The packet body reading is split out of
gdb_receive_packet() into gdb_receive_packet_body() so both share it.

Reproduced with a fake GDB server sending the stop reply before the ack:
the old code fails the read with exactly the CI error, the new one skips
the packet and reads the data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVi4u4Lf8HPw1emy5uyGSB
@JohnAmadis
JohnAmadis merged commit 6a0c3e6 into master Oct 5, 2026
2 checks passed
JohnAmadis pushed a commit to choco-technologies/dmod-boot that referenced this pull request Oct 5, 2026
choco-technologies/dmlog#58 is merged; same tree as the commit tested
before, now on dmlog master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVi4u4Lf8HPw1emy5uyGSB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants