xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_debug.h (revision cd1c8b85eb30b568e9816221430c479ace7a559d)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
56b4acc8bSahrens  * Common Development and Distribution License (the "License").
66b4acc8bSahrens  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
223f9d6ad7SLin Ling  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23*cd1c8b85SMatthew Ahrens  * Copyright (c) 2012 by Delphix. All rights reserved.
24fa9e4066Sahrens  */
25fa9e4066Sahrens 
26fa9e4066Sahrens #ifndef _SYS_ZFS_DEBUG_H
27fa9e4066Sahrens #define	_SYS_ZFS_DEBUG_H
28fa9e4066Sahrens 
29fa9e4066Sahrens #ifdef	__cplusplus
30fa9e4066Sahrens extern "C" {
31fa9e4066Sahrens #endif
32fa9e4066Sahrens 
33fa9e4066Sahrens #ifndef TRUE
34fa9e4066Sahrens #define	TRUE 1
35fa9e4066Sahrens #endif
36fa9e4066Sahrens 
37fa9e4066Sahrens #ifndef FALSE
38fa9e4066Sahrens #define	FALSE 0
39fa9e4066Sahrens #endif
40fa9e4066Sahrens 
41fa9e4066Sahrens /*
42fa9e4066Sahrens  * ZFS debugging
43fa9e4066Sahrens  */
44fa9e4066Sahrens 
45fa9e4066Sahrens #if defined(DEBUG) || !defined(_KERNEL)
46fa9e4066Sahrens #define	ZFS_DEBUG
47fa9e4066Sahrens #endif
48fa9e4066Sahrens 
49fa9e4066Sahrens extern int zfs_flags;
50fa9e4066Sahrens 
51fa9e4066Sahrens #define	ZFS_DEBUG_DPRINTF	0x0001
52fa9e4066Sahrens #define	ZFS_DEBUG_DBUF_VERIFY	0x0002
53fa9e4066Sahrens #define	ZFS_DEBUG_DNODE_VERIFY	0x0004
54fa9e4066Sahrens #define	ZFS_DEBUG_SNAPNAMES	0x0008
556b4acc8bSahrens #define	ZFS_DEBUG_MODIFY	0x0010
56fa9e4066Sahrens 
57fa9e4066Sahrens #ifdef ZFS_DEBUG
58fa9e4066Sahrens extern void __dprintf(const char *file, const char *func,
59fa9e4066Sahrens     int line, const char *fmt, ...);
60fa9e4066Sahrens #define	dprintf(...) \
61fa9e4066Sahrens 	if (zfs_flags & ZFS_DEBUG_DPRINTF) \
62fa9e4066Sahrens 		__dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
63fa9e4066Sahrens #else
64fa9e4066Sahrens #define	dprintf(...) ((void)0)
65fa9e4066Sahrens #endif /* ZFS_DEBUG */
66fa9e4066Sahrens 
670125049cSahrens extern void zfs_panic_recover(const char *fmt, ...);
680125049cSahrens 
693f9d6ad7SLin Ling typedef struct zfs_dbgmsg {
703f9d6ad7SLin Ling 	list_node_t zdm_node;
713f9d6ad7SLin Ling 	time_t zdm_timestamp;
723f9d6ad7SLin Ling 	char zdm_msg[1]; /* variable length allocation */
733f9d6ad7SLin Ling } zfs_dbgmsg_t;
743f9d6ad7SLin Ling 
753f9d6ad7SLin Ling extern void zfs_dbgmsg_init(void);
763f9d6ad7SLin Ling extern void zfs_dbgmsg_fini(void);
773f9d6ad7SLin Ling extern void zfs_dbgmsg(const char *fmt, ...);
783f9d6ad7SLin Ling 
79*cd1c8b85SMatthew Ahrens #ifndef _KERNEL
80*cd1c8b85SMatthew Ahrens extern int dprintf_find_string(const char *string);
81*cd1c8b85SMatthew Ahrens #endif
82*cd1c8b85SMatthew Ahrens 
83fa9e4066Sahrens #ifdef	__cplusplus
84fa9e4066Sahrens }
85fa9e4066Sahrens #endif
86fa9e4066Sahrens 
87fa9e4066Sahrens #endif	/* _SYS_ZFS_DEBUG_H */
88