alokp@chromium.org | 91b7232 | 2010-06-02 15:50:56 +0000 | [diff] [blame^] | 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 | |
| 13 | #include "compiler/ParseHelper.h" |
| 14 | |
| 15 | static const int kTraceBufferLen = 1024; |
| 16 | |
| 17 | #ifdef TRACE_ENABLED |
| 18 | extern "C" { |
| 19 | void Trace(const char *format, ...) { |
| 20 | if (!format) return; |
| 21 | |
| 22 | TParseContext* parseContext = GetGlobalParseContext(); |
| 23 | if (parseContext) { |
| 24 | char buf[kTraceBufferLen]; |
| 25 | va_list args; |
| 26 | va_start(args, format); |
| 27 | vsnprintf(buf, kTraceBufferLen, format, args); |
| 28 | va_end(args); |
| 29 | |
| 30 | parseContext->infoSink.debug << buf; |
| 31 | } |
| 32 | } |
| 33 | } // extern "C" |
| 34 | #endif // TRACE_ENABLED |
| 35 | |