Ignore the metadata PT_LOAD segment emitted by PS1 linker scripts and
validate loadable segment ranges before invoking the loader callback.
Fixes kernel crash when loading.
Emit rwatch, watch, or awatch stop fields for the matching client and
preserve that complete stop reply for later '?' queries, while falling
back to a generic trap for unrelated breakpoints.
Pass the actual breakpoint type to callbacks, let their return value
control whether the breakpoint is retained, and then follow the normal
breakpoint pause path. This makes callback-backed execute and memory
breakpoints observable without bypassing the instruction-completion
behavior used by watchpoints.
Interpret Z2/Z3/Z4 kind values as byte lengths and represent each
watched byte with an owned CPU breakpoint. Validate MIPS
execute-breakpoint kinds, reject zero, overflowing, or excessively
large watch ranges, and avoid invasive changes to the CPU
memory-access dispatcher.
Represent protocol breakpoint types with a scoped enum and track each
client's logical breakpoints separately from a shared reference-counted
CPU breakpoint registry. Disconnects now remove only breakpoints
created by GDB, preserve pre-existing UI breakpoints, and keep
breakpoints alive while another GDB client still references them.
Remember whether the system was running before the first debugger
client forced it to pause, and resume only after the final client
disconnects. This prevents a dropped connection or disabled server
from leaving an originally running system paused, while preserving a
pause that predated debugger attachment and avoiding premature resumes
with multiple clients.
Accept the remote protocol's C and S packet forms, including their
optional resume addresses, so GDB can continue or step after reporting
a signal. Validate the signal and address fields completely; signal
delivery itself is intentionally ignored because the emulated
bare-metal target has no inferior process signal mechanism.
Enforce the advertised PacketSize while scanning the receive buffer.
Close clients that exceed the framed packet limit so an unterminated
or oversized request cannot fill the fixed receive buffer and leave
the connection permanently stalled.
Keep the most recently framed RSP reply for each client and resend it
when GDB returns a negative acknowledgement. Build acknowledgement and
reply frames separately so only the reply packet is retained for
protocol recovery.
Expose BufferedStreamSocket's allow-smaller policy through Write while
preserving the existing default for other callers. GDB replies now
require enough queue space for the complete RSP packet and close the
connection instead of silently discarding an unwritten suffix.
Advertise a 16 KiB RSP PacketSize and cap memory reads so their
hex-encoded replies fit within it. This prevents small m packets from
requesting multi-gigabyte allocations and keeps generated replies
within the server's transport capacity.
Invalidate affected emulated instruction-cache lines and translated
RAM code pages after a successful M packet. This ensures debugger
patches and GDB's fallback software breakpoints execute the newly
written instructions instead of stale cached code.
Decode and validate the complete G packet before mutating CPU state,
preserve the zero and read-only BadVaddr registers, and return the
protocol-defined OK response. Apply SR and CAUSE masks and side
effects, and rebuild the instruction pipeline only when PC changes.
Require command payloads, numeric fields, breakpoint kinds, and
checksums to be consumed in full. This prevents valid command prefixes
and partial numeric conversions from accepting trailing garbage while
retaining the protocol-defined breakpoint packet layout.
A checksum-valid packet must be acknowledged even when its command
arguments are malformed. Return an RSP error or unsupported reply from
the affected handlers instead of sending a negative transport ACK,
which caused GDB to retransmit the same valid packet indefinitely.
Record the signal reported by each client's most recent stop reply and
use it when handling the '?' query. Interrupt requests now report
SIGINT while single-step, breakpoint, and other system pauses continue
to report SIGTRAP.
Avoid calling SetPC when an address-qualified continue or single-step
names the CPU's current PC. The next instruction is already prefetched
at that address, and rebuilding the pipeline would incorrectly discard
pending load and branch-delay state.
Honor the optional resume address carried by the remote protocol's
single-step packet. Validate the address and update the CPU through
SetPC before setting the single-step flag so the instruction pipeline
resumes from the requested location.
Route continue packets through the normal checksum-validated command
dispatcher and parse the optional resume address defined by the remote
protocol. Address-qualified continues now update the CPU through SetPC
before resuming instead of being treated as unsupported commands.
Acknowledge step and continue packets when they are received, then send
the eventual stop reply without another leading ACK. This avoids
emitting two acknowledgements for a single resume packet and prevents
external system resumes from producing stray protocol ACKs.