tracetool/backend: remove redundant trace event checks
Use CHECK_TRACE_EVENT_GET_STATE in log, syslog, dtrace and simple backend, so that the "if (trace_event_get_state)" is created from common code and unified when multiple backends are active. When a single backend is active there is no code change (except for the log backend, as shown in tests/tracetool/log.h), but the code in the backends is simpler. Signed-off-by: Tanish Desai <tanishdesai37@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20250929154938.594389-8-pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
809caa0d40
commit
494492c5c5
5 changed files with 20 additions and 28 deletions
|
|
@ -16,6 +16,7 @@ from tracetool import out
|
|||
|
||||
|
||||
PUBLIC = True
|
||||
CHECK_TRACE_EVENT_GET_STATE = True
|
||||
|
||||
|
||||
def generate_h_begin(events, group):
|
||||
|
|
@ -28,14 +29,11 @@ def generate_h(event, group):
|
|||
if len(event.args) > 0:
|
||||
argnames = ", " + argnames
|
||||
|
||||
out(' if (trace_event_get_state(%(event_id)s)) {',
|
||||
'#line %(event_lineno)d "%(event_filename)s"',
|
||||
out('#line %(event_lineno)d "%(event_filename)s"',
|
||||
' ftrace_write("%(name)s " %(fmt)s "\\n" %(argnames)s);',
|
||||
'#line %(out_next_lineno)d "%(out_filename)s"',
|
||||
' }',
|
||||
name=event.name,
|
||||
args=event.args,
|
||||
event_id="TRACE_" + event.name.upper(),
|
||||
event_lineno=event.lineno,
|
||||
event_filename=event.filename,
|
||||
fmt=event.fmt.rstrip("\n"),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from tracetool import out
|
|||
|
||||
|
||||
PUBLIC = True
|
||||
CHECK_TRACE_EVENT_GET_STATE = True
|
||||
|
||||
|
||||
def generate_h_begin(events, group):
|
||||
|
|
@ -28,14 +29,11 @@ def generate_h(event, group):
|
|||
if len(event.args) > 0:
|
||||
argnames = ", " + argnames
|
||||
|
||||
cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
|
||||
|
||||
out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {',
|
||||
out(' if (qemu_loglevel_mask(LOG_TRACE)) {',
|
||||
'#line %(event_lineno)d "%(event_filename)s"',
|
||||
' qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);',
|
||||
' qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);',
|
||||
'#line %(out_next_lineno)d "%(out_filename)s"',
|
||||
' }',
|
||||
cond=cond,
|
||||
' }',
|
||||
event_lineno=event.lineno,
|
||||
event_filename=event.filename,
|
||||
name=event.name,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from tracetool import out
|
|||
|
||||
|
||||
PUBLIC = True
|
||||
CHECK_TRACE_EVENT_GET_STATE = True
|
||||
|
||||
|
||||
def is_string(arg):
|
||||
|
|
@ -36,13 +37,8 @@ def generate_h_begin(events, group):
|
|||
|
||||
|
||||
def generate_h(event, group):
|
||||
event_id = 'TRACE_' + event.name.upper()
|
||||
cond = "trace_event_get_state(%s)" % event_id
|
||||
out(' if (%(cond)s) {',
|
||||
' _simple_%(api)s(%(args)s);',
|
||||
' }',
|
||||
out(' _simple_%(api)s(%(args)s);',
|
||||
api=event.api(),
|
||||
cond=cond,
|
||||
args=", ".join(event.args.names()))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from tracetool import out
|
|||
|
||||
|
||||
PUBLIC = True
|
||||
CHECK_TRACE_EVENT_GET_STATE = True
|
||||
|
||||
|
||||
def generate_h_begin(events, group):
|
||||
|
|
@ -28,14 +29,9 @@ def generate_h(event, group):
|
|||
if len(event.args) > 0:
|
||||
argnames = ", " + argnames
|
||||
|
||||
cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
|
||||
|
||||
out(' if (%(cond)s) {',
|
||||
'#line %(event_lineno)d "%(event_filename)s"',
|
||||
out('#line %(event_lineno)d "%(event_filename)s"',
|
||||
' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);',
|
||||
'#line %(out_next_lineno)d "%(out_filename)s"',
|
||||
' }',
|
||||
cond=cond,
|
||||
event_lineno=event.lineno,
|
||||
event_filename=event.filename,
|
||||
name=event.name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue