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