ChibiOS/RT  5.1.0
Tracing
Collaboration diagram for Tracing:

Detailed Description

System events tracing service.

Trace record types

#define CH_TRACE_TYPE_UNUSED   0U
 
#define CH_TRACE_TYPE_SWITCH   1U
 
#define CH_TRACE_TYPE_ISR_ENTER   2U
 
#define CH_TRACE_TYPE_ISR_LEAVE   3U
 
#define CH_TRACE_TYPE_HALT   4U
 
#define CH_TRACE_TYPE_USER   5U
 

Events to trace

#define CH_DBG_TRACE_MASK_DISABLED   255U
 
#define CH_DBG_TRACE_MASK_NONE   0U
 
#define CH_DBG_TRACE_MASK_SWITCH   1U
 
#define CH_DBG_TRACE_MASK_ISR   2U
 
#define CH_DBG_TRACE_MASK_HALT   4U
 
#define CH_DBG_TRACE_MASK_USER   8U
 
#define CH_DBG_TRACE_MASK_SLOW
 
#define CH_DBG_TRACE_MASK_ALL
 

Debug related settings

#define CH_DBG_TRACE_MASK   CH_DBG_TRACE_MASK_DISABLED
 Trace buffer entries. More...
 
#define CH_DBG_TRACE_BUFFER_SIZE   128
 Trace buffer entries. More...
 

Data Structures

struct  ch_trace_event_t
 Trace buffer record. More...
 
struct  ch_trace_buffer_t
 Trace buffer header. More...
 

Functions

static NOINLINE void trace_next (void)
 Writes a time stamp and increases the trace buffer pointer. More...
 
void _trace_init (void)
 Trace circular buffer subsystem initialization. More...
 
void _trace_switch (thread_t *ntp, thread_t *otp)
 Inserts in the circular debug trace buffer a context switch record. More...
 
void _trace_isr_enter (const char *isr)
 Inserts in the circular debug trace buffer an ISR-enter record. More...
 
void _trace_isr_leave (const char *isr)
 Inserts in the circular debug trace buffer an ISR-leave record. More...
 
void _trace_halt (const char *reason)
 Inserts in the circular debug trace buffer an halt record. More...
 
void chDbgWriteTraceI (void *up1, void *up2)
 Adds an user trace record to the trace buffer. More...
 
void chDbgWriteTrace (void *up1, void *up2)
 Adds an user trace record to the trace buffer. More...
 
void chDbgSuspendTraceI (uint16_t mask)
 Suspends one or more trace events. More...
 
void chDbgSuspendTrace (uint16_t mask)
 Suspends one or more trace events. More...
 
void chDbgResumeTraceI (uint16_t mask)
 Resumes one or more trace events. More...
 
void chDbgResumeTrace (uint16_t mask)
 Resumes one or more trace events. More...
 

Macro Definition Documentation

#define CH_DBG_TRACE_MASK   CH_DBG_TRACE_MASK_DISABLED

Trace buffer entries.

Definition at line 78 of file chtrace.h.

#define CH_DBG_TRACE_BUFFER_SIZE   128

Trace buffer entries.

Note
The trace buffer is only allocated if CH_DBG_TRACE_MASK is different from CH_DBG_TRACE_MASK_DISABLED.

Definition at line 87 of file chtrace.h.

Referenced by _trace_init(), and trace_next().

Function Documentation

static NOINLINE void trace_next ( void  )
static

Writes a time stamp and increases the trace buffer pointer.

Function Class:
Not an API, this function is for internal use only.

Definition at line 57 of file chtrace.c.

References ch_trace_buffer_t::buffer, ch, CH_CFG_TRACE_HOOK, CH_DBG_TRACE_BUFFER_SIZE, chSysGetRealtimeCounterX, chVTGetSystemTimeX(), ch_system::dbg, ch_trace_buffer_t::ptr, ch_trace_event_t::rtstamp, ch_trace_event_t::time, and ch_system_debug::trace_buffer.

Referenced by _trace_halt(), _trace_isr_enter(), _trace_isr_leave(), _trace_switch(), and chDbgWriteTraceI().

Here is the call graph for this function:

void _trace_init ( void  )

Trace circular buffer subsystem initialization.

Note
Internal use only.

Definition at line 85 of file chtrace.c.

References ch_trace_buffer_t::buffer, ch, CH_DBG_TRACE_BUFFER_SIZE, ch_system::dbg, ch_trace_buffer_t::ptr, ch_trace_buffer_t::size, ch_trace_buffer_t::suspended, ch_system_debug::trace_buffer, and ch_trace_event_t::type.

Referenced by chSysInit().

