1.如何查看tracepoint
/sys/kernel/debug/tracing/events/
通过perf list tracepoint
查看
2. tracepoint理解
因此tracepoint方式如下:
#undef TRACE_SYSTEM
#define TRACE_SYSTEM xhr_test
#if !defined(_TRACE_TE_TEST_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_TE_TEST_H
#include <linux/tracepoint.h>
TRACE_EVENT(te_test, // 定义函数trace_te_test
TP_PROTO(int num), // 函数接收参数 int 类型
TP_ARGS(num),
TP_STRUCT__entry(
__field(int, output) // 字段名
__field(int, count) // 字段名
),
TP_fast_assign(
__entry->count++;
__entry->output = num; // output 等于传入的参数 num
),
TP_printk("count=%d output=%d",
__entry->count, __entry->output)
);
#endif /* _TRACE_TE_TEST_H */
/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH . //定义路径,找不到你就写绝对路径
#define TRACE_INCLUDE_FILE trace_event //定义文件 trace_event.h
#include <trace/define_trace.h>
因此,只要调用 trace_te_test(int num)
即可
3.快速查找tracepoint
grep -rn TRACE_EVENT(name, ...)