git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/stable_2.2.x@3298 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
c651b12d63
commit
d241a7cd34
|
@ -36,17 +36,17 @@
|
|||
#define _CHDEBUG_H_
|
||||
|
||||
/**
|
||||
* @brief Trace buffer entries.
|
||||
* @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.
|
||||
* @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
|
||||
|
||||
/**
|
||||
|
@ -56,35 +56,30 @@
|
|||
* 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
|
||||
|
||||
#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Trace buffer record.
|
||||
* @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.
|
||||
* @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
|
||||
|
@ -101,13 +96,16 @@ 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 */
|
||||
|
||||
|
@ -129,10 +127,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 */
|
||||
|
@ -148,7 +148,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) {}
|
||||
#define dbg_trace(otp) {}
|
||||
#endif
|
||||
|
||||
#if !defined(__DOXYGEN__)
|
||||
|
@ -156,12 +156,12 @@ typedef struct {
|
|||
extern "C" {
|
||||
#endif
|
||||
#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
|
||||
extern TraceBuffer trace_buffer;
|
||||
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 *panic_msg;
|
||||
extern char *dbg_panic_msg;
|
||||
void chDbgPanic(char *msg);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
/**
|
||||
* @brief Public trace buffer.
|
||||
*/
|
||||
TraceBuffer trace_buffer;
|
||||
ch_trace_buffer_t dbg_trace_buffer;
|
||||
|
||||
/**
|
||||
* @brief Trace circular buffer subsystem initialization.
|
||||
|
@ -54,8 +54,8 @@ TraceBuffer trace_buffer;
|
|||
*/
|
||||
void trace_init(void) {
|
||||
|
||||
trace_buffer.tb_size = TRACE_BUFFER_SIZE;
|
||||
trace_buffer.tb_ptr = &trace_buffer.tb_buffer[0];
|
||||
dbg_trace_buffer.tb_size = CH_TRACE_BUFFER_SIZE;
|
||||
dbg_trace_buffer.tb_ptr = &dbg_trace_buffer.tb_buffer[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,14 +65,15 @@ void trace_init(void) {
|
|||
*
|
||||
* @notapi
|
||||
*/
|
||||
void chDbgTrace(Thread *otp) {
|
||||
void dbg_trace(Thread *otp) {
|
||||
|
||||
trace_buffer.tb_ptr->cse_wtobjp = otp->p_u.wtobjp;
|
||||
trace_buffer.tb_ptr->cse_time = chTimeNow();
|
||||
trace_buffer.tb_ptr->cse_state = otp->p_state;
|
||||
trace_buffer.tb_ptr->cse_tid = (unsigned)currp >> 6;
|
||||
if (++trace_buffer.tb_ptr >= &trace_buffer.tb_buffer[TRACE_BUFFER_SIZE])
|
||||
trace_buffer.tb_ptr = &trace_buffer.tb_buffer[0];
|
||||
dbg_trace_buffer.tb_ptr->se_time = chTimeNow();
|
||||
dbg_trace_buffer.tb_ptr->se_tp = currp;
|
||||
dbg_trace_buffer.tb_ptr->se_wtobjp = otp->p_u.wtobjp;
|
||||
dbg_trace_buffer.tb_ptr->se_state = (uint8_t)otp->p_state;
|
||||
if (++dbg_trace_buffer.tb_ptr >=
|
||||
&dbg_trace_buffer.tb_buffer[CH_TRACE_BUFFER_SIZE])
|
||||
dbg_trace_buffer.tb_ptr = &dbg_trace_buffer.tb_buffer[0];
|
||||
}
|
||||
#endif /* CH_DBG_ENABLE_TRACE */
|
||||
|
||||
|
@ -81,10 +82,9 @@ void chDbgTrace(Thread *otp) {
|
|||
/**
|
||||
* @brief Pointer to the panic message.
|
||||
* @details This pointer is meant to be accessed through the debugger, it is
|
||||
* written once and then the system is halted. This variable can be
|
||||
* set to @p NULL if the halt is caused by a stack overflow.
|
||||
* written once and then the system is halted.
|
||||
*/
|
||||
char *panic_msg;
|
||||
char *dbg_panic_msg;
|
||||
|
||||
/**
|
||||
* @brief Prints a panic message on the console and then halts the system.
|
||||
|
@ -93,7 +93,7 @@ char *panic_msg;
|
|||
*/
|
||||
void chDbgPanic(char *msg) {
|
||||
|
||||
panic_msg = msg;
|
||||
dbg_panic_msg = msg;
|
||||
chSysHalt();
|
||||
}
|
||||
#endif /* CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || CH_DBG_ENABLE_STACK_CHECK */
|
||||
|
|
|
@ -138,10 +138,10 @@ Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size,
|
|||
#if CH_DBG_FILL_THREADS
|
||||
_thread_memfill((uint8_t *)wsp,
|
||||
(uint8_t *)wsp + sizeof(Thread),
|
||||
THREAD_FILL_VALUE);
|
||||
CH_THREAD_FILL_VALUE);
|
||||
_thread_memfill((uint8_t *)wsp + sizeof(Thread),
|
||||
(uint8_t *)wsp + size,
|
||||
STACK_FILL_VALUE);
|
||||
CH_STACK_FILL_VALUE);
|
||||
#endif
|
||||
|
||||
chSysLock();
|
||||
|
@ -189,10 +189,10 @@ Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
|
|||
#if CH_DBG_FILL_THREADS
|
||||
_thread_memfill((uint8_t *)wsp,
|
||||
(uint8_t *)wsp + sizeof(Thread),
|
||||
THREAD_FILL_VALUE);
|
||||
CH_THREAD_FILL_VALUE);
|
||||
_thread_memfill((uint8_t *)wsp + sizeof(Thread),
|
||||
(uint8_t *)wsp + mp->mp_object_size,
|
||||
STACK_FILL_VALUE);
|
||||
CH_STACK_FILL_VALUE);
|
||||
#endif
|
||||
|
||||
chSysLock();
|
||||
|
|
|
@ -119,7 +119,7 @@ void chSchGoSleepS(tstate_t newstate) {
|
|||
#endif
|
||||
setcurrp(fifo_remove(&rlist.r_queue));
|
||||
currp->p_state = THD_STATE_CURRENT;
|
||||
chDbgTrace(otp);
|
||||
dbg_trace(otp);
|
||||
chSysSwitchI(currp, otp);
|
||||
}
|
||||
#endif /* !defined(PORT_OPTIMIZED_GOSLEEPS) */
|
||||
|
@ -228,7 +228,7 @@ void chSchWakeupS(Thread *ntp, msg_t msg) {
|
|||
#endif
|
||||
setcurrp(ntp);
|
||||
ntp->p_state = THD_STATE_CURRENT;
|
||||
chDbgTrace(otp);
|
||||
dbg_trace(otp);
|
||||
chSysSwitchI(ntp, otp);
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ void chSchDoRescheduleI(void) {
|
|||
setcurrp(fifo_remove(&rlist.r_queue));
|
||||
currp->p_state = THD_STATE_CURRENT;
|
||||
chSchReadyI(otp);
|
||||
chDbgTrace(otp);
|
||||
dbg_trace(otp);
|
||||
chSysSwitchI(currp, otp);
|
||||
}
|
||||
#endif /* !defined(PORT_OPTIMIZED_DORESCHEDULEI) */
|
||||
|
|
|
@ -187,10 +187,10 @@ Thread *chThdCreateStatic(void *wsp, size_t size,
|
|||
#if CH_DBG_FILL_THREADS
|
||||
_thread_memfill((uint8_t *)wsp,
|
||||
(uint8_t *)wsp + sizeof(Thread),
|
||||
THREAD_FILL_VALUE);
|
||||
CH_THREAD_FILL_VALUE);
|
||||
_thread_memfill((uint8_t *)wsp + sizeof(Thread),
|
||||
(uint8_t *)wsp + size,
|
||||
STACK_FILL_VALUE);
|
||||
CH_STACK_FILL_VALUE);
|
||||
#endif
|
||||
chSysLock();
|
||||
chSchWakeupS(tp = chThdCreateI(wsp, size, prio, pf, arg), RDY_OK);
|
||||
|
|
|
@ -138,7 +138,7 @@ void PendSVVector(void) {
|
|||
/* Set the round-robin time quantum.*/
|
||||
rlist.r_preempt = CH_TIME_QUANTUM;
|
||||
#endif
|
||||
chDbgTrace(otp);
|
||||
dbg_trace(otp);
|
||||
sp_thd = ntp->p_ctx.r13;
|
||||
|
||||
POP_CONTEXT(sp_thd)
|
||||
|
|
|
@ -69,6 +69,9 @@
|
|||
*****************************************************************************
|
||||
|
||||
*** 2.2.7 ***
|
||||
- NEW: The debug macros chDbgCheck() and chDbgAssert() now can be externally
|
||||
redefined. The macro chDbgCheck() no more includes the line number in the
|
||||
description because incompatibility with the Cosmic compiler.
|
||||
- NEW: Added a new functionality to the registry subsystem, now it is possible
|
||||
to associate a name to the threads using chRegSetThreadName. The main and
|
||||
idle threads have their name assigned by default.
|
||||
|
|
Loading…
Reference in New Issue