Skip to content
Snippets Groups Projects
Unverified Commit 25d3671a authored by bors[bot]'s avatar bors[bot] Committed by GitHub
Browse files

Merge #383


383: Macros: Add dbg r=jounathaen a=mkroening



Co-authored-by: default avatarMartin Kröning <m.kroening@hotmail.de>
parents 7432ac97 be9acb4d
No related branches found
No related tags found
No related merge requests found
Pipeline #669876 failed
......@@ -26,6 +26,34 @@ macro_rules! println {
($($arg:tt)+) => (print!("{}\n", ::core::format_args!($($arg)+)));
}
/// Prints and returns the value of a given expression for quick and dirty
/// debugging.
// Copied from std/macros.rs
#[macro_export]
macro_rules! dbg {
// NOTE: We cannot use `concat!` to make a static string as a format argument
// of `eprintln!` because `file!` could contain a `{` or
// `$val` expression could be a block (`{ .. }`), in which case the `eprintln!`
// will be malformed.
() => {
$crate::println!("[{}:{}]", ::core::file!(), ::core::line!())
};
($val:expr $(,)?) => {
// Use of `match` here is intentional because it affects the lifetimes
// of temporaries - https://stackoverflow.com/a/48732525/1063961
match $val {
tmp => {
$crate::println!("[{}:{}] {} = {:#?}",
::core::file!(), ::core::line!(), ::core::stringify!($val), &tmp);
tmp
}
}
};
($($val:expr),+ $(,)?) => {
($($crate::dbg!($val)),+,)
};
}
/// Runs `f` on the kernel stack.
///
/// All arguments and return values have to fit into registers:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment