Add bindings for instruction disassembly #8
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.
This is my attempt at wrapping xed_format_generic in an idiomatic wrapper. I'm rather happy with how it turned out.
This PR introduces three function variants to cover the different use cases for xed_format_generic. All three are methods of
DecodedInst
.This is the simplest one. No configuration, just provide a syntax and get a disassembly string.
More complex. Now you configure it by passing in options. This variant is still infallible so it probably won't work with any complicated disassembly callback. In order to be infallible it requires that the callback's error type is std::convert::Infallible.
This one supports the most options. It supports any disassembly callback and takes care of plumbing the error around in the XED callback.
There are a couple of different types that are used as part of this API. I've created a new top-level
disassemble
module and stuck them in there. It also gives a convenient place to stick some guide level documentation and example on how to use the API.Other notes
DisassemblyCallback
for bothFnMut(u64, &mut WriteBuf<'_>) -> Option<u64>
andFnMut(u64, &mut WriteBuf<'_>) -> Result<Option<u64>, E>
. I've chosen to only implement it for the first one with the idea that actually implementing the trait on a type is less likely to be as much of an issue when the disassembly callback is complicated enough to need to return a result.