blob: 651734661b3dc24d2819d4bb0ea57e0854e0c099 [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
John Bauman66b8ab22014-05-06 15:57:45 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
John Bauman66b8ab22014-05-06 15:57:45 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
John Bauman66b8ab22014-05-06 15:57:45 -040014
15// debug.cpp: Debugging utilities.
16
Nicolas Capenscc863da2015-01-21 15:50:55 -050017#include "debug.h"
John Bauman66b8ab22014-05-06 15:57:45 -040018
19#include <stdarg.h>
20#include <stdio.h>
21
Nicolas Capenscc863da2015-01-21 15:50:55 -050022#include "InitializeParseContext.h"
23#include "ParseHelper.h"
John Bauman66b8ab22014-05-06 15:57:45 -040024
John Bauman66b8ab22014-05-06 15:57:45 -040025#ifdef TRACE_ENABLED
Nicolas Capensa5dfd97d2018-09-28 15:27:08 -040026namespace sh {
John Bauman66b8ab22014-05-06 15:57:45 -040027void Trace(const char *format, ...) {
Nicolas Capens0bac2852016-05-07 06:09:58 -040028 if (!format) return;
John Bauman66b8ab22014-05-06 15:57:45 -040029
Nicolas Capens0bac2852016-05-07 06:09:58 -040030 TParseContext* parseContext = GetGlobalParseContext();
31 if (parseContext) {
Alexis Hetu7208e932016-06-02 11:19:24 -040032 const int kTraceBufferLen = 1024;
Nicolas Capens0bac2852016-05-07 06:09:58 -040033 char buf[kTraceBufferLen];
34 va_list args;
35 va_start(args, format);
36 vsnprintf(buf, kTraceBufferLen, format, args);
37 va_end(args);
John Bauman66b8ab22014-05-06 15:57:45 -040038
Nicolas Capens0bac2852016-05-07 06:09:58 -040039 parseContext->trace(buf);
40 }
John Bauman66b8ab22014-05-06 15:57:45 -040041}
Nicolas Capensa5dfd97d2018-09-28 15:27:08 -040042} // namespace sh
John Bauman66b8ab22014-05-06 15:57:45 -040043#endif // TRACE_ENABLED
44