Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/gpu/drm/amd/display/modules/freesync/   (Linux Kernel Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 40 kB image not shown  

 debug.rs   Interaktion und
PortierbarkeitRust

 

pub(crate) struct TraceScope {
    text: String,
    style: anstyle::Style,
    guard: DebugDepthGuard,
}

impl TraceScope {
    pub(crate) fn new(text: impl core::fmt::Display) -> Self {
        let text = text.to_string();
        let style = anstyle::Style::new();
        trace(&format!("> {text}"), style);
        Self {
            text,
            style,
            guard: DEBUG_DEPTH.scoped(),
        }
    }
}

impl Drop for TraceScope {
    fn drop(&mut self) {
        let text = &self.text;
        let style = self.style;
        drop(self.guard.take());
        trace(&format!("< {text}"), style);
    }
}

pub(crate) fn trace(text: &str, style: anstyle::Style) {
    #![allow(unexpected_cfgs)] // HACK: fixed in newer versions
    let depth = DEBUG_DEPTH.depth();
    anstream::eprintln!("{:depth$}{style}{text}{style:#}", "");
}

pub(crate) struct DebugDepth(core::sync::atomic::AtomicUsize);

impl DebugDepth {
    pub(crate) fn scoped(&self) -> DebugDepthGuard {
        DebugDepthGuard::new()
    }

    pub(crate) fn enter_unchecked(&self) -> usize {
        self.0.fetch_add(1, core::sync::atomic::Ordering::SeqCst)
    }

    pub(crate) fn exit_unchecked(&self) {
        let _ = self.0.fetch_sub(1, core::sync::atomic::Ordering::SeqCst);
    }

    pub(crate) fn depth(&self) -> usize {
        self.0.load(core::sync::atomic::Ordering::SeqCst)
    }
}

static DEBUG_DEPTH: DebugDepth = DebugDepth(core::sync::atomic::AtomicUsize::new(0));

pub(crate) struct DebugDepthGuard {
    depth: usize,
    inc: bool,
}

impl DebugDepthGuard {
    pub(crate) fn new() -> Self {
        let depth = DEBUG_DEPTH.enter_unchecked();
        Self { depth, inc: true }
    }

    fn take(&mut self) -> Self {
        let depth = self.depth;
        let inc = self.inc;
        self.inc = false;
        Self { depth, inc }
    }
}

impl Drop for DebugDepthGuard {
    fn drop(&mut self) {
        if self.inc {
            DEBUG_DEPTH.exit_unchecked();
        }
    }
}

impl AsRef<usize> for DebugDepthGuard {
    #[inline(always)]
    fn as_ref(&self) -> &usize {
        &self.depth
    }
}

impl core::ops::Deref for DebugDepthGuard {
    type Target = usize;

    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.depth
    }
}

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.0Angebot  (Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-12) ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.