Skip to content

Commit

Permalink
Fix wrong register entrypoint called, fix docsrs build for qemu package
Browse files Browse the repository at this point in the history
  • Loading branch information
novafacing committed Dec 19, 2023
1 parent ea8e8e5 commit 9c6279d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 87 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-2.0-only"
publish = true
readme = "README.md"
repository = "https://github.com/novafacing/qemu-rs"
version = "8.1.3-v2"
version = "8.1.3-v3"

[workspace]
resolver = "2"
Expand All @@ -20,6 +20,6 @@ members = [
]

[workspace.dependencies]
qemu-plugin-sys = { version = "8.1.3-v2", path = "qemu-plugin-sys" }
qemu-plugin = { version = "8.1.3-v2", path = "qemu-plugin" }
qemu = { version = "8.1.3-v2", path = "qemu" }
qemu-plugin-sys = { version = "8.1.3-v3", path = "qemu-plugin-sys" }
qemu-plugin = { version = "8.1.3-v3", path = "qemu-plugin" }
qemu = { version = "8.1.3-v3", path = "qemu" }
2 changes: 1 addition & 1 deletion qemu-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ version.workspace = true
[dependencies]
anyhow = "1.0.75"
once_cell = "1.19.0"
qemu-plugin-sys = { version = "8.1.3-v2", workspace = true }
qemu-plugin-sys = { version = "8.1.3-v3", workspace = true }
thiserror = "1.0.51"
18 changes: 6 additions & 12 deletions qemu-plugin/examples/tiny/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::Result;
use anyhow::{anyhow, Result};
use ctor::ctor;
use qemu_plugin::{
plugin::{HasCallbacks, Plugin, Register, PLUGIN},
Expand All @@ -8,6 +8,7 @@ use std::sync::Mutex;

struct TinyTrace {}

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

impl HasCallbacks for TinyTrace {
Expand All @@ -16,25 +17,18 @@ impl HasCallbacks for TinyTrace {
_id: PluginId,
tb: TranslationBlock,
) -> Result<()> {
tb.instructions().enumerate().try_for_each(|(idx, insn)| {
if idx == 0 {
println!("====TB: {:08x}", insn.vaddr());
}

tb.instructions().try_for_each(|insn| {
println!("{:08x}: {}", insn.vaddr(), insn.disas()?);
Ok::<(), anyhow::Error>(())
})?;

Ok(())
Ok(())
})
}
}

impl Plugin for TinyTrace {}

#[ctor]
fn init() {
PLUGIN
.set(Mutex::new(Box::new(TinyTrace {})))
.map_err(|_| anyhow::anyhow!("Failed to set plugin"))
.map_err(|_| anyhow!("Failed to set plugin"))
.expect("Failed to set plugin");
}
2 changes: 1 addition & 1 deletion qemu-plugin/src/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub unsafe extern "C" fn qemu_plugin_install(
};

plugin
.register(id, &args, &info)
.register_default(id, &args, &info)
.expect("Failed to register plugin");

PLUGIN_INSTALL_SUCCESS
Expand Down
3 changes: 0 additions & 3 deletions qemu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ readme.workspace = true
repository.workspace = true
version.workspace = true

[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]

[[bin]]
name = "qemu-aarch64"
required-features = ["binaries", "aarch64-linux-user"]
Expand Down
1 change: 1 addition & 0 deletions qemu/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,7 @@ fn install(build: &Path) -> Result<()> {

fn main() -> Result<()> {
if var("DOCS_RS").is_ok() {
println!("cargo:rustc-cfg=docs_rs");
return Ok(());
}

Expand Down
Loading

0 comments on commit 9c6279d

Please sign in to comment.