/mysql/include/mysql/my_dbug.h

http://ghostcb.googlecode.com/ · C++ Header · 115 lines · 97 code · 4 blank · 14 comment · 12 complexity · 312c94e6b5af9cc25bd3313f3146d2fb MD5 · raw file

  1. /* Copyright (C) 2000 MySQL AB
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  12. #ifndef _dbug_h
  13. #define _dbug_h
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #if !defined(DBUG_OFF) && !defined(_lint)
  18. struct _db_code_state_;
  19. extern int _db_keyword_(struct _db_code_state_ *cs, const char *keyword);
  20. extern int _db_strict_keyword_(const char *keyword);
  21. extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
  22. extern int _db_explain_init_(char *buf, size_t len);
  23. extern void _db_setjmp_(void);
  24. extern void _db_longjmp_(void);
  25. extern void _db_process_(const char *name);
  26. extern void _db_push_(const char *control);
  27. extern void _db_pop_(void);
  28. extern void _db_set_(struct _db_code_state_ *cs, const char *control);
  29. extern void _db_set_init_(const char *control);
  30. extern void _db_enter_(const char *_func_,const char *_file_,uint _line_,
  31. const char **_sfunc_,const char **_sfile_,
  32. uint *_slevel_, char ***);
  33. extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
  34. uint *_slevel_);
  35. extern void _db_pargs_(uint _line_,const char *keyword);
  36. extern void _db_doprnt_ _VARARGS((const char *format,...))
  37. ATTRIBUTE_FORMAT(printf, 1, 2);
  38. extern void _db_dump_(uint _line_,const char *keyword,
  39. const unsigned char *memory, size_t length);
  40. extern void _db_end_(void);
  41. extern void _db_lock_file_(void);
  42. extern void _db_unlock_file_(void);
  43. extern FILE *_db_fp_(void);
  44. #define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
  45. char **_db_framep_; \
  46. _db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
  47. &_db_framep_)
  48. #define DBUG_LEAVE \
  49. _db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)
  50. #define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
  51. #define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
  52. #define DBUG_EXECUTE(keyword,a1) \
  53. do {if (_db_keyword_(0, (keyword))) { a1 }} while(0)
  54. #define DBUG_EXECUTE_IF(keyword,a1) \
  55. do {if (_db_strict_keyword_ (keyword)) { a1 } } while(0)
  56. #define DBUG_EVALUATE(keyword,a1,a2) \
  57. (_db_keyword_(0,(keyword)) ? (a1) : (a2))
  58. #define DBUG_EVALUATE_IF(keyword,a1,a2) \
  59. (_db_strict_keyword_((keyword)) ? (a1) : (a2))
  60. #define DBUG_PRINT(keyword,arglist) \
  61. do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
  62. #define DBUG_PUSH(a1) _db_push_ (a1)
  63. #define DBUG_POP() _db_pop_ ()
  64. #define DBUG_SET(a1) _db_set_ (0, (a1))
  65. #define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
  66. #define DBUG_PROCESS(a1) _db_process_(a1)
  67. #define DBUG_FILE _db_fp_()
  68. #define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
  69. #define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
  70. #define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
  71. #define DBUG_END() _db_end_ ()
  72. #define DBUG_LOCK_FILE _db_lock_file_()
  73. #define DBUG_UNLOCK_FILE _db_unlock_file_()
  74. #define DBUG_ASSERT(A) assert(A)
  75. #define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
  76. #define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
  77. #define IF_DBUG(A) A
  78. #else /* No debugger */
  79. #define DBUG_ENTER(a1)
  80. #define DBUG_LEAVE
  81. #define DBUG_RETURN(a1) do { return(a1); } while(0)
  82. #define DBUG_VOID_RETURN do { return; } while(0)
  83. #define DBUG_EXECUTE(keyword,a1) do { } while(0)
  84. #define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
  85. #define DBUG_EVALUATE(keyword,a1,a2) (a2)
  86. #define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
  87. #define DBUG_PRINT(keyword,arglist) do { } while(0)
  88. #define DBUG_PUSH(a1)
  89. #define DBUG_SET(a1)
  90. #define DBUG_SET_INITIAL(a1)
  91. #define DBUG_POP()
  92. #define DBUG_PROCESS(a1)
  93. #define DBUG_SETJMP(a1) setjmp(a1)
  94. #define DBUG_LONGJMP(a1) longjmp(a1)
  95. #define DBUG_DUMP(keyword,a1,a2)
  96. #define DBUG_END()
  97. #define DBUG_ASSERT(A) do { } while(0)
  98. #define DBUG_LOCK_FILE
  99. #define DBUG_FILE (stderr)
  100. #define DBUG_UNLOCK_FILE
  101. #define DBUG_EXPLAIN(buf,len)
  102. #define DBUG_EXPLAIN_INITIAL(buf,len)
  103. #define IF_DBUG(A)
  104. #endif
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif