MFC: Fix a panic on boot that can occur if you hit keys on the keyboard
[dragonfly.git] / sbin / growfs / debug.h
blobd39be3e9c2079f85e7a21ea84eab66b82136cec3
1 /*
2 * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
3 * Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgment:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors, as well as Christoph
21 * Herrmann and Thomas-Henning von Kamptz.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
38 * $TSHeader: src/sbin/growfs/debug.h,v 1.2 2000/11/16 18:43:50 tom Exp $
39 * $FreeBSD: src/sbin/growfs/debug.h,v 1.1.2.1 2001/07/16 15:02:13 tomsoft Exp $
40 * $DragonFly: src/sbin/growfs/debug.h,v 1.4 2006/04/03 01:58:49 dillon Exp $
44 #ifdef FS_DEBUG
46 /* ********************************************************** INCLUDES ***** */
47 #include <sys/param.h>
49 #include <vfs/ufs/dinode.h>
50 #include <vfs/ufs/fs.h>
52 void dbg_open(const char *);
53 void dbg_close(void);
54 void dbg_dump_hex(struct fs *, const char *, unsigned char *);
55 void dbg_dump_fs(struct fs *, const char *);
56 void dbg_dump_cg(const char *, struct cg *);
57 void dbg_dump_csum(const char *, struct csum *);
58 void dbg_dump_ino(struct fs *, const char *, struct ufs1_dinode *);
59 void dbg_dump_iblk(struct fs *, const char *, char *, size_t);
60 void dbg_dump_inmap(struct fs *, const char *, struct cg *);
61 void dbg_dump_frmap(struct fs *, const char *, struct cg *);
62 void dbg_dump_clmap(struct fs *, const char *, struct cg *);
63 void dbg_dump_clsum(struct fs *, const char *, struct cg *);
64 void dbg_dump_sptbl(struct fs *, const char *, struct cg *);
66 #define DBG_OPEN(P) dbg_open((P))
67 #define DBG_CLOSE dbg_close()
68 #define DBG_DUMP_HEX(F,C,M) dbg_dump_hex((F),(C),(M))
69 #define DBG_DUMP_FS(F,C) dbg_dump_fs((F),(C))
70 #define DBG_DUMP_CG(F,C,M) dbg_dump_cg((C),(M))
71 #define DBG_DUMP_CSUM(F,C,M) dbg_dump_csum((C),(M))
72 #define DBG_DUMP_INO(F,C,M) dbg_dump_ino((F),(C),(M))
73 #define DBG_DUMP_IBLK(F,C,M,L) dbg_dump_iblk((F),(C),(M),(L))
74 #define DBG_DUMP_INMAP(F,C,M) dbg_dump_inmap((F),(C),(M))
75 #define DBG_DUMP_FRMAP(F,C,M) dbg_dump_frmap((F),(C),(M))
76 #define DBG_DUMP_CLMAP(F,C,M) dbg_dump_clmap((F),(C),(M))
77 #define DBG_DUMP_CLSUM(F,C,M) dbg_dump_clsum((F),(C),(M))
78 #define DBG_DUMP_SPTBL(F,C,M) dbg_dump_sptbl((F),(C),(M))
80 #define DL_TRC 0x01
81 #define DL_INFO 0x02
82 extern int _dbg_lvl_;
84 #define DBG_FUNC(N) char __FKT__[] = (N);
85 #define DBG_ENTER if(_dbg_lvl_ & DL_TRC) { \
86 fprintf(stderr, "~>%s: %s\n", __FILE__, __FKT__ ); \
88 #define DBG_LEAVE if(_dbg_lvl_ & DL_TRC) { \
89 fprintf(stderr, "~<%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \
91 #define DBG_TRC if(_dbg_lvl_ & DL_TRC) { \
92 fprintf(stderr, "~=%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \
94 #define DBG_PRINT0(A) if(_dbg_lvl_ & DL_INFO) { \
95 fprintf(stderr, "~ %s", (A)); \
97 #define DBG_PRINT1(A,B) if(_dbg_lvl_ & DL_INFO) { \
98 fprintf(stderr, "~ "); \
99 fprintf(stderr, (A), (B)); \
101 #define DBG_PRINT2(A,B,C) if(_dbg_lvl_ & DL_INFO) { \
102 fprintf(stderr, "~ "); \
103 fprintf(stderr, (A), (B), (C)); \
105 #define DBG_PRINT3(A,B,C,D) if(_dbg_lvl_ & DL_INFO) { \
106 fprintf(stderr, "~ "); \
107 fprintf(stderr, (A), (B), (C), (D)); \
109 #define DBG_PRINT4(A,B,C,D,E) if(_dbg_lvl_ & DL_INFO) { \
110 fprintf(stderr, "~ "); \
111 fprintf(stderr, (A), (B), (C), (D), (E)); \
113 #else /* not FS_DEBUG */
115 #define DBG_OPEN(P)
116 #define DBG_CLOSE
117 #define DBG_DUMP_HEX(F,C,M)
118 #define DBG_DUMP_FS(F,C)
119 #define DBG_DUMP_CG(F,C,M)
120 #define DBG_DUMP_CSUM(F,C,M)
121 #define DBG_DUMP_INO(F,C,M)
122 #define DBG_DUMP_IBLK(F,C,M,L)
123 #define DBG_DUMP_INMAP(F,C,M)
124 #define DBG_DUMP_FRMAP(F,C,M)
125 #define DBG_DUMP_CLMAP(F,C,M)
126 #define DBG_DUMP_CLSUM(F,C,M)
127 #define DBG_DUMP_SPTBL(F,C,M)
128 #define DBG_FUNC(N)
129 #define DBG_ENTER
130 #define DBG_TRC
131 #define DBG_LEAVE
132 #define DBG_PRINT0(A)
133 #define DBG_PRINT1(A,B)
134 #define DBG_PRINT2(A,B,C)
135 #define DBG_PRINT3(A,B,C,D)
136 #define DBG_PRINT4(A,B,C,D,E)
138 #endif /* FS_DEBUG */