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.
Hi,
I'm trying to add support for writing memory related to #324.
For now, the changes for the Python API are an optional
write_fn
parameter toProgram.add_memory_segment
, and the methodProgram.write
.Before I try to tackle the missing pieces (writable objects, and optional write support in the Program constructors), I wanted to make sure I'm on the right track.
Note that on the C-side, instead of adding
*_write
functions as counterparts to the*_read
functions, I tried to maintain as much as possible a unique*_rw(bool is_write, void *buf, size_t count)
kind of functions.This has the advantage of reusing the internal logic of some functions for both cases (eg:
drgn_program_read_rw
).However, I'm now seeing that maybe the buf parameter should be
const void *
for the write functions, or I need to make some dirty casts :/.Also, the naming choices are maybe not the best (
memory_interface
is meh, and if we keep the*_rw
functions, maybe*_transfer
would be prettier).Anyway, feel free to review the changes and tell me if I made some mistakes, I'll need to rebase it anyway to add the Signed-Off-By that I forgot in the commits :).