1 #ifndef DEBUG_H 2 #define DEBUG_H 3 #error 8 4 /* Debug - debug stuff 5 ** 6 ** Initial version by Axel Dörfler, axeld@pinc-software.de 7 ** UDF version by Tyler Dauwalder, tyler@dauwalder.net 8 ** This file may be used under the terms of the MIT License. 9 */ 10 11 #ifdef DEBUG 12 # include <string.h> 13 #endif 14 15 #ifdef USER 16 # include <stdio.h> 17 # define __out printf 18 #else 19 # define __out dprintf 20 #endif 21 22 // Which debugger should be used when? 23 // The DEBUGGER() macro actually has no effect if DEBUG is not defined, 24 // use the DIE() macro if you really want to die. 25 #ifdef DEBUG 26 # ifdef USER 27 # define DEBUGGER(x) debugger x 28 # else 29 # define DEBUGGER(x) kernel_debugger x 30 # endif 31 #else 32 # define DEBUGGER(x) ; 33 #endif 34 35 #ifdef USER 36 # define DIE(x) debugger x 37 #else 38 # define DIE(x) kernel_debugger x 39 #endif 40 41 // Short overview over the debug output macros: 42 // PRINT() 43 // is for general messages that very unlikely should appear in a release build 44 // FATAL() 45 // this is for fatal messages, when something has really gone wrong 46 // INFORM() 47 // general information, as disk size, etc. 48 // REPORT_ERROR(status_t) 49 // prints out error information 50 // RETURN_ERROR(status_t) 51 // calls REPORT_ERROR() and return the value 52 // D() 53 // the statements in D() are only included if DEBUG is defined 54 55 #include <KernelExport.h> 56 #define kprintf printf 57 #define dprintf printf 58 59 #ifdef DEBUG 60 #define PRINT(x) { __out("udf: "); __out x; } 61 #define REPORT_ERROR(status) __out("udf: %s:%s:%ld: %s\n", __FILE__, __FUNCTION__, __LINE__, strerror(status)); 62 #define RETURN_ERROR(err) { status_t _status = err; if (_status < B_OK) REPORT_ERROR(_status); return _status;} 63 #define FATAL(x) { __out("udf: "); __out x; } 64 #define INFORM(x) { __out("udf: "); __out x; } 65 #define FUNCTION() __out("udf: %s()\n",__FUNCTION__); 66 #define FUNCTION_START(x) { __out("udf: %s() ",__FUNCTION__); __out x; } 67 // #define FUNCTION() ; 68 // #define FUNCTION_START(x) ; 69 #define D(x) {x;}; 70 #define ASSERT(x) { if (!(x)) DEBUGGER(("udf: assert failed: " #x "\n")); } 71 #else 72 #define PRINT(x) ; 73 #define REPORT_ERROR(status) ; 74 #define RETURN_ERROR(status) return status; 75 #define FATAL(x) { __out("udf: "); __out x; } 76 #define INFORM(x) { __out("udf: "); __out x; } 77 #define FUNCTION() ; 78 #define FUNCTION_START(x) ; 79 #define D(x) ; 80 #define ASSERT(x) ; 81 #endif 82 83 #ifdef DEBUG 84 #endif 85 86 #endif /* DEBUG_H */ 87