Implementation of debug functions. Macro used for better performance.
Add some debug prints into memory hooks.