diff --git a/dist/core.c b/dist/core.c index fcd1876..3d15316 100644 --- a/dist/core.c +++ b/dist/core.c @@ -61296,6 +61296,8 @@ void callgrind_start_instrumentation() {} void callgrind_stop_instrumentation() {} +void callgrind_toggle_collect() {} + void callgrind_add_obj_skip(uint8_t const *path) { (void)path; } #else #include "callgrind.h" @@ -61315,6 +61317,8 @@ void callgrind_start_instrumentation() { CALLGRIND_START_INSTRUMENTATION; } void callgrind_stop_instrumentation() { CALLGRIND_STOP_INSTRUMENTATION; } +void callgrind_toggle_collect() { CALLGRIND_TOGGLE_COLLECT; } + void callgrind_add_obj_skip(uint8_t const *path) { CALLGRIND_ADD_OBJ_SKIP(path); } diff --git a/includes/core.h b/includes/core.h index de4e65d..0690d91 100644 --- a/includes/core.h +++ b/includes/core.h @@ -49,6 +49,13 @@ uint64_t instrument_hooks_current_timestamp(void); void callgrind_start_instrumentation(); void callgrind_stop_instrumentation(); +// Toggle callgrind cost collection on/off without re-instrumenting. +// Unlike start/stop instrumentation, this does not flush the simulated +// cache, so it can be used to exclude code regions from measurement +// without introducing artificial cold-cache costs. +// Safe to call outside Valgrind: expands to a no-op. +void callgrind_toggle_collect(); + // Register an object file path on callgrind's runtime --obj-skip list. // Equivalent to passing --obj-skip= on the valgrind command line. // Safe to call outside Valgrind: expands to a no-op. diff --git a/src/helpers/valgrind_wrapper.c b/src/helpers/valgrind_wrapper.c index 00ed042..c338c04 100644 --- a/src/helpers/valgrind_wrapper.c +++ b/src/helpers/valgrind_wrapper.c @@ -17,6 +17,8 @@ void callgrind_start_instrumentation() {} void callgrind_stop_instrumentation() {} +void callgrind_toggle_collect() {} + void callgrind_add_obj_skip(uint8_t const *path) { (void)path; } #else #include "callgrind.h" @@ -36,6 +38,8 @@ void callgrind_start_instrumentation() { CALLGRIND_START_INSTRUMENTATION; } void callgrind_stop_instrumentation() { CALLGRIND_STOP_INSTRUMENTATION; } +void callgrind_toggle_collect() { CALLGRIND_TOGGLE_COLLECT; } + void callgrind_add_obj_skip(uint8_t const *path) { CALLGRIND_ADD_OBJ_SKIP(path); }