daniel5151 / gdbstub

An ergonomic, featureful, and easy-to-integrate implementation of the GDB Remote Serial Protocol in Rust (with no-compromises #![no_std] support)
Other
291 stars 45 forks source link

`read_addrs()` can return fewer bytes than requested #115

Closed geigerzaehler closed 1 year ago

geigerzaehler commented 1 year ago

Description

The read_addrs() method for targets now returns a number of bytes that were read. This allows a target to gracefully signal the client that memory at an address range is not accessible.

I’ve implemented this functionality for the armv4t example to be able to test it.

Closes #111.

API Stability

This PR requires a breaking API change.

Checklist

I’m not sure how to update the changelog.

Validation

Read before accessible area

(gdb) x 0x00
0x0:    Cannot access memory at address 0x0
TRACE gdbstub::protocol::recv_packet     > <-- $m0,4#fd
TRACE gdbstub::protocol::response_writer > --> $#00

Read partially accessible memory

(gdb) x/4xb 0x6554fffe
0x6554fffe:     0x00    0x00    Cannot access memory at address 0x65550000
TRACE gdbstub::protocol::recv_packet     > <-- $m6554fffe,1#35
TRACE gdbstub::protocol::response_writer > --> $00#60
TRACE gdbstub::protocol::recv_packet     > <-- $m6554ffff,1#36
TRACE gdbstub::protocol::response_writer > --> $00#60
TRACE gdbstub::protocol::recv_packet     > <-- $m65550000,1#5f
TRACE gdbstub::protocol::response_writer > --> $#00

Read after accessible area

(gdb) x 0x6555000e
0x6555000e:     Cannot access memory at address 0x6555000e
TRACE gdbstub::protocol::recv_packet     > <-- $m6555000e,4#97
TRACE gdbstub::protocol::response_writer > --> $#00
geigerzaehler commented 1 year ago

I’ve addressed all your comments. Sorry I took a while.

daniel5151 commented 1 year ago

Sorry I took a while.

all good :)

I'll take a look in the next day or two

geigerzaehler commented 1 year ago

I‘ve fixed the lint and the docs. Should be good to go know :crossed_fingers: