From 532ffca768bfe00f6653708beabc0cfdaa3103ee Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 24 Apr 2022 15:42:27 +0200 Subject: [PATCH] Permit allocations in debug and tracing messages Otherwise debugging becomes a lot more difficult when using the assert_no_alloc feature. --- src/debug.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/debug.rs b/src/debug.rs index d2a1eab7..19546303 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -20,7 +20,7 @@ macro_rules! nih_log { #[macro_export] macro_rules! nih_trace { ($($args:tt)*) => ( - $crate::log::trace!($($args)*) + $crate::util::permit_alloc(|| $crate::log::trace!($($args)*)) ); } @@ -32,12 +32,12 @@ macro_rules! nih_trace { macro_rules! nih_debug_assert { ($cond:expr $(,)?) => ( if cfg!(debug_assertions) && !$cond { - $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($cond))); + $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($cond)))); } ); ($cond:expr, $format:expr $(, $($args:tt)*)?) => ( if cfg!(debug_assertions) && !$cond { - $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($cond), ", ", $format), $($($args)*)?); + $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($cond), ", ", $format), $($($args)*)?)); } ); } @@ -48,12 +48,12 @@ macro_rules! nih_debug_assert { macro_rules! nih_debug_assert_failure { () => ( if cfg!(debug_assertions) { - $crate::log::debug!("Debug assertion failed"); + $crate::util::permit_alloc(|| $crate::log::debug!("Debug assertion failed")); } ); ($format:expr $(, $($args:tt)*)?) => ( if cfg!(debug_assertions) { - $crate::log::debug!(concat!("Debug assertion failed: ", $format), $($($args)*)?); + $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", $format), $($($args)*)?)); } ); } @@ -64,12 +64,12 @@ macro_rules! nih_debug_assert_failure { macro_rules! nih_debug_assert_eq { ($left:expr, $right:expr $(,)?) => ( if cfg!(debug_assertions) && $left != $right { - $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right))); + $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right)))); } ); ($left:expr, $right:expr, $format:expr $(, $($args:tt)*)?) => ( if cfg!(debug_assertions) && $left != $right { - $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right), ", ", $format), $($($args)*)?); + $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right), ", ", $format), $($($args)*)?)); } ); } @@ -80,12 +80,12 @@ macro_rules! nih_debug_assert_eq { macro_rules! nih_debug_assert_ne { ($left:expr, $right:expr $(,)?) => ( if cfg!(debug_assertions) && $left == $right { - $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right))); + $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right)))); } ); ($left:expr, $right:expr, $format:expr $(, $($args:tt)*)?) => ( if cfg!(debug_assertions) && $left == $right { - $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right), ", ", $format), $($($args)*)?); + $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right), ", ", $format), $($($args)*)?)); } ); }