|
1 | 1 | use proc_macro::*;
|
2 | 2 | use quote::ToTokens;
|
3 | 3 |
|
4 |
| -/// This macro wraps a syscall handler function by renaming the original function and making a new |
| 4 | +// FIXME: These doctests are effectively disabled via `compile_fail`. |
| 5 | +// For them to work, this crate would need to depend on shadow_rs. We can't do that though, |
| 6 | +// since shadow_rs depends on this crate. This could perhaps be fixed by moving the parts |
| 7 | +// of shadow_rs neede by this crate out to a separate crate to break the cycle. |
| 8 | +/// This macro wraps a syscall handler by renaming the original function and making a new |
5 | 9 | /// function with the original name that calls the original function. When the syscall handler
|
6 | 10 | /// function is called, it will log the syscall if syscall logging is enabled in Shadow.
|
7 | 11 | ///
|
8 | 12 | /// For example,
|
9 | 13 | ///
|
10 |
| -/// ``` |
11 |
| -/// #[log_syscall(/* rv */ libc::c_int, /* fd */ libc::c_int)] |
12 |
| -/// pub fn close(ctx: &mut ThreadContext, args: &SysCallArgs) -> SyscallResult {} |
| 14 | +/// ```compile_fail |
| 15 | +/// # use syscall_logger::log_syscall; |
| 16 | +/// # use shadow_rs::host::context::ThreadContext; |
| 17 | +/// # use shadow_rs::host::syscall_types::{SysCallArgs, SyscallResult}; |
| 18 | +/// struct MyHandler {} |
| 19 | +/// |
| 20 | +/// impl MyHandler { |
| 21 | +/// #[log_syscall(/* rv */ libc::c_int, /* fd */ libc::c_int)] |
| 22 | +/// pub fn close(ctx: &mut ThreadContext, args: &SysCallArgs) -> SyscallResult {} |
| 23 | +/// } |
13 | 24 | /// ```
|
14 | 25 | ///
|
15 | 26 | /// will become,
|
16 | 27 | ///
|
17 |
| -/// ``` |
18 |
| -/// pub fn close(ctx: &mut ThreadContext, args: &SysCallArgs) -> SyscallResult { |
19 |
| -/// ... |
20 |
| -/// let rv = close_original(ctx, args); |
21 |
| -/// ... |
22 |
| -/// rv |
23 |
| -/// } |
24 |
| -/// fn close_original(ctx: &mut ThreadContext, args: &SysCallArgs) -> SyscallResult { |
| 28 | +/// ```compile_fail |
| 29 | +/// # use shadow_rs::host::context::ThreadContext; |
| 30 | +/// # use shadow_rs::host::syscall_types::{SysCallArgs, SyscallResult}; |
| 31 | +/// struct MyHandler {} |
| 32 | +/// |
| 33 | +/// impl MyHandler { |
| 34 | +/// pub fn close(ctx: &mut ThreadContext, args: &SysCallArgs) -> SyscallResult { |
| 35 | +/// // ... |
| 36 | +/// let rv = close_original(ctx, args); |
| 37 | +/// // ... |
| 38 | +/// rv |
| 39 | +/// } |
| 40 | +/// fn close_original(ctx: &mut ThreadContext, args: &SysCallArgs) -> SyscallResult { |
| 41 | +/// } |
25 | 42 | /// }
|
26 | 43 | /// ```
|
27 | 44 | #[proc_macro_attribute]
|
|
0 commit comments