aboutsummaryrefslogtreecommitdiffstats
path: root/src/chdebug.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/chdebug.c')
-rw-r--r--src/chdebug.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/chdebug.c b/src/chdebug.c
index 4a16e2d2a..63d5090ee 100644
--- a/src/chdebug.c
+++ b/src/chdebug.c
@@ -26,58 +26,57 @@
#include <ch.h>
-#if CH_USE_DEBUG
-
-char *panicmsg;
+#if CH_DBG_ENABLE_TRACE
+/**
+ * @brief Public trace buffer.
+ */
+TraceBuffer trace_buffer;
/**
- * @brief Debug subsystem initialization.
+ * @brief Trace circular buffer subsystem initialization.
*/
-void debug_init(void) {
+void trace_init(void) {
-#if CH_USE_TRACE
- dbgtb.tb_size = TRACE_BUFFER_SIZE;
- dbgtb.tb_ptr = &dbgtb.tb_buffer[0];
-#endif
+ trace_buffer.tb_size = TRACE_BUFFER_SIZE;
+ trace_buffer.tb_ptr = &trace_buffer.tb_buffer[0];
}
-
/**
- * @brief Prints a panic message on the console/debugger and then halts the
- * system.
+ * @brief Inserts in the circular debug trace buffer a context switch record.
*
- * @param msg the pointer to the message string
+ * @param otp the thread being switched out
+ * @param ntp the thread to be resumed
*/
-void chDbgPanic(char *msg) {
+void chDbgTrace(Thread *otp, Thread *ntp) {
- panicmsg = msg;
- chSysPuts("PANIC: ");
- chSysPuts(msg);
- chSysHalt();
+ trace_buffer.tb_ptr->cse_wtobjp = otp->p_wtobjp;
+ trace_buffer.tb_ptr->cse_time = chSysGetTime();
+ trace_buffer.tb_ptr->cse_state = otp->p_state;
+ trace_buffer.tb_ptr->cse_tid = (unsigned)ntp >> 4;
+ if (++trace_buffer.tb_ptr >= &trace_buffer.tb_buffer[TRACE_BUFFER_SIZE])
+ trace_buffer.tb_ptr = &trace_buffer.tb_buffer[0];
}
+#endif /* CH_DBG_ENABLE_TRACE */
-#if CH_USE_TRACE
+#if CH_DBG_ENABLE_ASSERTS
/**
- * @brief Public trace buffer.
+ * @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.
*/
-TraceBuffer dbgtb;
+char *panic_msg;
/**
- * @brief Inserts in the circular debug trace buffer a context switch record.
+ * @brief Prints a panic message on the console and then halts the system.
*
- * @param otp the thread being switched out
- * @param ntp the thread to be resumed
+ * @param msg the pointer to the panic message string
*/
-void chDbgTrace(Thread *otp, Thread *ntp) {
+void chDbgPanic(char *msg) {
- dbgtb.tb_ptr->cse_wtobjp = otp->p_wtobjp;
- dbgtb.tb_ptr->cse_time = chSysGetTime();
- dbgtb.tb_ptr->cse_state = otp->p_state;
- dbgtb.tb_ptr->cse_tid = (unsigned)ntp >> 4;
- if (++dbgtb.tb_ptr >= &dbgtb.tb_buffer[TRACE_BUFFER_SIZE])
- dbgtb.tb_ptr = &dbgtb.tb_buffer[0];
+ panic_msg = msg;
+ chSysPuts("PANIC: ");
+ chSysPuts(msg);
+ chSysHalt();
}
-#endif /* CH_USE_TRACE */
-
-#endif /* CH_USE_DEBUG */
+#endif /* CH_DBG_ENABLE_ASSERTS */
/** @} */