0N/A/*
2362N/A * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#if !defined(_DEBUG_TRACE_H)
0N/A#define _DEBUG_TRACE_H
0N/A
0N/A#if defined(__cplusplus)
0N/Aextern "C" {
0N/A#endif
0N/A
0N/A#if defined(DEBUG)
0N/A
0N/A#include "debug_util.h"
0N/A
0N/Atypedef int dtrace_id;
0N/Aenum {
0N/A UNDEFINED_TRACE_ID = -1 /* indicates trace point has not been registered yet */
0N/A};
0N/A
0N/A/* prototype for client provided output callback function */
0N/Atypedef void (*DTRACE_OUTPUT_CALLBACK)(const char * msg);
0N/A
0N/A/* prototype for client provided print callback function */
0N/Atypedef void (*DTRACE_PRINT_CALLBACK)(const char * file, int line, int argc, const char * fmt, va_list arglist);
0N/A
0N/Aextern void DTrace_EnableAll(dbool_t enabled);
0N/Aextern void DTrace_EnableFile(const char * file, dbool_t enabled);
0N/Aextern void DTrace_EnableLine(const char * file, int linenum, dbool_t enabled);
0N/Aextern void DTrace_SetOutputCallback(DTRACE_OUTPUT_CALLBACK pfn);
0N/Aextern void DTrace_Initialize();
0N/Aextern void DTrace_Shutdown();
0N/Avoid DTrace_DisableMutex();
0N/Aextern void DTrace_VPrintImpl(const char * fmt, va_list arglist);
0N/Aextern void DTrace_PrintImpl(const char * fmt, ...);
0N/Aextern void DTrace_PrintFunction(DTRACE_PRINT_CALLBACK pfn, dtrace_id * pFileTraceId, dtrace_id * pTraceId, const char * file, int line, int argc, const char * fmt, ...);
0N/A
0N/A/* these functions are exported only for use in macros-- do not call them directly!!! */
0N/Aextern void DTrace_VPrint(const char * file, int line, int argc, const char * fmt, va_list arglist);
0N/Aextern void DTrace_VPrintln(const char * file, int line, int argc, const char * fmt, va_list arglist);
0N/A
0N/A/* each file includes this flag indicating module trace status */
0N/Astatic dtrace_id _Dt_FileTraceId = UNDEFINED_TRACE_ID;
0N/A
0N/A/* not meant to be called from client code--
0N/A * it's just a template for the other macros
0N/A */
0N/A#define _DTrace_Template(_func, _ac, _f, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \
0N/A{ \
0N/A static dtrace_id _dt_lineid_ = UNDEFINED_TRACE_ID; \
0N/A DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, __FILE__, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
0N/A}
0N/A
0N/A/* printf style trace macros */
0N/A#define DTRACE_PRINT(_fmt) \
0N/A _DTrace_Template(DTrace_VPrint, 0, (_fmt), 0, 0, 0, 0, 0, 0, 0, 0)
0N/A#define DTRACE_PRINT1(_fmt, _arg1) \
0N/A _DTrace_Template(DTrace_VPrint, 1, (_fmt), (_arg1), 0, 0, 0, 0, 0, 0, 0)
0N/A#define DTRACE_PRINT2(_fmt, _arg1, _arg2) \
0N/A _DTrace_Template(DTrace_VPrint, 2, (_fmt), (_arg1), (_arg2), 0, 0, 0, 0, 0, 0)
0N/A#define DTRACE_PRINT3(_fmt, _arg1, _arg2, _arg3) \
0N/A _DTrace_Template(DTrace_VPrint, 3, (_fmt), (_arg1), (_arg2), (_arg3), 0, 0, 0, 0, 0)
0N/A#define DTRACE_PRINT4(_fmt, _arg1, _arg2, _arg3, _arg4) \
0N/A _DTrace_Template(DTrace_VPrint, 4, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), 0, 0, 0, 0)
0N/A#define DTRACE_PRINT5(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5) \
0N/A _DTrace_Template(DTrace_VPrint, 5, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), (_arg5), 0, 0, 0)
0N/A#define DTRACE_PRINT6(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6) \
0N/A _DTrace_Template(DTrace_VPrint, 6, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), (_arg5), (_arg6), 0, 0)
0N/A#define DTRACE_PRINT7(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7) \
0N/A _DTrace_Template(DTrace_VPrint, 7, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), (_arg5), (_arg6), (_arg7), 0)
0N/A#define DTRACE_PRINT8(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8) \
0N/A _DTrace_Template(DTrace_VPrint, 8, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), (_arg5), (_arg6), (_arg7), (_arg8))
0N/A
0N/A/* printf style trace macros that automatically output a newline */
0N/A#define DTRACE_PRINTLN(_fmt) \
0N/A _DTrace_Template(DTrace_VPrintln, 0, (_fmt), 0, 0, 0, 0, 0, 0, 0, 0)
0N/A#define DTRACE_PRINTLN1(_fmt, _arg1) \
0N/A _DTrace_Template(DTrace_VPrintln, 1, (_fmt), (_arg1), 0, 0, 0, 0, 0, 0, 0)
0N/A#define DTRACE_PRINTLN2(_fmt, _arg1, _arg2) \
0N/A _DTrace_Template(DTrace_VPrintln, 2, (_fmt), (_arg1), (_arg2), 0, 0, 0, 0, 0, 0)
0N/A#define DTRACE_PRINTLN3(_fmt, _arg1, _arg2, _arg3) \
0N/A _DTrace_Template(DTrace_VPrintln, 3, (_fmt), (_arg1), (_arg2), (_arg3), 0, 0, 0, 0, 0)
0N/A#define DTRACE_PRINTLN4(_fmt, _arg1, _arg2, _arg3, _arg4) \
0N/A _DTrace_Template(DTrace_VPrintln, 4, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), 0, 0, 0, 0)
0N/A#define DTRACE_PRINTLN5(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5) \
0N/A _DTrace_Template(DTrace_VPrintln, 5, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), (_arg5), 0, 0, 0)
0N/A#define DTRACE_PRINTLN6(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6) \
0N/A _DTrace_Template(DTrace_VPrintln, 6, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), (_arg5), (_arg6), 0, 0)
0N/A#define DTRACE_PRINTLN7(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7) \
0N/A _DTrace_Template(DTrace_VPrintln, 7, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), (_arg5), (_arg6), (_arg7), 0)
0N/A#define DTRACE_PRINTLN8(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8) \
0N/A _DTrace_Template(DTrace_VPrintln, 8, (_fmt), (_arg1), (_arg2), (_arg3), (_arg4), (_arg5), (_arg6), (_arg7), (_arg8))
0N/A
0N/A#else /* else DEBUG not defined */
0N/A
0N/A/* printf style trace macros */
0N/A#define DTRACE_PRINT(_fmt)
0N/A#define DTRACE_PRINT1(_fmt, _arg1)
0N/A#define DTRACE_PRINT2(_fmt, _arg1, _arg2)
0N/A#define DTRACE_PRINT3(_fmt, _arg1, _arg2, _arg3)
0N/A#define DTRACE_PRINT4(_fmt, _arg1, _arg2, _arg3, _arg4)
0N/A#define DTRACE_PRINT5(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5)
0N/A#define DTRACE_PRINT6(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6)
0N/A#define DTRACE_PRINT7(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7)
0N/A#define DTRACE_PRINT8(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8)
0N/A
0N/A/* printf style trace macros that automatically output a newline */
0N/A#define DTRACE_PRINTLN(_fmt)
0N/A#define DTRACE_PRINTLN1(_fmt, _arg1)
0N/A#define DTRACE_PRINTLN2(_fmt, _arg1, _arg2)
0N/A#define DTRACE_PRINTLN3(_fmt, _arg1, _arg2, _arg3)
0N/A#define DTRACE_PRINTLN4(_fmt, _arg1, _arg2, _arg3, _arg4)
0N/A#define DTRACE_PRINTLN5(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5)
0N/A#define DTRACE_PRINTLN6(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6)
0N/A#define DTRACE_PRINTLN7(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7)
0N/A#define DTRACE_PRINTLN8(_fmt, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8)
0N/A
0N/A#endif /* endif DEBUG defined */
0N/A
0N/A#if defined(__cplusplus)
0N/A} /* extern "C" */
0N/A#endif
0N/A
0N/A#endif /* _DEBUG_TRACE_H */