xref: /qemu/trace-events (revision cd245a19329edfcd968b00d05ad92de7a0e2daa1)
194a420b1SStefan Hajnoczi# Trace events for debugging and performance instrumentation
294a420b1SStefan Hajnoczi#
394a420b1SStefan Hajnoczi# This file is processed by the tracetool script during the build.
494a420b1SStefan Hajnoczi#
594a420b1SStefan Hajnoczi# To add a new trace event:
694a420b1SStefan Hajnoczi#
794a420b1SStefan Hajnoczi# 1. Choose a name for the trace event.  Declare its arguments and format
894a420b1SStefan Hajnoczi#    string.
994a420b1SStefan Hajnoczi#
1094a420b1SStefan Hajnoczi# 2. Call the trace event from code using trace_##name, e.g. multiwrite_cb() ->
1194a420b1SStefan Hajnoczi#    trace_multiwrite_cb().  The source file must #include "trace.h".
1294a420b1SStefan Hajnoczi#
1394a420b1SStefan Hajnoczi# Format of a trace event:
1494a420b1SStefan Hajnoczi#
151e2cf2bcSStefan Hajnoczi# [disable] <name>(<type1> <arg1>[, <type2> <arg2>] ...) "<format-string>"
1694a420b1SStefan Hajnoczi#
1794a420b1SStefan Hajnoczi# Example: qemu_malloc(size_t size) "size %zu"
1894a420b1SStefan Hajnoczi#
191e2cf2bcSStefan Hajnoczi# The "disable" keyword will build without the trace event.
201e2cf2bcSStefan Hajnoczi# In case of 'simple' trace backend, it will allow the trace event to be
211e2cf2bcSStefan Hajnoczi# compiled, but this would be turned off by default. It can be toggled on via
221e2cf2bcSStefan Hajnoczi# the monitor.
231e2cf2bcSStefan Hajnoczi#
2494a420b1SStefan Hajnoczi# The <name> must be a valid as a C function name.
2594a420b1SStefan Hajnoczi#
2694a420b1SStefan Hajnoczi# Types should be standard C types.  Use void * for pointers because the trace
2794a420b1SStefan Hajnoczi# system may not have the necessary headers included.
2894a420b1SStefan Hajnoczi#
2994a420b1SStefan Hajnoczi# The <format-string> should be a sprintf()-compatible format string.
30*cd245a19SStefan Hajnoczi
31*cd245a19SStefan Hajnoczi# qemu-malloc.c
32*cd245a19SStefan Hajnoczidisable qemu_malloc(size_t size, void *ptr) "size %zu ptr %p"
33*cd245a19SStefan Hajnoczidisable qemu_realloc(void *ptr, size_t size, void *newptr) "ptr %p size %zu newptr %p"
34*cd245a19SStefan Hajnoczidisable qemu_free(void *ptr) "ptr %p"
35*cd245a19SStefan Hajnoczi
36*cd245a19SStefan Hajnoczi# osdep.c
37*cd245a19SStefan Hajnoczidisable qemu_memalign(size_t alignment, size_t size, void *ptr) "alignment %zu size %zu ptr %p"
38*cd245a19SStefan Hajnoczidisable qemu_valloc(size_t size, void *ptr) "size %zu ptr %p"
39*cd245a19SStefan Hajnoczidisable qemu_vfree(void *ptr) "ptr %p"
40