I would like to interpose all drop handlers in a Rust program. Specifically, I want to wrap the actual drop handler call with a prologue and an epilogue.
fn drop(&mut self) {
prologue();
real_drop(self); // The actual drop handler defined by the original code
epilogue();
}
In my specific case the prologue
would be incrementing a counter at a fixed memory address and the epilogue
decrementing it.
I believe this requires rustc
compiler change, and I'm ready to do so. Actually, I am already building the program with a custom rustc
and LLVM toolchain.
I am grateful to any help. Thanks in advance.