BlitzMax Extended  0.8.11
Pushing Blitz to the Max.
blitz_debug.h
Go to the documentation of this file.
00001 
00016 #ifndef BLITZ_DEBUG_H
00017 #define BLITZ_DEBUG_H
00018 
00019 #include "_common.h"
00020 
00021 BB_BEGIN_DECLS
00022 
00023 #ifdef BB_DEBUG
00024 void bb_assert(const char *expr, const char *file, int line, const char *msg, ...);
00025 
00037 #   define BB_ASSERT(expr, msg, ...) \
00038     if (!(expr)) { bb_assert(#expr, __FILE__, __LINE__, (msg), ##__VA_ARGS__); }
00039 #else
00040 #   define BB_ASSERT(expr, msg, ...)
00041 #endif
00042 
00047 enum BBDebugDeclKind
00048 {
00050     BBDEBUGDECL_END,
00051     
00053     BBDEBUGDECL_CONST,
00054     
00056     BBDEBUGDECL_LOCAL,
00057     
00059     BBDEBUGDECL_FIELD,
00060     
00062     BBDEBUGDECL_GLOBAL,
00063     
00065     BBDEBUGDECL_VARPARAM,
00066 
00071     BBDEBUGDECL_TYPEMETHOD,
00072     
00074     BBDEBUGDECL_TYPEFUNCTION
00075 };
00076 
00077 typedef enum BBDebugDeclKind        BBDebugDeclKind;
00078 
00084 struct BBDebugDecl
00085 {
00087     BBDebugDeclKind     kind;
00088     
00090     const char          *name;
00091     
00093     const char          *type_tag;
00094     
00095     union {
00096         BBString*       const_value;
00097         BBSize          local_offset;
00098         BBSize          field_offset;
00099         void            *global_address;
00100     };
00101 };
00102 
00103 typedef struct BBDebugDecl          BBDebugDecl;
00104 
00109 enum BBDebugScopeKind
00110 {
00112     BBDEBUGSCOPE_FUNCTION = 1,
00113     
00115     BBDEBUGSCOPE_USERTYPE,
00116     
00118     BBDEBUGSCOPE_LOCALBLOCK
00119 };
00120 
00121 typedef enum BBDebugScopeKind       BBDebugScopeKind;
00122 
00131 struct BBDebugScope
00132 {
00134     BBDebugScopeKind    kind;
00135     
00137     const char          *name;
00138     
00140     BBDebugDecl         decls[1];
00141 };
00142 
00143 #ifdef BB_ENABLE_HELPER
00144 
00145 //  Used internally to create debug scopes for BlitzMax classes
00146 //  implemented in C e.g. bbRuntimeExceptionClass
00147 typedef struct bb_debugscope_s
00148 {
00149     BBDebugScopeKind    kind;
00150     const char          *name;
00151     BBDebugDecl         decls[];
00152 } bb_debugscope_t;
00153 
00154 #endif  // BB_ENABLE_HELPER
00155 
00159 struct BBDebugStm
00160 {
00162     const char          *source_file;
00163     
00165     BBSize              line_num;
00166     
00168     BBSize              char_num;
00169 };
00170 
00171 typedef struct BBDebugStm       BBDebugStm;
00172 typedef struct BBDebugScope     BBDebugScope;
00173 
00174 extern void (*bbOnDebugStop)();
00175 extern void (*bbOnDebugLog)(BBString *msg);
00176 extern void (*bbOnDebugEnterStm)(BBDebugStm *stm);
00177 extern void (*bbOnDebugEnterScope)(BBDebugScope *scope, void *inst);
00178 extern void (*bbOnDebugLeaveScope)();
00179 extern void (*bbOnDebugPushExState)();
00180 extern void (*bbOnDebugPopExState)();
00181 extern void (*bbOnDebugUnhandledEx)(BBObject *ex);
00182 
00183 
00184 #ifndef BB_DISABLE_DEPRECATED
00185 
00186 extern void bbCAssertEx();
00187 
00188 #ifndef NDEBUG
00189 #   define bbassert(expr) if (!(expr)) { bbCAssertEx(); }
00190 #else
00191 #   define bbassert(expr)
00192 #endif
00193 
00194 #endif  // !BB_DISABLE_DEPRECATED
00195 
00196 BB_END_DECLS
00197 
00198 #endif  // BLITZ_DEBUG_H