trace: eliminate dupe trace_event_get_state_dynamic_by_id() calls
Each backend generates the same trace_event_get_state_dynamic_by_id()
call for the TRACE....DSTATE() macro body, so when multiple backends
are enabled, the same check is repeated:
#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) || \
trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) || \
tracepoint_enabled(qemu, test_wibble) || \
false)
Expanding the use of the 'backend.check_trace_event_get_state'
attr in the C header generator removes the duplication, in the
same way that the Rust generator already does.
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20261102142844.3464712-17-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
1 parent
4a9c326244
commit
243f6bf6be
7 files changed
+17
-34
No files matched your search
@@ -133,8 +133,8 @@ class Wrapper:
|
||||
def generate(self, event, group, check_trace_event_get_state=None):
|
||||
self._run_function("generate_%s", event, group, check_trace_event_get_state=check_trace_event_get_state)
|
||||
|
||||
def generate_backend_dstate(self, event, group):
|
||||
self._run_function("generate_%s_backend_dstate", event, group)
|
||||
def generate_backend_dstate(self, event, group, check_trace_event_get_state=None):
|
||||
self._run_function("generate_%s_backend_dstate", event, group, check_trace_event_get_state=check_trace_event_get_state)
|
||||
|
||||
def generate_end(self, events, group):
|
||||
self._run_function("generate_%s_end", events, group)
|
||||
@@ -40,10 +40,6 @@ def generate_h(event, group):
|
||||
argnames=argnames)
|
||||
|
||||
|
||||
def generate_h_backend_dstate(event, group):
|
||||
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
|
||||
event_id="TRACE_" + event.name.upper())
|
||||
|
||||
def generate_rs(event, group):
|
||||
out(' let format_string = c"%(fmt)s\\n";',
|
||||
' unsafe {bindings::ftrace_write(format_string.as_ptr() as *const c_char, %(args)s);}',
|
||||
|
||||
@@ -41,10 +41,6 @@ def generate_h(event, group):
|
||||
argnames=argnames)
|
||||
|
||||
|
||||
def generate_h_backend_dstate(event, group):
|
||||
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
|
||||
event_id="TRACE_" + event.name.upper())
|
||||
|
||||
def generate_rs(event, group):
|
||||
out(' let format_string = c"%(fmt)s\\n";',
|
||||
' if (unsafe { bindings::qemu_loglevel } & bindings::LOG_TRACE) != 0 {',
|
||||
|
||||
@@ -42,11 +42,6 @@ def generate_h(event, group):
|
||||
args=", ".join(event.args.names()))
|
||||
|
||||
|
||||
def generate_h_backend_dstate(event, group):
|
||||
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
|
||||
event_id="TRACE_" + event.name.upper())
|
||||
|
||||
|
||||
def generate_c_begin(events, group):
|
||||
out('#include "trace/simple.h"',
|
||||
'')
|
||||
|
||||
@@ -43,7 +43,3 @@ def generate_rs(event, group):
|
||||
' unsafe {::trace::syslog(::trace::LOG_INFO, format_string.as_ptr() as *const c_char, %(args)s);}',
|
||||
fmt=expand_format_string(event.fmt, event.name + " "),
|
||||
args=event.args.rust_call_varargs())
|
||||
|
||||
def generate_h_backend_dstate(event, group):
|
||||
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
|
||||
event_id="TRACE_" + event.name.upper())
|
||||
@@ -55,7 +55,13 @@ def generate(events, backend, group):
|
||||
api=e.api(e.QEMU_BACKEND_DSTATE))
|
||||
|
||||
if "disable" not in e.properties:
|
||||
backend.generate_backend_dstate(e, group)
|
||||
backend.generate_backend_dstate(e, group, check_trace_event_get_state=False)
|
||||
|
||||
if backend.check_trace_event_get_state:
|
||||
event_id = 'TRACE_' + e.name.upper()
|
||||
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
|
||||
event_id=event_id)
|
||||
backend.generate_backend_dstate(e, group, check_trace_event_get_state=True)
|
||||
|
||||
out(' false)')
|
||||
|
||||
|
||||
+8
-14
@@ -44,11 +44,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) || \
|
||||
trace_event_get_state_dynamic_by_id(TRACE_TEST_BLAH) || \
|
||||
tracepoint_enabled(qemu, test_blah) || \
|
||||
trace_event_get_state_dynamic_by_id(TRACE_TEST_BLAH) || \
|
||||
false)
|
||||
|
||||
static inline void trace_test_blah(void *context, const char *filename)
|
||||
@@ -58,26 +55,23 @@ static inline void trace_test_blah(void *context, const char *filename)
|
||||
if (trace_event_get_state(TRACE_TEST_BLAH)) {
|
||||
#line 4 "trace-events"
|
||||
ftrace_write("test_blah " "Blah context=%p filename=%s" "\n" , context, filename);
|
||||
#line 62 "all.h"
|
||||
#line 59 "all.h"
|
||||
if (qemu_loglevel_mask(LOG_TRACE)) {
|
||||
#line 4 "trace-events"
|
||||
qemu_log("test_blah " "Blah context=%p filename=%s" "\n", context, filename);
|
||||
#line 66 "all.h"
|
||||
#line 63 "all.h"
|
||||
}
|
||||
_simple_trace_test_blah(context, filename);
|
||||
#line 4 "trace-events"
|
||||
syslog(LOG_INFO, "test_blah " "Blah context=%p filename=%s" , context, filename);
|
||||
#line 71 "all.h"
|
||||
#line 68 "all.h"
|
||||
}
|
||||
}
|
||||
|
||||
#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) || \
|
||||
trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) || \
|
||||
tracepoint_enabled(qemu, test_wibble) || \
|
||||
trace_event_get_state_dynamic_by_id(TRACE_TEST_WIBBLE) || \
|
||||
false)
|
||||
|
||||
static inline void trace_test_wibble(void *context, int value)
|
||||
@@ -87,16 +81,16 @@ static inline void trace_test_wibble(void *context, int value)
|
||||
if (trace_event_get_state(TRACE_TEST_WIBBLE)) {
|
||||
#line 5 "trace-events"
|
||||
ftrace_write("test_wibble " "Wibble context=%p value=%d" "\n" , context, value);
|
||||
#line 91 "all.h"
|
||||
#line 85 "all.h"
|
||||
if (qemu_loglevel_mask(LOG_TRACE)) {
|
||||
#line 5 "trace-events"
|
||||
qemu_log("test_wibble " "Wibble context=%p value=%d" "\n", context, value);
|
||||
#line 95 "all.h"
|
||||
#line 89 "all.h"
|
||||
}
|
||||
_simple_trace_test_wibble(context, value);
|
||||
#line 5 "trace-events"
|
||||
syslog(LOG_INFO, "test_wibble " "Wibble context=%p value=%d" , context, value);
|
||||
#line 100 "all.h"
|
||||
#line 94 "all.h"
|
||||
}
|
||||
}
|
||||
#endif /* TRACE_TESTSUITE_GENERATED_TRACERS_H */
|
||||
Reference in new issue
Block a user