Skip to content

Commit 9b65c94

Browse files
committed
Support trace logging of function entry/exit
1 parent 390da5e commit 9b65c94

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/entry.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,30 @@ use crate::{conf, HandshakeState, ShutdownResult};
4444
/// versioning happening there,
4545
/// - the name should appear in the list of all entry points there.
4646
macro_rules! entry {
47-
(pub fn $name:ident($($args:tt)*) $body:block) => {
47+
(pub fn $name:ident($($aname:ident: $aty:ty),*$(,)?) $body:block) => {
4848
#[no_mangle]
49-
pub extern "C" fn $name($($args)*) { ffi_panic_boundary! { $body } }
49+
pub extern "C" fn $name($($aname: $aty),*) {
50+
ffi_panic_boundary! {
51+
#[cfg(debug_assertions)]
52+
log::trace!("-> {}{:?}", &stringify!($name)[1..], &($($aname,)*));
53+
$body
54+
#[cfg(debug_assertions)]
55+
log::trace!("<- {}", &stringify!($name)[1..]);
56+
}
57+
}
5058
};
51-
(pub fn $name:ident($($args:tt)*) -> $ret:ty $body:block) => {
59+
(pub fn $name:ident($($aname:ident: $aty:ty),*$(,)?) -> $ret:ty $body:block) => {
5260
#[no_mangle]
53-
pub extern "C" fn $name($($args)*) -> $ret { ffi_panic_boundary! { $body } }
61+
pub extern "C" fn $name($($aname: $aty),*) -> $ret {
62+
ffi_panic_boundary! {
63+
#[cfg(debug_assertions)]
64+
log::trace!("-> {}{:?}", &stringify!($name)[1..], &($($aname,)*));
65+
let r = $body;
66+
#[cfg(debug_assertions)]
67+
log::trace!("<- {} [{:?}]", &stringify!($name)[1..], r);
68+
r
69+
}
70+
}
5471
};
5572
}
5673

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ mod x509;
5656
///
5757
/// # Lifetime
5858
/// Functions that return SSL_METHOD, like `TLS_method()`, give static-lifetime pointers.
59+
#[derive(Debug)]
5960
pub struct SslMethod {
6061
client_versions: &'static [&'static SupportedProtocolVersion],
6162
server_versions: &'static [&'static SupportedProtocolVersion],

0 commit comments

Comments
 (0)