If emitting a trace event requires computation for the parameters passed to the probe, the callers should guard that computation with trace_event_by_state_backends(), which is a macro expanding to the a check of the "TRACE_...._DSTATE()" expression. For the log backend this should include a check for LOG_TRACE being present in the configured log level.
Signed-off-by: Daniel P. Berrangé <[email protected]> --- scripts/tracetool/backend/log.py | 3 ++- tests/tracetool/all.h | 6 ++++-- tests/tracetool/log.h | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py index 9e3e5046f5f..7834e5b0d40 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -42,7 +42,8 @@ def generate_h(event, group): def generate_h_backend_dstate(event, group): - out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\', + out(' (trace_event_get_state_dynamic_by_id(%(event_id)s) && \\\n' + ' qemu_loglevel_mask(LOG_TRACE)) || \\', event_id="TRACE_" + event.name.upper()) def generate_rs(event, group): diff --git a/tests/tracetool/all.h b/tests/tracetool/all.h index 41fa4d0e8a2..a2c2d40388e 100644 --- a/tests/tracetool/all.h +++ b/tests/tracetool/all.h @@ -45,7 +45,8 @@ void _simple_trace_test_wibble(void *context, int value); #define TRACE_TEST_BLAH_BACKEND_DSTATE() ( \ QEMU_TEST_BLAH_ENABLED() || \ trace_event_get_state_dynamic_by_id(TRACE_TEST_BLAH) || \ - trace_event_get_state_dynamic_by_id(TRACE_TEST_BLAH) || \ + (trace_event_get_state_dynamic_by_id(TRACE_TEST_BLAH) && \ + qemu_loglevel_mask(LOG_TRACE)) || \ trace_event_get_state_dynamic_by_id(TRACE_TEST_BLAH) || \ trace_event_get_state_dynamic_by_id(TRACE_TEST_BLAH) || \ tracepoint_enabled(qemu, test_blah) || \ @@ -74,7 +75,8 @@ static inline void trace_test_blah(void *context, const char *filename) #define TRACE_TEST_WIBBLE_BACKEND_DSTATE() ( \ QEMU_TEST_WIBBLE_ENABLED() || \ trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) || \ - trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) || \ + (trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) && \ + qemu_loglevel_mask(LOG_TRACE)) || \ trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) || \ trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) || \ tracepoint_enabled(qemu, test_wibble) || \ diff --git a/tests/tracetool/log.h b/tests/tracetool/log.h index ff510d54908..fe08277887f 100644 --- a/tests/tracetool/log.h +++ b/tests/tracetool/log.h @@ -16,7 +16,8 @@ extern uint8_t _TRACE_TEST_WIBBLE_DSTATE; #define TRACE_TEST_BLAH_BACKEND_DSTATE() ( \ - trace_event_get_state_dynamic_by_id(TRACE_TEST_BLAH) || \ + (trace_event_get_state_dynamic_by_id(TRACE_TEST_BLAH) && \ + qemu_loglevel_mask(LOG_TRACE)) || \ false) static inline void trace_test_blah(void *context, const char *filename) @@ -31,7 +32,8 @@ static inline void trace_test_blah(void *context, const char *filename) } #define TRACE_TEST_WIBBLE_BACKEND_DSTATE() ( \ - trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) || \ + (trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) && \ + qemu_loglevel_mask(LOG_TRACE)) || \ false) static inline void trace_test_wibble(void *context, int value) -- 2.55.0
