From a8d7cd1835fdef40edb990a526d340fc016e0310 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 30 Sep 2014 16:14:20 -0700 Subject: [PATCH] hooks --- src/bitcoindjs.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index c0d6ffb1..7eee33ff 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -86,9 +86,11 @@ * ~/bitcoin/src/main.h */ +extern "C" { #include #include #include +} #include #include @@ -2367,6 +2369,63 @@ jstx_to_ctx(const Local entry, CTransaction& tx, uint256 hashBlock) { } #endif +/** + * Hooks + */ + +#if 0 +static int last_height = -1; + +extern "C" void __attribute__ ((constructor)) +trace_begin(void) { + return; +} + +extern "C" void __attribute__ ((destructor)) +trace_end(void) { + return; +} + +extern "C" void +__cyg_profile_func_enter(void *func, void *caller) { + return; +} + +extern "C" void +__cyg_profile_func_exit(void *func, void *caller) { + int cur_height = chainActive.Height(); + if (cur_height != last_height) { + printf("new block\n"); + last_height = cur_height; + } + // if (func == &AcceptBlock || caller == &AcceptBlock || func == AcceptBlock || caller == AcceptBlock) { + // printf("accept block\n"); + // } +} +#endif + +extern "C" { + #include + #include + #include + #include + #include + + int printf(const char *, ...); + void __cyg_profile_func_enter(void *this_fn, void *call_site) __attribute__((no_instrument_function)); + void __cyg_profile_func_exit(void *this_fn, void *call_site) __attribute__((no_instrument_function)); +} + +void __cyg_profile_func_enter(void *this_fn, void *call_site) { + printf("enter\n"); + (void)call_site; +} + +void __cyg_profile_func_exit(void *this_fn, void *call_site) { + printf("exit\n"); + (void)call_site; +} + /** * Init */