> Is that codable in rust currently?

Well, there are two parts to this: the automatic insertion of logging calls, 
and the runtime feature to enable/disable them.  The former would be part of 
the compiler and can directly emit appropriate LLVM along with table entries to 
say what should be NOP'd out.  The runtime component can probably be written in 
(unsafe) Rust since it's ultimately just writing known sequences of bytes to 
known addresses.  It will need to know some details about memory protection, 
architectures where a system call is required to flush the i-cache, etc.  It 
may also need support from the Rust scheduler to avoid modifying code directly 
under the instruction pointer.

Linux uses GCC extended asm and some linker features to implement their 
self-modifying debug/trace macros.  For automatically hooking every function 
call, they repurpose GCC's profiling support, which inserts a call to mcount() 
at the beginning of each function.

A while back I wrote up a small demonstration of techniques based on what Linux 
does:

    
http://mainisusuallyafunction.blogspot.com/2011/11/self-modifying-code-for-debug-tracing.html

keegan
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to