TranslationBlock

Struct TranslationBlock 

Source
pub struct TranslationBlock<'a> { /* private fields */ }
Expand description

Wrapper structure for a qemu_plugin_tb *

§Safety

This structure is safe to use as long as the pointer is valid. The pointer is always opaque, and therefore may not be dereferenced.

§Example

struct MyPlugin;

impl qemu_plugin::plugin::Register for MyPlugin {}

impl qemu_plugin::plugin::HasCallbacks for MyPlugin {
    fn on_translation_block_translate(
        &mut self,
        id: qemu_plugin::PluginId,
        tb: qemu_plugin::TranslationBlock,
    ) -> Result<()> {
        for insn in tb.instructions() {
            println!("{:08x}: {}", insn.vaddr(), insn.disas()?);
        }   
        Ok(())
    }
}

Implementations§

Source§

impl<'a> TranslationBlock<'a>

Source

pub fn size(&self) -> usize

Returns the number of instructions in the translation block

Source

pub fn vaddr(&self) -> u64

Returns the virtual address for the start of a translation block

Source

pub fn instruction(&'a self, index: usize) -> Result<Instruction<'a>>

Returns the instruction in the translation block at index. If the index is out of bounds, an error is returned.

§Arguments
  • index: The index of the instruction to return
Source

pub fn instructions(&'a self) -> TranslationBlockIterator<'a>

Returns an iterator over the instructions in the translation block

Source

pub fn register_execute_callback<F>(&self, cb: F)
where F: FnMut(VCPUIndex) + Send + Sync + 'static,

Register a callback to be run on execution of this translation block

§Arguments
  • cb: The callback to be run
Source

pub fn register_execute_callback_flags<F>(&self, cb: F, flags: CallbackFlags)
where F: FnMut(VCPUIndex) + Send + Sync + 'static,

Register a callback to be run on execution of this translation block

§Arguments
  • cb: The callback to be run
Source

pub fn register_conditional_execute_callback<F>( &self, cb: F, cond: PluginCondition, entry: PluginU64, immediate: u64, )
where F: FnMut(VCPUIndex) + Send + Sync + 'static,

Register a callback to be conditionally run on execution of this translation block

§Arguments
  • cb: The callback to be run
  • cond: The condition for the callback to be run
  • entry The entry to increment the scoreboard for
  • immediate: The immediate value to use for the callback
Source

pub fn register_conditional_execute_callback_flags<F>( &self, cb: F, flags: CallbackFlags, cond: PluginCondition, entry: PluginU64, immediate: u64, )
where F: FnMut(VCPUIndex) + Send + Sync + 'static,

Register a callback to be conditionally run on execution of this translation block

§Arguments
  • cb: The callback to be run
  • flags: The flags for the callback
  • cond: The condition for the callback to be run
  • entry: The entry to increment the scoreboard for
  • immediate: The immediate value to use for the callback

Trait Implementations§

Source§

impl<'a> From<*mut qemu_plugin_tb> for TranslationBlock<'a>

Source§

fn from(tb: *mut qemu_plugin_tb) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for TranslationBlock<'a>

§

impl<'a> RefUnwindSafe for TranslationBlock<'a>

§

impl<'a> Send for TranslationBlock<'a>

§

impl<'a> Sync for TranslationBlock<'a>

§

impl<'a> Unpin for TranslationBlock<'a>

§

impl<'a> UnwindSafe for TranslationBlock<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.