linux/include/trace/trace_custom_events.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * This is similar to the trace_events.h file, but is to only
 * create custom trace events to be attached to existing tracepoints.
 * Where as the TRACE_EVENT() macro (from trace_events.h) will create
 * both the trace event and the tracepoint it will attach the event to,
 * TRACE_CUSTOM_EVENT() is to create only a custom version of an existing
 * trace event (created by TRACE_EVENT() or DEFINE_EVENT()), and will
 * be placed in the "custom" system.
 */

#include <linux/trace_events.h>

/* All custom events are placed in the custom group */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM

#ifndef TRACE_SYSTEM_VAR
#define TRACE_SYSTEM_VAR
#endif

/* The init stage creates the system string and enum mappings */

#include "stages/init.h"

#undef TRACE_CUSTOM_EVENT
#define TRACE_CUSTOM_EVENT

/* Stage 1 creates the structure of the recorded event layout */

#include "stages/stage1_struct_define.h"

#undef DECLARE_CUSTOM_EVENT_CLASS
#define DECLARE_CUSTOM_EVENT_CLASS

#undef DEFINE_CUSTOM_EVENT
#define DEFINE_CUSTOM_EVENT

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/* Stage 2 creates the custom class */

#include "stages/stage2_data_offsets.h"

#undef DECLARE_CUSTOM_EVENT_CLASS
#define DECLARE_CUSTOM_EVENT_CLASS

#undef DEFINE_CUSTOM_EVENT
#define DEFINE_CUSTOM_EVENT

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/* Stage 3 create the way to print the custom event */

#include "stages/stage3_trace_output.h"

#undef DECLARE_CUSTOM_EVENT_CLASS
#define DECLARE_CUSTOM_EVENT_CLASS

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/* Stage 4 creates the offset layout for the fields */

#include "stages/stage4_event_fields.h"

#undef DECLARE_CUSTOM_EVENT_CLASS
#define DECLARE_CUSTOM_EVENT_CLASS

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/* Stage 5 creates the helper function for dynamic fields */

#include "stages/stage5_get_offsets.h"

#undef DECLARE_CUSTOM_EVENT_CLASS
#define DECLARE_CUSTOM_EVENT_CLASS

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/* Stage 6 creates the probe function that records the event */

#include "stages/stage6_event_callback.h"

#undef DECLARE_CUSTOM_EVENT_CLASS
#define DECLARE_CUSTOM_EVENT_CLASS
/*
 * The ftrace_test_custom_probe is compiled out, it is only here as a build time check
 * to make sure that if the tracepoint handling changes, the ftrace probe will
 * fail to compile unless it too is updated.
 */

#undef DEFINE_CUSTOM_EVENT
#define DEFINE_CUSTOM_EVENT

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/* Stage 7 creates the actual class and event structure for the custom event */

#include "stages/stage7_class_define.h"

#undef DECLARE_CUSTOM_EVENT_CLASS
#define DECLARE_CUSTOM_EVENT_CLASS

#undef DEFINE_CUSTOM_EVENT
#define DEFINE_CUSTOM_EVENT

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)