void _trace_switch ( thread_t ntp,
thread_t otp 
)

Inserts in the circular debug trace buffer a context switch record.

Parameters
[in]ntpthe thread being switched in
[in]otpthe thread being switched out
Function Class:
Not an API, this function is for internal use only.

Definition at line 104 of file chtrace.c.

References ch, currp, ch_system::dbg, ch_trace_buffer_t::ptr, ch_trace_event_t::state, ch_thread::state, ch_trace_buffer_t::suspended, ch_trace_event_t::sw, ch_system_debug::trace_buffer, trace_next(), ch_trace_event_t::type, ch_thread::u, and ch_thread::wtobjp.

Here is the call graph for this function:

void _trace_isr_enter ( const char *  isr)

Inserts in the circular debug trace buffer an ISR-enter record.

Parameters
[in]isrname of the isr
Function Class:
Not an API, this function is for internal use only.

Definition at line 124 of file chtrace.c.

References ch, ch_system::dbg, ch_trace_event_t::isr, ch_trace_buffer_t::ptr, ch_trace_event_t::state, ch_trace_buffer_t::suspended, ch_system_debug::trace_buffer, trace_next(), and ch_trace_event_t::type.

Here is the call graph for this function:

void _trace_isr_leave ( const char *  isr)

Inserts in the circular debug trace buffer an ISR-leave record.

Parameters
[in]isrname of the isr
Function Class:
Not an API, this function is for internal use only.

Definition at line 143 of file chtrace.c.

References ch, ch_system::dbg, ch_trace_event_t::isr, ch_trace_buffer_t::ptr, ch_trace_event_t::state, ch_trace_buffer_t::suspended, ch_system_debug::trace_buffer, trace_next(), and ch_trace_event_t::type.

Here is the call graph for this function:

void _trace_halt ( const char *  reason)

Inserts in the circular debug trace buffer an halt record.

Parameters
[in]reasonthe halt error string
Function Class:
Not an API, this function is for internal use only.

Definition at line 162 of file chtrace.c.

References ch, ch_system::dbg, ch_trace_event_t::halt, ch_trace_buffer_t::ptr, ch_trace_event_t::state, ch_trace_buffer_t::suspended, ch_system_debug::trace_buffer, trace_next(), and ch_trace_event_t::type.

Referenced by chSysHalt().

Here is the call graph for this function:

void chDbgWriteTraceI ( void *  up1,
void *  up2 
)

Adds an user trace record to the trace buffer.

Parameters
[in]up1user parameter 1
[in]up2user parameter 2
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 180 of file chtrace.c.

References ch, chDbgCheckClassI(), ch_system::dbg, ch_trace_buffer_t::ptr, ch_trace_event_t::state, ch_trace_buffer_t::suspended, ch_system_debug::trace_buffer, trace_next(), ch_trace_event_t::type, and ch_trace_event_t::user.

Referenced by chDbgWriteTrace().

Here is the call graph for this function:

void chDbgWriteTrace ( void *  up1,
void *  up2 
)

Adds an user trace record to the trace buffer.

Parameters
[in]up1user parameter 1
[in]up2user parameter 2
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 201 of file chtrace.c.

References chDbgWriteTraceI(), chSysLock(), and chSysUnlock().

Here is the call graph for this function:

void chDbgSuspendTraceI ( uint16_t  mask)

Suspends one or more trace events.

Parameters
[in]maskmask of the trace events to be suspended
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 215 of file chtrace.c.

References ch, chDbgCheckClassI(), ch_system::dbg, ch_trace_buffer_t::suspended, and ch_system_debug::trace_buffer.

Referenced by chDbgSuspendTrace().

Here is the call graph for this function:

void chDbgSuspendTrace ( uint16_t  mask)

Suspends one or more trace events.

Parameters
[in]maskmask of the trace events to be suspended
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 229 of file chtrace.c.

References chDbgSuspendTraceI(), chSysLock(), and chSysUnlock().

Here is the call graph for this function:

void chDbgResumeTraceI ( uint16_t  mask)

Resumes one or more trace events.

Parameters
[in]maskmask of the trace events to be resumed
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 243 of file chtrace.c.

References ch, chDbgCheckClassI(), ch_system::dbg, ch_trace_buffer_t::suspended, and ch_system_debug::trace_buffer.

Referenced by chDbgResumeTrace().

Here is the call graph for this function:

void chDbgResumeTrace ( uint16_t  mask)

Resumes one or more trace events.

Parameters
[in]maskmask of the trace events to be resumed
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 257 of file chtrace.c.

References chDbgResumeTraceI(), chSysLock(), and chSysUnlock().

Here is the call graph for this function: