xref: /freebsd-src/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_dbgmsg.h (revision 7a7741af18d6c8a804cc643cb7ecda9d730c6aa6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or https://opensource.org/licenses/CDDL-1.0.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 #if defined(_KERNEL)
23 #if defined(HAVE_DECLARE_EVENT_CLASS)
24 
25 #undef TRACE_SYSTEM
26 #define	TRACE_SYSTEM zfs
27 
28 #undef TRACE_SYSTEM_VAR
29 #define	TRACE_SYSTEM_VAR zfs_dbgmsg
30 
31 #if !defined(_TRACE_DBGMSG_H) || defined(TRACE_HEADER_MULTI_READ)
32 #define	_TRACE_DBGMSG_H
33 
34 #include <linux/tracepoint.h>
35 #include <sys/types.h>
36 
37 /*
38  * This file defines tracepoint events for use by the dbgmsg(),
39  * dprintf(), and SET_ERROR() interfaces. These are grouped here because
40  * they all provide a way to store simple messages in the debug log (as
41  * opposed to events used by the DTRACE_PROBE interfaces which typically
42  * dump structured data).
43  *
44  * This header is included inside the trace.h multiple inclusion guard,
45  * and it is guarded above against direct inclusion, so it and need not
46  * be guarded separately.
47  */
48 
49 /*
50  * Generic support for one argument tracepoints of the form:
51  *
52  * DTRACE_PROBE1(...,
53  *     const char *, ...);
54  */
55 /* BEGIN CSTYLED */
56 DECLARE_EVENT_CLASS(zfs_dprintf_class,
57 	TP_PROTO(const char *msg),
58 	TP_ARGS(msg),
59 	TP_STRUCT__entry(
60 	    __string(msg, msg)
61 	),
62 	TP_fast_assign(
63 	    __assign_str_impl(msg, msg);
64 	),
65 	TP_printk("%s", __get_str(msg))
66 );
67 /* END CSTYLED */
68 
69 #define	DEFINE_DPRINTF_EVENT(name) \
70 DEFINE_EVENT(zfs_dprintf_class, name, \
71     TP_PROTO(const char *msg), \
72     TP_ARGS(msg))
73 DEFINE_DPRINTF_EVENT(zfs_zfs__dprintf);
74 
75 #endif /* _TRACE_DBGMSG_H */
76 
77 #undef TRACE_INCLUDE_PATH
78 #undef TRACE_INCLUDE_FILE
79 #define	TRACE_INCLUDE_PATH sys
80 #define	TRACE_INCLUDE_FILE trace_dbgmsg
81 #include <trace/define_trace.h>
82 
83 #else
84 
85 DEFINE_DTRACE_PROBE1(zfs__dprintf);
86 
87 #endif /* HAVE_DECLARE_EVENT_CLASS */
88 #endif /* _KERNEL */
89