xref: /titanic_44/usr/src/cmd/fs.d/cachefs/mdbug/mdbug.h (revision d583b39bfb4e2571d3e41097c5c357ffe353ad45)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *
24  *			mdbug.h
25  *
26  *	Include file for the mdbug class.
27  */
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 /* Copyright (c) 1994 by Sun Microsystems, Inc. */
31 
32 /*
33  * .LIBRARY base
34  * .NAME mdbug - macros for debugging C++ programs.
35  * .FILE dbug.cc
36  * .FILE mdbug.h
37  */
38 
39 /*
40  * .SECTION Description
41  * The mdbug package provides a set of macros for debugging C++ programs.
42  * Features include tracing function entry and exit points, printing
43  * of debug messages, and heap corruption detection.  All features can
44  * be selectively enabled at run time using command line options.  Also
45  * defining the macro DBUG_OFF removes all mdbug code from the compilation.
46  */
47 
48 #ifndef MDBUG_H
49 #define	MDBUG_H
50 
51 #define	DBUG_STMT(A) do { A } while (0)
52 
53 #ifndef DBUG_OFF
54 #define	DBUG_LENGTH 64
55 typedef struct dbug_object {
56 	char	d_func[DBUG_LENGTH];		/* Name of current function. */
57 	char	d_file[DBUG_LENGTH];		/* Name of current file. */
58 	struct dbug_object	*d_prev;	/* dbug_routine object */
59 	int	 d_leaveline;			/* Exit line from routine. */
60 } dbug_object_t;
61 
62 void dbug_object_create();
63 void dbug_object_destroy(char *function_name, int line);
64 int db_keyword(dbug_object_t *dbug_object_p, const char *keyword);
65 void db_pargs(dbug_object_t *dbug_object_p, int line, char *keyword);
66 void db_printf(char *keyword, char *format, ...);
67 void db_traceprint(int line, const char *keyword);
68 void db_assert(dbug_object_t *dbug_object_p, int line, const char *msgp);
69 void db_precond(dbug_object_t *dbug_object_p, int line, const char *msgp);
70 char *db_push(const char *control);
71 void db_pop();
72 void db_process(const char *namep);
73 void dbug_thread_exit(void *data);
74 dbug_object_t *db_get_dbug_object_p();
75 void doabort();
76 
77 
78 #define	dbug_enter(A)		dbug_object_create(__LINE__, __FILE__, A)
79 #define	dbug_leave(A)		dbug_object_destroy(A, __LINE__)
80 #define	dbug_traceprint(KEY)	db_traceprint(__LINE__, KEY)
81 #define	dbug_push(A)		db_push(A)
82 void	dbug_pop();
83 #define	dbug_process(A)		db_process(A)
84 void	dbug_assert();
85 #define	dbug_assert(A)\
86 	if (!(A)) { db_assert(db_get_dbug_object_p(), __LINE__, ""); }
87 #define	dbug_precond(A)\
88 	if (!(A)) { db_precond(db_get_dbug_object_p(), __LINE__, ""); }
89 void	dbug_execute();
90 #define	dbug_print(A)		db_printf A
91 int	db_debugon();
92 
93 #else /* if DBUG_OFF */
94 
95 #define	dbug_enter(A)			0
96 #define	dbug_leave(A)			0
97 #define	dbug_traceprint(KEY)		0
98 #define	dbug_push(A)			0
99 #define	dbug_pop()			0
100 #define	dbug_process(A)			0
101 #define	dbug_execute(KEY, CODE)		0
102 #define	dbug_print(A)
103 #define	dbug_assert(A)			0
104 #define	dbug_precond(A)			0
105 #define	db_debugon()			0
106 
107 #endif /* DBUG_OFF */
108 #endif /* MDBUG_H */
109