Percepio Trace Recorder v4.8.0.hotfix1
Loading...
Searching...
No Matches
trcRecorder.h
Go to the documentation of this file.
1/*
2 * Trace Recorder for Tracealyzer v4.8.0.hotfix1
3 * Copyright 2023 Percepio AB
4 * www.percepio.com
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9#ifndef TRC_RECORDER_H
10#define TRC_RECORDER_H
11
18#ifdef __cplusplus
19extern "C" {
20#endif
21
29#define TRC_ACKNOWLEDGED (0xABC99123)
30
31#include <trcDefines.h>
32#include <trcConfig.h>
33#include <trcKernelPortConfig.h>
34
35/* If TRC_CFG_RECORDER_MODE is not defined we assume there is no support
36 * for the classic snapshot mode and default to streaming mode where
37 * the new RingBuffer snapshot mode provides snapshot functionality.
38 */
39#ifndef TRC_CFG_RECORDER_MODE
40#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_STREAMING
41#endif
42
43/* Some types may be defined differently based on TRC_CFG_RECORDER_MODE */
44#include <trcTypes.h>
45
46#ifndef TRC_CFG_TEST_MODE
47#define TRC_CFG_TEST_MODE 0
48#endif
49
50#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)
51#include <trcSnapshotConfig.h>
52#include <trcKernelPortSnapshotConfig.h>
53
54/* Calls xTraceError if the _assert condition is false. For void functions,
55where no return value is to be provided. */
56#define TRC_ASSERT_VOID(_assert, _err) if (! (_assert)){ prvTraceError(_err); return; }
57
58/* Calls xTraceError if the _assert condition is false. For non-void functions,
59where a return value is to be provided. */
60#define TRC_ASSERT_RET(_assert, _err, _return) if (! (_assert)){ prvTraceError(_err); return _return; }
61
62typedef uint8_t traceUBChannel;
63typedef uint8_t traceObjectClass;
64
65#undef traceHandle
66#if (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1)
67typedef uint16_t traceHandle;
68#else /* (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1) */
69typedef uint8_t traceHandle;
70#endif /* (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1) */
71
72#undef TraceISRHandle_t
73#define TraceISRHandle_t traceHandle
74
75#include <trcHardwarePort.h>
76#include <trcKernelPort.h>
77
78/* Not yet available in snapshot mode */
79#define xTracePrintFormat0(_c, _f)
80#define xTracePrintFormat1(_c, _f, _p1)
81#define xTracePrintFormat2(_c, _f, _p1, _p2)
82#define xTracePrintFormat3(_c, _f, _p1, _p2, _p3)
83#define xTracePrintFormat4(_c, _f, _p1, _p2, _p3, _p4)
84#define vTraceConsoleChannelPrintF(fmt, ...) (void)
85#define xTraceConsoleChannelPrintF(fmt, ...) (void)
86#define prvTraceStoreEvent_None(...)
87#define prvTraceStoreEvent_Handle(...)
88#define prvTraceStoreEvent_Param(...)
89#define prvTraceStoreEvent_HandleParam(...)
90#define prvTraceStoreEvent_ParamParam(...)
91#define prvTraceStoreEvent_HandleParamParam(...)
92#define prvTraceStoreEvent_ParamParamParam(...)
93
94#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) */
95
96#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
97#include <trcStreamingConfig.h>
98#include <trcKernelPortStreamingConfig.h>
99
100/* Unless specified in trcConfig.h we assume this is a single core target */
101#ifndef TRC_CFG_CORE_COUNT
102#define TRC_CFG_CORE_COUNT 1
103#endif
104
105/* Unless specified in trcConfig.h we assume this is a single core target */
106#ifndef TRC_CFG_GET_CURRENT_CORE
107#define TRC_CFG_GET_CURRENT_CORE() 0
108#endif
109
110/* Unless specified in trcConfig.h or trcKernelPortConfig.h we assume
111 * GCC statement expressions aren't supported. */
112#ifndef TRC_CFG_USE_GCC_STATEMENT_EXPR
113#define TRC_CFG_USE_GCC_STATEMENT_EXPR 0
114#endif
115
116/* Backwards compatibility */
117#undef traceHandle
118#define traceHandle TraceISRHandle_t
119
120/* Maximum event size */
121#define TRC_MAX_BLOB_SIZE (16UL * sizeof(TraceUnsignedBaseType_t))
122
123/* Platform name length */
124#define TRC_PLATFORM_CFG_LENGTH 8UL
125
126/* Header size */
127#define TRC_HEADER_BUFFER_SIZE (sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint8_t) + sizeof(uint8_t) + (sizeof(char) * (TRC_PLATFORM_CFG_LENGTH)))
128
129typedef struct TraceHeaderBuffer /* Aligned */
130{
131 uint8_t buffer[TRC_HEADER_BUFFER_SIZE];
132} TraceHeaderBuffer_t;
133
134#include <trcHardwarePort.h>
135#include <trcKernelPort.h>
136#include <trcString.h>
137#include <trcStaticBuffer.h>
138#include <trcError.h>
139#include <trcEvent.h>
140#include <trcEventBuffer.h>
142#include <trcTimestamp.h>
143#include <trcEntryTable.h>
144#include <trcStreamPort.h>
145#include <trcISR.h>
146#include <trcTask.h>
147#include <trcObject.h>
148#include <trcPrint.h>
149#include <trcHeap.h>
150#include <trcExtension.h>
151#include <trcUtility.h>
152#include <trcStackMonitor.h>
154#include <trcDiagnostics.h>
155#include <trcAssert.h>
156#include <trcRunnable.h>
157#include <trcDependency.h>
158
159#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
160
161/* These includes offer functionality for Streaming mode only, but they are included here in order to avoid compilation errors */
162#include <trcInterval.h>
163#include <trcStateMachine.h>
164#include <trcCounter.h>
165
166#if (TRC_USE_TRACEALYZER_RECORDER == 1)
167
168/******************************************************************************/
169/*** Common API - both Snapshot and Streaming mode ****************************/
170/******************************************************************************/
171
186traceResult xTraceInitialize(void);
187
259traceResult xTraceEnable(uint32_t uiStartOption);
260
267traceResult xTraceDisable(void);
268
318void vTraceSetFilterGroup(uint16_t filterGroup);
319
340void vTraceSetFilterMask(uint16_t filterMask);
341
342#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)
343
344#include <stdarg.h>
345
351#define TRACE_GET_LOW16(value) ((uint16_t)((value) & 0x0000FFFF))
352
358#define TRACE_GET_HIGH16(value) ((uint16_t)(((value) >> 16) & 0x0000FFFF))
359
366#define TRACE_SET_LOW16(current, value) (((current) & 0xFFFF0000) | (value))
367
374#define TRACE_SET_HIGH16(current, value) (((current) & 0x0000FFFF) | (((uint32_t)(value)) << 16))
375
376#if defined (TRC_CFG_ENABLE_STACK_MONITOR) && (TRC_CFG_ENABLE_STACK_MONITOR == 1) && (TRC_CFG_SCHEDULING_ONLY == 0)
382void prvAddTaskToStackMonitor(void* task);
383
389void prvRemoveTaskFromStackMonitor(void* task);
390
394void prvReportStackUsage(void);
395
396#else /* defined (TRC_CFG_ENABLE_STACK_MONITOR) && (TRC_CFG_ENABLE_STACK_MONITOR == 1) && (TRC_CFG_SCHEDULING_ONLY == 0) */
397
398#define prvAddTaskToStackMonitor(task)
399#define prvRemoveTaskFromStackMonitor(task)
400#define prvReportStackUsage()
401
402#endif /* defined (TRC_CFG_ENABLE_STACK_MONITOR) && (TRC_CFG_ENABLE_STACK_MONITOR == 1) && (TRC_CFG_SCHEDULING_ONLY == 0) */
403
407traceHandle xTraceSetISRProperties(const char* szName, uint8_t uiPriority);
408
427traceResult xTraceISRRegister(const char* szName, uint32_t uiPriority, TraceISRHandle_t* pxISRHandle);
428
453traceResult xTraceISRBegin(TraceISRHandle_t xHandle);
454
455#define vTraceStoreISRBegin(__handle) (void)xTraceISRBegin((TraceISRHandle_t)(__handle))
456
484traceResult xTraceISREnd(int pendingISR);
485
486#define vTraceStoreISREnd(__pendingISR) (void)xTraceISREnd(__pendingISR)
487
494uint32_t xTraceIsRecorderEnabled(void);
495
502uint32_t xTraceIsRecorderInitialized(void);
503
514traceResult xTraceTaskInstanceFinishedNow(void);
515
530traceResult xTraceTaskInstanceFinishedNext(void);
531
541traceResult xTraceStringRegister(const char* label, TraceStringHandle_t* pxString);
542
552TraceStringHandle_t xTraceRegisterString(const char* name);
553
554#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)
633traceResult xTracePrintF(TraceStringHandle_t chn, const char* fmt, ...);
634#else
635#define xTracePrintF(chn, fmt, ...) ((void)(chn), (void)(fmt), TRC_SUCCESS) /* Comma operator is used to avoid "unused variable" compiler warnings in a single statement */
636#endif
637
638#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)
652traceResult xTraceVPrintF(TraceStringHandle_t eventLabel, const char* formatStr, va_list vl);
653#else
654#define xTraceVPrintF(chn, formatStr, vl) ((void)(chn), (void)(formatStr), (void)(vl), TRC_SUCCESS) /* Comma operator is used to avoid "unused variable" compiler warnings in a single statement */
655#endif
656
657#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)
674traceResult xTracePrint(TraceStringHandle_t chn, const char* str);
675#else
676#define xTracePrint(chn, str) ((void)(chn), (void)(str), TRC_SUCCESS)
677#endif
678
679/******************************************************************************/
680/*** Extended API for Snapshot mode *******************************************/
681/******************************************************************************/
682
686typedef void(*TRACE_STOP_HOOK)(void);
687
695void vTraceSetStopHook(TRACE_STOP_HOOK stopHookFunction);
696
707void vTraceClear(void);
708
709/*****************************************************************************/
710/*** INTERNAL SNAPSHOT FUNCTIONS *********************************************/
711/*****************************************************************************/
712
713#define TRC_UNUSED
714
715#ifndef TRC_CFG_INCLUDE_OBJECT_DELETE
716#define TRC_CFG_INCLUDE_OBJECT_DELETE 0
717#endif
718
719#ifndef TRC_CFG_INCLUDE_READY_EVENTS
720#define TRC_CFG_INCLUDE_READY_EVENTS 1
721#endif
722
723#ifndef TRC_CFG_INCLUDE_OSTICK_EVENTS
724#define TRC_CFG_INCLUDE_OSTICK_EVENTS 0
725#endif
726
727/* This macro will create a task in the object table */
728#undef trcKERNEL_HOOKS_TASK_CREATE
729#define trcKERNEL_HOOKS_TASK_CREATE(SERVICE, CLASS, pxTCB) \
730 if ((pxTCB) != 0) \
731 { \
732 TRACE_SET_OBJECT_NUMBER(TASK, pxTCB); \
733 TRACE_SET_OBJECT_FILTER(TASK, pxTCB, CurrentFilterGroup); \
734 prvTraceSetObjectName(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_NAME(pxTCB)); \
735 prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_PRIORITY(pxTCB)); \
736 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
737 if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \
738 prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \
739 } \
740 else \
741 { \
742 /* pxTCB is null */ \
743 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
744 { \
745 prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, 0); \
746 } \
747 }
748
749/* This macro will remove the task and store it in the event buffer */
750#undef trcKERNEL_HOOKS_TASK_DELETE
751#define trcKERNEL_HOOKS_TASK_DELETE(SERVICE, SERVICE_NAME, SERVICE_PROP, pxTCB) \
752 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
753 if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \
754 prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \
755 prvTraceStoreObjectNameOnCloseEvent(SERVICE_NAME, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \
756 prvTraceStoreObjectPropertiesOnCloseEvent(SERVICE_PROP, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \
757 prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_PRIORITY(pxTCB)); \
758 prvTraceSetObjectState(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TASK_STATE_INSTANCE_NOT_ACTIVE); \
759 prvTraceFreeObjectHandle(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));
760
761
762/* This macro will setup a task in the object table */
763#undef trcKERNEL_HOOKS_OBJECT_CREATE
764#define trcKERNEL_HOOKS_OBJECT_CREATE(SERVICE, CLASS, pxObject) \
765 TRACE_SET_OBJECT_NUMBER(CLASS, pxObject); \
766 TRACE_SET_OBJECT_FILTER(CLASS, pxObject, CurrentFilterGroup); \
767 prvMarkObjectAsUsed(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\
768 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
769 if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \
770 prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \
771 prvTraceSetObjectState(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), 0);
772
773/* This macro will setup a task in the object table */
774#undef trcKERNEL_HOOKS_OBJECT_CREATE_FAILED
775#define trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(SERVICE, TRACE_CLASS)\
776 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
777 { \
778 prvTraceStoreKernelCall(SERVICE, TRACE_CLASS, 0); \
779 }
780
781/* This macro will remove the object and store it in the event buffer */
782#undef trcKERNEL_HOOKS_OBJECT_DELETE
783#define trcKERNEL_HOOKS_OBJECT_DELETE(SERVICE, SERVICE_NAME, SERVICE_PROP, CLASS, pxObject) \
784 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
785 if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \
786 prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \
787 prvTraceStoreObjectNameOnCloseEvent(SERVICE_NAME, TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \
788 prvTraceStoreObjectPropertiesOnCloseEvent(SERVICE_PROP, TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \
789 prvTraceFreeObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));
790
791/* This macro will create a call to a kernel service with a certain result, with an object as parameter */
792#undef trcKERNEL_HOOKS_KERNEL_SERVICE
793#define trcKERNEL_HOOKS_KERNEL_SERVICE(SERVICE, CLASS, pxObject) \
794 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
795 if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \
796 prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));
797
798/* This macro will create a call to a kernel service with a certain result, with a null object as parameter */
799#undef trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT
800#define trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT(SERVICE, TRACECLASS) \
801 if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
802 prvTraceStoreKernelCall(SERVICE, TRACECLASS, 0);
803
804/* This macro will create a call to a kernel service with a certain result, with an object as parameter */
805#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM
806#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(SERVICE, CLASS, pxObject, param) \
807 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
808 if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \
809 prvTraceStoreKernelCallWithParam(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), (uint32_t)param);
810
811/* This macro will create a call to a kernel service with a certain result, with a null object and other value as parameter */
812#undef trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT_WITH_PARAM
813#define trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT_WITH_PARAM(SERVICE, TRACECLASS, param) \
814 if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
815 prvTraceStoreKernelCallWithParam(SERVICE, TRACECLASS, 0, param);
816
817/* This macro will create a call to a kernel service with a certain result, with an object as parameter */
818#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY
819#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(SERVICE, param) \
820 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
821 prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, (uint32_t)param);
822
823/* This macro will create a call to a kernel service with a certain result, with an object as parameter */
824#undef trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR
825#define trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(SERVICE, CLASS, pxObject) \
826 if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \
827 prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));
828
829/* This macro will create a call to a kernel service with a certain result, with a null object as parameter */
830#undef trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT_FROM_ISR
831#define trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT_FROM_ISR(SERVICE, TRACECLASS) \
832 prvTraceStoreKernelCall(SERVICE, TRACECLASS, 0);
833
834/* This macro will create a call to a kernel service with a certain result, with an object as parameter */
835#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR
836#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR(SERVICE, CLASS, pxObject, param) \
837 if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \
838 prvTraceStoreKernelCallWithParam(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), (uint32_t)param);
839
840/* This macro will create a call to a kernel service with a certain result, with a null object and other value as parameter */
841#undef trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT_WITH_PARAM_FROM_ISR
842#define trcKERNEL_HOOKS_KERNEL_SERVICE_NULL_OBJECT_WITH_PARAM_FROM_ISR(SERVICE, TRACECLASS, param) \
843 prvTraceStoreKernelCallWithParam(SERVICE, TRACECLASS, 0, param);
844
845/* This macro will create a call to a kernel service with a certain result, with an object as parameter */
846#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY_FROM_ISR
847#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY_FROM_ISR(SERVICE, param) \
848 prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, (uint32_t)param);
849
850/* This macro will set the state for an object */
851#undef trcKERNEL_HOOKS_SET_OBJECT_STATE
852#define trcKERNEL_HOOKS_SET_OBJECT_STATE(CLASS, pxObject, STATE) \
853 prvTraceSetObjectState(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), (uint8_t)STATE);
854
855/* This macro will flag a certain task as a finished instance */
856#undef trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED
857#define trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED() \
858 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
859 prvTraceSetTaskInstanceFinished(TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK()));
860
861#if (TRC_CFG_INCLUDE_READY_EVENTS == 1)
862/* This macro will create an event to indicate that a task became Ready */
863#undef trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE
864#define trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB) \
865 if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \
866 prvTraceStoreTaskReady(TRACE_GET_TASK_NUMBER(pxTCB));
867#else /*(TRC_CFG_INCLUDE_READY_EVENTS == 1)*/
868#undef trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE
869#define trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB)
870#endif /*(TRC_CFG_INCLUDE_READY_EVENTS == 1)*/
871
872/* This macro will update the internal tick counter and call prvTracePortGetTimeStamp(0) to update the internal counters */
873#undef trcKERNEL_HOOKS_INCREMENT_TICK
874#define trcKERNEL_HOOKS_INCREMENT_TICK() \
875 { \
876 extern uint32_t uiTraceTickCount; \
877 uiTraceTickCount++; \
878 prvTracePortGetTimeStamp(0); \
879 }
880
881#if (TRC_CFG_INCLUDE_OSTICK_EVENTS == 1)
882/* This macro will create an event indicating that the OS tick count has increased */
883#undef trcKERNEL_HOOKS_NEW_TIME
884#define trcKERNEL_HOOKS_NEW_TIME(SERVICE, xValue) \
885 prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, xValue);
886#else /*(TRC_CFG_INCLUDE_OSTICK_EVENTS == 1)*/
887#undef trcKERNEL_HOOKS_NEW_TIME
888#define trcKERNEL_HOOKS_NEW_TIME(SERVICE, xValue)
889#endif /*(TRC_CFG_INCLUDE_OSTICK_EVENTS == 1)*/
890
891/* This macro will create a task switch event to the currently executing task */
892#undef trcKERNEL_HOOKS_TASK_SWITCH
893#define trcKERNEL_HOOKS_TASK_SWITCH( pxTCB ) \
894 if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \
895 prvTraceStoreTaskswitch(TRACE_GET_TASK_NUMBER(pxTCB));
896
897/* This macro will create an event to indicate that the task has been suspended */
898#undef trcKERNEL_HOOKS_TASK_SUSPEND
899#define trcKERNEL_HOOKS_TASK_SUSPEND(SERVICE, pxTCB) \
900 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
901 if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \
902 prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \
903 prvTraceSetTaskInstanceFinished((uint8_t)TRACE_GET_TASK_NUMBER(pxTCB));
904
905/* This macro will create an event to indicate that a task has called a wait/delay function */
906#undef trcKERNEL_HOOKS_TASK_DELAY
907#define trcKERNEL_HOOKS_TASK_DELAY(SERVICE, pxTCB, xValue) \
908 if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \
909 { \
910 prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, xValue); \
911 prvTraceSetTaskInstanceFinished((uint8_t)TRACE_GET_TASK_NUMBER(pxTCB)); \
912 }
913
914/* This macro will create an event to indicate that a task has gotten its priority changed */
915#undef trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE
916#define trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(SERVICE, pxTCB, uxNewPriority) \
917 if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \
918 { \
919 prvTraceStoreKernelCallWithParam(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), prvTraceGetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)));\
920 prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), (uint8_t)uxNewPriority); \
921 }
922
923/* This macro will create an event to indicate that the task has been resumed */
924#undef trcKERNEL_HOOKS_TASK_RESUME
925#define trcKERNEL_HOOKS_TASK_RESUME(SERVICE, pxTCB) \
926 if (TRACE_GET_OBJECT_FILTER(TASK, TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \
927 if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \
928 prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));
929
930/* This macro will create an event to indicate that the task has been resumed from ISR */
931#undef trcKERNEL_HOOKS_TASK_RESUME_FROM_ISR
932#define trcKERNEL_HOOKS_TASK_RESUME_FROM_ISR(SERVICE, pxTCB) \
933 if (TRACE_GET_OBJECT_FILTER(TASK, pxTCB) & CurrentFilterMask) \
934 prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));
935
936#if !defined TRC_CFG_INCLUDE_READY_EVENTS || TRC_CFG_INCLUDE_READY_EVENTS == 1
942void prvTraceSetReadyEventsEnabled(uint32_t flag);
943
949void prvTraceStoreTaskReady(traceHandle handle);
950#else
951#define prvTraceSetReadyEventsEnabled(status) (void)status;
952#endif
953
959void prvTraceStoreLowPower(uint32_t flag);
960
966void prvTraceStoreTaskswitch(traceHandle task_handle);
967
968#if (TRC_CFG_SCHEDULING_ONLY == 0)
969
977void prvTraceStoreKernelCall(uint32_t eventcode, traceObjectClass objectClass, uint32_t objectNumber);
978
985void prvTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode, uint32_t param);
986
995void prvTraceStoreKernelCallWithParam(uint32_t evtcode, traceObjectClass objectClass,
996 uint32_t objectNumber, uint32_t param);
997#else
998
999#define prvTraceStoreKernelCall(eventcode, objectClass, byteParam) {}
1000#define prvTraceStoreKernelCallWithNumericParamOnly(evtcode, param) {}
1001#define prvTraceStoreKernelCallWithParam(evtcode, objectClass, objectNumber, param) {}
1002
1003#endif
1004
1010void prvTraceSetTaskInstanceFinished(traceHandle handle);
1011
1019void prvTraceSetPriorityProperty(uint8_t objectclass, traceHandle id, uint8_t value);
1020
1029uint8_t prvTraceGetPriorityProperty(uint8_t objectclass, traceHandle id);
1030
1038void prvTraceSetObjectState(uint8_t objectclass, traceHandle id, uint8_t value);
1039
1046void prvMarkObjectAsUsed(traceObjectClass objectclass, traceHandle handle);
1047
1055void prvTraceStoreObjectNameOnCloseEvent(uint8_t evtcode, traceHandle handle,
1056 traceObjectClass objectclass);
1057
1065void prvTraceStoreObjectPropertiesOnCloseEvent(uint8_t evtcode, traceHandle handle,
1066 traceObjectClass objectclass);
1067
1068/* Internal constants for task state */
1069#define TASK_STATE_INSTANCE_NOT_ACTIVE 0
1070#define TASK_STATE_INSTANCE_ACTIVE 1
1071
1072
1073#if (TRC_CFG_INCLUDE_ISR_TRACING == 0)
1074
1075#undef vTraceSetISRProperties
1076#define vTraceSetISRProperties(handle, name, priority) (void)(handle), (void)(name), (void)(priority) /* Comma operator is used to avoid "unused variable" compiler warnings in a single statement */
1077
1078#undef vTraceStoreISRBegin
1079#define vTraceStoreISRBegin(x) (void)(x)
1080
1081#undef vTraceStoreISREnd
1082#define vTraceStoreISREnd(x) (void)(x)
1083
1084#undef xTraceSetISRProperties
1085#define xTraceSetISRProperties(name, priority) ((void)(name), (void)(priority), (traceHandle)0) /* Comma operator in parenthesis is used to avoid "unused variable" compiler warnings and return 0 in a single statement */
1086
1087#endif /*(TRC_CFG_INCLUDE_ISR_TRACING == 0)*/
1088
1099void* xTraceGetTraceBuffer(void);
1100
1110uint32_t uiTraceGetTraceBufferSize(void);
1111
1112#if (TRC_CFG_SCHEDULING_ONLY == 1)
1113#undef TRC_CFG_INCLUDE_USER_EVENTS
1114#define TRC_CFG_INCLUDE_USER_EVENTS 0
1115#endif /*(TRC_CFG_SCHEDULING_ONLY == 1)*/
1116
1117#if ((TRC_CFG_INCLUDE_USER_EVENTS == 1) && (TRC_CFG_SCHEDULING_ONLY == 0)) && (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)
1118
1127traceUBChannel xTraceRegisterUBChannel(TraceStringHandle_t channel, TraceStringHandle_t formatStr);
1128
1135void vTraceUBData(traceUBChannel channel, ...);
1136
1142void vTraceUBEvent(traceUBChannel channel);
1143#else
1144#define xTraceRegisterChannelFormat(eventLabel, formatStr) ((void)(eventLabel), (void)(formatStr), 0)
1145#define vTraceUBData(label, ...) (void)(label)
1146#endif /*(TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)*/
1147
1148#define NEventCodes 0x100
1149
1150/* Our local critical sections for the recorder */
1151#define trcCRITICAL_SECTION_BEGIN() {TRACE_ENTER_CRITICAL_SECTION(); recorder_busy++;}
1152#define trcCRITICAL_SECTION_END() {recorder_busy--; TRACE_EXIT_CRITICAL_SECTION();}
1153
1154#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M)
1155 #define trcSR_ALLOC_CRITICAL_SECTION_ON_CORTEX_M_ONLY TRACE_ALLOC_CRITICAL_SECTION
1156 #define trcCRITICAL_SECTION_BEGIN_ON_CORTEX_M_ONLY trcCRITICAL_SECTION_BEGIN
1157 #define trcCRITICAL_SECTION_END_ON_CORTEX_M_ONLY trcCRITICAL_SECTION_END
1158#else
1159 #define trcSR_ALLOC_CRITICAL_SECTION_ON_CORTEX_M_ONLY() {}
1160 #define trcCRITICAL_SECTION_BEGIN_ON_CORTEX_M_ONLY() recorder_busy++;
1161 #define trcCRITICAL_SECTION_END_ON_CORTEX_M_ONLY() recorder_busy--;
1162#endif
1163
1188typedef struct
1189{
1190 uint16_t indexOfNextAvailableHandle[ TRACE_NCLASSES ];
1191 uint16_t lowestIndexOfClass[ TRACE_NCLASSES ];
1192 uint16_t highestIndexOfClass[ TRACE_NCLASSES ];
1193 uint16_t handleCountWaterMarksOfClass[ TRACE_NCLASSES ];
1194 traceHandle objectHandles[ TRACE_KERNEL_OBJECT_COUNT ];
1196
1197extern objectHandleStackType objectHandleStacks;
1198
1216typedef struct
1217{
1218 /* = NCLASSES */
1219 uint32_t NumberOfObjectClasses;
1220 uint32_t ObjectPropertyTableSizeInBytes;
1222 /* This is used to calculate the index in the dynamic object table
1223 (handle - 1 - nofStaticObjects = index)*/
1224#if (TRC_CFG_USE_16BIT_OBJECT_HANDLES == 1)
1225 traceHandle NumberOfObjectsPerClass[2*((TRACE_NCLASSES+1)/2)];
1226#else
1227 traceHandle NumberOfObjectsPerClass[4*((TRACE_NCLASSES+3)/4)];
1228#endif
1229 /* Allocation size rounded up to the closest multiple of 4 */
1230 uint8_t NameLengthPerClass[ 4*((TRACE_NCLASSES+3)/4) ];
1232 /* Allocation size rounded up to the closest multiple of 2 */
1233 uint8_t TotalPropertyBytesPerClass[ 4*((TRACE_NCLASSES+3)/4) ];
1235 /* */
1236 uint16_t StartIndexOfClass[ 2*((TRACE_NCLASSES+1)/2) ];
1238 /* The actual handles issued, should be Initiated to all zeros */
1239 uint8_t objbytes[ 4*((TRACE_OBJECT_TABLE_SIZE+3)/4) ];
1241
1245typedef struct
1246{
1247 /* = SYMBOL_HISTORY_TABLE_SIZE_IN_BYTES */
1248 uint32_t symTableSize;
1250 /* Entry 0 is reserved. Any reference to entry 0 implies NULL*/
1251 uint32_t nextFreeSymbolIndex;
1253 /* Size rounded up to closest multiple of 4, to avoid alignment issues*/
1254 uint8_t symbytes[4*(((TRC_CFG_SYMBOL_TABLE_SIZE)+3)/4)];
1256 /* Used for lookups - Up to 64 linked lists within the symbol table
1257 connecting all entries with the same 6 bit checksum.
1258 This field holds the current list heads. Should be initiated to zeros */
1259 uint16_t latestEntryOfChecksum[64];
1261
1262
1263/*******************************************************************************
1264 * The data structures of the different events, all 4 bytes long
1265 ******************************************************************************/
1266
1267typedef struct
1268{
1269 uint8_t type;
1270 uint8_t objHandle;
1271 uint16_t dts; /* differential timestamp - time since last event */
1272} TSEvent, TREvent;
1273
1274typedef struct
1275{
1276 uint8_t type;
1277 uint8_t dummy;
1278 uint16_t dts; /* differential timestamp - time since last event */
1279} LPEvent;
1280
1281typedef struct
1282{
1283 uint8_t type;
1284 uint8_t objHandle;
1285 uint16_t dts; /* differential timestamp - time since last event */
1286} KernelCall;
1287
1288typedef struct
1289{
1290 uint8_t type;
1291 uint8_t objHandle;
1292 uint8_t param;
1293 uint8_t dts; /* differential timestamp - time since last event */
1294} KernelCallWithParamAndHandle;
1295
1296typedef struct
1297{
1298 uint8_t type;
1299 uint8_t dts; /* differential timestamp - time since last event */
1300 uint16_t param;
1301} KernelCallWithParam16;
1302
1303typedef struct
1304{
1305 uint8_t type;
1306 uint8_t objHandle; /* the handle of the closed object */
1307 uint16_t symbolIndex; /* the name of the closed object */
1308} ObjCloseNameEvent;
1309
1310typedef struct
1311{
1312 uint8_t type;
1313 uint8_t arg1;
1314 uint8_t arg2;
1315 uint8_t arg3;
1316} ObjClosePropEvent;
1317
1318typedef struct
1319{
1320 uint8_t type;
1321 uint8_t unused1;
1322 uint8_t unused2;
1323 uint8_t dts;
1324} TaskInstanceStatusEvent;
1325
1326typedef struct
1327{
1328 uint8_t type;
1329 uint8_t dts;
1330 uint16_t payload; /* the name of the user event */
1331} UserEvent;
1332
1333typedef struct
1334{
1335 uint8_t type;
1336
1337 /* 8 bits extra for storing DTS, if it does not fit in ordinary event
1338 (this one is always MSB if used) */
1339 uint8_t xts_8;
1340
1341 /* 16 bits extra for storing DTS, if it does not fit in ordinary event. */
1342 uint16_t xts_16;
1343} XTSEvent;
1344
1345typedef struct
1346{
1347 uint8_t type;
1348
1349 uint8_t xps_8;
1350 uint16_t xps_16;
1351} XPSEvent;
1352
1353typedef struct{
1354 uint8_t type;
1355 uint8_t dts;
1356 uint16_t size;
1357} MemEventSize;
1358
1359typedef struct{
1360 uint8_t type;
1361 uint8_t addr_high;
1362 uint16_t addr_low;
1363} MemEventAddr;
1364
1365/*******************************************************************************
1366 * The separate user event buffer structure. Can be enabled in trcConfig.h.
1367 ******************************************************************************/
1368
1369#if (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)
1370typedef struct
1371{
1372 TraceStringHandle_t name;
1373 TraceStringHandle_t defaultFormat;
1374} ChannelFormatPair;
1375
1376typedef struct
1377{
1378 uint16_t bufferID;
1379 uint16_t version;
1380 uint32_t wraparoundCounter;
1381 uint32_t numberOfSlots;
1382 uint32_t nextSlotToWrite;
1383 uint8_t numberOfChannels;
1384 uint8_t padding1;
1385 uint8_t padding2;
1386 uint8_t padding3;
1387 ChannelFormatPair channels[(TRC_CFG_UB_CHANNELS)+1];
1388 uint8_t channelBuffer[((TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) + 3) & 0xFFFFFFFC]; /* 1 byte per slot, with padding for 4 byte alignment */
1389 uint8_t dataBuffer[(TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) * 4]; /* 4 bytes per slot */
1390
1391} UserEventBuffer;
1392#endif /* (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1) */
1393
1394/*******************************************************************************
1395 * The main data structure, read by Tracealyzer from the RAM dump
1396 ******************************************************************************/
1397
1398typedef struct
1399{
1400 volatile uint8_t startmarker0; /* Volatile is important, see init code. */
1401 volatile uint8_t startmarker1;
1402 volatile uint8_t startmarker2;
1403 volatile uint8_t startmarker3;
1404 volatile uint8_t startmarker4;
1405 volatile uint8_t startmarker5;
1406 volatile uint8_t startmarker6;
1407 volatile uint8_t startmarker7;
1408 volatile uint8_t startmarker8;
1409 volatile uint8_t startmarker9;
1410 volatile uint8_t startmarker10;
1411 volatile uint8_t startmarker11;
1412
1413 /* Used to determine Kernel and Endianess */
1414 uint16_t version;
1415
1416 /* Currently 7 */
1417 uint8_t minor_version;
1418
1419 /* This should be 0 if lower IRQ priority values implies higher priority
1420 levels, such as on ARM Cortex M. If the opposite scheme is used, i.e.,
1421 if higher IRQ priority values means higher priority, this should be 1. */
1422 uint8_t irq_priority_order;
1423
1424 /* sizeof(RecorderDataType) - just for control */
1425 uint32_t filesize;
1426
1427 /* Current number of events recorded */
1428 uint32_t numEvents;
1429
1430 /* The buffer size, in number of event records */
1431 uint32_t maxEvents;
1432
1433 /* The event buffer index, where to write the next event */
1434 uint32_t nextFreeIndex;
1435
1436 /* 1 if the buffer is full, 0 otherwise */
1437 uint32_t bufferIsFull;
1438
1439 /* The frequency of the clock/timer/counter used as time base */
1440 uint32_t frequency;
1441
1442 /* The absolute timestamp of the last stored event, in the native
1443 timebase, modulo frequency! */
1444 uint32_t absTimeLastEvent;
1445
1446 /* The number of seconds in total - lasts for 136 years */
1447 uint32_t absTimeLastEventSecond;
1448
1449 /* 1 if the recorder has been started, 0 if not yet started or stopped.
1450 This is a 32 bit variable due to alignment issues. */
1451 uint32_t recorderActive;
1452
1453 /* If > 0, tells the maximum time between two traced ISRs that execute
1454 back-to-back. If the time between vTraceStoreISREnd and a directly
1455 following vTraceISRBegin is above isrTailchainingThreshold, we assume a
1456 return to the previous context in between the ISRs, otherwise we assume
1457 the have executed back-to-back and don't show any fragment of the previous
1458 context in between. */
1459 uint32_t isrTailchainingThreshold;
1460
1461 /* The maximum amount of heap memory that was allocated */
1462 uint32_t heapMemMaxUsage;
1463
1464 /* The amount of heap memory used */
1465 uint32_t heapMemUsage;
1466
1467 /* 0xF0F0F0F0 - for control only */
1468 int32_t debugMarker0;
1469
1470 /* Set to value of TRC_CFG_USE_16BIT_OBJECT_HANDLES */
1471 uint32_t isUsing16bitHandles;
1472
1473 /* The Object Property Table holds information about currently active
1474 tasks, queues, and other recorded objects. This is updated on each
1475 create call and includes object name and other properties. */
1476 ObjectPropertyTableType ObjectPropertyTable;
1477
1478 /* 0xF1F1F1F1 - for control only */
1479 int32_t debugMarker1;
1480
1481 /* The Symbol Table stores strings for User Events and is also used to
1482 store names of deleted objects, which still may be in the trace but no
1483 longer are available. */
1484 symbolTableType SymbolTable;
1485
1486 /* For inclusion of float support, and for endian detection of floats.
1487 The value should be (float)1 or (uint32_t)0 */
1488#if (TRC_CFG_INCLUDE_FLOAT_SUPPORT == 1)
1489 float exampleFloatEncoding;
1490#else
1491 uint32_t exampleFloatEncoding;
1492#endif
1493 /* This is non-zero if an internal error occurred in the recorder, e.g., if
1494 one of the Nxxx constants was too small. The systemInfo string will then
1495 contain an error message that is displayed when attempting to view the
1496 trace file. */
1497 uint32_t internalErrorOccured;
1498
1499 /* 0xF2F2F2F2 - for control only */
1500 int32_t debugMarker2;
1501
1502 /* Error messages from the recorder. */
1503 char systemInfo[80];
1504
1505 /* 0xF3F3F3F3 - for control only */
1506 int32_t debugMarker3;
1507
1508 /* The event data, in 4-byte records */
1509 uint8_t eventData[ (TRC_CFG_EVENT_BUFFER_SIZE) * 4 ];
1510
1511#if (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)
1512 UserEventBuffer userEventBuffer;
1513#endif
1514
1515 /* This should always be 0 */
1516 uint32_t endOfSecondaryBlocks;
1517
1518 uint8_t endmarker0;
1519 uint8_t endmarker1;
1520 uint8_t endmarker2;
1521 uint8_t endmarker3;
1522 uint8_t endmarker4;
1523 uint8_t endmarker5;
1524 uint8_t endmarker6;
1525 uint8_t endmarker7;
1526 uint8_t endmarker8;
1527 uint8_t endmarker9;
1528 uint8_t endmarker10;
1529 uint8_t endmarker11;
1530} RecorderDataType;
1531
1532extern RecorderDataType* RecorderDataPtr;
1533
1534/* Internal functions */
1535
1541void prvTraceError(const char* msg);
1542
1555void prvTracePortGetTimeStamp(uint32_t *puiTimestamp);
1556
1564traceHandle prvTraceGetObjectHandle(traceObjectClass objectclass);
1565
1572void prvTraceFreeObjectHandle(traceObjectClass objectclass,
1573 traceHandle handle);
1574
1575/* Private function. Use the public functions in trcKernelPort.h */
1576
1584void prvTraceSetObjectName(traceObjectClass objectclass,
1585 traceHandle handle,
1586 const char* name);
1587
1588/* Internal macros */
1589
1590#define TRACE_PROPERTY_NAME_GET(objectclass, objecthandle) \
1591 (const char*)(& RecorderDataPtr->ObjectPropertyTable.objbytes \
1592 [uiIndexOfObject(objecthandle, objectclass)])
1593
1594#define TRACE_PROPERTY_OBJECT_STATE(objectclass, handle) \
1595 RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclass) \
1596 + RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[objectclass]]
1597
1598#define TRACE_PROPERTY_ACTOR_PRIORITY(objectclass, handle) \
1599 RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclass) \
1600 + RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[objectclass] + 1]
1601
1602/* DEBUG ASSERTS */
1603#if defined TRC_CFG_USE_TRACE_ASSERT && TRC_CFG_USE_TRACE_ASSERT != 0
1604#define TRACE_ASSERT(eval, msg, defRetVal) \
1605 if (!(eval)) \
1606 { \
1607 prvTraceError("TRACE_ASSERT: " msg); \
1608 return defRetVal; \
1609 }
1610#else
1611#define TRACE_ASSERT(eval, msg, defRetVal)
1612#endif
1613
1614typedef RecorderDataType TraceRecorderData_t;
1615
1616#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)*/
1617
1618#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
1619
1620#ifndef TRC_EXTERNAL_BUFFERS
1621#define TRC_EXTERNAL_BUFFERS 0
1622#endif
1623
1624typedef struct TraceRecorderData /* Aligned */
1625{
1626 uint32_t uiSessionCounter;
1627 uint32_t uiRecorderEnabled;
1628 TraceUnsignedBaseType_t uxTraceSystemStates[TRC_CFG_CORE_COUNT];
1629 uint32_t reserved; /* alignment */
1630
1631 TraceAssertData_t xAssertBuffer; /* aligned */
1632 TraceEntryIndexTable_t xEntryIndexTableBuffer; /* aligned */
1633#if (TRC_EXTERNAL_BUFFERS == 0)
1634 TraceHeaderBuffer_t xHeaderBuffer; /* aligned */
1635 TraceEntryTable_t xEntryTable; /* aligned */
1636 TraceTimestampData_t xTimestampBuffer; /* aligned */
1637#endif
1638 TraceStreamPortBuffer_t xStreamPortBuffer; /* verify alignment in xTraceInitialize() */
1639 TraceStaticBufferTable_t xStaticBufferBuffer; /* aligned */
1640 TraceEventDataTable_t xEventDataBuffer; /* verify alignment in xTraceInitialize() */
1641 TracePrintData_t xPrintBuffer; /* aligned */
1642 TraceErrorData_t xErrorBuffer; /* aligned */
1643 TraceISRData_t xISRBuffer; /* aligned */
1644 TraceKernelPortDataBuffer_t xKernelPortBuffer; /* verify alignment in xTraceInitialize() */
1645 TraceTaskData_t xTaskInfoBuffer; /* aligned */
1646 TraceStackMonitorData_t xStackMonitorBuffer; /* aligned */
1647 TraceDiagnosticsData_t xDiagnosticsBuffer; /* aligned */
1648 TraceExtensionData_t xExtensionBuffer; /* aligned */
1649 TraceCounterData_t xCounterBuffer; /* aligned */
1650} TraceRecorderData_t;
1651
1652extern TraceRecorderData_t* pxTraceRecorderData;
1653extern uint32_t RecorderInitialized;
1654
1663traceResult xTraceHeaderInitialize(TraceHeaderBuffer_t* pxBuffer);
1664
1671#define xTraceIsRecorderEnabled() (xTraceIsRecorderInitialized() && pxTraceRecorderData->uiRecorderEnabled)
1672
1679#define xTraceIsRecorderInitialized() xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_CORE)
1680
1689#define xTraceSetComponentInitialized(uiComponentBit) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(RecorderInitialized |= (uiComponentBit), TRC_SUCCESS)
1690
1699#define xTraceIsComponentInitialized(uiComponentBit) (RecorderInitialized & (uiComponentBit))
1700
1709#define xTraceStateSet(uxState) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(pxTraceRecorderData->uxTraceSystemStates[TRC_CFG_GET_CURRENT_CORE()] = (uxState), TRC_SUCCESS)
1710
1719#define xTraceStateGet(puxState) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puxState) = pxTraceRecorderData->uxTraceSystemStates[TRC_CFG_GET_CURRENT_CORE()], TRC_SUCCESS)
1720
1727traceResult xTraceTzCtrl(void);
1728
1729/******************************************************************************/
1730/*** INTERNAL STREAMING FUNCTIONS *********************************************/
1731/******************************************************************************/
1732
1738#define prvTraceStoreEvent_None(_eventID) xTraceEventCreate0(_eventID)
1739
1746#define prvTraceStoreEvent_Handle(_eventID, _handle) xTraceEventCreate1(_eventID, (TraceUnsignedBaseType_t)(_handle))
1747
1754#define prvTraceStoreEvent_Param(_eventID, _param1) xTraceEventCreate1(_eventID, (TraceUnsignedBaseType_t)(_param1))
1755
1763#define prvTraceStoreEvent_HandleParam(_eventID, _handle, _param1) xTraceEventCreate2(_eventID, (TraceUnsignedBaseType_t)(_handle), (TraceUnsignedBaseType_t)(_param1))
1764
1772#define prvTraceStoreEvent_ParamParam(_eventID, _param1, _param2) xTraceEventCreate2(_eventID, (TraceUnsignedBaseType_t)(_param1), (TraceUnsignedBaseType_t)(_param2))
1773
1782#define prvTraceStoreEvent_HandleParamParam(_eventID, _handle, _param1, _param2) xTraceEventCreate3(_eventID, (TraceUnsignedBaseType_t)(_handle), (TraceUnsignedBaseType_t)(_param1), (TraceUnsignedBaseType_t)(_param2))
1783
1792#define prvTraceStoreEvent_ParamParamParam(_eventID, _param1, _param2, _param3) xTraceEventCreate3(_eventID, (TraceUnsignedBaseType_t)(_param1), (TraceUnsignedBaseType_t)(_param2), (TraceUnsignedBaseType_t)(_param3))
1793
1799#define vTraceSetStopHook(x) (void)(x)
1800
1804#define vTraceInitTimestamps()
1805
1806#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
1807
1808#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM)
1817traceResult xTraceSetBuffer(TraceRecorderData_t *pxBuffer);
1818#else
1819#define xTraceSetBuffer(p) (TRC_SUCCESS)
1820#endif
1821
1831traceResult xTraceGetEventBuffer(void** ppvBuffer, TraceUnsignedBaseType_t * puiSize);
1832
1833#else /* when TRC_USE_TRACEALYZER_RECORDER == 0 */
1834
1835#define xTraceInitialize() (TRC_SUCCESS)
1836#define xTraceEnable(x) ((void)(x), TRC_SUCCESS)
1837#define xTraceDisable() (TRC_SUCCESS)
1838#define xTraceStringRegister(x, y) ((void)(x), (void)y, TRC_SUCCESS) /* Comma operator in parenthesis is used to avoid "unused variable" compiler warnings and return 0 in a single statement */
1839#define xTracePrint(chn, ...) ((void)(chn), TRC_SUCCESS)
1840#define xTracePrintF(chn, fmt, ...) ((void)(chn), (void)(fmt), TRC_SUCCESS) /* Comma operator is used to avoid "unused variable" compiler warnings in a single statement */
1841#define xTraceVPrintF(chn, formatStr, vl) ((void)(chn), (void)(formatStr), (void)(vl), TRC_SUCCESS) /* Comma operator is used to avoid "unused variable" compiler warnings in a single statement */
1842#define xTraceTaskInstanceFinishedNow()
1843#define xTraceTaskInstanceFinishedNext()
1844#define vTraceStoreISRBegin(x) (void)(x)
1845#define vTraceStoreISREnd(x) (void)(x)
1846#define xTraceSetISRProperties(a, b) ((void)(a), (void)(b), (traceHandle)0) /* Comma operator in parenthesis is used to avoid "unused variable" compiler warnings and return 0 in a single statement */
1847#define xTraceRegisterChannelFormat(eventLabel, formatStr) ((void)(eventLabel), (void)(formatStr), 0) /* Comma operator in parenthesis is used to avoid "unused variable" compiler warnings and return 0 in a single statement */
1848#define vTraceUBData(label, ...) (void)(label)
1849
1850#define vTraceSetFilterGroup(x) (void)(x)
1851#define vTraceSetFilterMask(x) (void)(x)
1852
1853#define prvTraceSetReadyEventsEnabled(status) (void)(status)
1854
1855#define vTraceExcludeTask(handle) (void)(handle)
1856
1857#define vTraceConsoleChannelPrintF(fmt, ...) (void)(fmt)
1858
1859#ifndef TRC_ALLOC_CUSTOM_BUFFER
1860#define TRC_ALLOC_CUSTOM_BUFFER(bufname)
1861#endif
1862
1863#define xTraceIsRecorderEnabled() (0)
1864#define xTraceIsRecorderInitialized() (0)
1865
1866#define xTraceSetBuffer(p) (TRC_SUCCESS)
1867#define xTraceGetEventBuffer(p) (TRC_FAIL)
1868
1869#define vTraceSetStopHook(x) (void)(x)
1870
1871#define TraceRecorderData_t uint32_t
1872
1873#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
1874
1878#define vTraceInitialize (void)xTraceInitialize
1879
1883#define vTraceEnable (void)xTraceEnable
1884
1888#define vTraceStop (void)xTraceDisable
1889
1893#define vTraceInstanceFinishedNow (void)xTraceTaskInstanceFinishedNow
1894
1898#define vTraceInstanceFinishedNext (void)xTraceTaskInstanceFinishedNext
1899
1903#define vTracePrintF (void)xTracePrintF
1904
1908#define vTraceVPrintF (void)xTraceVPrintF
1909
1913#define vTracePrint (void)xTracePrint
1914
1918#define vTraceSetRecorderDataBuffer(pxBuffer) xTraceSetBuffer((TraceRecorderData_t*)(pxBuffer))
1919
1920#ifdef __cplusplus
1921}
1922#endif
1923
1924#endif /* TRC_RECORDER_H */
traceResult xTraceISRRegister(const char *szName, uint32_t uiPriority, TraceISRHandle_t *pxISRHandle)
Registers an ISR.
Definition: trcISR.c:49
traceResult xTraceISRBegin(TraceISRHandle_t xHandle)
Registers the beginning of an Interrupt Service Routine, using a TraceISRHandle_t provided by xTraceI...
Definition: trcISR.c:108
traceResult xTraceVPrintF(TraceStringHandle_t eventLabel, const char *formatStr, va_list vl)
xTracePrintF variant that accepts a va_list. See xTracePrintF documentation for further details.
Definition: trcPrint.c:189
traceResult xTracePrint(TraceStringHandle_t chn, const char *str)
A faster version of xTracePrintF, that only allows for logging a string.
Definition: trcPrint.c:41
traceResult xTracePrintF(TraceStringHandle_t chn, const char *fmt,...)
Generates "User Events", with formatted text and data, similar to a "printf". User Events can be used...
Definition: trcPrint.c:170
Object property table struct.
Definition: trcRecorder.h:1217
A structure representing the kernel port buffer.
Definition: trcKernelPort.h:73
A structure representing the trace stream port buffer.
Definition: trcStreamPort.h:93
Trace Timestamp Structure.
Definition: trcTimestamp.h:38
Object handle stack struct.
Definition: trcRecorder.h:1189
Symbol table structure.
Definition: trcRecorder.h:1246
Public trace assert APIs.
Public trace counter APIs.
Public trace dependency APIs.
Public trace diagnostic APIs.
Public trace entry table APIs.
Public trace error APIs.
Public trace event buffer APIs.
Public trace event APIs.
Public trace extension APIs.
Public trace heap APIs.
Public trace ISR APIs.
Public internal event buffer APIs.
Public trace interval APIs.
Public trace object APIs.
Public trace print APIs.
uint32_t uiTraceGetTraceBufferSize(void)
Gets the size of the recorder data structure. For use together with xTraceGetTraceBuffer if you wish ...
Definition: trcSnapshotRecorder.c:523
#define xTraceIsRecorderInitialized()
Query if recorder initialized.
Definition: trcRecorder.h:1679
void prvTraceSetTaskInstanceFinished(traceHandle handle)
Flags a task instance as finished.
Definition: trcSnapshotRecorder.c:2354
traceResult xTraceTzCtrl(void)
Call this function periodically.
Definition: trcStreamingRecorder.c:443
traceResult xTraceISREnd(int pendingISR)
Registers the end of an Interrupt Service Routine.
traceResult xTraceTaskInstanceFinishedNext(void)
Marks the current "task instance" as finished on the next kernel call.
Definition: trcSnapshotRecorder.c:594
#define xTraceIsRecorderEnabled()
Query if recorder is enabled.
Definition: trcRecorder.h:1671
traceResult xTraceTaskInstanceFinishedNow(void)
Creates an event that ends the current task instance at this very instant. This makes the viewer to s...
Definition: trcSnapshotRecorder.c:625
traceHandle prvTraceGetObjectHandle(traceObjectClass objectclass)
Reserve an object handle.
Definition: trcSnapshotRecorder.c:2404
void * xTraceGetTraceBuffer(void)
Returns a pointer to the recorder data structure. Use this together with uiTraceGetTraceBufferSize if...
Definition: trcSnapshotRecorder.c:511
void prvTraceFreeObjectHandle(traceObjectClass objectclass, traceHandle handle)
Free an object handle.
Definition: trcSnapshotRecorder.c:2456
void vTraceClear(void)
Resets the recorder.
Definition: trcSnapshotRecorder.c:376
traceResult xTraceHeaderInitialize(TraceHeaderBuffer_t *pxBuffer)
Initializes the header data.
Definition: trcStreamingRecorder.c:279
void prvTraceStoreObjectNameOnCloseEvent(uint8_t evtcode, traceHandle handle, traceObjectClass objectclass)
Stores the name of an object because it is being deleted.
Definition: trcSnapshotRecorder.c:2254
void prvReportStackUsage(void)
Reports on the current stack usage.
Definition: trcSnapshotRecorder.c:3255
traceResult xTraceInitialize(void)
Initializes the recorder data. xTraceInitialize() or xTraceEnable(...) must be called before any atte...
Definition: trcSnapshotRecorder.c:1631
#define vTraceSetStopHook(x)
Snapshot mode only. Trace stop hook.
Definition: trcRecorder.h:1799
void vTraceSetFilterMask(uint16_t filterMask)
For snapshot mode only: Sets the "filter mask" that is used to filter the events by object....
Definition: trcSnapshotRecorder.c:2637
traceResult xTraceDisable(void)
Disables tracing.
Definition: trcSnapshotRecorder.c:364
void prvRemoveTaskFromStackMonitor(void *task)
Remove a task from the stack monitor.
Definition: trcSnapshotRecorder.c:3241
void(* TRACE_STOP_HOOK)(void)
Trace stop callback type.
Definition: trcRecorder.h:686
void prvTraceSetPriorityProperty(uint8_t objectclass, traceHandle id, uint8_t value)
Set priority.
Definition: trcSnapshotRecorder.c:2314
void prvTraceSetObjectState(uint8_t objectclass, traceHandle id, uint8_t value)
Set object state.
Definition: trcSnapshotRecorder.c:2334
void prvTraceSetObjectName(traceObjectClass objectclass, traceHandle handle, const char *name)
Set the object name.
Definition: trcSnapshotRecorder.c:2516
void prvTraceStoreTaskswitch(traceHandle task_handle)
Stores a Task Switch event.
Definition: trcSnapshotRecorder.c:2194
traceResult xTraceGetEventBuffer(void **ppvBuffer, TraceUnsignedBaseType_t *puiSize)
Retrieve the event buffer and event buffer size.
Definition: trcSnapshotRecorder.c:315
void prvTraceStoreKernelCall(uint32_t eventcode, traceObjectClass objectClass, uint32_t objectNumber)
Stores a Kernel Service call event with an Object handle parameter.
Definition: trcSnapshotRecorder.c:1986
traceResult xTraceStringRegister(const char *label, TraceStringHandle_t *pxString)
Registers a string and returns a handle that can be used when tracing.
Definition: trcSnapshotRecorder.c:1611
void prvTraceStoreObjectPropertiesOnCloseEvent(uint8_t evtcode, traceHandle handle, traceObjectClass objectclass)
Stores the property of an object because it is being deleted.
Definition: trcSnapshotRecorder.c:2284
void prvTraceError(const char *msg)
Signals a trace error.
Definition: trcSnapshotRecorder.c:2617
void prvTraceStoreTaskReady(traceHandle handle)
Stores a Task Ready event.
Definition: trcSnapshotRecorder.c:1787
void prvTraceSetReadyEventsEnabled(uint32_t flag)
Dynamically enables ready events.
Definition: trcSnapshotRecorder.c:1777
void prvTraceStoreLowPower(uint32_t flag)
Stores a Low Power mode event.
Definition: trcSnapshotRecorder.c:1851
traceResult xTraceSetBuffer(TraceRecorderData_t *pxBuffer)
Set the recorder data buffer.
Definition: trcSnapshotRecorder.c:302
void prvTraceStoreKernelCallWithNumericParamOnly(uint32_t evtcode, uint32_t param)
Stores a Kernel Service call event with only a numeric parameter.
Definition: trcSnapshotRecorder.c:2144
void prvMarkObjectAsUsed(traceObjectClass objectclass, traceHandle handle)
Mark object as used.
Definition: trcSnapshotRecorder.c:2488
void prvTracePortGetTimeStamp(uint32_t *puiTimestamp)
Returns the current time based on the HWTC macros which provide a hardware isolation layer towards th...
Definition: trcSnapshotRecorder.c:3103
uint8_t prvTraceGetPriorityProperty(uint8_t objectclass, traceHandle id)
Get priority.
Definition: trcSnapshotRecorder.c:2324
void prvAddTaskToStackMonitor(void *task)
Adds a task to the stack monitor.
Definition: trcSnapshotRecorder.c:3218
void prvTraceStoreKernelCallWithParam(uint32_t evtcode, traceObjectClass objectClass, uint32_t objectNumber, uint32_t param)
Stores a Kernel Service call event with an Object handle and a numeric parameter.
Definition: trcSnapshotRecorder.c:2047
TraceStringHandle_t xTraceRegisterString(const char *name)
Registers a string and returns a handle that can be used when tracing.
Definition: trcSnapshotRecorder.c:1622
void vTraceSetFilterGroup(uint16_t filterGroup)
For snapshot mode only: Sets the "filter group" to assign when creating RTOS objects,...
Definition: trcSnapshotRecorder.c:2642
Public trace runnable APIs.
Public trace stack monitor APIs.
Public trace state machine APIs.
Public trace static buffer APIs.
Public trace string APIs.
Public trace task APIs.
Public trace timestamp APIs.