1 /*
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
42 typedef int dtrace_id;
43 enum {
44 UNDEFINED_TRACE_ID = -1 /* indicates trace point has not been registered yet */
45 };
46
47 /* prototype for client provided output callback function */
48 typedef void (*DTRACE_OUTPUT_CALLBACK)(const char * msg);
49
50 /* prototype for client provided print callback function */
51 typedef void (*DTRACE_PRINT_CALLBACK)(const char * file, int line, int argc, const char * fmt, va_list arglist);
52
53 extern void DTrace_EnableAll(dbool_t enabled);
54 extern void DTrace_EnableFile(const char * file, dbool_t enabled);
55 extern void DTrace_EnableLine(const char * file, int linenum, dbool_t enabled);
56 extern void DTrace_SetOutputCallback(DTRACE_OUTPUT_CALLBACK pfn);
57 extern void DTrace_Initialize();
58 extern void DTrace_Shutdown();
59 void DTrace_DisableMutex();
60 extern void DTrace_VPrintImpl(const char * fmt, va_list arglist);
61 extern void DTrace_PrintImpl(const char * fmt, ...);
62 extern void DTrace_PrintFunction(DTRACE_PRINT_CALLBACK pfn, dtrace_id * pFileTraceId, dtrace_id * pTraceId, const char * file, int line, int argc, const char * fmt, ...);
63
64 /* these functions are exported only for use in macros-- do not call them directly!!! */
65 extern void DTrace_VPrint(const char * file, int line, int argc, const char * fmt, va_list arglist);
66 extern void DTrace_VPrintln(const char * file, int line, int argc, const char * fmt, va_list arglist);
67
68 /* each file includes this flag indicating module trace status */
69 static dtrace_id _Dt_FileTraceId = UNDEFINED_TRACE_ID;
70
71 /* not meant to be called from client code--
72 * it's just a template for the other macros
73 */
74 #define _DTrace_Template(_func, _ac, _f, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \
75 { \
76 static dtrace_id _dt_lineid_ = UNDEFINED_TRACE_ID; \
77 DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, THIS_FILE, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
78 }
79
80 /* printf style trace macros */
81 #define DTRACE_PRINT(_fmt) \
82 _DTrace_Template(DTrace_VPrint, 0, (_fmt), 0, 0, 0, 0, 0, 0, 0, 0)
83 #define DTRACE_PRINT1(_fmt, _arg1) \
84 _DTrace_Template(DTrace_VPrint, 1, (_fmt), (_arg1), 0, 0, 0, 0, 0, 0, 0)
85 #define DTRACE_PRINT2(_fmt, _arg1, _arg2) \
86 _DTrace_Template(DTrace_VPrint, 2, (_fmt), (_arg1), (_arg2), 0, 0, 0, 0, 0, 0)
|
1 /*
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
42 typedef int dtrace_id;
43 enum {
44 UNDEFINED_TRACE_ID = -1 /* indicates trace point has not been registered yet */
45 };
46
47 /* prototype for client provided output callback function */
48 typedef void (*DTRACE_OUTPUT_CALLBACK)(const char * msg);
49
50 /* prototype for client provided print callback function */
51 typedef void (*DTRACE_PRINT_CALLBACK)(const char * file, int line, int argc, const char * fmt, va_list arglist);
52
53 extern void DTrace_EnableAll(dbool_t enabled);
54 extern void DTrace_EnableFile(const char * file, dbool_t enabled);
55 extern void DTrace_EnableLine(const char * file, int linenum, dbool_t enabled);
56 extern void DTrace_SetOutputCallback(DTRACE_OUTPUT_CALLBACK pfn);
57 extern void DTrace_Initialize();
58 extern void DTrace_Shutdown();
59 void DTrace_DisableMutex();
60 extern void DTrace_VPrintImpl(const char * fmt, va_list arglist);
61 extern void DTrace_PrintImpl(const char * fmt, ...);
62 /* JNIEXPORT because these functions are also called from libawt_xawt */
63 JNIEXPORT void JNICALL DTrace_PrintFunction(DTRACE_PRINT_CALLBACK pfn, dtrace_id * pFileTraceId, dtrace_id * pTraceId, const char * file, int line, int argc, const char * fmt, ...);
64
65 /* these functions are exported only for use in macros-- do not call them directly!!! */
66 JNIEXPORT void JNICALL DTrace_VPrint(const char * file, int line, int argc, const char * fmt, va_list arglist);
67 JNIEXPORT void JNICALL DTrace_VPrintln(const char * file, int line, int argc, const char * fmt, va_list arglist);
68
69 /* each file includes this flag indicating module trace status */
70 static dtrace_id _Dt_FileTraceId = UNDEFINED_TRACE_ID;
71
72 /* not meant to be called from client code--
73 * it's just a template for the other macros
74 */
75 #define _DTrace_Template(_func, _ac, _f, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \
76 { \
77 static dtrace_id _dt_lineid_ = UNDEFINED_TRACE_ID; \
78 DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, THIS_FILE, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
79 }
80
81 /* printf style trace macros */
82 #define DTRACE_PRINT(_fmt) \
83 _DTrace_Template(DTrace_VPrint, 0, (_fmt), 0, 0, 0, 0, 0, 0, 0, 0)
84 #define DTRACE_PRINT1(_fmt, _arg1) \
85 _DTrace_Template(DTrace_VPrint, 1, (_fmt), (_arg1), 0, 0, 0, 0, 0, 0, 0)
86 #define DTRACE_PRINT2(_fmt, _arg1, _arg2) \
87 _DTrace_Template(DTrace_VPrint, 2, (_fmt), (_arg1), (_arg2), 0, 0, 0, 0, 0, 0)
|