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. 25 * 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. 37 * 38 * $TSHeader: src/sbin/growfs/debug.h,v 1.2 2000/11/16 18:43:50 tom Exp $ 39 * $FreeBSD$ 40 * 41 */ 42 43 #ifdef FS_DEBUG 44 45 /* ********************************************************** INCLUDES ***** */ 46 #include <sys/param.h> 47 48 #include <ufs/ufs/dinode.h> 49 #include <ufs/ffs/fs.h> 50 51 void dbg_open(const char *); 52 void dbg_close(void); 53 void dbg_dump_hex(struct fs *, const char *, unsigned char *); 54 void dbg_dump_fs(struct fs *, const char *); 55 void dbg_dump_cg(const char *, struct cg *); 56 void dbg_dump_csum(const char *, struct csum *); 57 void dbg_dump_ino(struct fs *, const char *, struct dinode *); 58 void dbg_dump_iblk(struct fs *, const char *, char *, size_t); 59 void dbg_dump_inmap(struct fs *, const char *, struct cg *); 60 void dbg_dump_frmap(struct fs *, const char *, struct cg *); 61 void dbg_dump_clmap(struct fs *, const char *, struct cg *); 62 void dbg_dump_clsum(struct fs *, const char *, struct cg *); 63 void dbg_dump_sptbl(struct fs *, const char *, struct cg *); 64 65 #define DBG_OPEN(P) dbg_open((P)) 66 #define DBG_CLOSE dbg_close() 67 #define DBG_DUMP_HEX(F,C,M) dbg_dump_hex((F),(C),(M)) 68 #define DBG_DUMP_FS(F,C) dbg_dump_fs((F),(C)) 69 #define DBG_DUMP_CG(F,C,M) dbg_dump_cg((C),(M)) 70 #define DBG_DUMP_CSUM(F,C,M) dbg_dump_csum((C),(M)) 71 #define DBG_DUMP_INO(F,C,M) dbg_dump_ino((F),(C),(M)) 72 #define DBG_DUMP_IBLK(F,C,M,L) dbg_dump_iblk((F),(C),(M),(L)) 73 #define DBG_DUMP_INMAP(F,C,M) dbg_dump_inmap((F),(C),(M)) 74 #define DBG_DUMP_FRMAP(F,C,M) dbg_dump_frmap((F),(C),(M)) 75 #define DBG_DUMP_CLMAP(F,C,M) dbg_dump_clmap((F),(C),(M)) 76 #define DBG_DUMP_CLSUM(F,C,M) dbg_dump_clsum((F),(C),(M)) 77 #define DBG_DUMP_SPTBL(F,C,M) dbg_dump_sptbl((F),(C),(M)) 78 79 #define DL_TRC 0x01 80 #define DL_INFO 0x02 81 extern int _dbg_lvl_; 82 83 #define DBG_FUNC(N) char __FKT__[] = (N); 84 #define DBG_ENTER if(_dbg_lvl_ & DL_TRC) { \ 85 fprintf(stderr, "~>%s: %s\n", __FILE__, __FKT__ ); \ 86 } 87 #define DBG_LEAVE if(_dbg_lvl_ & DL_TRC) { \ 88 fprintf(stderr, "~<%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \ 89 } 90 #define DBG_TRC if(_dbg_lvl_ & DL_TRC) { \ 91 fprintf(stderr, "~=%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \ 92 } 93 #define DBG_PRINT0(A) if(_dbg_lvl_ & DL_INFO) { \ 94 fprintf(stderr, "~ %s", (A)); \ 95 } 96 #define DBG_PRINT1(A,B) if(_dbg_lvl_ & DL_INFO) { \ 97 fprintf(stderr, "~ "); \ 98 fprintf(stderr, (A), (B)); \ 99 } 100 #define DBG_PRINT2(A,B,C) if(_dbg_lvl_ & DL_INFO) { \ 101 fprintf(stderr, "~ "); \ 102 fprintf(stderr, (A), (B), (C)); \ 103 } 104 #define DBG_PRINT3(A,B,C,D) if(_dbg_lvl_ & DL_INFO) { \ 105 fprintf(stderr, "~ "); \ 106 fprintf(stderr, (A), (B), (C), (D)); \ 107 } 108 #define DBG_PRINT4(A,B,C,D,E) if(_dbg_lvl_ & DL_INFO) { \ 109 fprintf(stderr, "~ "); \ 110 fprintf(stderr, (A), (B), (C), (D), (E)); \ 111 } 112 #else /* not FS_DEBUG */ 113 114 #define DBG_OPEN(P) 115 #define DBG_CLOSE 116 #define DBG_DUMP_HEX(F,C,M) 117 #define DBG_DUMP_FS(F,C) 118 #define DBG_DUMP_CG(F,C,M) 119 #define DBG_DUMP_CSUM(F,C,M) 120 #define DBG_DUMP_INO(F,C,M) 121 #define DBG_DUMP_IBLK(F,C,M,L) 122 #define DBG_DUMP_INMAP(F,C,M) 123 #define DBG_DUMP_FRMAP(F,C,M) 124 #define DBG_DUMP_CLMAP(F,C,M) 125 #define DBG_DUMP_CLSUM(F,C,M) 126 #define DBG_DUMP_SPTBL(F,C,M) 127 #define DBG_FUNC(N) 128 #define DBG_ENTER 129 #define DBG_TRC 130 #define DBG_LEAVE 131 #define DBG_PRINT0(A) 132 #define DBG_PRINT1(A,B) 133 #define DBG_PRINT2(A,B,C) 134 #define DBG_PRINT3(A,B,C,D) 135 #define DBG_PRINT4(A,B,C,D,E) 136 137 #endif /* FS_DEBUG */ 138