rtdebug.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * File : rtdebug.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. */
  10. #ifndef __RTDEBUG_H__
  11. #define __RTDEBUG_H__
  12. #include <rtconfig.h>
  13. /* Using this macro to control all kernel debug features. */
  14. #ifdef RT_DEBUG
  15. /* Turn on some of these (set to non-zero) to debug kernel */
  16. #ifndef RT_DEBUG_MEM
  17. #define RT_DEBUG_MEM 0
  18. #endif
  19. #ifndef RT_DEBUG_MEMHEAP
  20. #define RT_DEBUG_MEMHEAP 0
  21. #endif
  22. #ifndef RT_DEBUG_MODULE
  23. #define RT_DEBUG_MODULE 0
  24. #endif
  25. #ifndef RT_DEBUG_SCHEDULER
  26. #define RT_DEBUG_SCHEDULER 0
  27. #endif
  28. #ifndef RT_DEBUG_SLAB
  29. #define RT_DEBUG_SLAB 0
  30. #endif
  31. #ifndef RT_DEBUG_THREAD
  32. #define RT_DEBUG_THREAD 0
  33. #endif
  34. #ifndef RT_DEBUG_TIMER
  35. #define RT_DEBUG_TIMER 0
  36. #endif
  37. #ifndef RT_DEBUG_IRQ
  38. #define RT_DEBUG_IRQ 0
  39. #endif
  40. #ifndef RT_DEBUG_IPC
  41. #define RT_DEBUG_IPC 0
  42. #endif
  43. /* Turn on this to enable context check */
  44. #ifndef RT_DEBUG_CONTEXT_CHECK
  45. #define RT_DEBUG_CONTEXT_CHECK 1
  46. #endif
  47. #define RT_DEBUG_LOG(type,message) do { if (type) rt_kprintf message;} while (0)
  48. #define RT_ASSERT(EX) if (!(EX)) {volatile char dummy = 0;\
  49. rt_kprintf("(%s) assert failed at %s:%d \n", \
  50. #EX, __FUNCTION__, __LINE__); while (dummy == 0);}
  51. /* Macro to check current context */
  52. #if RT_DEBUG_CONTEXT_CHECK
  53. #define RT_DEBUG_NOT_IN_INTERRUPT do {\
  54. rt_base_t level;\
  55. level = rt_hw_interrupt_disable();\
  56. if (rt_interrupt_get_nest() != 0){\
  57. rt_kprintf("Function[%s] shall not used in ISR\n", __FUNCTION__);\
  58. RT_ASSERT(0)}\
  59. rt_hw_interrupt_enable(level);} while (0)
  60. #endif
  61. #else /* RT_DEBUG */
  62. #define RT_ASSERT(EX)
  63. #define RT_DEBUG_LOG(type,message)
  64. #define RT_DEBUG_NOT_IN_INTERRUPT
  65. #endif /* RT_DEBUG */
  66. #endif /* __RTDEBUG_H__ */