xref: /qemu/trace-events (revision 1e2cf2bc455622f9e0903a360cdaf6b89ec949a2)
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#
15*1e2cf2bcSStefan Hajnoczi# [disable] <name>(<type1> <arg1>[, <type2> <arg2>] ...) "<format-string>"
1694a420b1SStefan Hajnoczi#
1794a420b1SStefan Hajnoczi# Example: qemu_malloc(size_t size) "size %zu"
1894a420b1SStefan Hajnoczi#
19*1e2cf2bcSStefan Hajnoczi# The "disable" keyword will build without the trace event.
20*1e2cf2bcSStefan Hajnoczi# In case of 'simple' trace backend, it will allow the trace event to be
21*1e2cf2bcSStefan Hajnoczi# compiled, but this would be turned off by default. It can be toggled on via
22*1e2cf2bcSStefan Hajnoczi# the monitor.
23*1e2cf2bcSStefan 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