1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2 // 3 // 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 6 // 7 // 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. 14 15 #ifndef Debug_hpp 16 #define Debug_hpp 17 18 #ifdef __ANDROID__ 19 #include "DebugAndroid.hpp" 20 #else 21 22 #include <assert.h> 23 #include <stdio.h> 24 25 #undef min 26 #undef max 27 28 namespace rr 29 { 30 void trace(const char *format, ...); 31 32 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) 33 #define TRACE(format, ...) trace("[0x%0.8X]%s(" format ")\n", this, __FUNCTION__, ##__VA_ARGS__) 34 #else 35 #define TRACE(...) ((void)0) 36 #endif 37 38 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) 39 #define UNIMPLEMENTED() {trace("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); ASSERT(false);} 40 #else 41 #define UNIMPLEMENTED() ((void)0) 42 #endif 43 44 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) 45 #define ASSERT(expression) {if(!(expression)) trace("\t! Assert failed in %s(%d): " #expression "\n", __FUNCTION__, __LINE__); assert(expression);} 46 #else 47 #define ASSERT assert 48 #endif 49 } 50 51 #endif // __ANDROID__ 52 #endif // Debug_hpp 53