On Wed, Sep 24, 2025 at 09:13:15AM +0200, Paolo Bonzini wrote:
> On 9/23/25 21:23, Stefan Hajnoczi wrote:
> > > + out('// SPDX-License-Identifier: GPL-2.0-or-later',
> > > + '// This file is @generated by tracetool, do not edit.',
> > > + '',
> > > + '#[allow(unused_imports)]',
> > > + 'use std::ffi::c_char;',
> > > + '#[allow(unused_imports)]',
> > > + 'use util::bindings;',
> > > + '',
> > > + '#[inline(always)]',
> > > + 'fn trace_event_get_state_dynamic_by_id(_id: u16) -> bool {',
> > > + ' unsafe { (trace_events_enabled_count != 0) && (_id != 0) }',
> > > + '}',
> >
> > This was translated to Rust from:
> >
> > /* it's on fast path, avoid consistency checks (asserts) */
> > #define trace_event_get_state_dynamic_by_id(id) \
> > (unlikely(trace_events_enabled_count) && _ ## id ## _DSTATE)
> >
> > The _id != 0 expression is incorrect. The purpose was to check whether
> > the trace event is currently enabled (i.e. dynamically at runtime).
>
> The expression is correct, but the function and argument names are not. It
> should be
>
> fn trace_event_state_is_enabled(dstate: u16) -> bool {
> unsafe { trace_events_enabled_count } != 0 && dstate != 0
> }The generated code is missing DTrace's SDT semaphore (see generate_h_backend_dstate() in scripts/tracetool/backend/dtrace.py). The conditional must be taken when a tool like SystemTap or GDB sets the SDT semaphore. Right now it will not be taken because the conditional only looks at _ ## id ## _DSTATE and not the SDT semaphore. Stefan
signature.asc
Description: PGP signature
