blitz_debug.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. unsigned int kind;
  27. const char *name,*type_tag;
  28. union{
  29. BBString* const_value;
  30. unsigned int field_offset;
  31. void* var_address;
  32. BBFuncPtr func_ptr;
  33. };
  34. };
  35. enum{
  36. BBDEBUGSCOPE_FUNCTION=1,
  37. BBDEBUGSCOPE_USERTYPE=2,
  38. BBDEBUGSCOPE_LOCALBLOCK=3,
  39. BBDEBUGSCOPE_USERINTERFACE=4,
  40. BBDEBUGSCOPE_USERSTRUCT=5,
  41. BBDEBUGSCOPE_USERENUM=6,
  42. };
  43. struct BBDebugScope{
  44. unsigned int kind;
  45. const char *name;
  46. BBDebugDecl decls[1];
  47. };
  48. struct BBDebugStm{
  49. BBULONG id;
  50. int line_num,char_num;
  51. };
  52. typedef struct BBSource {
  53. BBULONG id;
  54. char * file;
  55. unsigned int count;
  56. unsigned int lines[32];
  57. } BBSource;
  58. extern void bbCAssertEx();
  59. extern void (*bbOnDebugStop)();
  60. extern void (*bbOnDebugLog)( BBString *msg );
  61. extern void (*bbOnDebugEnterStm)( BBDebugStm *stm );
  62. extern void (*bbOnDebugEnterScope)( BBDebugScope *scope );//,void *inst );
  63. extern void (*bbOnDebugLeaveScope)();
  64. extern void (*bbOnDebugPushExState)();
  65. extern void (*bbOnDebugPopExState)();
  66. extern void (*bbOnDebugUnhandledEx)( BBObject *ex );
  67. void bbRegisterSource(BBULONG sourceId, const char * source);
  68. BBSource * bbSourceForId(BBULONG id);
  69. BBSource * bbSourceForName(BBString * filename);
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #endif