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