2011/12/6 Lluís Vilanova <vilan...@ac.upc.edu>: > Adds a 'TRACE_${NAME}_ENABLED' preprocessor define for each tracing event in > "trace.h".
I think we should take it a step further: support TRACE_${NAME}_ENABLED at run-time. This means skipping the trace event code if the event is currently disabled. If the user enables it at runtime then the if (TRACE_${NAME}_ENABLED) will evaluate to true and we execute the code. SystemTap has support for this and it would be easy to do runtime support for stderr and simple (where we can test trace_list[event_id].state). The SystemTap mechanism is a macro, e.g. QEMU_${NAME}_ENABLED(), which fits perfectly with what you have posted. What do you think? (The difference is that your patch plus compiler dead-code elimination would completely remove the code when built without a trace event. What I'm suggesting becomes a test and branch to skip over the code which always gets compiled in.) Stefan