1 // 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // debug.cpp: Debugging utilities. 8 9 #include "compiler/debug.h" 10 11 #include <stdarg.h> 12 #include <stdio.h> 13 14 #include "compiler/ParseHelper.h" 15 16 static const int kTraceBufferLen = 1024; 17 18 #ifdef TRACE_ENABLED 19 extern "C" { 20 void Trace(const char *format, ...) { 21 if (!format) return; 22 23 TParseContext* parseContext = GetGlobalParseContext(); 24 if (parseContext) { 25 char buf[kTraceBufferLen]; 26 va_list args; 27 va_start(args, format); 28 vsnprintf(buf, kTraceBufferLen, format, args); 29 va_end(args); 30 31 parseContext->infoSink.debug << buf; 32 } 33 } 34 } // extern "C" 35 #endif // TRACE_ENABLED 36 37