diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2016-10-04 14:35:59 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-10-12 09:54:53 +0200 |
commit | 80dd5c4918aba98f025ca60c838dd68b6e33ff0e (patch) | |
tree | d5f3211dfac8171b53185f8f2b92d209d8c04bbb /scripts/tracetool | |
parent | 0bc6484d58bd7f43fbf6fc87c7974910b698489c (diff) |
trace: introduce a formal group name for trace events
The declarations in the generated-tracers.h file are
assuming there's only ever going to be one instance
of this header, as they are not namespaced. When we
have one header per event group, if a single source
file needs to include multiple sets of trace events,
the symbols will all clash.
This change thus introduces a '--group NAME' arg to the
'tracetool' program. This will cause all the symbols in
the generated header files to be given a unique namespace.
If no group is given, the group name 'common' is used,
which is suitable for the current usage where there is
only one global trace-events file used for code generation.
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: LluĂs Vilanova <vilanova@ac.upc.edu>
Message-id: 1475588159-30598-21-git-send-email-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts/tracetool')
-rw-r--r-- | scripts/tracetool/__init__.py | 6 | ||||
-rw-r--r-- | scripts/tracetool/backend/__init__.py | 12 | ||||
-rw-r--r-- | scripts/tracetool/backend/dtrace.py | 4 | ||||
-rw-r--r-- | scripts/tracetool/backend/ftrace.py | 4 | ||||
-rw-r--r-- | scripts/tracetool/backend/log.py | 4 | ||||
-rw-r--r-- | scripts/tracetool/backend/simple.py | 8 | ||||
-rw-r--r-- | scripts/tracetool/backend/syslog.py | 4 | ||||
-rw-r--r-- | scripts/tracetool/backend/ust.py | 4 | ||||
-rw-r--r-- | scripts/tracetool/format/__init__.py | 4 | ||||
-rw-r--r-- | scripts/tracetool/format/c.py | 18 | ||||
-rw-r--r-- | scripts/tracetool/format/d.py | 2 | ||||
-rw-r--r-- | scripts/tracetool/format/h.py | 14 | ||||
-rw-r--r-- | scripts/tracetool/format/simpletrace_stap.py | 2 | ||||
-rw-r--r-- | scripts/tracetool/format/stap.py | 2 | ||||
-rw-r--r-- | scripts/tracetool/format/tcg_h.py | 8 | ||||
-rw-r--r-- | scripts/tracetool/format/tcg_helper_c.py | 2 | ||||
-rw-r--r-- | scripts/tracetool/format/tcg_helper_h.py | 2 | ||||
-rw-r--r-- | scripts/tracetool/format/tcg_helper_wrapper_h.py | 2 | ||||
-rw-r--r-- | scripts/tracetool/format/ust_events_c.py | 2 | ||||
-rw-r--r-- | scripts/tracetool/format/ust_events_h.py | 9 |
20 files changed, 59 insertions, 54 deletions
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index ac2cb8fa98..365446fa53 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -364,7 +364,7 @@ def try_import(mod_name, attr_name=None, attr_default=None): return False, None -def generate(events, format, backends, +def generate(events, group, format, backends, binary=None, probe_prefix=None): """Generate the output for the given (format, backends) pair. @@ -372,6 +372,8 @@ def generate(events, format, backends, ---------- events : list list of Event objects to generate for + group: str + Name of the tracing group format : str Output format name. backends : list @@ -401,4 +403,4 @@ def generate(events, format, backends, tracetool.backend.dtrace.BINARY = binary tracetool.backend.dtrace.PROBEPREFIX = probe_prefix - tracetool.format.generate(events, format, backend) + tracetool.format.generate(events, format, backend, group) diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/backend/__init__.py index d4b6dab9ca..f735a259c0 100644 --- a/scripts/tracetool/backend/__init__.py +++ b/scripts/tracetool/backend/__init__.py @@ -113,11 +113,11 @@ class Wrapper: if func is not None: func(*args, **kwargs) - def generate_begin(self, events): - self._run_function("generate_%s_begin", events) + def generate_begin(self, events, group): + self._run_function("generate_%s_begin", events, group) - def generate(self, event): - self._run_function("generate_%s", event) + def generate(self, event, group): + self._run_function("generate_%s", event, group) - def generate_end(self, events): - self._run_function("generate_%s_end", events) + def generate_end(self, events, group): + self._run_function("generate_%s_end", events, group) diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py index ab9ecfab30..79505c6b1a 100644 --- a/scripts/tracetool/backend/dtrace.py +++ b/scripts/tracetool/backend/dtrace.py @@ -35,12 +35,12 @@ def binary(): return BINARY -def generate_h_begin(events): +def generate_h_begin(events, group): out('#include "trace/generated-tracers-dtrace.h"', '') -def generate_h(event): +def generate_h(event, group): out(' QEMU_%(uppername)s(%(argnames)s);', uppername=event.name.upper(), argnames=", ".join(event.args.names())) diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py index 4b83b44f3c..db9fe7ad57 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -19,12 +19,12 @@ from tracetool import out PUBLIC = True -def generate_h_begin(events): +def generate_h_begin(events, group): out('#include "trace/ftrace.h"', '') -def generate_h(event): +def generate_h(event, group): argnames = ", ".join(event.args.names()) if len(event.args) > 0: argnames = ", " + argnames diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py index 426bb6e2a2..4f4a4d38b1 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -19,12 +19,12 @@ from tracetool import out PUBLIC = True -def generate_h_begin(events): +def generate_h_begin(events, group): out('#include "qemu/log.h"', '') -def generate_h(event): +def generate_h(event, group): argnames = ", ".join(event.args.names()) if len(event.args) > 0: argnames = ", " + argnames diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py index 1114e3550b..9885e83cd4 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -27,7 +27,7 @@ def is_string(arg): return False -def generate_h_begin(events): +def generate_h_begin(events, group): for event in events: out('void _simple_%(api)s(%(args)s);', api=event.api(), @@ -35,13 +35,13 @@ def generate_h_begin(events): out('') -def generate_h(event): +def generate_h(event, group): out(' _simple_%(api)s(%(args)s);', api=event.api(), args=", ".join(event.args.names())) -def generate_c_begin(events): +def generate_c_begin(events, group): out('#include "qemu/osdep.h"', '#include "trace.h"', '#include "trace/control.h"', @@ -49,7 +49,7 @@ def generate_c_begin(events): '') -def generate_c(event): +def generate_c(event, group): out('void _simple_%(api)s(%(args)s)', '{', ' TraceBufferRecord rec;', diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py index 5f693bdf4d..b8ff2790c4 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -19,12 +19,12 @@ from tracetool import out PUBLIC = True -def generate_h_begin(events): +def generate_h_begin(events, group): out('#include <syslog.h>', '') -def generate_h(event): +def generate_h(event, group): argnames = ", ".join(event.args.names()) if len(event.args) > 0: argnames = ", " + argnames diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py index ed4c227f69..4594db6128 100644 --- a/scripts/tracetool/backend/ust.py +++ b/scripts/tracetool/backend/ust.py @@ -19,13 +19,13 @@ from tracetool import out PUBLIC = True -def generate_h_begin(events): +def generate_h_begin(events, group): out('#include <lttng/tracepoint.h>', '#include "trace/generated-ust-provider.h"', '') -def generate_h(event): +def generate_h(event, group): argnames = ", ".join(event.args.names()) if len(event.args) > 0: argnames = ", " + argnames diff --git a/scripts/tracetool/format/__init__.py b/scripts/tracetool/format/__init__.py index 812570ff6f..cf6e0e2da5 100644 --- a/scripts/tracetool/format/__init__.py +++ b/scripts/tracetool/format/__init__.py @@ -74,7 +74,7 @@ def exists(name): return tracetool.try_import("tracetool.format." + name)[1] -def generate(events, format, backend): +def generate(events, format, backend, group): if not exists(format): raise ValueError("unknown format: %s" % format) format = format.replace("-", "_") @@ -82,4 +82,4 @@ def generate(events, format, backend): "generate")[1] if func is None: raise AttributeError("format has no 'generate': %s" % format) - func(events, backend) + func(events, backend, group) diff --git a/scripts/tracetool/format/c.py b/scripts/tracetool/format/c.py index 7ac6d4c508..47115ed8af 100644 --- a/scripts/tracetool/format/c.py +++ b/scripts/tracetool/format/c.py @@ -16,7 +16,7 @@ __email__ = "stefanha@linux.vnet.ibm.com" from tracetool import out -def generate(events, backend): +def generate(events, backend, group): active_events = [e for e in events if "disable" not in e.properties] @@ -47,7 +47,8 @@ def generate(events, backend): sstate = "TRACE_%s_ENABLED" % e.name.upper(), dstate = e.api(e.QEMU_DSTATE)) - out('TraceEvent *trace_events[] = {') + out('TraceEvent *%(group)s_trace_events[] = {', + group = group.lower()) for e in events: out(' &%(event)s,', event = e.api(e.QEMU_EVENT)) @@ -56,13 +57,14 @@ def generate(events, backend): '};', '') - out('static void trace_register_events(void)', + out('static void trace_%(group)s_register_events(void)', '{', - ' trace_event_register_group(trace_events);', + ' trace_event_register_group(%(group)s_trace_events);', '}', - 'trace_init(trace_register_events)') + 'trace_init(trace_%(group)s_register_events)', + group = group.lower()) - backend.generate_begin(active_events) + backend.generate_begin(active_events, group) for event in active_events: - backend.generate(event) - backend.generate_end(active_events) + backend.generate(event, group) + backend.generate_end(active_events, group) diff --git a/scripts/tracetool/format/d.py b/scripts/tracetool/format/d.py index c77d5b7ab0..78397c24d2 100644 --- a/scripts/tracetool/format/d.py +++ b/scripts/tracetool/format/d.py @@ -29,7 +29,7 @@ RESERVED_WORDS = ( ) -def generate(events, backend): +def generate(events, backend, group): events = [e for e in events if "disable" not in e.properties] diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index f4748c301f..3682f4e6a8 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -16,11 +16,11 @@ __email__ = "stefanha@linux.vnet.ibm.com" from tracetool import out -def generate(events, backend): +def generate(events, backend, group): out('/* This file is autogenerated by tracetool, do not edit. */', '', - '#ifndef TRACE__GENERATED_TRACERS_H', - '#define TRACE__GENERATED_TRACERS_H', + '#ifndef TRACE_%s_GENERATED_TRACERS_H' % group.upper(), + '#define TRACE_%s_GENERATED_TRACERS_H' % group.upper(), '', '#include "qemu-common.h"', '#include "trace/control.h"', @@ -46,7 +46,7 @@ def generate(events, backend): enabled=enabled) out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled)) - backend.generate_begin(events) + backend.generate_begin(events, group) for e in events: if "vcpu" in e.properties: @@ -68,11 +68,11 @@ def generate(events, backend): cond=cond) if "disable" not in e.properties: - backend.generate(e) + backend.generate(e, group) out(' }', '}') - backend.generate_end(events) + backend.generate_end(events, group) - out('#endif /* TRACE__GENERATED_TRACERS_H */') + out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group.upper()) diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/tracetool/format/simpletrace_stap.py index ac3580fbcc..c35e662e00 100644 --- a/scripts/tracetool/format/simpletrace_stap.py +++ b/scripts/tracetool/format/simpletrace_stap.py @@ -19,7 +19,7 @@ from tracetool.backend.simple import is_string from tracetool.format.stap import stap_escape -def generate(events, backend): +def generate(events, backend, group): out('/* This file is autogenerated by tracetool, do not edit. */', '', 'global event_name_to_id_map', diff --git a/scripts/tracetool/format/stap.py b/scripts/tracetool/format/stap.py index 9e780f1b06..e8ef3e762d 100644 --- a/scripts/tracetool/format/stap.py +++ b/scripts/tracetool/format/stap.py @@ -34,7 +34,7 @@ def stap_escape(identifier): return identifier -def generate(events, backend): +def generate(events, backend, group): events = [e for e in events if "disable" not in e.properties] diff --git a/scripts/tracetool/format/tcg_h.py b/scripts/tracetool/format/tcg_h.py index e2331f251d..5f213f6cba 100644 --- a/scripts/tracetool/format/tcg_h.py +++ b/scripts/tracetool/format/tcg_h.py @@ -27,12 +27,12 @@ def vcpu_transform_args(args): ]) -def generate(events, backend): +def generate(events, backend, group): out('/* This file is autogenerated by tracetool, do not edit. */', '/* You must include this file after the inclusion of helper.h */', '', - '#ifndef TRACE__GENERATED_TCG_TRACERS_H', - '#define TRACE__GENERATED_TCG_TRACERS_H', + '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(), + '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(), '', '#include "trace.h"', '#include "exec/helper-proto.h"', @@ -63,4 +63,4 @@ def generate(events, backend): out('}') out('', - '#endif /* TRACE__GENERATED_TCG_TRACERS_H */') + '#endif /* TRACE_%s_GENERATED_TCG_TRACERS_H */' % group.upper()) diff --git a/scripts/tracetool/format/tcg_helper_c.py b/scripts/tracetool/format/tcg_helper_c.py index e3485b7f92..cc26e03008 100644 --- a/scripts/tracetool/format/tcg_helper_c.py +++ b/scripts/tracetool/format/tcg_helper_c.py @@ -40,7 +40,7 @@ def vcpu_transform_args(args, mode): assert False -def generate(events, backend): +def generate(events, backend, group): events = [e for e in events if "disable" not in e.properties] diff --git a/scripts/tracetool/format/tcg_helper_h.py b/scripts/tracetool/format/tcg_helper_h.py index dc76c15ebc..6b184b641b 100644 --- a/scripts/tracetool/format/tcg_helper_h.py +++ b/scripts/tracetool/format/tcg_helper_h.py @@ -18,7 +18,7 @@ from tracetool.transform import * import tracetool.vcpu -def generate(events, backend): +def generate(events, backend, group): events = [e for e in events if "disable" not in e.properties] diff --git a/scripts/tracetool/format/tcg_helper_wrapper_h.py b/scripts/tracetool/format/tcg_helper_wrapper_h.py index 020f4422a9..ff53447512 100644 --- a/scripts/tracetool/format/tcg_helper_wrapper_h.py +++ b/scripts/tracetool/format/tcg_helper_wrapper_h.py @@ -18,7 +18,7 @@ from tracetool.transform import * import tracetool.vcpu -def generate(events, backend): +def generate(events, backend, group): events = [e for e in events if "disable" not in e.properties] diff --git a/scripts/tracetool/format/ust_events_c.py b/scripts/tracetool/format/ust_events_c.py index 9967c7a82e..cd87d8ab8f 100644 --- a/scripts/tracetool/format/ust_events_c.py +++ b/scripts/tracetool/format/ust_events_c.py @@ -16,7 +16,7 @@ __email__ = "stefanha@redhat.com" from tracetool import out -def generate(events, backend): +def generate(events, backend, group): events = [e for e in events if "disabled" not in e.properties] diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool/format/ust_events_h.py index 3e8a7cdf19..d853155d21 100644 --- a/scripts/tracetool/format/ust_events_h.py +++ b/scripts/tracetool/format/ust_events_h.py @@ -16,7 +16,7 @@ __email__ = "stefanha@redhat.com" from tracetool import out -def generate(events, backend): +def generate(events, backend, group): events = [e for e in events if "disabled" not in e.properties] @@ -28,8 +28,9 @@ def generate(events, backend): '#undef TRACEPOINT_INCLUDE_FILE', '#define TRACEPOINT_INCLUDE_FILE ./generated-ust-provider.h', '', - '#if !defined (TRACE__GENERATED_UST_H) || defined(TRACEPOINT_HEADER_MULTI_READ)', - '#define TRACE__GENERATED_UST_H', + '#if !defined (TRACE_%s_GENERATED_UST_H) || \\' % group.upper(), + ' defined(TRACEPOINT_HEADER_MULTI_READ)', + '#define TRACE_%s_GENERATED_UST_H' % group.upper(), '', '#include "qemu-common.h"', '#include <lttng/tracepoint.h>', @@ -94,7 +95,7 @@ def generate(events, backend): '', name=e.name) - out('#endif /* TRACE__GENERATED_UST_H */', + out('#endif /* TRACE_%s_GENERATED_UST_H */' % group.upper(), '', '/* This part must be outside ifdef protection */', '#include <lttng/tracepoint-event.h>') |