debug.h revision 69800
169800Stomsoft/* 269800Stomsoft * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz 369800Stomsoft * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. 469800Stomsoft * All rights reserved. 569800Stomsoft * 669800Stomsoft * This code is derived from software contributed to Berkeley by 769800Stomsoft * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt. 869800Stomsoft * 969800Stomsoft * Redistribution and use in source and binary forms, with or without 1069800Stomsoft * modification, are permitted provided that the following conditions 1169800Stomsoft * are met: 1269800Stomsoft * 1. Redistributions of source code must retain the above copyright 1369800Stomsoft * notice, this list of conditions and the following disclaimer. 1469800Stomsoft * 2. Redistributions in binary form must reproduce the above copyright 1569800Stomsoft * notice, this list of conditions and the following disclaimer in the 1669800Stomsoft * documentation and/or other materials provided with the distribution. 1769800Stomsoft * 3. All advertising materials mentioning features or use of this software 1869800Stomsoft * must display the following acknowledgment: 1969800Stomsoft * This product includes software developed by the University of 2069800Stomsoft * California, Berkeley and its contributors, as well as Christoph 2169800Stomsoft * Herrmann and Thomas-Henning von Kamptz. 2269800Stomsoft * 4. Neither the name of the University nor the names of its contributors 2369800Stomsoft * may be used to endorse or promote products derived from this software 2469800Stomsoft * without specific prior written permission. 2569800Stomsoft * 2669800Stomsoft * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2769800Stomsoft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2869800Stomsoft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2969800Stomsoft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3069800Stomsoft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3169800Stomsoft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3269800Stomsoft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3369800Stomsoft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3469800Stomsoft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3569800Stomsoft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3669800Stomsoft * SUCH DAMAGE. 3769800Stomsoft * 3869800Stomsoft * $TSHeader: src/sbin/growfs/debug.h,v 1.2 2000/11/16 18:43:50 tom Exp $ 3969800Stomsoft * $FreeBSD: head/sbin/growfs/debug.h 69800 2000-12-09 15:27:35Z tomsoft $ 4069800Stomsoft * 4169800Stomsoft */ 4269800Stomsoft 4369800Stomsoft#ifdef FS_DEBUG 4469800Stomsoft 4569800Stomsoft/* ********************************************************** INCLUDES ***** */ 4669800Stomsoft#include <sys/param.h> 4769800Stomsoft 4869800Stomsoft#include <ufs/ufs/dinode.h> 4969800Stomsoft#include <ufs/ffs/fs.h> 5069800Stomsoft 5169800Stomsoftvoid dbg_open(const char *); 5269800Stomsoftvoid dbg_close(void); 5369800Stomsoftvoid dbg_dump_hex(struct fs *, const char *, unsigned char *); 5469800Stomsoftvoid dbg_dump_fs(struct fs *, const char *); 5569800Stomsoftvoid dbg_dump_cg(const char *, struct cg *); 5669800Stomsoftvoid dbg_dump_csum(const char *, struct csum *); 5769800Stomsoftvoid dbg_dump_ino(struct fs *, const char *, struct dinode *); 5869800Stomsoftvoid dbg_dump_iblk(struct fs *, const char *, char *, size_t); 5969800Stomsoftvoid dbg_dump_inmap(struct fs *, const char *, struct cg *); 6069800Stomsoftvoid dbg_dump_frmap(struct fs *, const char *, struct cg *); 6169800Stomsoftvoid dbg_dump_clmap(struct fs *, const char *, struct cg *); 6269800Stomsoftvoid dbg_dump_clsum(struct fs *, const char *, struct cg *); 6369800Stomsoftvoid dbg_dump_sptbl(struct fs *, const char *, struct cg *); 6469800Stomsoft 6569800Stomsoft#define DBG_OPEN(P) dbg_open((P)) 6669800Stomsoft#define DBG_CLOSE dbg_close() 6769800Stomsoft#define DBG_DUMP_HEX(F,C,M) dbg_dump_hex((F),(C),(M)) 6869800Stomsoft#define DBG_DUMP_FS(F,C) dbg_dump_fs((F),(C)) 6969800Stomsoft#define DBG_DUMP_CG(F,C,M) dbg_dump_cg((C),(M)) 7069800Stomsoft#define DBG_DUMP_CSUM(F,C,M) dbg_dump_csum((C),(M)) 7169800Stomsoft#define DBG_DUMP_INO(F,C,M) dbg_dump_ino((F),(C),(M)) 7269800Stomsoft#define DBG_DUMP_IBLK(F,C,M,L) dbg_dump_iblk((F),(C),(M),(L)) 7369800Stomsoft#define DBG_DUMP_INMAP(F,C,M) dbg_dump_inmap((F),(C),(M)) 7469800Stomsoft#define DBG_DUMP_FRMAP(F,C,M) dbg_dump_frmap((F),(C),(M)) 7569800Stomsoft#define DBG_DUMP_CLMAP(F,C,M) dbg_dump_clmap((F),(C),(M)) 7669800Stomsoft#define DBG_DUMP_CLSUM(F,C,M) dbg_dump_clsum((F),(C),(M)) 7769800Stomsoft#define DBG_DUMP_SPTBL(F,C,M) dbg_dump_sptbl((F),(C),(M)) 7869800Stomsoft 7969800Stomsoft#define DL_TRC 0x01 8069800Stomsoft#define DL_INFO 0x02 8169800Stomsoftextern int _dbg_lvl_; 8269800Stomsoft 8369800Stomsoft#define DBG_FUNC(N) char __FKT__[] = (N); 8469800Stomsoft#define DBG_ENTER if(_dbg_lvl_ & DL_TRC) { \ 8569800Stomsoft fprintf(stderr, "~>%s: %s\n", __FILE__, __FKT__ ); \ 8669800Stomsoft } 8769800Stomsoft#define DBG_LEAVE if(_dbg_lvl_ & DL_TRC) { \ 8869800Stomsoft fprintf(stderr, "~<%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \ 8969800Stomsoft } 9069800Stomsoft#define DBG_TRC if(_dbg_lvl_ & DL_TRC) { \ 9169800Stomsoft fprintf(stderr, "~=%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \ 9269800Stomsoft } 9369800Stomsoft#define DBG_PRINT0(A) if(_dbg_lvl_ & DL_INFO) { \ 9469800Stomsoft fprintf(stderr, "~ %s", (A)); \ 9569800Stomsoft } 9669800Stomsoft#define DBG_PRINT1(A,B) if(_dbg_lvl_ & DL_INFO) { \ 9769800Stomsoft fprintf(stderr, "~ "); \ 9869800Stomsoft fprintf(stderr, (A), (B)); \ 9969800Stomsoft } 10069800Stomsoft#define DBG_PRINT2(A,B,C) if(_dbg_lvl_ & DL_INFO) { \ 10169800Stomsoft fprintf(stderr, "~ "); \ 10269800Stomsoft fprintf(stderr, (A), (B), (C)); \ 10369800Stomsoft } 10469800Stomsoft#define DBG_PRINT3(A,B,C,D) if(_dbg_lvl_ & DL_INFO) { \ 10569800Stomsoft fprintf(stderr, "~ "); \ 10669800Stomsoft fprintf(stderr, (A), (B), (C), (D)); \ 10769800Stomsoft } 10869800Stomsoft#define DBG_PRINT4(A,B,C,D,E) if(_dbg_lvl_ & DL_INFO) { \ 10969800Stomsoft fprintf(stderr, "~ "); \ 11069800Stomsoft fprintf(stderr, (A), (B), (C), (D), (E)); \ 11169800Stomsoft } 11269800Stomsoft#else /* not FS_DEBUG */ 11369800Stomsoft 11469800Stomsoft#define DBG_OPEN(P) 11569800Stomsoft#define DBG_CLOSE 11669800Stomsoft#define DBG_DUMP_HEX(F,C,M) 11769800Stomsoft#define DBG_DUMP_FS(F,C) 11869800Stomsoft#define DBG_DUMP_CG(F,C,M) 11969800Stomsoft#define DBG_DUMP_CSUM(F,C,M) 12069800Stomsoft#define DBG_DUMP_INO(F,C,M) 12169800Stomsoft#define DBG_DUMP_IBLK(F,C,M,L) 12269800Stomsoft#define DBG_DUMP_INMAP(F,C,M) 12369800Stomsoft#define DBG_DUMP_FRMAP(F,C,M) 12469800Stomsoft#define DBG_DUMP_CLMAP(F,C,M) 12569800Stomsoft#define DBG_DUMP_CLSUM(F,C,M) 12669800Stomsoft#define DBG_DUMP_SPTBL(F,C,M) 12769800Stomsoft#define DBG_FUNC(N) 12869800Stomsoft#define DBG_ENTER 12969800Stomsoft#define DBG_TRC 13069800Stomsoft#define DBG_LEAVE 13169800Stomsoft#define DBG_PRINT0(A) 13269800Stomsoft#define DBG_PRINT1(A,B) 13369800Stomsoft#define DBG_PRINT2(A,B,C) 13469800Stomsoft#define DBG_PRINT3(A,B,C,D) 13569800Stomsoft#define DBG_PRINT4(A,B,C,D,E) 13669800Stomsoft 13769800Stomsoft#endif /* FS_DEBUG */ 138