Hi Stefan,

[snip]

> > diff --git a/scripts/simpletrace-rust/.rustfmt.toml 
> > b/scripts/simpletrace-rust/.rustfmt.toml
> > new file mode 100644
> > index 000000000000..97a97c24ebfb
> > --- /dev/null
> > +++ b/scripts/simpletrace-rust/.rustfmt.toml
> > @@ -0,0 +1,9 @@
> > +brace_style = "AlwaysNextLine"
> > +comment_width = 80
> > +edition = "2021"
> > +group_imports = "StdExternalCrate"
> > +imports_granularity = "item"
> > +max_width = 80
> > +use_field_init_shorthand = true
> > +use_try_shorthand = true
> > +wrap_comments = true
> 
> There should be QEMU-wide policy. That said, why is it necessary to customize 
> rustfmt?

Indeed, but QEMU's style for Rust is currently undefined, so I'm trying
to add this to make it easier to check the style...I will separate it
out as a style policy proposal.

[snip]

> > +trait Analyzer
> > +{
> 
> The Python version treats this as an API so that users can write trace
> analysis scripts. I see below that you're using non-doc comments. That
> suggests you don't see this as a public API that people can write trace
> analysis scripts against?

Yes, for the initial version, I'm not exposing it for now. It could be
exposed later if needed and then we can support multiple script builds
by defining multiple workspaces in cargo.

Thanks,
Zhao

> > +    /* Called at the start of the trace. */
> > +    fn begin(&self) {}
> > +
> > +    /* Called if no specific method for processing a trace event. */
> > +    fn catchall(
> > +        &mut self,
> > +        rec_args: &[EventArgPayload],
> > +        event: &Event,
> > +        timestamp_ns: u64,
> > +        pid: u32,
> > +        event_id: u64,
> > +    ) -> Result<String>;
> > +
> > +    /* Called at the end of the trace. */
> > +    fn end(&self) {}
> > +
> > +    /*
> > +     * TODO: Support "variable" parameters (i.e. variants of 
> > process_event()
> > +     * with different parameters, like **kwargs in python), when we need a
> > +     * simpletrace rust module.
> > +     */
> > +    fn process_event(
> > +        &mut self,
> > +        rec_args: &[EventArgPayload],
> > +        event: &Event,
> > +        event_id: u64,
> > +        timestamp_ns: u64,
> > +        pid: u32,
> > +    ) -> Result<String>
> > +    {
> > +        self.catchall(rec_args, event, timestamp_ns, pid, event_id)
> > +
> > +        /*
> > +         * TODO: Support custom function hooks (like getattr() in python),
> > +         * when we need a simpletrace rust module.
> > +         */
> > +    }
> > +}

Reply via email to