From 411e6a635117a17986c22d98176e80c6921f70a6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 27 Feb 2010 08:40:21 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1678 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 163 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 os/kernel/include/chdebug.h (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h new file mode 100644 index 000000000..5cd056a81 --- /dev/null +++ b/os/kernel/include/chdebug.h @@ -0,0 +1,163 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file debug.h + * @brief Debug macros and structures. + * + * @addtogroup debug + * @{ + */ + +#ifndef _DEBUG_H_ +#define _DEBUG_H_ + +/** + * @brief Trace buffer entries. + */ +#ifndef TRACE_BUFFER_SIZE +#define TRACE_BUFFER_SIZE 64 +#endif + +/** + * @brief Fill value for thread stack area in debug mode. + */ +#ifndef STACK_FILL_VALUE +#define STACK_FILL_VALUE 0x55 +#endif + +/** + * @brief Fill value for thread area in debug mode. + * @note The chosen default value is 0xFF in order to make evident which + * thread fields were not initialized when inspecting the memory with + * a debugger. A uninitialized field is not an error in itself but it + * better to know it. + */ +#ifndef THREAD_FILL_VALUE +#define THREAD_FILL_VALUE 0xFF +#endif + +#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) +/** + * @brief Trace buffer record. + */ +typedef struct { + void *cse_wtobjp; /**< @brief Object where going to + sleep. */ + systime_t cse_time; /**< @brief Time of the switch + event. */ + uint16_t cse_state: 4; /**< @brief Switched out thread + state. */ + uint16_t cse_tid: 12; /**< @brief Switched in thread id. */ +} CtxSwcEvent; + +/** + * @brief Trace buffer header. + */ +typedef struct { + unsigned tb_size; /**< @brief Trace buffer size + (entries). */ + CtxSwcEvent *tb_ptr; /**< @brief Pointer to the ring buffer + front. */ + /** @brief Ring buffer.*/ + CtxSwcEvent tb_buffer[TRACE_BUFFER_SIZE]; +} TraceBuffer; +#endif /* CH_DBG_ENABLE_TRACE */ + +#define __QUOTE_THIS(p) #p + +#if CH_DBG_ENABLE_CHECKS +/** + * @brief Function parameter check. + * @details If the condition check fails then the kernel panics and halts. + * @note The condition is tested only if the @p CH_DBG_ENABLE_CHECKS switch + * is specified in @p chconf.h else the macro does nothing. + * + * @param[in] c the condition to be verified to be true + * @param[in] func the undecorated function name + */ +#define chDbgCheck(c, func) { \ + if (!(c)) \ + chDbgPanic(__QUOTE_THIS(func)"(), line "__QUOTE_THIS(__LINE__)); \ +} +#else /* !CH_DBG_ENABLE_CHECKS */ +#define chDbgCheck(c, func) { \ + (void)(c), (void)__QUOTE_THIS(func)"(), line "__QUOTE_THIS(__LINE__); \ +} +#endif /* !CH_DBG_ENABLE_CHECKS */ + +#if CH_DBG_ENABLE_ASSERTS +/** + * @brief Condition assertion. + * @details If the condition check fails then the kernel panics with the + * specified message and halts. + * @note The condition is tested only if the @p CH_DBG_ENABLE_ASSERTS switch + * is specified in @p chconf.h else the macro does nothing. + * @note The convention for the message is the following:
+ * @(), #@ + * @note The remark string is not currently used except for putting a + * comment in the code about the assertion. + * + * @param[in] c the condition to be verified to be true + * @param[in] m the text message + * @param[in] r a remark string + */ +#define chDbgAssert(c, m, r) { \ + if (!(c)) \ + chDbgPanic(m); \ +} +#else /* !CH_DBG_ENABLE_ASSERTS */ +#define chDbgAssert(c, m, r) {(void)(c);} +#endif /* !CH_DBG_ENABLE_ASSERTS */ + +#if !(CH_DBG_ENABLE_ASSERTS || \ + CH_DBG_ENABLE_CHECKS || \ + CH_DBG_ENABLE_STACK_CHECK) +/* When the debug features are disabled this function is replaced by an empty + macro.*/ +#define chDbgPanic(msg) {} +#endif + +#if !CH_DBG_ENABLE_TRACE +/* When the trace feature is disabled this function is replaced by an empty + macro.*/ +#define chDbgTrace(otp, ntp) {} +#endif + +#if !defined(__DOXYGEN__) +#ifdef __cplusplus +extern "C" { +#endif +#if CH_DBG_ENABLE_TRACE + extern TraceBuffer trace_buffer; + void trace_init(void); + void chDbgTrace(Thread *otp, Thread *ntp); +#endif +#if CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || CH_DBG_ENABLE_STACK_CHECK + extern char *panic_msg; + void chDbgPanic(char *msg); +#endif +#ifdef __cplusplus +} +#endif +#endif /* !defined(__DOXYGEN__) */ + +#endif /* _DEBUG_H_ */ + +/** @} */ -- cgit v1.2.3 From 5fb790997fec3b9d965c57e57b4edd156c8b8954 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 27 Feb 2010 08:54:22 +0000 Subject: Renamed the kernel header to match their source files. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1679 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 5cd056a81..316d9e633 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -18,15 +18,15 @@ */ /** - * @file debug.h + * @file chdebug.h * @brief Debug macros and structures. * * @addtogroup debug * @{ */ -#ifndef _DEBUG_H_ -#define _DEBUG_H_ +#ifndef _CHDEBUG_H_ +#define _CHDEBUG_H_ /** * @brief Trace buffer entries. @@ -158,6 +158,6 @@ extern "C" { #endif #endif /* !defined(__DOXYGEN__) */ -#endif /* _DEBUG_H_ */ +#endif /* _CHDEBUG_H_ */ /** @} */ -- cgit v1.2.3 From 075b89133ec371480bdcf670d3f412b1cf131b0e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 14 Mar 2010 09:13:21 +0000 Subject: Performance optimization (not complete yet). git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1739 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 316d9e633..c79be7a3b 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -147,7 +147,7 @@ extern "C" { #if CH_DBG_ENABLE_TRACE extern TraceBuffer trace_buffer; void trace_init(void); - void chDbgTrace(Thread *otp, Thread *ntp); + void chDbgTrace(Thread *ntp, Thread *otp); #endif #if CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || CH_DBG_ENABLE_STACK_CHECK extern char *panic_msg; -- cgit v1.2.3 From e55b9dfdcb1a285aed416fc49d702b01e18de03f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Mar 2010 20:39:23 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1759 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index c79be7a3b..b9da339b7 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -137,7 +137,7 @@ typedef struct { #if !CH_DBG_ENABLE_TRACE /* When the trace feature is disabled this function is replaced by an empty macro.*/ -#define chDbgTrace(otp, ntp) {} +#define chDbgTrace(otp) {} #endif #if !defined(__DOXYGEN__) @@ -147,7 +147,7 @@ extern "C" { #if CH_DBG_ENABLE_TRACE extern TraceBuffer trace_buffer; void trace_init(void); - void chDbgTrace(Thread *ntp, Thread *otp); + void chDbgTrace(Thread *otp); #endif #if CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || CH_DBG_ENABLE_STACK_CHECK extern char *panic_msg; -- cgit v1.2.3 From 9ffea7e261ec4016d788abbbf7c4a6d3a78e0a04 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 18 Sep 2010 06:48:56 +0000 Subject: Documentation improvements, renamed some event APIs. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2179 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index b9da339b7..e6d6f231c 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -82,7 +82,7 @@ typedef struct { #define __QUOTE_THIS(p) #p -#if CH_DBG_ENABLE_CHECKS +#if CH_DBG_ENABLE_CHECKS || defined(__DOXYGEN__) /** * @brief Function parameter check. * @details If the condition check fails then the kernel panics and halts. @@ -102,7 +102,7 @@ typedef struct { } #endif /* !CH_DBG_ENABLE_CHECKS */ -#if CH_DBG_ENABLE_ASSERTS +#if CH_DBG_ENABLE_ASSERTS || defined(__DOXYGEN__) /** * @brief Condition assertion. * @details If the condition check fails then the kernel panics with the @@ -144,7 +144,7 @@ typedef struct { #ifdef __cplusplus extern "C" { #endif -#if CH_DBG_ENABLE_TRACE +#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) extern TraceBuffer trace_buffer; void trace_init(void); void chDbgTrace(Thread *otp); -- cgit v1.2.3 From 07351222e6d0b6b3dcd4f50ecb18bc09e7402d1c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 21 Sep 2010 10:22:06 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2184 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index e6d6f231c..e29b095e8 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -91,6 +91,8 @@ typedef struct { * * @param[in] c the condition to be verified to be true * @param[in] func the undecorated function name + * + * @api */ #define chDbgCheck(c, func) { \ if (!(c)) \ @@ -117,6 +119,8 @@ typedef struct { * @param[in] c the condition to be verified to be true * @param[in] m the text message * @param[in] r a remark string + * + * @api */ #define chDbgAssert(c, m, r) { \ if (!(c)) \ -- cgit v1.2.3 From e7e79a6ccb4f3e320b2b8b7bad1b14d65218641d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Mar 2011 18:38:08 +0000 Subject: License updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index e29b095e8..5d6b455fe 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -1,5 +1,6 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From f5ae2552307f20f3fa3d987591fa60576981ce3d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 29 Mar 2011 14:51:08 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2850 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 5d6b455fe..471da5532 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -151,7 +151,7 @@ extern "C" { #endif #if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) extern TraceBuffer trace_buffer; - void trace_init(void); + void _trace_init(void); void chDbgTrace(Thread *otp); #endif #if CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || CH_DBG_ENABLE_STACK_CHECK -- cgit v1.2.3 From b38e1f2c96ca1940f210be9ec2de6eeb076f1a10 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 9 Jul 2011 09:15:49 +0000 Subject: Improvements to the trace buffer and other debug features. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3139 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 471da5532..419ad001c 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -32,15 +32,15 @@ /** * @brief Trace buffer entries. */ -#ifndef TRACE_BUFFER_SIZE -#define TRACE_BUFFER_SIZE 64 +#ifndef CH_TRACE_BUFFER_SIZE +#define CH_TRACE_BUFFER_SIZE 64 #endif /** * @brief Fill value for thread stack area in debug mode. */ -#ifndef STACK_FILL_VALUE -#define STACK_FILL_VALUE 0x55 +#ifndef CH_STACK_FILL_VALUE +#define CH_STACK_FILL_VALUE 0x55 #endif /** @@ -50,39 +50,34 @@ * a debugger. A uninitialized field is not an error in itself but it * better to know it. */ -#ifndef THREAD_FILL_VALUE -#define THREAD_FILL_VALUE 0xFF +#ifndef CH_THREAD_FILL_VALUE +#define CH_THREAD_FILL_VALUE 0xFF #endif +#define __QUOTE_THIS(p) #p + #if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) /** * @brief Trace buffer record. */ typedef struct { - void *cse_wtobjp; /**< @brief Object where going to - sleep. */ - systime_t cse_time; /**< @brief Time of the switch - event. */ - uint16_t cse_state: 4; /**< @brief Switched out thread - state. */ - uint16_t cse_tid: 12; /**< @brief Switched in thread id. */ -} CtxSwcEvent; + systime_t se_time; /**< @brief Time of the switch event. */ + Thread *se_tp; /**< @brief Switched in thread. */ + void *se_wtobjp; /**< @brief Object where going to sleep.*/ + uint8_t se_state; /**< @brief Switched out thread state. */ +} ch_swc_event_t; /** * @brief Trace buffer header. */ typedef struct { - unsigned tb_size; /**< @brief Trace buffer size - (entries). */ - CtxSwcEvent *tb_ptr; /**< @brief Pointer to the ring buffer - front. */ + unsigned tb_size; /**< @brief Trace buffer size (entries).*/ + ch_swc_event_t *tb_ptr; /**< @brief Pointer to the buffer front.*/ /** @brief Ring buffer.*/ - CtxSwcEvent tb_buffer[TRACE_BUFFER_SIZE]; -} TraceBuffer; + ch_swc_event_t tb_buffer[CH_TRACE_BUFFER_SIZE]; +} ch_trace_buffer_t; #endif /* CH_DBG_ENABLE_TRACE */ -#define __QUOTE_THIS(p) #p - #if CH_DBG_ENABLE_CHECKS || defined(__DOXYGEN__) /** * @brief Function parameter check. @@ -150,12 +145,12 @@ typedef struct { extern "C" { #endif #if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) - extern TraceBuffer trace_buffer; + extern ch_trace_buffer_t ch_dbg_trace_buffer; void _trace_init(void); void chDbgTrace(Thread *otp); #endif #if CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || CH_DBG_ENABLE_STACK_CHECK - extern char *panic_msg; + extern char *ch_dbg_panic_msg; void chDbgPanic(char *msg); #endif #ifdef __cplusplus -- cgit v1.2.3 From fbdd64538eb54452fd320e20eaba2fb094874a3e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 10 Jul 2011 08:45:36 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3144 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 419ad001c..2fb3b2385 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -145,12 +145,12 @@ typedef struct { extern "C" { #endif #if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) - extern ch_trace_buffer_t ch_dbg_trace_buffer; + extern ch_trace_buffer_t dbg_trace_buffer; void _trace_init(void); void chDbgTrace(Thread *otp); #endif #if CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || CH_DBG_ENABLE_STACK_CHECK - extern char *ch_dbg_panic_msg; + extern char *dbg_panic_msg; void chDbgPanic(char *msg); #endif #ifdef __cplusplus -- cgit v1.2.3 From 0c276798fd9ed7c2d91abd54d8fb2f3a20147130 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 1 Aug 2011 14:33:04 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3188 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 2fb3b2385..b2edf176e 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -90,13 +90,15 @@ typedef struct { * * @api */ +#if !defined(chDbgCheck) #define chDbgCheck(c, func) { \ if (!(c)) \ - chDbgPanic(__QUOTE_THIS(func)"(), line "__QUOTE_THIS(__LINE__)); \ + chDbgPanic(__QUOTE_THIS(func)"()"); \ } +#endif /* !defined(chDbgCheck) */ #else /* !CH_DBG_ENABLE_CHECKS */ #define chDbgCheck(c, func) { \ - (void)(c), (void)__QUOTE_THIS(func)"(), line "__QUOTE_THIS(__LINE__); \ + (void)(c), (void)__QUOTE_THIS(func)"()"; \ } #endif /* !CH_DBG_ENABLE_CHECKS */ @@ -118,10 +120,12 @@ typedef struct { * * @api */ +#if !defined(chDbgAssert) #define chDbgAssert(c, m, r) { \ if (!(c)) \ chDbgPanic(m); \ } +#endif /* !defined(chDbgAssert) */ #else /* !CH_DBG_ENABLE_ASSERTS */ #define chDbgAssert(c, m, r) {(void)(c);} #endif /* !CH_DBG_ENABLE_ASSERTS */ -- cgit v1.2.3 From b9933c2089f5f0cd93738ae9081c45fcf3df54b7 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 11 Aug 2011 17:51:37 +0000 Subject: Implemented system state checker debug option, remove the option CH_USE_NESTED_LOCKS. Documentation improvements and fixes. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3221 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 101 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 20 deletions(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index b2edf176e..3bfadb750 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -29,15 +29,31 @@ #ifndef _CHDEBUG_H_ #define _CHDEBUG_H_ +#if CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || \ + CH_DBG_ENABLE_STACK_CHECK || CH_DBG_SYSTEM_STATE_CHECK +#define CH_DBG_ENABLED TRUE +#else +#define CH_DBG_ENABLED FALSE +#endif + +#define __QUOTE_THIS(p) #p + +/*===========================================================================*/ /** - * @brief Trace buffer entries. + * @name Debug related settings + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Trace buffer entries. */ #ifndef CH_TRACE_BUFFER_SIZE #define CH_TRACE_BUFFER_SIZE 64 #endif /** - * @brief Fill value for thread stack area in debug mode. + * @brief Fill value for thread stack area in debug mode. */ #ifndef CH_STACK_FILL_VALUE #define CH_STACK_FILL_VALUE 0x55 @@ -54,11 +70,31 @@ #define CH_THREAD_FILL_VALUE 0xFF #endif -#define __QUOTE_THIS(p) #p +/** @} */ + +/*===========================================================================*/ +/* System state checker related code and variables. */ +/*===========================================================================*/ + +#if !CH_DBG_SYSTEM_STATE_CHECK +#define dbg_check_disable() +#define dbg_check_suspend() +#define dbg_check_enable() +#define dbg_check_lock() +#define dbg_check_unlock() +#define dbg_check_lock_from_isr() +#define dbg_check_unlock_from_isr() +#define dbg_check_enter_isr() +#define dbg_check_leave_isr() +#endif + +/*===========================================================================*/ +/* Trace related structures and macros. */ +/*===========================================================================*/ #if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) /** - * @brief Trace buffer record. + * @brief Trace buffer record. */ typedef struct { systime_t se_time; /**< @brief Time of the switch event. */ @@ -68,7 +104,7 @@ typedef struct { } ch_swc_event_t; /** - * @brief Trace buffer header. + * @brief Trace buffer header. */ typedef struct { unsigned tb_size; /**< @brief Trace buffer size (entries).*/ @@ -76,9 +112,25 @@ typedef struct { /** @brief Ring buffer.*/ ch_swc_event_t tb_buffer[CH_TRACE_BUFFER_SIZE]; } ch_trace_buffer_t; + +#if !defined(__DOXYGEN__) +extern ch_trace_buffer_t dbg_trace_buffer; +#endif + #endif /* CH_DBG_ENABLE_TRACE */ +#if !CH_DBG_ENABLE_TRACE +/* When the trace feature is disabled this function is replaced by an empty + macro.*/ +#define dbg_trace(otp) +#endif + +/*===========================================================================*/ +/* Parameters checking related macros. */ +/*===========================================================================*/ + #if CH_DBG_ENABLE_CHECKS || defined(__DOXYGEN__) + /** * @brief Function parameter check. * @details If the condition check fails then the kernel panics and halts. @@ -102,6 +154,10 @@ typedef struct { } #endif /* !CH_DBG_ENABLE_CHECKS */ +/*===========================================================================*/ +/* Assertions related macros. */ +/*===========================================================================*/ + #if CH_DBG_ENABLE_ASSERTS || defined(__DOXYGEN__) /** * @brief Condition assertion. @@ -130,37 +186,42 @@ typedef struct { #define chDbgAssert(c, m, r) {(void)(c);} #endif /* !CH_DBG_ENABLE_ASSERTS */ -#if !(CH_DBG_ENABLE_ASSERTS || \ - CH_DBG_ENABLE_CHECKS || \ - CH_DBG_ENABLE_STACK_CHECK) +extern char *dbg_panic_msg; + +/*===========================================================================*/ +/* Panic related macros. */ +/*===========================================================================*/ + +#if !CH_DBG_ENABLED /* When the debug features are disabled this function is replaced by an empty macro.*/ #define chDbgPanic(msg) {} #endif -#if !CH_DBG_ENABLE_TRACE -/* When the trace feature is disabled this function is replaced by an empty - macro.*/ -#define chDbgTrace(otp) {} -#endif - -#if !defined(__DOXYGEN__) #ifdef __cplusplus extern "C" { #endif +#if CH_DBG_SYSTEM_STATE_CHECK + void dbg_check_disable(void); + void dbg_check_suspend(void); + void dbg_check_enable(void); + void dbg_check_lock(void); + void dbg_check_unlock(void); + void dbg_check_lock_from_isr(void); + void dbg_check_unlock_from_isr(void); + void dbg_check_enter_isr(void); + void dbg_check_leave_isr(void); +#endif #if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) - extern ch_trace_buffer_t dbg_trace_buffer; void _trace_init(void); - void chDbgTrace(Thread *otp); + void dbg_trace(Thread *otp); #endif -#if CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || CH_DBG_ENABLE_STACK_CHECK - extern char *dbg_panic_msg; +#if CH_DBG_ENABLED void chDbgPanic(char *msg); #endif #ifdef __cplusplus } #endif -#endif /* !defined(__DOXYGEN__) */ #endif /* _CHDEBUG_H_ */ -- cgit v1.2.3 From 43752ee8d132fc57028a9ff15156c5bfcd81c013 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 12 Aug 2011 11:10:19 +0000 Subject: Extended state check to all kernel I-class and s-class APIs, corrected some test cases where call protocol rules were not strictly observerd. No the whole test suite pass with the state checker enabled. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3223 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 3bfadb750..f3bf6b026 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -86,6 +86,8 @@ #define dbg_check_unlock_from_isr() #define dbg_check_enter_isr() #define dbg_check_leave_isr() +#define chDbgCheckClassI(); +#define chDbgCheckClassS(); #endif /*===========================================================================*/ @@ -211,6 +213,8 @@ extern "C" { void dbg_check_unlock_from_isr(void); void dbg_check_enter_isr(void); void dbg_check_leave_isr(void); + void chDbgCheckClassI(void); + void chDbgCheckClassS(void); #endif #if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) void _trace_init(void); -- cgit v1.2.3 From c9be79def630f153b0b2d28e905939c15743f989 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 23 Aug 2011 10:09:08 +0000 Subject: Kernel documentation fixes and improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3251 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index f3bf6b026..d11eb2eb2 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -132,7 +132,10 @@ extern ch_trace_buffer_t dbg_trace_buffer; /*===========================================================================*/ #if CH_DBG_ENABLE_CHECKS || defined(__DOXYGEN__) - +/** + * @name Macro Functions + * @{ + */ /** * @brief Function parameter check. * @details If the condition check fails then the kernel panics and halts. @@ -150,6 +153,7 @@ extern ch_trace_buffer_t dbg_trace_buffer; chDbgPanic(__QUOTE_THIS(func)"()"); \ } #endif /* !defined(chDbgCheck) */ +/** @} */ #else /* !CH_DBG_ENABLE_CHECKS */ #define chDbgCheck(c, func) { \ (void)(c), (void)__QUOTE_THIS(func)"()"; \ @@ -161,6 +165,10 @@ extern ch_trace_buffer_t dbg_trace_buffer; /*===========================================================================*/ #if CH_DBG_ENABLE_ASSERTS || defined(__DOXYGEN__) +/** + * @name Macro Functions + * @{ + */ /** * @brief Condition assertion. * @details If the condition check fails then the kernel panics with the @@ -184,6 +192,7 @@ extern ch_trace_buffer_t dbg_trace_buffer; chDbgPanic(m); \ } #endif /* !defined(chDbgAssert) */ +/** @} */ #else /* !CH_DBG_ENABLE_ASSERTS */ #define chDbgAssert(c, m, r) {(void)(c);} #endif /* !CH_DBG_ENABLE_ASSERTS */ -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index d11eb2eb2..b899233e4 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From c6914081835f10258d873af8526ae405ffe5b25c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 17 Jun 2012 06:53:49 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4283 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index b899233e4..24dce243e 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -77,6 +77,8 @@ /*===========================================================================*/ #if !CH_DBG_SYSTEM_STATE_CHECK +#define dbg_enter_lock() +#define dbg_leave_lock() #define dbg_check_disable() #define dbg_check_suspend() #define dbg_check_enable() @@ -88,6 +90,9 @@ #define dbg_check_leave_isr() #define chDbgCheckClassI(); #define chDbgCheckClassS(); +#else +#define dbg_enter_lock() (dbg_lock_cnt = 1) +#define dbg_leave_lock() (dbg_lock_cnt = 0) #endif /*===========================================================================*/ @@ -213,6 +218,8 @@ extern char *dbg_panic_msg; extern "C" { #endif #if CH_DBG_SYSTEM_STATE_CHECK + extern cnt_t dbg_isr_cnt; + extern cnt_t dbg_lock_cnt; void dbg_check_disable(void); void dbg_check_suspend(void); void dbg_check_enable(void); -- cgit v1.2.3 From 2abe2c479f15f9b4c66af007461c1ab2e2626ee0 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 23 Jun 2012 12:03:00 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4328 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 24dce243e..d4e257238 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -202,8 +202,6 @@ extern ch_trace_buffer_t dbg_trace_buffer; #define chDbgAssert(c, m, r) {(void)(c);} #endif /* !CH_DBG_ENABLE_ASSERTS */ -extern char *dbg_panic_msg; - /*===========================================================================*/ /* Panic related macros. */ /*===========================================================================*/ @@ -237,7 +235,8 @@ extern "C" { void dbg_trace(Thread *otp); #endif #if CH_DBG_ENABLED - void chDbgPanic(char *msg); + extern const char *dbg_panic_msg; + void chDbgPanic(const char *msg); #endif #ifdef __cplusplus } -- cgit v1.2.3 From 21fa4d3249f91c97a5fe4a958b681ea1352ff5df Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 3 Jul 2012 18:23:54 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4391 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index d4e257238..358e7b04d 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -153,15 +153,15 @@ extern ch_trace_buffer_t dbg_trace_buffer; * @api */ #if !defined(chDbgCheck) -#define chDbgCheck(c, func) { \ - if (!(c)) \ - chDbgPanic(__QUOTE_THIS(func)"()"); \ +#define chDbgCheck(c, func) { \ + if (!(c)) \ + chDbgPanic(__QUOTE_THIS(func)"()"); \ } #endif /* !defined(chDbgCheck) */ /** @} */ #else /* !CH_DBG_ENABLE_CHECKS */ -#define chDbgCheck(c, func) { \ - (void)(c), (void)__QUOTE_THIS(func)"()"; \ +#define chDbgCheck(c, func) { \ + (void)(c), (void)__QUOTE_THIS(func)"()"; \ } #endif /* !CH_DBG_ENABLE_CHECKS */ @@ -192,9 +192,9 @@ extern ch_trace_buffer_t dbg_trace_buffer; * @api */ #if !defined(chDbgAssert) -#define chDbgAssert(c, m, r) { \ - if (!(c)) \ - chDbgPanic(m); \ +#define chDbgAssert(c, m, r) { \ + if (!(c)) \ + chDbgPanic(m); \ } #endif /* !defined(chDbgAssert) */ /** @} */ -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 358e7b04d..1d9b96e86 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From c86a83d45a588d43c7a0fa546c581b166a952540 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 4 Apr 2013 09:45:32 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5544 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chdebug.h') diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 1d9b96e86..4a75474e2 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -142,7 +142,7 @@ extern ch_trace_buffer_t dbg_trace_buffer; * @{ */ /** - * @brief Function parameter check. + * @brief Function parameters check. * @details If the condition check fails then the kernel panics and halts. * @note The condition is tested only if the @p CH_DBG_ENABLE_CHECKS switch * is specified in @p chconf.h else the macro does nothing. -- cgit v1.2.3