blob: 10cbe43b8d548b8e261858a7974f2843634cd84e [file] [log] [blame]
alokp@chromium.org91b72322010-06-02 15:50:56 +00001//
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
Geoff Lang17732822013-08-29 13:46:49 -04009#include "compiler/translator/compilerdebug.h"
alokp@chromium.org91b72322010-06-02 15:50:56 +000010
11#include <stdarg.h>
apatrick@chromium.org8187fa82010-06-15 22:09:28 +000012#include <stdio.h>
alokp@chromium.org91b72322010-06-02 15:50:56 +000013
Geoff Lang17732822013-08-29 13:46:49 -040014#include "compiler/translator/InitializeParseContext.h"
Jamie Madill6b9cb252013-10-17 10:45:47 -040015#include "compiler/translator/ParseContext.h"
alokp@chromium.org91b72322010-06-02 15:50:56 +000016
Jamie Madill74d03ea2013-12-03 13:47:39 -050017#ifdef TRACE_ENABLED
alokp@chromium.org91b72322010-06-02 15:50:56 +000018static const int kTraceBufferLen = 1024;
19
alokp@chromium.org91b72322010-06-02 15:50:56 +000020extern "C" {
21void Trace(const char *format, ...) {
22 if (!format) return;
23
24 TParseContext* parseContext = GetGlobalParseContext();
25 if (parseContext) {
26 char buf[kTraceBufferLen];
27 va_list args;
28 va_start(args, format);
29 vsnprintf(buf, kTraceBufferLen, format, args);
30 va_end(args);
31
alokp@chromium.org8b851c62012-06-15 16:25:11 +000032 parseContext->trace(buf);
alokp@chromium.org91b72322010-06-02 15:50:56 +000033 }
34}
35} // extern "C"
36#endif // TRACE_ENABLED
37