debug.h revision 131720
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: head/sbin/growfs/debug.h 131720 2004-07-06 17:48:34Z stefanf $ 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 51void dbg_open(const char *); 52void dbg_close(void); 53void dbg_dump_hex(struct fs *, const char *, unsigned char *); 54void dbg_dump_fs(struct fs *, const char *); 55void dbg_dump_cg(const char *, struct cg *); 56void dbg_dump_csum(const char *, struct csum *); 57void dbg_dump_csum_total(const char *, struct csum_total *); 58void dbg_dump_ufs1_ino(struct fs *, const char *, struct ufs1_dinode *); 59void dbg_dump_ufs2_ino(struct fs *, const char *, struct ufs2_dinode *); 60void dbg_dump_iblk(struct fs *, const char *, char *, size_t); 61void dbg_dump_inmap(struct fs *, const char *, struct cg *); 62void dbg_dump_frmap(struct fs *, const char *, struct cg *); 63void dbg_dump_clmap(struct fs *, const char *, struct cg *); 64void dbg_dump_clsum(struct fs *, const char *, struct cg *); 65void dbg_dump_sptbl(struct fs *, const char *, struct cg *); 66 67#define DBG_OPEN(P) dbg_open((P)) 68#define DBG_CLOSE dbg_close() 69#define DBG_DUMP_HEX(F,C,M) dbg_dump_hex((F),(C),(M)) 70#define DBG_DUMP_FS(F,C) dbg_dump_fs((F),(C)) 71#define DBG_DUMP_CG(F,C,M) dbg_dump_cg((C),(M)) 72#define DBG_DUMP_CSUM(F,C,M) dbg_dump_csum((C),(M)) 73#define DBG_DUMP_INO(F,C,M) (F)->fs_magic == FS_UFS1_MAGIC \ 74 ? dbg_dump_ufs1_ino((F),(C),(struct ufs1_dinode *)(M)) \ 75 : dbg_dump_ufs2_ino((F),(C),(struct ufs2_dinode *)(M)) 76#define DBG_DUMP_IBLK(F,C,M,L) dbg_dump_iblk((F),(C),(M),(L)) 77#define DBG_DUMP_INMAP(F,C,M) dbg_dump_inmap((F),(C),(M)) 78#define DBG_DUMP_FRMAP(F,C,M) dbg_dump_frmap((F),(C),(M)) 79#define DBG_DUMP_CLMAP(F,C,M) dbg_dump_clmap((F),(C),(M)) 80#define DBG_DUMP_CLSUM(F,C,M) dbg_dump_clsum((F),(C),(M)) 81#ifdef NOT_CURRENTLY 82#define DBG_DUMP_SPTBL(F,C,M) dbg_dump_sptbl((F),(C),(M)) 83#endif 84 85#define DL_TRC 0x01 86#define DL_INFO 0x02 87extern int _dbg_lvl_; 88 89#define DBG_FUNC(N) char __FKT__[] = {N}; 90#define DBG_ENTER if(_dbg_lvl_ & DL_TRC) { \ 91 fprintf(stderr, "~>%s: %s\n", __FILE__, __FKT__ ); \ 92 } 93#define DBG_LEAVE if(_dbg_lvl_ & DL_TRC) { \ 94 fprintf(stderr, "~<%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \ 95 } 96#define DBG_TRC if(_dbg_lvl_ & DL_TRC) { \ 97 fprintf(stderr, "~=%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \ 98 } 99#define DBG_PRINT0(A) if(_dbg_lvl_ & DL_INFO) { \ 100 fprintf(stderr, "~ %s", (A)); \ 101 } 102#define DBG_PRINT1(A,B) if(_dbg_lvl_ & DL_INFO) { \ 103 fprintf(stderr, "~ "); \ 104 fprintf(stderr, (A), (B)); \ 105 } 106#define DBG_PRINT2(A,B,C) if(_dbg_lvl_ & DL_INFO) { \ 107 fprintf(stderr, "~ "); \ 108 fprintf(stderr, (A), (B), (C)); \ 109 } 110#define DBG_PRINT3(A,B,C,D) if(_dbg_lvl_ & DL_INFO) { \ 111 fprintf(stderr, "~ "); \ 112 fprintf(stderr, (A), (B), (C), (D)); \ 113 } 114#define DBG_PRINT4(A,B,C,D,E) if(_dbg_lvl_ & DL_INFO) { \ 115 fprintf(stderr, "~ "); \ 116 fprintf(stderr, (A), (B), (C), (D), (E)); \ 117 } 118#else /* not FS_DEBUG */ 119 120#define DBG_OPEN(P) 121#define DBG_CLOSE 122#define DBG_DUMP_HEX(F,C,M) 123#define DBG_DUMP_FS(F,C) 124#define DBG_DUMP_CG(F,C,M) 125#define DBG_DUMP_CSUM(F,C,M) 126#define DBG_DUMP_INO(F,C,M) 127#define DBG_DUMP_IBLK(F,C,M,L) 128#define DBG_DUMP_INMAP(F,C,M) 129#define DBG_DUMP_FRMAP(F,C,M) 130#define DBG_DUMP_CLMAP(F,C,M) 131#define DBG_DUMP_CLSUM(F,C,M) 132#define DBG_DUMP_SPTBL(F,C,M) 133#define DBG_FUNC(N) 134#define DBG_ENTER 135#define DBG_TRC 136#define DBG_LEAVE 137#define DBG_PRINT0(A) 138#define DBG_PRINT1(A,B) 139#define DBG_PRINT2(A,B,C) 140#define DBG_PRINT3(A,B,C,D) 141#define DBG_PRINT4(A,B,C,D,E) 142 143#endif /* FS_DEBUG */ 144