aboutsummaryrefslogtreecommitdiff
path: root/scripts/tracetool
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/tracetool')
-rw-r--r--scripts/tracetool/__init__.py41
-rw-r--r--scripts/tracetool/format/tcg_h.py83
-rw-r--r--scripts/tracetool/format/tcg_helper_c.py79
-rw-r--r--scripts/tracetool/format/tcg_helper_h.py48
-rw-r--r--scripts/tracetool/format/tcg_helper_wrapper_h.py70
-rw-r--r--scripts/tracetool/vcpu.py14
6 files changed, 4 insertions, 331 deletions
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 5bc94d95cf..5393c7fc5c 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -87,8 +87,6 @@ ALLOWED_TYPES = [
"ssize_t",
"uintptr_t",
"ptrdiff_t",
- # Magic substitution is done by tracetool
- "TCGv",
]
def validate_type(name):
@@ -232,7 +230,7 @@ class Event(object):
"(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
"\s*")
- _VALID_PROPS = set(["disable", "tcg", "tcg-trans", "tcg-exec", "vcpu"])
+ _VALID_PROPS = set(["disable", "vcpu"])
def __init__(self, name, props, fmt, args, lineno, filename, orig=None,
event_trans=None, event_exec=None):
@@ -321,15 +319,6 @@ class Event(object):
fmt = [fmt_trans, fmt]
args = Arguments.build(groups["args"])
- if "tcg-trans" in props:
- raise ValueError("Invalid property 'tcg-trans'")
- if "tcg-exec" in props:
- raise ValueError("Invalid property 'tcg-exec'")
- if "tcg" not in props and not isinstance(fmt, str):
- raise ValueError("Only events with 'tcg' property can have two format strings")
- if "tcg" in props and isinstance(fmt, str):
- raise ValueError("Events with 'tcg' property must have two format strings")
-
event = Event(name, props, fmt, args, lineno, filename)
# add implicit arguments when using the 'vcpu' property
@@ -409,33 +398,7 @@ def read_events(fobj, fname):
e.args = (arg0,) + e.args[1:]
raise
- # transform TCG-enabled events
- if "tcg" not in event.properties:
- events.append(event)
- else:
- event_trans = event.copy()
- event_trans.name += "_trans"
- event_trans.properties += ["tcg-trans"]
- event_trans.fmt = event.fmt[0]
- # ignore TCG arguments
- args_trans = []
- for atrans, aorig in zip(
- event_trans.transform(tracetool.transform.TCG_2_HOST).args,
- event.args):
- if atrans == aorig:
- args_trans.append(atrans)
- event_trans.args = Arguments(args_trans)
-
- event_exec = event.copy()
- event_exec.name += "_exec"
- event_exec.properties += ["tcg-exec"]
- event_exec.fmt = event.fmt[1]
- event_exec.args = event_exec.args.transform(tracetool.transform.TCG_2_HOST)
-
- new_event = [event_trans, event_exec]
- event.event_trans, event.event_exec = new_event
-
- events.extend(new_event)
+ events.append(event)
return events
diff --git a/scripts/tracetool/format/tcg_h.py b/scripts/tracetool/format/tcg_h.py
deleted file mode 100644
index 4d84440aff..0000000000
--- a/scripts/tracetool/format/tcg_h.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-Generate .h file for TCG code generation.
-"""
-
-__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
-__license__ = "GPL version 2 or (at your option) any later version"
-
-__maintainer__ = "Stefan Hajnoczi"
-__email__ = "stefanha@redhat.com"
-
-
-from tracetool import out, Arguments
-import tracetool.vcpu
-
-
-def vcpu_transform_args(args):
- assert len(args) == 1
- return Arguments([
- args,
- # NOTE: this name must be kept in sync with the one in "tcg_h"
- # NOTE: Current helper code uses TCGv_env (CPUArchState*)
- ("TCGv_env", "__tcg_" + args.names()[0]),
- ])
-
-
-def generate(events, backend, group):
- if group == "root":
- header = "trace/trace-root.h"
- else:
- header = "trace.h"
-
- out('/* This file is autogenerated by tracetool, do not edit. */',
- '/* You must include this file after the inclusion of helper.h */',
- '',
- '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
- '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
- '',
- '#include "exec/helper-proto.h"',
- '#include "%s"' % header,
- '',
- )
-
- for e in events:
- # just keep one of them
- if "tcg-exec" not in e.properties:
- continue
-
- out('static inline void %(name_tcg)s(%(args)s)',
- '{',
- name_tcg=e.original.api(e.QEMU_TRACE_TCG),
- args=tracetool.vcpu.transform_args("tcg_h", e.original))
-
- if "disable" not in e.properties:
- args_trans = e.original.event_trans.args
- args_exec = tracetool.vcpu.transform_args(
- "tcg_helper_c", e.original.event_exec, "wrapper")
- if "vcpu" in e.properties:
- trace_cpu = e.args.names()[0]
- cond = "trace_event_get_vcpu_state(%(cpu)s,"\
- " TRACE_%(id)s)"\
- % dict(
- cpu=trace_cpu,
- id=e.original.event_exec.name.upper())
- else:
- cond = "true"
-
- out(' %(name_trans)s(%(argnames_trans)s);',
- ' if (%(cond)s) {',
- ' gen_helper_%(name_exec)s(%(argnames_exec)s);',
- ' }',
- name_trans=e.original.event_trans.api(e.QEMU_TRACE),
- name_exec=e.original.event_exec.api(e.QEMU_TRACE),
- argnames_trans=", ".join(args_trans.names()),
- argnames_exec=", ".join(args_exec.names()),
- cond=cond)
-
- out('}')
-
- out('',
- '#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
deleted file mode 100644
index 72576e67d1..0000000000
--- a/scripts/tracetool/format/tcg_helper_c.py
+++ /dev/null
@@ -1,79 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-Generate trace/generated-helpers.c.
-"""
-
-__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
-__license__ = "GPL version 2 or (at your option) any later version"
-
-__maintainer__ = "Stefan Hajnoczi"
-__email__ = "stefanha@redhat.com"
-
-
-from tracetool import Arguments, out
-from tracetool.transform import *
-import tracetool.vcpu
-
-
-def vcpu_transform_args(args, mode):
- assert len(args) == 1
- # NOTE: this name must be kept in sync with the one in "tcg_h"
- args = Arguments([(args.types()[0], "__tcg_" + args.names()[0])])
- if mode == "code":
- return Arguments([
- # Does cast from helper requirements to tracing types
- ("CPUState *", "env_cpu(%s)" % args.names()[0]),
- ])
- else:
- args = Arguments([
- # NOTE: Current helper code uses TCGv_env (CPUArchState*)
- ("CPUArchState *", args.names()[0]),
- ])
- if mode == "header":
- return args
- elif mode == "wrapper":
- return args.transform(HOST_2_TCG)
- else:
- assert False
-
-
-def generate(events, backend, group):
- if group == "root":
- header = "trace/trace-root.h"
- else:
- header = "trace.h"
-
- events = [e for e in events
- if "disable" not in e.properties]
-
- out('/* This file is autogenerated by tracetool, do not edit. */',
- '',
- '#include "qemu/osdep.h"',
- '#include "cpu.h"',
- '#include "exec/helper-proto.h"',
- '#include "%s"' % header,
- '',
- )
-
- for e in events:
- if "tcg-exec" not in e.properties:
- continue
-
- e_args_api = tracetool.vcpu.transform_args(
- "tcg_helper_c", e.original, "header").transform(
- HOST_2_TCG_COMPAT, TCG_2_TCG_HELPER_DEF)
- e_args_call = tracetool.vcpu.transform_args(
- "tcg_helper_c", e, "code")
-
- out('void %(name_tcg)s(%(args_api)s)',
- '{',
- # NOTE: the check was already performed at TCG-generation time
- ' %(name)s(%(args_call)s);',
- '}',
- name_tcg="helper_%s_proxy" % e.api(),
- name=e.api(e.QEMU_TRACE_NOCHECK),
- args_api=e_args_api,
- args_call=", ".join(e_args_call.casted()),
- )
diff --git a/scripts/tracetool/format/tcg_helper_h.py b/scripts/tracetool/format/tcg_helper_h.py
deleted file mode 100644
index 08554fbc85..0000000000
--- a/scripts/tracetool/format/tcg_helper_h.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-Generate trace/generated-helpers.h.
-"""
-
-__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
-__license__ = "GPL version 2 or (at your option) any later version"
-
-__maintainer__ = "Stefan Hajnoczi"
-__email__ = "stefanha@redhat.com"
-
-
-from tracetool import out
-from tracetool.transform import *
-import tracetool.vcpu
-
-
-def generate(events, backend, group):
- events = [e for e in events
- if "disable" not in e.properties]
-
- out('/* This file is autogenerated by tracetool, do not edit. */',
- '',
- )
-
- for e in events:
- if "tcg-exec" not in e.properties:
- continue
-
- # TCG helper proxy declaration
- fmt = "DEF_HELPER_FLAGS_%(argc)d(%(name)s, %(flags)svoid%(types)s)"
- e_args = tracetool.vcpu.transform_args("tcg_helper_c", e.original, "header")
- args = e_args.transform(HOST_2_TCG_COMPAT, HOST_2_TCG,
- TCG_2_TCG_HELPER_DECL)
- types = ", ".join(args.types())
- if types != "":
- types = ", " + types
-
- flags = "TCG_CALL_NO_RWG, "
-
- out(fmt,
- flags=flags,
- argc=len(args),
- name=e.api() + "_proxy",
- types=types,
- )
diff --git a/scripts/tracetool/format/tcg_helper_wrapper_h.py b/scripts/tracetool/format/tcg_helper_wrapper_h.py
deleted file mode 100644
index 0c5a9797d1..0000000000
--- a/scripts/tracetool/format/tcg_helper_wrapper_h.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-Generate trace/generated-helpers-wrappers.h.
-"""
-
-__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
-__license__ = "GPL version 2 or (at your option) any later version"
-
-__maintainer__ = "Stefan Hajnoczi"
-__email__ = "stefanha@redhat.com"
-
-
-from tracetool import out
-from tracetool.transform import *
-import tracetool.vcpu
-
-
-def generate(events, backend, group):
- events = [e for e in events
- if "disable" not in e.properties]
-
- out('/* This file is autogenerated by tracetool, do not edit. */',
- '',
- '#define tcg_temp_new_nop(v) (v)',
- '#define tcg_temp_free_nop(v)',
- '',
- )
-
- for e in events:
- if "tcg-exec" not in e.properties:
- continue
-
- # tracetool.generate always transforms types to host
- e_args = tracetool.vcpu.transform_args("tcg_helper_c", e.original, "wrapper")
-
- # mixed-type to TCG helper bridge
- args_tcg_compat = e_args.transform(HOST_2_TCG_COMPAT)
-
- code_new = [
- "%(tcg_type)s __%(name)s = %(tcg_func)s(%(name)s);" %
- {"tcg_type": transform_type(type_, HOST_2_TCG),
- "tcg_func": transform_type(type_, HOST_2_TCG_TMP_NEW),
- "name": name}
- for (type_, name) in args_tcg_compat
- ]
-
- code_free = [
- "%(tcg_func)s(__%(name)s);" %
- {"tcg_func": transform_type(type_, HOST_2_TCG_TMP_FREE),
- "name": name}
- for (type_, name) in args_tcg_compat
- ]
-
- gen_name = "gen_helper_" + e.api()
-
- out('static inline void %(name)s(%(args)s)',
- '{',
- ' %(code_new)s',
- ' %(proxy_name)s(%(tmp_names)s);',
- ' %(code_free)s',
- '}',
- name=gen_name,
- args=e_args,
- proxy_name=gen_name + "_proxy",
- code_new="\n ".join(code_new),
- code_free="\n ".join(code_free),
- tmp_names=", ".join(["__%s" % name for _, name in e_args]),
- )
diff --git a/scripts/tracetool/vcpu.py b/scripts/tracetool/vcpu.py
index 868b4cb04c..d232cb1d06 100644
--- a/scripts/tracetool/vcpu.py
+++ b/scripts/tracetool/vcpu.py
@@ -19,19 +19,9 @@ from tracetool import Arguments, try_import
def transform_event(event):
"""Transform event to comply with the 'vcpu' property (if present)."""
if "vcpu" in event.properties:
- # events with 'tcg-trans' and 'tcg-exec' are auto-generated from
- # already-patched events
- assert "tcg-trans" not in event.properties
- assert "tcg-exec" not in event.properties
-
event.args = Arguments([("void *", "__cpu"), event.args])
- if "tcg" in event.properties:
- fmt = "\"cpu=%p \""
- event.fmt = [fmt + event.fmt[0],
- fmt + event.fmt[1]]
- else:
- fmt = "\"cpu=%p \""
- event.fmt = fmt + event.fmt
+ fmt = "\"cpu=%p \""
+ event.fmt = fmt + event.fmt
return event