/*******************************************************************************\r
- * Tracealyzer v2.6.0 Recorder Library\r
+ * Tracealyzer v2.7.7 Recorder Library\r
* Percepio AB, www.percepio.com\r
*\r
- * trcBase.h\r
+ * trcKernel.c\r
*\r
- * Core functionality of the Tracealyzer recorder library.\r
+ * Functions used by trcKernelHooks.h for storing various kernel events.\r
*\r
* Terms of Use\r
* This software is copyright Percepio AB. The recorder library is free for\r
* damages, or the exclusion of implied warranties or limitations on how long an\r
* implied warranty may last, so the above limitations may not apply to you.\r
*\r
- * Copyright Percepio AB, 2013.\r
+ * Tabs are used for indent in this file (1 tab = 4 spaces)\r
+ *\r
+ * Copyright Percepio AB, 2012-2015.\r
* www.percepio.com\r
******************************************************************************/\r
\r
*****************************************************************************/\r
typedef struct\r
{\r
- /* For each object class, the index of the next handle to allocate */\r
- uint16_t indexOfNextAvailableHandle[ TRACE_NCLASSES ];\r
+ /* For each object class, the index of the next handle to allocate */\r
+ uint16_t indexOfNextAvailableHandle[ TRACE_NCLASSES ];\r
\r
- /* The lowest index of this class (constant) */\r
- uint16_t lowestIndexOfClass[ TRACE_NCLASSES ];\r
+ /* The lowest index of this class (constant) */\r
+ uint16_t lowestIndexOfClass[ TRACE_NCLASSES ];\r
\r
- /* The highest index of this class (constant) */\r
- uint16_t highestIndexOfClass[ TRACE_NCLASSES ];\r
+ /* The highest index of this class (constant) */\r
+ uint16_t highestIndexOfClass[ TRACE_NCLASSES ];\r
\r
- /* The highest use count for this class (for statistics) */\r
- uint16_t handleCountWaterMarksOfClass[ TRACE_NCLASSES ];\r
+ /* The highest use count for this class (for statistics) */\r
+ uint16_t handleCountWaterMarksOfClass[ TRACE_NCLASSES ];\r
\r
- /* The free object handles - a set of stacks within this array */\r
- objectHandleType objectHandles[ TRACE_KERNEL_OBJECT_COUNT ];\r
+ /* The free object handles - a set of stacks within this array */\r
+ objectHandleType objectHandles[ TRACE_KERNEL_OBJECT_COUNT ];\r
\r
} objectHandleStackType;\r
\r
\r
typedef struct\r
{\r
- /* = NCLASSES */\r
- uint32_t NumberOfObjectClasses;\r
+ /* = NCLASSES */\r
+ uint32_t NumberOfObjectClasses;\r
\r
- uint32_t ObjectPropertyTableSizeInBytes;\r
+ uint32_t ObjectPropertyTableSizeInBytes;\r
\r
- /* This is used to calculate the index in the dynamic object table\r
- (handle - 1 - nofStaticObjects = index)*/\r
+ /* This is used to calculate the index in the dynamic object table\r
+ (handle - 1 - nofStaticObjects = index)*/\r
#if (USE_16BIT_OBJECT_HANDLES == 1) \r
- objectHandleType NumberOfObjectsPerClass[2*((TRACE_NCLASSES+1)/2)];\r
+ objectHandleType NumberOfObjectsPerClass[2*((TRACE_NCLASSES+1)/2)];\r
#else\r
objectHandleType NumberOfObjectsPerClass[4*((TRACE_NCLASSES+3)/4)];\r
#endif\r
\r
- /* Allocation size rounded up to the closest multiple of 4 */\r
- uint8_t NameLengthPerClass[ 4*((TRACE_NCLASSES+3)/4) ];\r
+ /* Allocation size rounded up to the closest multiple of 4 */\r
+ uint8_t NameLengthPerClass[ 4*((TRACE_NCLASSES+3)/4) ];\r
\r
- uint8_t TotalPropertyBytesPerClass[ 4*((TRACE_NCLASSES+3)/4) ];\r
+ uint8_t TotalPropertyBytesPerClass[ 4*((TRACE_NCLASSES+3)/4) ];\r
\r
- /* Allocation size rounded up to the closest multiple of 2 */\r
- uint16_t StartIndexOfClass[ 2*((TRACE_NCLASSES+1)/2) ];\r
+ /* Allocation size rounded up to the closest multiple of 2 */\r
+ uint16_t StartIndexOfClass[ 2*((TRACE_NCLASSES+1)/2) ];\r
\r
- /* The actual handles issued, should be Initiated to all zeros */\r
- uint8_t objbytes[ 4*((TRACE_OBJECT_TABLE_SIZE+3)/4) ];\r
+ /* The actual handles issued, should be Initiated to all zeros */\r
+ uint8_t objbytes[ 4*((TRACE_OBJECT_TABLE_SIZE+3)/4) ];\r
} ObjectPropertyTableType;\r
\r
/* Symbol table data structure */\r
typedef struct\r
{\r
- /* = SYMBOL_HISTORY_TABLE_SIZE_IN_BYTES */\r
- uint32_t symTableSize;\r
+ /* = SYMBOL_HISTORY_TABLE_SIZE_IN_BYTES */\r
+ uint32_t symTableSize;\r
\r
- /* Entry 0 is reserved. Any reference to entry 0 implies NULL*/\r
- uint32_t nextFreeSymbolIndex;\r
+ /* Entry 0 is reserved. Any reference to entry 0 implies NULL*/\r
+ uint32_t nextFreeSymbolIndex;\r
\r
- /* Size rounded up to closest multiple of 4, to avoid alignment issues*/\r
- uint8_t symbytes[4*((SYMBOL_TABLE_SIZE+3)/4)];\r
+ /* Size rounded up to closest multiple of 4, to avoid alignment issues*/\r
+ uint8_t symbytes[4*((SYMBOL_TABLE_SIZE+3)/4)];\r
\r
- /* Used for lookups - Up to 64 linked lists within the symbol table\r
- connecting all entries with the same 6 bit checksum.\r
- This field holds the current list heads. Should be initiated to zeros */\r
- uint16_t latestEntryOfChecksum[64];\r
+ /* Used for lookups - Up to 64 linked lists within the symbol table\r
+ connecting all entries with the same 6 bit checksum.\r
+ This field holds the current list heads. Should be initiated to zeros */\r
+ uint16_t latestEntryOfChecksum[64];\r
} symbolTableType;\r
\r
\r
\r
typedef struct\r
{\r
- uint8_t type;\r
- uint8_t objHandle;\r
- uint16_t dts; /* differential timestamp - time since last event */\r
+ uint8_t type;\r
+ uint8_t objHandle;\r
+ uint16_t dts; /* differential timestamp - time since last event */\r
} TSEvent, TREvent;\r
\r
typedef struct\r
{\r
uint8_t type;\r
uint8_t dummy;\r
- uint16_t dts; /* differential timestamp - time since last event */\r
+ uint16_t dts; /* differential timestamp - time since last event */\r
} LPEvent;\r
\r
typedef struct\r
{\r
- uint8_t type;\r
- uint8_t objHandle;\r
- uint16_t dts; /* differential timestamp - time since last event */\r
+ uint8_t type;\r
+ uint8_t objHandle;\r
+ uint16_t dts; /* differential timestamp - time since last event */\r
} KernelCall;\r
\r
typedef struct\r
{\r
- uint8_t type;\r
- uint8_t objHandle;\r
- uint8_t param;\r
- uint8_t dts; /* differential timestamp - time since last event */\r
+ uint8_t type;\r
+ uint8_t objHandle;\r
+ uint8_t param;\r
+ uint8_t dts; /* differential timestamp - time since last event */\r
} KernelCallWithParamAndHandle;\r
\r
typedef struct\r
{\r
- uint8_t type;\r
- uint8_t dts; /* differential timestamp - time since last event */\r
- uint16_t param;\r
+ uint8_t type;\r
+ uint8_t dts; /* differential timestamp - time since last event */\r
+ uint16_t param;\r
} KernelCallWithParam16;\r
\r
typedef struct\r
{\r
- uint8_t type;\r
- uint8_t objHandle; /* the handle of the closed object */\r
- uint16_t symbolIndex; /* the name of the closed object */\r
+ uint8_t type;\r
+ uint8_t objHandle; /* the handle of the closed object */\r
+ uint16_t symbolIndex; /* the name of the closed object */\r
} ObjCloseNameEvent;\r
\r
typedef struct\r
{\r
- uint8_t type;\r
- uint8_t arg1;\r
- uint8_t arg2;\r
- uint8_t arg3;\r
+ uint8_t type;\r
+ uint8_t arg1;\r
+ uint8_t arg2;\r
+ uint8_t arg3;\r
} ObjClosePropEvent;\r
\r
typedef struct\r
{\r
- uint8_t type;\r
- uint8_t dts;\r
- uint16_t payload; /* the name of the user event */\r
+ uint8_t type;\r
+ uint8_t unused1;\r
+ uint8_t unused2;\r
+ uint8_t dts; \r
+} TaskInstanceStatusEvent;\r
+\r
+typedef struct\r
+{\r
+ uint8_t type;\r
+ uint8_t dts;\r
+ uint16_t payload; /* the name of the user event */\r
} UserEvent;\r
\r
typedef struct\r
{\r
- uint8_t type;\r
+ uint8_t type;\r
\r
- /* 8 bits extra for storing DTS, if it does not fit in ordinary event\r
- (this one is always MSB if used) */\r
- uint8_t xts_8;\r
+ /* 8 bits extra for storing DTS, if it does not fit in ordinary event\r
+ (this one is always MSB if used) */\r
+ uint8_t xts_8;\r
\r
- /* 16 bits extra for storing DTS, if it does not fit in ordinary event. */\r
- uint16_t xts_16;\r
+ /* 16 bits extra for storing DTS, if it does not fit in ordinary event. */\r
+ uint16_t xts_16;\r
} XTSEvent;\r
\r
typedef struct\r
\r
typedef struct\r
{\r
- uint8_t startmarker0;\r
- uint8_t startmarker1;\r
- uint8_t startmarker2;\r
- uint8_t startmarker3;\r
- uint8_t startmarker4;\r
- uint8_t startmarker5;\r
- uint8_t startmarker6;\r
- uint8_t startmarker7;\r
- uint8_t startmarker8;\r
- uint8_t startmarker9;\r
- uint8_t startmarker10;\r
- uint8_t startmarker11;\r
-\r
- /* Used to determine Kernel and Endianess */\r
- uint16_t version;\r
-\r
- /* Currently 3, since v2.6.0 */\r
- uint8_t minor_version;\r
+ uint8_t startmarker0;\r
+ uint8_t startmarker1;\r
+ uint8_t startmarker2;\r
+ uint8_t startmarker3;\r
+ uint8_t startmarker4;\r
+ uint8_t startmarker5;\r
+ uint8_t startmarker6;\r
+ uint8_t startmarker7;\r
+ uint8_t startmarker8;\r
+ uint8_t startmarker9;\r
+ uint8_t startmarker10;\r
+ uint8_t startmarker11;\r
+\r
+ /* Used to determine Kernel and Endianess */\r
+ uint16_t version;\r
\r
- /* This should be 0 if lower IRQ priority values implies higher priority\r
- levels, such as on ARM Cortex M. If the opposite scheme is used, i.e.,\r
- if higher IRQ priority values means higher priority, this should be 1. */\r
- uint8_t irq_priority_order;\r
+ /* Currently 3, since v2.6.0 */\r
+ uint8_t minor_version;\r
\r
- /* sizeof(RecorderDataType) - just for control */\r
- uint32_t filesize;\r
+ /* This should be 0 if lower IRQ priority values implies higher priority\r
+ levels, such as on ARM Cortex M. If the opposite scheme is used, i.e.,\r
+ if higher IRQ priority values means higher priority, this should be 1. */\r
+ uint8_t irq_priority_order;\r
\r
- /* Current number of events recorded */\r
- uint32_t numEvents;\r
+ /* sizeof(RecorderDataType) - just for control */\r
+ uint32_t filesize;\r
\r
- /* The buffer size, in number of event records */\r
- uint32_t maxEvents;\r
+ /* Current number of events recorded */\r
+ uint32_t numEvents;\r
\r
- /* The event buffer index, where to write the next event */\r
- uint32_t nextFreeIndex;\r
+ /* The buffer size, in number of event records */\r
+ uint32_t maxEvents;\r
\r
- /* 1 if the buffer is full, 0 otherwise */\r
- uint32_t bufferIsFull;\r
+ /* The event buffer index, where to write the next event */\r
+ uint32_t nextFreeIndex;\r
\r
- /* The frequency of the clock/timer/counter used as time base */\r
- uint32_t frequency;\r
+ /* 1 if the buffer is full, 0 otherwise */\r
+ uint32_t bufferIsFull;\r
\r
- /* The absolute timestamp of the last stored event, in the native\r
- timebase, modulo frequency! */\r
- uint32_t absTimeLastEvent;\r
+ /* The frequency of the clock/timer/counter used as time base */\r
+ uint32_t frequency;\r
\r
- /* The number of seconds in total - lasts for 136 years */\r
- uint32_t absTimeLastEventSecond;\r
+ /* The absolute timestamp of the last stored event, in the native\r
+ timebase, modulo frequency! */\r
+ uint32_t absTimeLastEvent;\r
\r
- /* 1 if the recorder has been started, 0 if not yet started or stopped.\r
- This is a 32 bit variable due to alignment issues. */\r
- uint32_t recorderActive;\r
+ /* The number of seconds in total - lasts for 136 years */\r
+ uint32_t absTimeLastEventSecond;\r
\r
- /* Not used, remains for compatibility and future use */\r
- uint8_t notused[28];\r
+ /* 1 if the recorder has been started, 0 if not yet started or stopped.\r
+ This is a 32 bit variable due to alignment issues. */\r
+ uint32_t recorderActive;\r
\r
- /* The amount of heap memory remaining at the last malloc or free event */ \r
+ /* Not used, remains for compatibility and future use */\r
+ uint8_t notused[28];\r
+ \r
+ /* The amount of heap memory remaining at the last malloc or free event */\r
uint32_t heapMemUsage;\r
\r
- /* 0xF0F0F0F0 - for control only */\r
- int32_t debugMarker0;\r
+ /* 0xF0F0F0F0 - for control only */\r
+ int32_t debugMarker0;\r
\r
/* Set to value of USE_16BIT_OBJECT_HANDLES */\r
uint32_t isUsing16bitHandles;\r
\r
- /* The Object Property Table holds information about currently active\r
- tasks, queues, and other recorded objects. This is updated on each\r
- create call and includes object name and other properties. */\r
- ObjectPropertyTableType ObjectPropertyTable;\r
+ /* The Object Property Table holds information about currently active\r
+ tasks, queues, and other recorded objects. This is updated on each\r
+ create call and includes object name and other properties. */\r
+ ObjectPropertyTableType ObjectPropertyTable;\r
\r
- /* 0xF1F1F1F1 - for control only */\r
- int32_t debugMarker1;\r
+ /* 0xF1F1F1F1 - for control only */\r
+ int32_t debugMarker1;\r
\r
- /* The Symbol Table stores strings for User Events and is also used to\r
- store names of deleted objects, which still may be in the trace but no\r
- longer are available. */\r
- symbolTableType SymbolTable;\r
+ /* The Symbol Table stores strings for User Events and is also used to\r
+ store names of deleted objects, which still may be in the trace but no\r
+ longer are available. */\r
+ symbolTableType SymbolTable;\r
\r
- /* For inclusion of float support, and for endian detection of floats.\r
- The value should be (float)1 or (uint32_t)0 */\r
+ /* For inclusion of float support, and for endian detection of floats.\r
+ The value should be (float)1 or (uint32_t)0 */\r
#if (INCLUDE_FLOAT_SUPPORT == 1)\r
- float exampleFloatEncoding;\r
+ float exampleFloatEncoding;\r
#else\r
- uint32_t exampleFloatEncoding;\r
+ uint32_t exampleFloatEncoding;\r
#endif\r
- /* This is non-zero if an internal error occurred in the recorder, e.g., if\r
- one of the Nxxx constants was too small. The systemInfo string will then\r
- contain an error message that is displayed when attempting to view the\r
- trace file. */\r
- uint32_t internalErrorOccured;\r
+ /* This is non-zero if an internal error occurred in the recorder, e.g., if\r
+ one of the Nxxx constants was too small. The systemInfo string will then\r
+ contain an error message that is displayed when attempting to view the\r
+ trace file. */\r
+ uint32_t internalErrorOccured;\r
\r
- /* 0xF2F2F2F2 - for control only */\r
- int32_t debugMarker2;\r
+ /* 0xF2F2F2F2 - for control only */\r
+ int32_t debugMarker2;\r
\r
- /* Generic system information string, presented in the tool. Note that this\r
- is also used for storing any internal error messages from the recorder, so\r
- do not make TRACE_DESCRIPTION_MAX_LENGTH too small. 80 is recommended. */\r
- char systemInfo[TRACE_DESCRIPTION_MAX_LENGTH];\r
+ /* Error messages from the recorder. */\r
+ char systemInfo[80];\r
\r
- /* 0xF3F3F3F3 - for control only */\r
- int32_t debugMarker3;\r
+ /* 0xF3F3F3F3 - for control only */\r
+ int32_t debugMarker3;\r
\r
- /* The event data, in 4-byte records */\r
- uint8_t eventData[ EVENT_BUFFER_SIZE * 4 ];\r
+ /* The event data, in 4-byte records */\r
+ uint8_t eventData[ EVENT_BUFFER_SIZE * 4 ];\r
\r
#if (USE_SEPARATE_USER_EVENT_BUFFER == 1)\r
UserEventBuffer userEventBuffer;\r
/* This should always be 0 */\r
uint32_t endOfSecondaryBlocks;\r
\r
- uint8_t endmarker0;\r
- uint8_t endmarker1;\r
- uint8_t endmarker2;\r
- uint8_t endmarker3;\r
- uint8_t endmarker4;\r
- uint8_t endmarker5;\r
- uint8_t endmarker6;\r
- uint8_t endmarker7;\r
- uint8_t endmarker8;\r
- uint8_t endmarker9;\r
- uint8_t endmarker10;\r
- uint8_t endmarker11;\r
+ uint8_t endmarker0;\r
+ uint8_t endmarker1;\r
+ uint8_t endmarker2;\r
+ uint8_t endmarker3;\r
+ uint8_t endmarker4;\r
+ uint8_t endmarker5;\r
+ uint8_t endmarker6;\r
+ uint8_t endmarker7;\r
+ uint8_t endmarker8;\r
+ uint8_t endmarker9;\r
+ uint8_t endmarker10;\r
+ uint8_t endmarker11;\r
} RecorderDataType;\r
\r
extern RecorderDataType* RecorderDataPtr;\r
void prvTraceGetChecksum(const char *pname, uint8_t* pcrc, uint8_t* plength);\r
\r
traceLabel prvTraceCreateSymbolTableEntry(const char* name,\r
- uint8_t crc6,\r
- uint8_t len,\r
- traceLabel channel);\r
+ uint8_t crc6,\r
+ uint8_t len,\r
+ traceLabel channel);\r
\r
traceLabel prvTraceLookupSymbolTableEntry(const char* name,\r
- uint8_t crc6,\r
- uint8_t len,\r
- traceLabel channel);\r
+ uint8_t crc6,\r
+ uint8_t len,\r
+ traceLabel channel);\r
\r
traceLabel prvTraceOpenSymbol(const char* name, traceLabel userEventChannel);\r
\r
objectHandleType xTraceGetObjectHandle(traceObjectClass objectclass);\r
\r
void vTraceFreeObjectHandle(traceObjectClass objectclass,\r
- objectHandleType handle);\r
+ objectHandleType handle);\r
\r
void vTraceSetObjectName(traceObjectClass objectclass,\r
- objectHandleType handle,\r
- const char* name);\r
+ objectHandleType handle,\r
+ const char* name);\r
\r
void* xTraceNextFreeEventBufferSlot(void);\r
\r
\r
\r
uint16_t uiIndexOfObject(objectHandleType objecthandle,\r
- uint8_t objectclass);\r
+ uint8_t objectclass);\r
\r
/*******************************************************************************\r
* vTraceError\r
#define TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) TRACE_CLEAR_FLAG_ISEXCLUDED(excludedEventCodes, eventCode)\r
#define TRACE_GET_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) TRACE_GET_FLAG_ISEXCLUDED(excludedEventCodes, eventCode)\r
\r
-#define TRACE_UPDATE_HEAP_USAGE_POSITIVE(change) {if (RecorderDataPtr != NULL) RecorderDataPtr->heapMemUsage += change;}\r
-#define TRACE_UPDATE_HEAP_USAGE_NEGATIVE(change) {if (RecorderDataPtr != NULL) RecorderDataPtr->heapMemUsage -= change;}\r
-\r
/* DEBUG ASSERTS */\r
#if defined USE_TRACE_ASSERT && USE_TRACE_ASSERT != 0\r
#define TRACE_ASSERT(eval, msg, defRetVal) \\r
\r
#endif\r
\r
-#endif
\ No newline at end of file
+#endif\r
+\r
+\r
+\r
+\r