rtdebug.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_MODULE
  20. #define RT_DEBUG_MODULE 0
  21. #endif
  22. #ifndef RT_DEBUG_SCHEDULER
  23. #define RT_DEBUG_SCHEDULER 0
  24. #endif
  25. #ifndef RT_DEBUG_SLAB
  26. #define RT_DEBUG_SLAB 0
  27. #endif
  28. #ifndef RT_DEBUG_THREAD
  29. #define RT_DEBUG_THREAD 0
  30. #endif
  31. #ifndef RT_DEBUG_TIMER
  32. #define RT_DEBUG_TIMER 0
  33. #endif
  34. #ifndef RT_DEBUG_IRQ
  35. #define RT_DEBUG_IRQ 0
  36. #endif
  37. #ifndef RT_DEBUG_IPC
  38. #define RT_DEBUG_IPC 0
  39. #endif
  40. /* Turn on this to enable context check */
  41. #ifndef RT_DEBUG_CONTEXT_CHECK
  42. #define RT_DEBUG_CONTEXT_CHECK 1
  43. #endif
  44. #define RT_DEBUG_LOG(type,message) do { if (type) rt_kprintf message;} while (0)
  45. #define RT_ASSERT(EX) if (!(EX)) {volatile char dummy = 0;\
  46. rt_kprintf("(%s) assert failed at %s:%d \n", \
  47. #EX, __FUNCTION__, __LINE__); while (dummy == 0);}
  48. /* Macro to check current context */
  49. #if RT_DEBUG_CONTEXT_CHECK
  50. #define RT_DEBUG_NOT_IN_INTERRUPT do {\
  51. rt_base_t level;\
  52. level = rt_hw_interrupt_disable();\
  53. if (rt_interrupt_get_nest() != 0){\
  54. rt_kprintf("Function[%s] shall not used in ISR\n", __FUNCTION__);\
  55. RT_ASSERT(0)}\
  56. rt_hw_interrupt_enable(level);} while (0)
  57. #endif
  58. #else /* RT_DEBUG */
  59. #define RT_ASSERT(EX)
  60. #define RT_DEBUG_LOG(type,message)
  61. #define RT_DEBUG_NOT_IN_INTERRUPT
  62. #endif /* RT_DEBUG */
  63. #endif /* __RTDEBUG_H__ */