< prev index next >

src/java.desktop/share/native/common/awt/debug/debug_trace.c

Print this page
rev 52622 : 8214120: [REDO] Fix sun.awt.nativedebug on X11 platforms
   1 /*
   2  * Copyright (c) 1999, 2001, 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


 220     /* not a real great overflow check (memory would already be hammered) but better than nothing */
 221     DASSERT(strlen(DTraceBuffer) < MAX_TRACE_BUFFER);
 222     /* output the trace message */
 223     DTrace_ClientPrint(DTraceBuffer);
 224 }
 225 
 226 /*
 227  * Print implementation for the use of client defined trace macros. Unsynchronized so it must
 228  * be used from within a DTRACE_PRINT_CALLBACK function.
 229  */
 230 void DTrace_PrintImpl(const char * fmt, ...) {
 231     va_list     arglist;
 232 
 233     va_start(arglist, fmt);
 234     DTrace_VPrintImpl(fmt, arglist);
 235     va_end(arglist);
 236 }
 237 
 238 /*
 239  * Called via DTRACE_PRINT macro. Outputs printf style formatted text.

 240  */
 241 void DTrace_VPrint( const char * file, int line, int argc, const char * fmt, va_list arglist ) {

 242     DASSERT(fmt != NULL);
 243     DTrace_VPrintImpl(fmt, arglist);
 244 }
 245 
 246 /*
 247  * Called via DTRACE_PRINTLN macro. Outputs printf style formatted text with an automatic newline.

 248  */
 249 void DTrace_VPrintln( const char * file, int line, int argc, const char * fmt, va_list arglist ) {

 250     DTrace_VPrintImpl(fmt, arglist);
 251     DTrace_PrintImpl("\n");
 252 }
 253 
 254 /*
 255  * Called via DTRACE_ macros. If tracing is enabled at the given location, it enters
 256  * the trace mutex and invokes the callback function to output the trace.

 257  */
 258 void DTrace_PrintFunction( DTRACE_PRINT_CALLBACK pfn, dtrace_id * pFileTraceId, dtrace_id * pLineTraceId,

 259                            const char * file, int line,
 260                            int argc, const char * fmt, ... ) {
 261     va_list     arglist;
 262 
 263     DASSERT(file != NULL);
 264     DASSERT(line > 0 && line < MAX_LINE);
 265     DASSERT(argc <= MAX_ARGC);
 266     DASSERT(fmt != NULL);
 267 
 268     DMutex_Enter(DTraceMutex);
 269     if ( DTrace_IsEnabledAt(pFileTraceId, pLineTraceId, file, line) ) {
 270         va_start(arglist, fmt);
 271         (*pfn)(file, line, argc, fmt, arglist);
 272         va_end(arglist);
 273     }
 274     DMutex_Exit(DTraceMutex);
 275 }
 276 
 277 /*
 278  * Sets a callback function to be used to output


   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


 220     /* not a real great overflow check (memory would already be hammered) but better than nothing */
 221     DASSERT(strlen(DTraceBuffer) < MAX_TRACE_BUFFER);
 222     /* output the trace message */
 223     DTrace_ClientPrint(DTraceBuffer);
 224 }
 225 
 226 /*
 227  * Print implementation for the use of client defined trace macros. Unsynchronized so it must
 228  * be used from within a DTRACE_PRINT_CALLBACK function.
 229  */
 230 void DTrace_PrintImpl(const char * fmt, ...) {
 231     va_list     arglist;
 232 
 233     va_start(arglist, fmt);
 234     DTrace_VPrintImpl(fmt, arglist);
 235     va_end(arglist);
 236 }
 237 
 238 /*
 239  * Called via DTRACE_PRINT macro. Outputs printf style formatted text.
 240  * JNIEXPORT because these functions are also called from libawt_xawt.
 241  */
 242 JNIEXPORT void JNICALL
 243 DTrace_VPrint( const char * file, int line, int argc, const char * fmt, va_list arglist ) {
 244     DASSERT(fmt != NULL);
 245     DTrace_VPrintImpl(fmt, arglist);
 246 }
 247 
 248 /*
 249  * Called via DTRACE_PRINTLN macro. Outputs printf style formatted text with an automatic newline.
 250  * JNIEXPORT because these functions are also called from libawt_xawt.
 251  */
 252 JNIEXPORT void JNICALL
 253 DTrace_VPrintln( const char * file, int line, int argc, const char * fmt, va_list arglist ) {
 254     DTrace_VPrintImpl(fmt, arglist);
 255     DTrace_PrintImpl("\n");
 256 }
 257 
 258 /*
 259  * Called via DTRACE_ macros. If tracing is enabled at the given location, it enters
 260  * the trace mutex and invokes the callback function to output the trace.
 261  * JNIEXPORT because these functions are also called from libawt_xawt.
 262  */
 263 JNIEXPORT void JNICALL
 264 DTrace_PrintFunction( DTRACE_PRINT_CALLBACK pfn, dtrace_id * pFileTraceId, dtrace_id * pLineTraceId,
 265                       const char * file, int line,
 266                       int argc, const char * fmt, ... ) {
 267     va_list     arglist;
 268 
 269     DASSERT(file != NULL);
 270     DASSERT(line > 0 && line < MAX_LINE);
 271     DASSERT(argc <= MAX_ARGC);
 272     DASSERT(fmt != NULL);
 273 
 274     DMutex_Enter(DTraceMutex);
 275     if ( DTrace_IsEnabledAt(pFileTraceId, pLineTraceId, file, line) ) {
 276         va_start(arglist, fmt);
 277         (*pfn)(file, line, argc, fmt, arglist);
 278         va_end(arglist);
 279     }
 280     DMutex_Exit(DTraceMutex);
 281 }
 282 
 283 /*
 284  * Sets a callback function to be used to output


< prev index next >