def transform_args(format, event, *args, **kwargs): """Transforms the arguments to suit the specified format. The format module must implement function 'vcpu_args', which receives the implicit arguments added by the 'vcpu' property, and must return suitable arguments for the given format. The function is only called for events with the 'vcpu' property. Parameters ========== format : str Format module name. event : Event args, kwargs Passed to 'vcpu_transform_args'. Returns ======= Arguments The transformed arguments, including the non-implicit ones. """ if "vcpu" in event.properties: ok, func = try_import("tracetool.format." + format, "vcpu_transform_args") assert ok assert func return Arguments( [func(event.args[:1], *args, **kwargs), event.args[1:]]) else: return event.args
def transform_event(event): """Transform event to comply with the 'vcpu' property (if present).""" if "vcpu" in event.properties: event.args = Arguments([("void *", "__cpu"), event.args]) fmt = "\"cpu=%p \"" event.fmt = fmt + event.fmt return event
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 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_GET_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 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([("CPUState *", "__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 return event