rtdebug.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef __RTDEBUG_H__
  2. #define __RTDEBUG_H__
  3. #include <rtconfig.h>
  4. /* Using this macro to control all kernel debug features. */
  5. #ifdef RT_DEBUG
  6. /* Turn on some of these (set to non-zero) to debug kernel */
  7. #ifndef RT_DEBUG_MEM
  8. #define RT_DEBUG_MEM 0
  9. #endif
  10. #ifndef RT_DEBUG_MODULE
  11. #define RT_DEBUG_MODULE 0
  12. #endif
  13. #ifndef RT_DEBUG_SCHEDULER
  14. #define RT_DEBUG_SCHEDULER 0
  15. #endif
  16. #ifndef RT_DEBUG_SLAB
  17. #define RT_DEBUG_SLAB 0
  18. #endif
  19. #ifndef RT_DEBUG_THREAD
  20. #define RT_DEBUG_THREAD 0
  21. #endif
  22. #ifndef RT_DEBUG_TIMER
  23. #define RT_DEBUG_TIMER 0
  24. #endif
  25. #ifndef RT_DEBUG_IRQ
  26. #define RT_DEBUG_IRQ 0
  27. #endif
  28. #ifndef RT_DEBUG_IPC
  29. #define RT_DEBUG_IPC 0
  30. #endif
  31. /* Turn on this to enable context check */
  32. #ifndef RT_DEBUG_CONTEXT_CHECK
  33. #define RT_DEBUG_CONTEXT_CHECK 1
  34. #endif
  35. #define RT_DEBUG_LOG(type,message) do{ if(type) rt_kprintf message;}while(0)
  36. #define RT_ASSERT(EX) if (!(EX)) {volatile char dummy=0;\
  37. rt_kprintf("(%s) assert failed at %s:%d \n", \
  38. #EX, __FUNCTION__, __LINE__); while (dummy==0);}
  39. /* Macro to check current context */
  40. #if RT_DEBUG_CONTEXT_CHECK
  41. #define RT_DEBUG_NOT_IN_INTERRUPT do {\
  42. rt_base_t level;\
  43. level = rt_hw_interrupt_disable();\
  44. if(rt_interrupt_get_nest() != 0){\
  45. rt_kprintf("Function[%s] shall not used in ISR\n", __FUNCTION__);\
  46. RT_ASSERT(0)}\
  47. rt_hw_interrupt_enable(level);} while (0)
  48. #endif
  49. #else /* RT_DEBUG */
  50. #define RT_ASSERT(EX)
  51. #define RT_DEBUG_LOG(type,message)
  52. #define RT_DEBUG_NOT_IN_INTERRUPT
  53. #endif /* RT_DEBUG */
  54. #endif /* __RTDEBUG_H__ */