ChibiOS  21.6.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_READY   1U
 
#define CH_TRACE_TYPE_SWITCH   2U
 
#define CH_TRACE_TYPE_ISR_ENTER   3U
 
#define CH_TRACE_TYPE_ISR_LEAVE   4U
 
#define CH_TRACE_TYPE_HALT   5U
 
#define CH_TRACE_TYPE_USER   6U
 

Events to trace

#define CH_DBG_TRACE_MASK_DISABLED   255U
 
#define CH_DBG_TRACE_MASK_NONE   0U
 
#define CH_DBG_TRACE_MASK_READY   1U
 
#define CH_DBG_TRACE_MASK_SWITCH   2U
 
#define CH_DBG_TRACE_MASK_ISR   4U
 
#define CH_DBG_TRACE_MASK_HALT   8U
 
#define CH_DBG_TRACE_MASK_USER   16U
 
#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  trace_event_t
 Trace buffer record. More...
 
struct  trace_buffer_t
 Trace buffer header. More...
 

Functions

static NOINLINE void trace_next (os_instance_t *oip)
 Writes a time stamp and increases the trace buffer pointer. More...
 
void __trace_object_init (trace_buffer_t *tbp)
 Circular trace buffer initialization. More...
 
void __trace_ready (thread_t *tp, msg_t msg)
 Inserts in the circular debug trace buffer a ready record. 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 chTraceWriteI (void *up1, void *up2)
 Adds an user trace record to the trace buffer. More...
 
void chTraceWrite (void *up1, void *up2)
 Adds an user trace record to the trace buffer. More...
 
void chTraceSuspendI (uint16_t mask)
 Suspends one or more trace events. More...
 
void chTraceSuspend (uint16_t mask)
 Suspends one or more trace events. More...
 
void chTraceResumeI (uint16_t mask)
 Resumes one or more trace events. More...
 
void chTraceResume (uint16_t mask)
 Resumes one or more trace events. More...
 

Macro Definition Documentation

◆ CH_DBG_TRACE_MASK

#define CH_DBG_TRACE_MASK   CH_DBG_TRACE_MASK_DISABLED

Trace buffer entries.

Definition at line 82 of file chtrace.h.

◆ CH_DBG_TRACE_BUFFER_SIZE

#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 91 of file chtrace.h.

Function Documentation

◆ trace_next()

static NOINLINE void trace_next ( os_instance_t oip)
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 trace_buffer_t::buffer, CH_CFG_TRACE_HOOK, CH_DBG_TRACE_BUFFER_SIZE, chSysGetRealtimeCounterX, chVTGetSystemTimeX, trace_buffer_t::ptr, trace_event_t::rtstamp, trace_event_t::time, and ch_os_instance::trace_buffer.

◆ __trace_object_init()

void __trace_object_init ( trace_buffer_t tbp)

Circular trace buffer initialization.

Note
Internal use only.
Parameters
[out]tbppointer to the trace_buffer_t structure
Function Class:
Not an API, this function is for internal use only.

Definition at line 88 of file chtrace.c.

References trace_buffer_t::suspended.

Referenced by chInstanceObjectInit().

◆ __trace_ready()

void __trace_ready ( thread_t tp,
msg_t  msg 
)

Inserts in the circular debug trace buffer a ready record.

Parameters
[in]tpthe thread that just become ready
[in]msgthe thread ready message
Function Class:
Not an API, this function is for internal use only.

Definition at line 107 of file chtrace.c.

References currcore, trace_buffer_t::suspended, and ch_os_instance::trace_buffer.

Referenced by __sch_ready_ahead(), and __sch_ready_behind().

◆ __trace_switch()

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 127 of file chtrace.c.

References currcore, trace_buffer_t::suspended, and ch_os_instance::trace_buffer.

◆ __trace_isr_enter()

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 146 of file chtrace.c.

References currcore, trace_buffer_t::suspended, and ch_os_instance::trace_buffer.

◆ __trace_isr_leave()

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 166 of file chtrace.c.

References currcore, trace_buffer_t::suspended, and ch_os_instance::trace_buffer.

◆ __trace_halt()

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 186 of file chtrace.c.

References currcore, trace_buffer_t::suspended, and ch_os_instance::trace_buffer.

Referenced by chSysHalt().

◆ chTraceWriteI()

void chTraceWriteI ( 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 205 of file chtrace.c.

References currcore.

Referenced by chTraceWrite().

◆ chTraceWrite()

void chTraceWrite ( 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 227 of file chtrace.c.

References chSysLock, chSysUnlock, and chTraceWriteI().

Here is the call graph for this function:

◆ chTraceSuspendI()

void chTraceSuspendI ( 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 241 of file chtrace.c.

Referenced by chTraceSuspend().

◆ chTraceSuspend()

void chTraceSuspend ( 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 255 of file chtrace.c.

References chSysLock, chSysUnlock, and chTraceSuspendI().

Here is the call graph for this function:

◆ chTraceResumeI()

void chTraceResumeI ( 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 269 of file chtrace.c.

Referenced by chTraceResume().

◆ chTraceResume()

void chTraceResume ( 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 283 of file chtrace.c.

References chSysLock, chSysUnlock, and chTraceResumeI().

Here is the call graph for this function: