From 892eac2cce846d11204036ad7e8fb80c8b332258 Mon Sep 17 00:00:00 2001 From: armink Date: Thu, 11 Jun 2015 10:59:25 +0800 Subject: [kservice]add hook for RT_ASSERT --- include/rtdebug.h | 9 +++++++-- include/rtthread.h | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/rtdebug.h b/include/rtdebug.h index 8fd07b5b76..a324a29623 100644 --- a/include/rtdebug.h +++ b/include/rtdebug.h @@ -84,8 +84,13 @@ while (0) if (!(EX)) \ { \ volatile char dummy = 0; \ - rt_kprintf("(%s) assert failed at %s:%d \n", #EX, __FUNCTION__, __LINE__);\ - while (dummy == 0); \ + if (rt_assert_hook == RT_NULL) \ + { \ + rt_kprintf("(%s) assert failed at %s:%d \n", #EX, __FUNCTION__, __LINE__);\ + while (dummy == 0); \ + } else { \ + rt_assert_hook(#EX, __FUNCTION__, __LINE__); \ + } \ } /* Macro to check current context */ diff --git a/include/rtthread.h b/include/rtthread.h index 9bb02abede..705795b522 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -515,6 +515,11 @@ rt_uint32_t rt_strcasecmp(const char *a, const char *b); void rt_show_version(void); +#ifdef RT_DEBUG +extern void (*rt_assert_hook)(const char* ex, const char* func, rt_size_t line); +void rt_assert_set_hook(void (*hook)(const char* ex, const char* func, rt_size_t line)); +#endif /* RT_DEBUG */ + /*@}*/ #ifdef __cplusplus -- cgit v1.3.1