summaryrefslogtreecommitdiff
path: root/usr/src/cmd/fs.d/cachefs/mdbug/mdbug.h
blob: 83b1e05876415da2fb4ef4d93fb2b7db40c01998 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 *
 *			mdbug.h
 *
 *	Include file for the mdbug class.
 */

#pragma ident	"%Z%%M%	%I%	%E% SMI"
/* Copyright (c) 1994 by Sun Microsystems, Inc. */

/*
 * .LIBRARY base
 * .NAME mdbug - macros for debugging C++ programs.
 * .FILE dbug.cc
 * .FILE mdbug.h
 */

/*
 * .SECTION Description
 * The mdbug package provides a set of macros for debugging C++ programs.
 * Features include tracing function entry and exit points, printing
 * of debug messages, and heap corruption detection.  All features can
 * be selectively enabled at run time using command line options.  Also
 * defining the macro DBUG_OFF removes all mdbug code from the compilation.
 */

#ifndef MDBUG_H
#define	MDBUG_H

#define	DBUG_STMT(A) do { A } while (0)

#ifndef DBUG_OFF
#define	DBUG_LENGTH 64
typedef struct dbug_object {
	char	d_func[DBUG_LENGTH];		/* Name of current function. */
	char	d_file[DBUG_LENGTH];		/* Name of current file. */
	struct dbug_object	*d_prev;	/* dbug_routine object */
	int	 d_leaveline;			/* Exit line from routine. */
} dbug_object_t;

void dbug_object_create();
void dbug_object_destroy(char *function_name, int line);
int db_keyword(dbug_object_t *dbug_object_p, const char *keyword);
void db_pargs(dbug_object_t *dbug_object_p, int line, char *keyword);
void db_printf(char *keyword, char *format, ...);
void db_traceprint(int line, const char *keyword);
void db_assert(dbug_object_t *dbug_object_p, int line, const char *msgp);
void db_precond(dbug_object_t *dbug_object_p, int line, const char *msgp);
char *db_push(const char *control);
void db_pop();
void db_process(const char *namep);
void dbug_thread_exit(void *data);
dbug_object_t *db_get_dbug_object_p();
void doabort();


#define	dbug_enter(A)		dbug_object_create(__LINE__, __FILE__, A)
#define	dbug_leave(A)		dbug_object_destroy(A, __LINE__)
#define	dbug_traceprint(KEY)	db_traceprint(__LINE__, KEY)
#define	dbug_push(A)		db_push(A)
void	dbug_pop();
#define	dbug_process(A)		db_process(A)
void	dbug_assert();
#define	dbug_assert(A)\
	if (!(A)) { db_assert(db_get_dbug_object_p(), __LINE__, ""); }
#define	dbug_precond(A)\
	if (!(A)) { db_precond(db_get_dbug_object_p(), __LINE__, ""); }
void	dbug_execute();
#define	dbug_print(A)		db_printf A
int	db_debugon();

#else /* if DBUG_OFF */

#define	dbug_enter(A)			0
#define	dbug_leave(A)			0
#define	dbug_traceprint(KEY)		0
#define	dbug_push(A)			0
#define	dbug_pop()			0
#define	dbug_process(A)			0
#define	dbug_execute(KEY, CODE)		0
#define	dbug_print(A)
#define	dbug_assert(A)			0
#define	dbug_precond(A)			0
#define	db_debugon()			0

#endif /* DBUG_OFF */
#endif /* MDBUG_H */