trace: [tcg] Define TCG tracing helper routines
Generates file "trace/generated-helpers.c" with TCG helper definitions to trace
events in guest code at execution time.
The helpers ('helper_trace_${event}_exec_proxy') cast the TCG-compatible native
argument types to their original types (as defined in "trace-events") and call
the tracing routine ('trace_${event}_exec').
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
			
			
This commit is contained in:
		
							parent
							
								
									707c8a98e4
								
							
						
					
					
						commit
						341ea69185
					
				| 
						 | 
				
			
			@ -12,6 +12,7 @@
 | 
			
		|||
/trace/generated-events.h
 | 
			
		||||
/trace/generated-events.c
 | 
			
		||||
/trace/generated-helpers.h
 | 
			
		||||
/trace/generated-helpers.c
 | 
			
		||||
/trace/generated-ust-provider.h
 | 
			
		||||
/trace/generated-ust.c
 | 
			
		||||
/libcacard/trace/generated-tracers.c
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										1
									
								
								Makefile
								
								
								
								
							| 
						 | 
				
			
			@ -58,6 +58,7 @@ endif
 | 
			
		|||
GENERATED_SOURCES += trace/generated-tracers.c
 | 
			
		||||
 | 
			
		||||
GENERATED_HEADERS += trace/generated-helpers.h
 | 
			
		||||
GENERATED_SOURCES += trace/generated-helpers.c
 | 
			
		||||
 | 
			
		||||
ifeq ($(findstring ust,$(TRACE_BACKENDS)),ust)
 | 
			
		||||
GENERATED_HEADERS += trace/generated-ust-provider.h
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
#######################################################################
 | 
			
		||||
# Common libraries for tools and emulators
 | 
			
		||||
stub-obj-y = stubs/
 | 
			
		||||
util-obj-y = util/ qobject/ qapi/ trace/
 | 
			
		||||
util-obj-y = util/ qobject/ qapi/
 | 
			
		||||
 | 
			
		||||
#######################################################################
 | 
			
		||||
# block-obj-y is code used by both qemu system emulation and qemu-img
 | 
			
		||||
| 
						 | 
				
			
			@ -106,6 +106,11 @@ common-obj-y += disas/
 | 
			
		|||
version-obj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.o
 | 
			
		||||
version-lobj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.lo
 | 
			
		||||
 | 
			
		||||
######################################################################
 | 
			
		||||
# tracing
 | 
			
		||||
util-obj-y +=  trace/
 | 
			
		||||
target-obj-y += trace/
 | 
			
		||||
 | 
			
		||||
######################################################################
 | 
			
		||||
# guest agent
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -159,15 +159,20 @@ endif # CONFIG_SOFTMMU
 | 
			
		|||
dummy := $(call unnest-vars,,obj-y)
 | 
			
		||||
all-obj-y := $(obj-y)
 | 
			
		||||
 | 
			
		||||
target-obj-y :=
 | 
			
		||||
block-obj-y :=
 | 
			
		||||
common-obj-y :=
 | 
			
		||||
include $(SRC_PATH)/Makefile.objs
 | 
			
		||||
dummy := $(call unnest-vars,,target-obj-y)
 | 
			
		||||
target-obj-y-save := $(target-obj-y)
 | 
			
		||||
dummy := $(call unnest-vars,.., \
 | 
			
		||||
               block-obj-y \
 | 
			
		||||
               block-obj-m \
 | 
			
		||||
               common-obj-y \
 | 
			
		||||
               common-obj-m)
 | 
			
		||||
target-obj-y := $(target-obj-y-save)
 | 
			
		||||
all-obj-y += $(common-obj-y)
 | 
			
		||||
all-obj-y += $(target-obj-y)
 | 
			
		||||
all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
 | 
			
		||||
 | 
			
		||||
# build either PROG or PROGW
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,50 @@
 | 
			
		|||
#!/usr/bin/env python
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
Generate trace/generated-helpers.c.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
__author__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
 | 
			
		||||
__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
 | 
			
		||||
__license__    = "GPL version 2 or (at your option) any later version"
 | 
			
		||||
 | 
			
		||||
__maintainer__ = "Stefan Hajnoczi"
 | 
			
		||||
__email__      = "stefanha@linux.vnet.ibm.com"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from tracetool import out
 | 
			
		||||
from tracetool.transform import *
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def generate(events, backend):
 | 
			
		||||
    events = [e for e in events
 | 
			
		||||
              if "disable" not in e.properties]
 | 
			
		||||
 | 
			
		||||
    out('/* This file is autogenerated by tracetool, do not edit. */',
 | 
			
		||||
        '',
 | 
			
		||||
        '#include "qemu-common.h"',
 | 
			
		||||
        '#include "trace.h"',
 | 
			
		||||
        '#include "exec/helper-proto.h"',
 | 
			
		||||
        '',
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    for e in events:
 | 
			
		||||
        if "tcg-exec" not in e.properties:
 | 
			
		||||
            continue
 | 
			
		||||
 | 
			
		||||
        # tracetool.generate always transforms types to host
 | 
			
		||||
        e_args = e.original.args
 | 
			
		||||
 | 
			
		||||
        values = ["(%s)%s" % (t, n)
 | 
			
		||||
                  for t, n in e.args.transform(TCG_2_TCG_HELPER_DEF)]
 | 
			
		||||
 | 
			
		||||
        out('void %(name_tcg)s(%(args)s)',
 | 
			
		||||
            '{',
 | 
			
		||||
            '    %(name)s(%(values)s);',
 | 
			
		||||
            '}',
 | 
			
		||||
            name_tcg="helper_%s_proxy" % e.api(),
 | 
			
		||||
            name=e.api(),
 | 
			
		||||
            args=e_args.transform(HOST_2_TCG_COMPAT, TCG_2_TCG_HELPER_DEF),
 | 
			
		||||
            values=", ".join(values),
 | 
			
		||||
            )
 | 
			
		||||
| 
						 | 
				
			
			@ -107,6 +107,18 @@ $(obj)/generated-helpers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf
 | 
			
		|||
		< $< > $@,"  GEN   $(patsubst %-timestamp,%,$@)")
 | 
			
		||||
	@cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@)
 | 
			
		||||
 | 
			
		||||
$(obj)/generated-helpers.c: $(obj)/generated-helpers.c-timestamp
 | 
			
		||||
$(obj)/generated-helpers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak
 | 
			
		||||
	$(call quiet-command,$(TRACETOOL) \
 | 
			
		||||
		--format=tcg-helper-c \
 | 
			
		||||
		--backend=$(TRACE_BACKENDS) \
 | 
			
		||||
		< $< > $@,"  GEN   $(patsubst %-timestamp,%,$@)")
 | 
			
		||||
	@cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@)
 | 
			
		||||
 | 
			
		||||
$(obj)/generated-helpers.o: $(obj)/generated-helpers.c
 | 
			
		||||
 | 
			
		||||
target-obj-y += generated-helpers.o
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
######################################################################
 | 
			
		||||
# Backend code
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue