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