mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 13:11:32 +00:00
Finished middleware impl and made a CallTrace middleware
This commit is contained in:
27
lib/middleware-common/src/call_trace.rs
Normal file
27
lib/middleware-common/src/call_trace.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use wasmer_runtime_core::{
|
||||
codegen::{Event, EventSink, FunctionMiddleware, InternalEvent},
|
||||
module::ModuleInfo,
|
||||
};
|
||||
|
||||
pub struct CallTrace;
|
||||
|
||||
impl FunctionMiddleware for CallTrace {
|
||||
type Error = String;
|
||||
fn feed_event<'a, 'b: 'a>(
|
||||
&mut self,
|
||||
op: Event<'a, 'b>,
|
||||
module_info: &ModuleInfo,
|
||||
sink: &mut EventSink<'a, 'b>,
|
||||
) -> Result<(), Self::Error> {
|
||||
match op {
|
||||
Event::Internal(InternalEvent::FunctionBegin(id)) => {
|
||||
sink.push(Event::Internal(InternalEvent::Bkpt(Box::new(move |_| {
|
||||
println!("func ({})", id);
|
||||
}))))
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
sink.push(op);
|
||||
Ok(())
|
||||
}
|
||||
}
|
9
lib/middleware-common/src/lib.rs
Normal file
9
lib/middleware-common/src/lib.rs
Normal file
@ -0,0 +1,9 @@
|
||||
pub mod call_trace;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user