Skip to content

Commit

Permalink
Do not use pushd and fix versioning for tiny plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
novafacing committed Jun 3, 2024
1 parent edb83c5 commit f6e4c5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ jobs:
- name: Build QEMU
run: |
pushd qemu-upstream
cd qemu-upstream
./configure --enable-plugins
pushd build
cd build
make -j$(nproc)
make install
popd
popd
cd ../..
- uses: dtolnay/rust-toolchain@nightly
- uses: actions/checkout@v4
Expand Down
20 changes: 14 additions & 6 deletions plugins/tiny/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ use anyhow::{anyhow, Result};
use ctor::ctor;
use qemu_plugin::{
plugin::{HasCallbacks, Plugin, Register, PLUGIN},
PluginId, TranslationBlock, VCPUIndex, qemu_plugin_get_registers,
RegisterDescriptor,
PluginId, TranslationBlock,
};
#[cfg(any(feature = "plugin-api-v2", feature = "plugin-api-v3"))]
use qemu_plugin::{qemu_plugin_get_registers, RegisterDescriptor, VCPUIndex};
use std::sync::Mutex;

#[derive(Default)]
struct TinyTrace {
#[cfg(any(feature = "plugin-api-v2", feature = "plugin-api-v3"))]
registers: Vec<RegisterDescriptor<'static>>,
}

impl Plugin for TinyTrace {}
impl Register for TinyTrace {}

impl HasCallbacks for TinyTrace {
#[cfg(any(feature = "plugin-api-v2", feature = "plugin-api-v3"))]
fn on_vcpu_init(&mut self, _id: PluginId, _vcpu_id: VCPUIndex) -> Result<()> {
self.registers = qemu_plugin_get_registers()?;
Ok(())
Expand All @@ -25,20 +28,25 @@ impl HasCallbacks for TinyTrace {
_id: PluginId,
tb: TranslationBlock,
) -> Result<()> {
#[cfg(any(feature = "plugin-api-v2", feature = "plugin-api-v3"))]
let registers = self.registers.clone();

tb.instructions().try_for_each(|insn| {
println!("{:08x}: {}", insn.vaddr(), insn.disas()?);
for register in &registers {
let value = register.read()?;
println!(" {}: {:?}", register.name, value);

#[cfg(any(feature = "plugin-api-v2", feature = "plugin-api-v3"))]
{
for register in &registers {
let value = register.read()?;
println!(" {}: {:?}", register.name, value);
}
}

Ok(())
})
}
}


#[ctor]
fn init() {
PLUGIN
Expand Down

0 comments on commit f6e4c5a

Please sign in to comment.