Conversation
f813a1a to
c22c06b
Compare
c22c06b to
213e7ab
Compare
|
|
||
| // implement display formatting | ||
|
|
||
| simple_display_impl!(i8, i16, i32, i64, isize); |
There was a problem hiding this comment.
I think we could reduce the macro usage here while keeping the boilerplate low with an extra layer of Traits. IMO this would make the code easier to read and debug, though maybe I just need to get more comfortable with Rust macros :).
I think it'd go something like:
trait SimpleSyscallDataDisplay : Display {};
impl SyscallDataDisplay for SimpleSyscallDataDisplay {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)
}
};
impl SimpleSyscallDataDisplay for i8;
impl SimpleSyscallDataDisplay for i16;
impl SimpleSyscallDataDisplay for i32;
...
There was a problem hiding this comment.
I don't know of a way to do this with traits.
If you use impl SyscallDataDisplay for dyn SimpleSyscallDataDisplay {...}, then impl SimpleSyscallDataDisplay for i8 won't implement SyscallDataDisplay for i8 since i8 is not a trait object: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=143bd80d7e99d949dacb88fc06a90253
If you use impl<T> SyscallDataDisplay for T where T: SimpleSyscallDataDisplay {...} and impl<T> SyscallDataDisplay for T where T: SimpleSyscallDataDebug {...}, then you get conflicting trait implementations: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=2478d50fdd6e8b3cf5ab0e7235e4732c
There was a problem hiding this comment.
I'll merge now, and then if there's a better way to do it I can make a new PR later.
Adds the configuration option and initializes the log file, but it's currently unused.
81fded6 to
0376888
Compare
Adds the experimental "use_strace_logging" option to log syscalls. The syscalls are logged to
hosts/hostname/hostname.procname.pid.stracefiles (one for each process). The goals are:The first goal is achieved using an abuse of generics, and the second goal is achieved using a proc macro.
For example, to add logging for a Rust syscall, annotate it with the
log_syscallmacro.Example of the
stracefile output for tor:Limitations:
...for arguments