blitz_debug.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef BLITZ_DEBUG_H
  2. #define BLITZ_DEBUG_H
  3. #include "blitz_types.h"
  4. #ifdef __cplusplus
  5. extern "C"{
  6. #endif
  7. #ifndef NDEBUG
  8. #define bbassert( x ) if( !(x) ) bbCAssertEx()
  9. #else
  10. #define bbassert( x )
  11. #endif
  12. typedef struct BBDebugStm BBDebugStm;
  13. typedef struct BBDebugDecl BBDebugDecl;
  14. typedef struct BBDebugScope BBDebugScope;
  15. enum{
  16. BBDEBUGDECL_END=0,
  17. BBDEBUGDECL_CONST=1,
  18. BBDEBUGDECL_LOCAL=2,
  19. BBDEBUGDECL_FIELD=3,
  20. BBDEBUGDECL_GLOBAL=4,
  21. BBDEBUGDECL_VARPARAM=5,
  22. BBDEBUGDECL_TYPEMETHOD=6,
  23. BBDEBUGDECL_TYPEFUNCTION=7
  24. };
  25. struct BBDebugDecl{
  26. int kind;
  27. const char *name,*type_tag;
  28. union{
  29. BBString* const_value;
  30. int local_offset;
  31. int field_offset;
  32. void *global_address;
  33. };
  34. };
  35. enum{
  36. BBDEBUGSCOPE_FUNCTION=1,
  37. BBDEBUGSCOPE_USERTYPE=2,
  38. BBDEBUGSCOPE_LOCALBLOCK=3
  39. };
  40. struct BBDebugScope{
  41. int kind;
  42. const char *name;
  43. BBDebugDecl decls[1];
  44. };
  45. struct BBDebugStm{
  46. const char *source_file;
  47. int line_num,char_num;
  48. };
  49. extern void bbCAssertEx();
  50. extern void (*bbOnDebugStop)();
  51. extern void (*bbOnDebugLog)( BBString *msg );
  52. extern void (*bbOnDebugEnterStm)( BBDebugStm *stm );
  53. extern void (*bbOnDebugEnterScope)( BBDebugScope *scope,void *inst );
  54. extern void (*bbOnDebugLeaveScope)();
  55. extern void (*bbOnDebugPushExState)();
  56. extern void (*bbOnDebugPopExState)();
  57. extern void (*bbOnDebugUnhandledEx)( BBObject *ex );
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif