]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcRecorder.h
Update trace recorder code.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-Trace / Include / trcRecorder.h
index ed0de039972d229425f321ad34da6bfaa5d0ee68..a7012fbed7e6d7e0031aae193a09a970a4aafd7a 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Trace Recorder Library for Tracealyzer v3.1.2\r
+ * Trace Recorder Library for Tracealyzer v4.1.1\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcRecorder.h\r
@@ -38,7 +38,7 @@
  *\r
  * Tabs are used for indent in this file (1 tab = 4 spaces)\r
  *\r
- * Copyright Percepio AB, 2017.\r
+ * Copyright Percepio AB, 2018.\r
  * www.percepio.com\r
  ******************************************************************************/\r
 \r
@@ -51,11 +51,11 @@ extern "C" {
 \r
 #include <stdarg.h>\r
 #include <stdint.h>\r
+#include <stddef.h>\r
 #include "trcConfig.h"\r
 #include "trcPortDefines.h"\r
 \r
 \r
-       \r
 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)\r
 typedef uint16_t traceString;\r
 typedef uint8_t traceUBChannel;\r
@@ -84,7 +84,12 @@ typedef const void* traceHandle;
 #endif\r
 \r
 #if (TRC_USE_TRACEALYZER_RECORDER == 1)\r
-       \r
+\r
+#define TRACE_GET_LOW16(value) ((uint16_t)((value) & 0x0000FFFF))\r
+#define TRACE_GET_HIGH16(value) ((uint16_t)(((value) >> 16) & 0x0000FFFF))\r
+#define TRACE_SET_LOW16(current, value)  (((current) & 0xFFFF0000) | (value))\r
+#define TRACE_SET_HIGH16(current, value) (((current) & 0x0000FFFF) | (((uint32_t)(value)) << 16))\r
+\r
 /******************************************************************************/\r
 /*** Common API - both Snapshot and Streaming mode ****************************/\r
 /******************************************************************************/\r
@@ -208,11 +213,14 @@ void vTraceEnable(int startOption);
  * In snapshot mode you are limited to maximum 15 arguments, that must not exceed\r
  * 32 bytes in total (not counting the format string). If exceeded, the recorder\r
  * logs an internal error (displayed when opening the trace) and stops recording. \r
- *\r
  ******************************************************************************/\r
+#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)\r
 void vTracePrintF(traceString chn, const char* fmt, ...);\r
+#else\r
+#define vTracePrintF(chn, ...) (void)chn\r
+#endif\r
 \r
-/******************************************************************************\r
+ /******************************************************************************\r
 * vTracePrint\r
 *\r
 * A faster version of vTracePrintF, that only allows for logging a string.\r
@@ -222,9 +230,12 @@ void vTracePrintF(traceString chn, const char* fmt, ...);
 *       traceString chn = xTraceRegisterString("MyChannel");\r
 *       ...\r
 *       vTracePrint(chn, "Hello World!");\r
-*\r
 ******************************************************************************/\r
+#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)\r
 void vTracePrint(traceString chn, const char* str);\r
+#else\r
+#define vTracePrint(chn, ...) (void)chn\r
+#endif\r
 \r
 /*******************************************************************************\r
 * xTraceRegisterString\r
@@ -235,9 +246,12 @@ void vTracePrint(traceString chn, const char* str);
 *       myEventHandle = xTraceRegisterString("MyUserEvent");\r
 *       ...\r
 *       vTracePrintF(myEventHandle, "My value is: %d", myValue);\r
-*\r
 ******************************************************************************/\r
+#if (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1)\r
 traceString xTraceRegisterString(const char* name);\r
+#else\r
+#define xTraceRegisterString(x) (x)\r
+#endif\r
 \r
 /*******************************************************************************\r
  * vTraceSet...Name(void* object, const char* name)\r
@@ -247,18 +261,8 @@ traceString xTraceRegisterString(const char* name);
  *\r
  * Kernel-specific functions for setting names of kernel objects, for display in\r
  * Tracealyzer.\r
- *\r
- * See trcKernelPort.h for details (since kernel-specific)\r
  ******************************************************************************/\r
-\r
-/*******************************************************************************\r
- * vTraceExclude... \r
- *\r
- * Kernel-specific macros for excluding specified events from the trace. Allows \r
- * for capturing longer traces in snapshot mode by selective tracing.\r
- *\r
- * See trcKernelPort.h for details (kernel-specific)\r
- ******************************************************************************/ \r
+/* See trcKernelPort.h for details (kernel-specific) */\r
 \r
 /*******************************************************************************\r
  * xTraceSetISRProperties\r
@@ -277,7 +281,6 @@ traceString xTraceRegisterString(const char* name);
  *              ...\r
  *              vTraceStoreISREnd(0);\r
  *      }\r
- *\r
  ******************************************************************************/\r
 traceHandle xTraceSetISRProperties(const char* name, uint8_t priority);\r
 \r
@@ -298,7 +301,6 @@ traceHandle xTraceSetISRProperties(const char* name, uint8_t priority);
  *              ...\r
  *              vTraceStoreISREnd(0);\r
  *      }\r
- *\r
  ******************************************************************************/\r
 void vTraceStoreISRBegin(traceHandle handle);\r
 \r
@@ -323,7 +325,6 @@ void vTraceStoreISRBegin(traceHandle handle);
  *              ...\r
  *              vTraceStoreISREnd(0);\r
  *      }\r
- *\r
  ******************************************************************************/\r
 void vTraceStoreISREnd(int isTaskSwitchRequired);\r
 \r
@@ -352,7 +353,7 @@ void vTraceInstanceFinishedNext(void);
 /*******************************************************************************\r
  * xTraceGetLastError\r
  *\r
- * Returns the last error, if any.\r
+ * Returns the last error or warning as a string, or NULL if none.\r
  *****************************************************************************/\r
 const char* xTraceGetLastError(void);\r
 \r
@@ -420,8 +421,11 @@ void vTraceSetRecorderDataBuffer(void* pRecorderData);
 *\r
 * This translates to a single static allocation, on which you can apply linker\r
 * directives to place it in a particular memory region.\r
+*\r
 * - Snapshot mode: "RecorderDataType <name>"\r
-* - Streaming mode: "char <name> [<size>]", with <size> from trcStreamingPort.h.\r
+*\r
+* - Streaming mode: "char <name> [<size>]", \r
+*   where <size> is defined in trcStreamingConfig.h.\r
 *\r
 * Example:\r
 *\r
@@ -434,17 +438,96 @@ void vTraceSetRecorderDataBuffer(void* pRecorderData);
 *      vTraceSetRecorderDataBuffer(&myTraceBuffer); // Note the "&"\r
 *      ...\r
 *      vTraceEnable(TRC_INIT); // Initialize the data structure\r
-*\r
 ******************************************************************************/\r
-#ifndef TRC_ALLOC_CUSTOM_BUFFER\r
-/* Definition for snapshot mode only. Also defined in trcStreamingPort.h */\r
 #if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM)\r
-#define TRC_ALLOC_CUSTOM_BUFFER(bufname) RecorderDataType bufname;\r
+       #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)\r
+               #define TRC_ALLOC_CUSTOM_BUFFER(bufname) RecorderDataType bufname;\r
+       #elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)\r
+               #ifdef TRC_CFG_RTT_BUFFER_SIZE_UP /* J-Link RTT */\r
+                       #define TRC_ALLOC_CUSTOM_BUFFER(bufname) char bufname [TRC_CFG_RTT_BUFFER_SIZE_UP];  /* Not static in this case, since declared in user code */\r
+               #else\r
+                       #define TRC_ALLOC_CUSTOM_BUFFER(bufname) char bufname [(TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)];\r
+               #endif\r
+       #endif\r
 #else\r
-#define TRC_ALLOC_CUSTOM_BUFFER(bufname)\r
-#endif\r
+       #define TRC_ALLOC_CUSTOM_BUFFER(bufname)\r
 #endif\r
 \r
+/******************************************************************************\r
+* xTraceIsRecordingEnabled\r
+*\r
+* Returns true (1) if the recorder is enabled (i.e. is recording), otherwise 0.\r
+******************************************************************************/\r
+int xTraceIsRecordingEnabled(void);\r
+\r
+/*******************************************************************************\r
+* vTraceSetFilterGroup\r
+*\r
+* Sets the "filter group" to assign when creating RTOS objects, such as tasks,\r
+* queues, semaphores and mutexes. This together with vTraceSetFilterMask \r
+* allows you to control what events that are recorded, based on the \r
+* objects they refer to.\r
+*\r
+* There are 16 filter groups named FilterGroup0 .. FilterGroup15.\r
+*\r
+* Note: We don't recommend filtering out the Idle task, so make sure to call \r
+* vTraceSetFilterGroup just before initializing the RTOS, in order to assign\r
+* such "default" objects to the right Filter Group (typically group 0).\r
+*\r
+* Example:\r
+*  \r
+*              // Assign tasks T1 to FilterGroup0 (default)\r
+*              <Create Task T1>  \r
+*\r
+*              // Assign Q1 and Q2 to FilterGroup1\r
+*              vTraceSetFilterGroup(FilterGroup1);\r
+*              <Create Queue Q1> \r
+*              <Create Queue Q2>\r
+*\r
+*              // Assigns Q3 to FilterGroup2\r
+*              vTraceSetFilterGroup(FilterGroup2);\r
+*              <Create Queue Q3>\r
+*\r
+*              // Only include FilterGroup0 and FilterGroup2, exclude FilterGroup1 (Q1 and Q2) from the trace\r
+*              vTraceSetFilterMask( FilterGroup0 | FilterGroup2 );\r
+*\r
+*              // Assign the default RTOS objects (e.g. Idle task) to FilterGroup0\r
+*              vTraceSetFilterGroup(FilterGroup0);\r
+*              <Start the RTOS scheduler>\r
+*\r
+* Note that you may define your own names for the filter groups using\r
+* preprocessor definitions, to make the code easier to understand.\r
+*\r
+* Example:\r
+*\r
+*              #define BASE FilterGroup0\r
+*              #define USB_EVENTS FilterGroup1\r
+*              #define CAN_EVENTS FilterGroup2\r
+*\r
+* Note that filtering per event type (regardless of object) is also available\r
+* in trcConfig.h.\r
+******************************************************************************/\r
+void vTraceSetFilterGroup(uint16_t filterGroup);\r
+\r
+/******************************************************************************\r
+* vTraceSetFilterMask\r
+*\r
+* Sets the "filter mask" that is used to filter the events by object. This can\r
+* be used to reduce the trace data rate, i.e., if your streaming interface is\r
+* a bottleneck or if you want longer snapshot traces without increasing the\r
+* buffer size.\r
+*\r
+* Note: There are two kinds of filters in the recorder. The other filter type\r
+* excludes all events of certain kinds (e.g., OS ticks). See trcConfig.h.\r
+*\r
+* The filtering is based on bitwise AND with the Filter Group ID, assigned\r
+* to RTOS objects such as tasks, queues, semaphores and mutexes. \r
+* This together with vTraceSetFilterGroup allows you to control what\r
+* events that are recorded, based on the objects they refer to.\r
+*\r
+* See example for vTraceSetFilterGroup.\r
+******************************************************************************/\r
+void vTraceSetFilterMask(uint16_t filterMask);\r
 \r
 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)\r
 \r
@@ -494,7 +577,6 @@ void vTraceSetStopHook(TRACE_STOP_HOOK stopHookFunction);
 * error. In that case, check xTraceGetLastError to get the error message.\r
 * Any error message is also presented when opening a trace file.\r
 *\r
-*\r
 * Snapshot mode only!\r
 ******************************************************************************/\r
 uint32_t uiTraceStart(void);\r
@@ -527,11 +609,7 @@ void vTraceClear(void);
 /*** INTERNAL SNAPSHOT FUNCTIONS *********************************************/\r
 /*****************************************************************************/\r
 \r
-#undef INCLUDE_xTaskGetSchedulerState\r
-#define INCLUDE_xTaskGetSchedulerState 1\r
-\r
-#undef INCLUDE_xTaskGetCurrentTaskHandle\r
-#define INCLUDE_xTaskGetCurrentTaskHandle 1\r
+#define TRC_UNUSED\r
 \r
 #ifndef TRC_CFG_INCLUDE_OBJECT_DELETE\r
 #define TRC_CFG_INCLUDE_OBJECT_DELETE 0\r
@@ -545,82 +623,105 @@ void vTraceClear(void);
 #define TRC_CFG_INCLUDE_OSTICK_EVENTS 0\r
 #endif\r
 \r
-#define TRC_UNUSED\r
+/* This macro will create a task in the object table */\r
+#undef trcKERNEL_HOOKS_TASK_CREATE\r
+#define trcKERNEL_HOOKS_TASK_CREATE(SERVICE, CLASS, pxTCB) \\r
+       TRACE_SET_TASK_NUMBER(pxTCB); \\r
+       TRACE_SET_TASK_FILTER(pxTCB, CurrentFilterGroup); \\r
+       prvTraceSetObjectName(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_NAME(pxTCB)); \\r
+       prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_PRIORITY(pxTCB)); \\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
+                       prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));\r
 \r
-#if (TRC_CFG_INCLUDE_OBJECT_DELETE == 1)\r
 /* This macro will remove the task and store it in the event buffer */\r
 #undef trcKERNEL_HOOKS_TASK_DELETE\r
-#define trcKERNEL_HOOKS_TASK_DELETE(SERVICE, pxTCB) \\r
-       prvTraceStoreKernelCall(TRACE_GET_TASK_EVENT_CODE(SERVICE, SUCCESS, CLASS, pxTCB), TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \\r
-       prvTraceStoreObjectNameOnCloseEvent(TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \\r
-       prvTraceStoreObjectPropertiesOnCloseEvent(TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \\r
+#define trcKERNEL_HOOKS_TASK_DELETE(SERVICE, SERVICE_NAME, SERVICE_PROP, pxTCB) \\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
+                       prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \\r
+       prvTraceStoreObjectNameOnCloseEvent(SERVICE_NAME, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \\r
+       prvTraceStoreObjectPropertiesOnCloseEvent(SERVICE_PROP, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_CLASS_TASK); \\r
        prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_PRIORITY(pxTCB)); \\r
        prvTraceSetObjectState(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TASK_STATE_INSTANCE_NOT_ACTIVE); \\r
        prvTraceFreeObjectHandle(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));\r
-#else /*(TRC_CFG_INCLUDE_OBJECT_DELETE == 1)*/\r
-#undef trcKERNEL_HOOKS_TASK_DELETE\r
-#define trcKERNEL_HOOKS_TASK_DELETE(SERVICE, pxTCB)\r
-#endif /*(TRC_CFG_INCLUDE_OBJECT_DELETE == 1)*/\r
 \r
-#if (TRC_CFG_INCLUDE_OBJECT_DELETE == 1)\r
-/* This macro will remove the object and store it in the event buffer */\r
-#undef trcKERNEL_HOOKS_OBJECT_DELETE\r
-#define trcKERNEL_HOOKS_OBJECT_DELETE(SERVICE, CLASS, pxObject) \\r
-       prvTraceStoreKernelCall(TRACE_GET_OBJECT_EVENT_CODE(SERVICE, SUCCESS, CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \\r
-       prvTraceStoreObjectNameOnCloseEvent(TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \\r
-       prvTraceStoreObjectPropertiesOnCloseEvent(TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \\r
-       prvTraceFreeObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\r
-#else /*TRC_CFG_INCLUDE_OBJECT_DELETE*/\r
-#undef trcKERNEL_HOOKS_OBJECT_DELETE\r
-#define trcKERNEL_HOOKS_OBJECT_DELETE(SERVICE, CLASS, pxObject)\r
-#endif /*TRC_CFG_INCLUDE_OBJECT_DELETE*/\r
-\r
-/* This macro will create a task in the object table */\r
-#undef trcKERNEL_HOOKS_TASK_CREATE\r
-#define trcKERNEL_HOOKS_TASK_CREATE(SERVICE, CLASS, pxTCB) \\r
-       TRACE_SET_TASK_NUMBER(pxTCB) \\r
-       prvTraceSetObjectName(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_NAME(pxTCB)); \\r
-       prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), TRACE_GET_TASK_PRIORITY(pxTCB)); \\r
-       prvTraceStoreKernelCall(TRACE_GET_TASK_EVENT_CODE(SERVICE, SUCCESS, CLASS, pxTCB), TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));\r
-\r
-/* This macro will create a failed create call to create a task */\r
-#undef trcKERNEL_HOOKS_TASK_CREATE_FAILED\r
-#define trcKERNEL_HOOKS_TASK_CREATE_FAILED(SERVICE, CLASS) \\r
-       prvTraceStoreKernelCall(TRACE_GET_TASK_EVENT_CODE(SERVICE, FAILED, CLASS, 0), TRACE_CLASS_TASK, 0);\r
 \r
 /* This macro will setup a task in the object table */\r
 #undef trcKERNEL_HOOKS_OBJECT_CREATE\r
 #define trcKERNEL_HOOKS_OBJECT_CREATE(SERVICE, CLASS, pxObject)\\r
        TRACE_SET_OBJECT_NUMBER(CLASS, pxObject);\\r
+       TRACE_SET_OBJECT_FILTER(CLASS, pxObject, CurrentFilterGroup); \\r
        prvMarkObjectAsUsed(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject),  TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\\r
-       prvTraceStoreKernelCall(TRACE_GET_OBJECT_EVENT_CODE(SERVICE, SUCCESS, CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \\r
+                       prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \\r
        prvTraceSetObjectState(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), 0);\r
 \r
-/* This macro will create a failed create call to create an object */\r
-#undef trcKERNEL_HOOKS_OBJECT_CREATE_FAILED\r
-#define trcKERNEL_HOOKS_OBJECT_CREATE_FAILED(SERVICE, CLASS, kernelClass) \\r
-       prvTraceStoreKernelCall(TRACE_GET_CLASS_EVENT_CODE(SERVICE, FAILED, CLASS, kernelClass), TRACE_GET_CLASS_TRACE_CLASS(CLASS, kernelClass), 0);\r
+/* This macro will remove the object and store it in the event buffer */\r
+#undef trcKERNEL_HOOKS_OBJECT_DELETE\r
+#define trcKERNEL_HOOKS_OBJECT_DELETE(SERVICE, SERVICE_NAME, SERVICE_PROP, CLASS, pxObject) \\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \\r
+                       prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject)); \\r
+       prvTraceStoreObjectNameOnCloseEvent(SERVICE_NAME, TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \\r
+       prvTraceStoreObjectPropertiesOnCloseEvent(SERVICE_PROP, TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)); \\r
+       prvTraceFreeObjectHandle(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\r
 \r
 /* This macro will create a call to a kernel service with a certain result, with an object as parameter */\r
 #undef trcKERNEL_HOOKS_KERNEL_SERVICE\r
-#define trcKERNEL_HOOKS_KERNEL_SERVICE(SERVICE, RESULT, CLASS, pxObject) \\r
-       prvTraceStoreKernelCall(TRACE_GET_OBJECT_EVENT_CODE(SERVICE, RESULT, CLASS, pxObject), TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\r
+#define trcKERNEL_HOOKS_KERNEL_SERVICE(SERVICE, CLASS, pxObject) \\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \\r
+                       prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\r
+\r
+/* This macro will create a call to a kernel service with a certain result, with an object as parameter */\r
+#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM\r
+#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM(SERVICE, CLASS, pxObject, param) \\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \\r
+                       prvTraceStoreKernelCallWithParam(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), (uint32_t)param);\r
+\r
+/* This macro will create a call to a kernel service with a certain result, with an object as parameter */\r
+#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY\r
+#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY(SERVICE, param) \\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, (uint32_t)param);\r
+\r
+/* This macro will create a call to a kernel service with a certain result, with an object as parameter */\r
+#undef trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR\r
+#define trcKERNEL_HOOKS_KERNEL_SERVICE_FROM_ISR(SERVICE, CLASS, pxObject) \\r
+       if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \\r
+               prvTraceStoreKernelCall(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject));\r
+\r
+/* This macro will create a call to a kernel service with a certain result, with an object as parameter */\r
+#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR\r
+#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_PARAM_FROM_ISR(SERVICE, CLASS, pxObject, param) \\r
+       if (TRACE_GET_OBJECT_FILTER(CLASS, pxObject) & CurrentFilterMask) \\r
+               prvTraceStoreKernelCallWithParam(SERVICE, TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), (uint32_t)param);\r
+\r
+/* This macro will create a call to a kernel service with a certain result, with an object as parameter */\r
+#undef trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY_FROM_ISR\r
+#define trcKERNEL_HOOKS_KERNEL_SERVICE_WITH_NUMERIC_PARAM_ONLY_FROM_ISR(SERVICE, param) \\r
+       prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, (uint32_t)param);\r
 \r
 /* This macro will set the state for an object */\r
 #undef trcKERNEL_HOOKS_SET_OBJECT_STATE\r
 #define trcKERNEL_HOOKS_SET_OBJECT_STATE(CLASS, pxObject, STATE) \\r
-       prvTraceSetObjectState(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), STATE);\r
+       prvTraceSetObjectState(TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject), TRACE_GET_OBJECT_NUMBER(CLASS, pxObject), (uint8_t)STATE);\r
 \r
 /* This macro will flag a certain task as a finished instance */\r
 #undef trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED\r
 #define trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED() \\r
-       prvTraceSetTaskInstanceFinished(TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK()));\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               prvTraceSetTaskInstanceFinished(TRACE_GET_TASK_NUMBER(TRACE_GET_CURRENT_TASK()));\r
 \r
 #if (TRC_CFG_INCLUDE_READY_EVENTS == 1)\r
 /* This macro will create an event to indicate that a task became Ready */\r
 #undef trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE\r
 #define trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB) \\r
-       prvTraceStoreTaskReady(TRACE_GET_TASK_NUMBER(pxTCB));\r
+       if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
+               prvTraceStoreTaskReady(TRACE_GET_TASK_NUMBER(pxTCB));\r
 #else /*(TRC_CFG_INCLUDE_READY_EVENTS == 1)*/\r
 #undef trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE\r
 #define trcKERNEL_HOOKS_MOVED_TASK_TO_READY_STATE(pxTCB)\r
@@ -629,7 +730,11 @@ void vTraceClear(void);
 /* This macro will update the internal tick counter and call prvTracePortGetTimeStamp(0) to update the internal counters */\r
 #undef trcKERNEL_HOOKS_INCREMENT_TICK\r
 #define trcKERNEL_HOOKS_INCREMENT_TICK() \\r
-       { extern uint32_t uiTraceTickCount; uiTraceTickCount++; prvTracePortGetTimeStamp(0); }\r
+       { \\r
+               extern uint32_t uiTraceTickCount; \\r
+               uiTraceTickCount++; \\r
+               prvTracePortGetTimeStamp(0); \\r
+       }\r
 \r
 #if (TRC_CFG_INCLUDE_OSTICK_EVENTS == 1)\r
 /* This macro will create an event indicating that the OS tick count has increased */\r
@@ -644,48 +749,46 @@ void vTraceClear(void);
 /* This macro will create a task switch event to the currently executing task */\r
 #undef trcKERNEL_HOOKS_TASK_SWITCH\r
 #define trcKERNEL_HOOKS_TASK_SWITCH( pxTCB ) \\r
-       prvTraceStoreTaskswitch(TRACE_GET_TASK_NUMBER(pxTCB));\r
+       if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
+               prvTraceStoreTaskswitch(TRACE_GET_TASK_NUMBER(pxTCB));\r
 \r
 /* This macro will create an event to indicate that the task has been suspended */\r
 #undef trcKERNEL_HOOKS_TASK_SUSPEND\r
 #define trcKERNEL_HOOKS_TASK_SUSPEND(SERVICE, pxTCB) \\r
-       prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
+                       prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)); \\r
        prvTraceSetTaskInstanceFinished((uint8_t)TRACE_GET_TASK_NUMBER(pxTCB));\r
 \r
 /* This macro will create an event to indicate that a task has called a wait/delay function */\r
 #undef trcKERNEL_HOOKS_TASK_DELAY\r
 #define trcKERNEL_HOOKS_TASK_DELAY(SERVICE, pxTCB, xValue) \\r
-       prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, xValue); \\r
-       prvTraceSetTaskInstanceFinished((uint8_t)TRACE_GET_TASK_NUMBER(pxTCB));\r
+       if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
+       { \\r
+               prvTraceStoreKernelCallWithNumericParamOnly(SERVICE, xValue); \\r
+               prvTraceSetTaskInstanceFinished((uint8_t)TRACE_GET_TASK_NUMBER(pxTCB)); \\r
+       }\r
 \r
 /* This macro will create an event to indicate that a task has gotten its priority changed */\r
 #undef trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE\r
 #define trcKERNEL_HOOKS_TASK_PRIORITY_CHANGE(SERVICE, pxTCB, uxNewPriority) \\r
-       prvTraceStoreKernelCallWithParam(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), prvTraceGetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)));\\r
-       prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), (uint8_t)uxNewPriority);\r
+       if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
+       { \\r
+               prvTraceStoreKernelCallWithParam(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), prvTraceGetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB)));\\r
+               prvTraceSetPriorityProperty(TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB), (uint8_t)uxNewPriority); \\r
+       }\r
 \r
 /* This macro will create an event to indicate that the task has been resumed */\r
 #undef trcKERNEL_HOOKS_TASK_RESUME\r
 #define trcKERNEL_HOOKS_TASK_RESUME(SERVICE, pxTCB) \\r
-       prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));\r
-       \r
-#undef trcKERNEL_HOOKS_TIMER_EVENT\r
-#define trcKERNEL_HOOKS_TIMER_EVENT(SERVICE, pxTimer) \\r
-       prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TIMER, TRACE_GET_TIMER_NUMBER(pxTimer));\r
-\r
-/* This macro will create a timer in the object table and assign the timer a trace handle (timer number).*/\r
-#undef trcKERNEL_HOOKS_TIMER_CREATE\r
-#define trcKERNEL_HOOKS_TIMER_CREATE(SERVICE, pxTimer) \\r
-TRACE_SET_TIMER_NUMBER(pxTimer); \\r
-prvTraceSetObjectName(TRACE_CLASS_TIMER, TRACE_GET_TIMER_NUMBER(pxTimer), TRACE_GET_TIMER_NAME(pxTimer)); \\r
-prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TIMER, TRACE_GET_TIMER_NUMBER(pxTimer));\r
-\r
-#undef trcKERNEL_HOOKS_TIMER_DELETE\r
-#define trcKERNEL_HOOKS_TIMER_DELETE(SERVICE, pxTimer) \\r
-prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TIMER, TRACE_GET_TIMER_NUMBER(pxTimer)); \\r
-prvTraceStoreObjectNameOnCloseEvent(TRACE_GET_TIMER_NUMBER(pxTimer), TRACE_CLASS_TIMER); \\r
-prvTraceStoreObjectPropertiesOnCloseEvent(TRACE_GET_TIMER_NUMBER(pxTimer), TRACE_CLASS_TIMER); \\r
-prvTraceFreeObjectHandle(TRACE_CLASS_TIMER, TRACE_GET_TIMER_NUMBER(pxTimer));\r
+       if (TRACE_GET_TASK_FILTER(TRACE_GET_CURRENT_TASK()) & CurrentFilterMask) \\r
+               if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
+                       prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));\r
+\r
+#undef trcKERNEL_HOOKS_TASK_RESUME_FROM_ISR\r
+#define trcKERNEL_HOOKS_TASK_RESUME_FROM_ISR(SERVICE, pxTCB) \\r
+       if (TRACE_GET_TASK_FILTER(pxTCB) & CurrentFilterMask) \\r
+               prvTraceStoreKernelCall(SERVICE, TRACE_CLASS_TASK, TRACE_GET_TASK_NUMBER(pxTCB));\r
 \r
 #if !defined TRC_CFG_INCLUDE_READY_EVENTS || TRC_CFG_INCLUDE_READY_EVENTS == 1\r
        void prvTraceSetReadyEventsEnabled(int status);\r
@@ -725,15 +828,11 @@ void prvTraceSetObjectState(uint8_t objectclass, traceHandle id, uint8_t value);
 \r
 void prvMarkObjectAsUsed(traceObjectClass objectclass, traceHandle handle);\r
 \r
-\r
-#if (TRC_CFG_INCLUDE_OBJECT_DELETE == 1)\r
-\r
-void prvTraceStoreObjectNameOnCloseEvent(traceHandle handle,\r
+void prvTraceStoreObjectNameOnCloseEvent(uint8_t evtcode, traceHandle handle,\r
                                                                                traceObjectClass objectclass);\r
 \r
-void prvTraceStoreObjectPropertiesOnCloseEvent(traceHandle handle,\r
+void prvTraceStoreObjectPropertiesOnCloseEvent(uint8_t evtcode, traceHandle handle,\r
                                                                                         traceObjectClass objectclass);\r
-#endif\r
 \r
 /* Internal constants for task state */\r
 #define TASK_STATE_INSTANCE_NOT_ACTIVE 0\r
@@ -742,9 +841,6 @@ void prvTraceStoreObjectPropertiesOnCloseEvent(traceHandle handle,
 \r
 #if (TRC_CFG_INCLUDE_ISR_TRACING == 0)\r
 \r
-//void prvTraceIncreaseISRActive(void);\r
-\r
-//void prvTraceDecreaseISRActive(void);\r
 #undef vTraceSetISRProperties\r
 #define vTraceSetISRProperties(handle, name, priority)\r
 \r
@@ -824,12 +920,6 @@ void vTraceUBEvent(traceUBChannel channel);
        #define trcCRITICAL_SECTION_END_ON_CORTEX_M_ONLY() recorder_busy--;\r
 #endif\r
 \r
-/* Structure to handle the exclude flags for all objects and tasks. We add some extra objects since index 0 is not used for each object class. */\r
-extern uint8_t trcExcludedObjects[(TRACE_KERNEL_OBJECT_COUNT + TRACE_NCLASSES) / 8 + 1];\r
-\r
-/* Structure to handle the exclude flags for all event codes */\r
-extern uint8_t trcExcludedEventCodes[NEventCodes / 8 + 1];\r
-\r
 /******************************************************************************\r
  * ObjectHandleStack\r
  * This data-structure is used to provide a mechanism for 1-byte trace object\r
@@ -838,6 +928,7 @@ extern uint8_t trcExcludedEventCodes[NEventCodes / 8 + 1];
  * each object class active at any given moment. There can be more "historic"\r
  * objects, that have been deleted - that number is only limited by the size of\r
  * the symbol table.\r
+ *\r
  * Note that handle zero (0) is not used, it is a code for an invalid handle.\r
  *\r
  * This data structure keeps track of the FREE handles, not the handles in use.\r
@@ -851,7 +942,6 @@ extern uint8_t trcExcludedEventCodes[NEventCodes / 8 + 1];
  * is not a valid handle, that is a signal of additional handles needed.\r
  * If a zero is received when popping a new handle, it is replaced by the\r
  * index of the popped handle instead.\r
- *\r
  *****************************************************************************/\r
 typedef struct\r
 {\r
@@ -884,6 +974,7 @@ extern objectHandleStackType objectHandleStacks;
  * represent the current state. If a property is changed during runtime, the OLD\r
  * value should be stored in the trace buffer, not the new value (since the new\r
  * value is found in the Object Property Table).\r
+ *\r
  * For close events this mechanism is the old names are stored in the symbol\r
  * table), for "priority set" (the old priority is stored in the event data)\r
  * and for "isActive", where the value decides if the task switch event type\r
@@ -927,7 +1018,7 @@ typedef struct
        uint32_t nextFreeSymbolIndex;\r
 \r
        /* Size rounded up to closest multiple of 4, to avoid alignment issues*/\r
-       uint8_t symbytes[4*((TRC_CFG_SYMBOL_TABLE_SIZE+3)/4)];\r
+       uint8_t symbytes[4*(((TRC_CFG_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
@@ -979,8 +1070,8 @@ typedef struct
 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 objHandle;              /* the handle of the closed object */\r
+       uint16_t symbolIndex;   /* the name of the closed object */\r
 } ObjCloseNameEvent;\r
 \r
 typedef struct\r
@@ -1060,9 +1151,9 @@ typedef struct
        uint8_t padding1;\r
        uint8_t padding2;\r
        uint8_t padding3;\r
-       ChannelFormatPair channels[TRC_CFG_UB_CHANNELS+1];\r
-       uint8_t channelBuffer[(TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE + 3) & 0xFFFFFFFC]; /* 1 byte per slot, with padding for 4 byte alignment */\r
-       uint8_t dataBuffer[TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE * 4]; /* 4 bytes per slot */\r
+       ChannelFormatPair channels[(TRC_CFG_UB_CHANNELS)+1];\r
+       uint8_t channelBuffer[((TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) + 3) & 0xFFFFFFFC]; /* 1 byte per slot, with padding for 4 byte alignment */\r
+       uint8_t dataBuffer[(TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE) * 4]; /* 4 bytes per slot */\r
 \r
 } UserEventBuffer;\r
 #endif\r
@@ -1182,7 +1273,7 @@ typedef struct
        int32_t debugMarker3;\r
 \r
        /* The event data, in 4-byte records */\r
-       uint8_t eventData[ TRC_CFG_EVENT_BUFFER_SIZE * 4 ];\r
+       uint8_t eventData[ (TRC_CFG_EVENT_BUFFER_SIZE) * 4 ];\r
 \r
 #if (TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER == 1)\r
        UserEventBuffer userEventBuffer;\r
@@ -1249,14 +1340,6 @@ RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclas
 RecorderDataPtr->ObjectPropertyTable.objbytes[uiIndexOfObject(handle, objectclass) \\r
 + RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[objectclass] + 1]\r
 \r
-#define TRACE_SET_FLAG_ISEXCLUDED(flags, bitIndex) flags[(bitIndex) >> 3] |= (1 << ((bitIndex) & 7))\r
-#define TRACE_CLEAR_FLAG_ISEXCLUDED(flags, bitIndex) flags[(bitIndex) >> 3] &= (uint8_t)(~(1 << ((bitIndex) & 7)))\r
-#define TRACE_GET_FLAG_ISEXCLUDED(flags, bitIndex) (flags[(bitIndex) >> 3] & (1 << ((bitIndex) & 7)))\r
-\r
-#define TRACE_SET_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) TRACE_SET_FLAG_ISEXCLUDED(trcExcludedEventCodes, eventCode)\r
-#define TRACE_CLEAR_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) TRACE_CLEAR_FLAG_ISEXCLUDED(trcExcludedEventCodes, eventCode)\r
-#define TRACE_GET_EVENT_CODE_FLAG_ISEXCLUDED(eventCode) TRACE_GET_FLAG_ISEXCLUDED(trcExcludedEventCodes, eventCode)\r
-\r
 /* DEBUG ASSERTS */\r
 #if defined TRC_CFG_USE_TRACE_ASSERT && TRC_CFG_USE_TRACE_ASSERT != 0\r
 #define TRACE_ASSERT(eval, msg, defRetVal) \\r
@@ -1273,6 +1356,279 @@ if (!(eval)) \
 \r
 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)\r
 \r
+/******************************************************************************\r
+ * Default values for STREAM PORT macros\r
+ *\r
+ * As a normal user, this is nothing you don't need to bother about. This is\r
+ * only important if you want to define your own custom streaming interface.\r
+ *\r
+ * You may override these in your own trcStreamingPort.h to create a custom\r
+ * stream port, and thereby stream the trace on any host-target interface.\r
+ * These default values are suitable for most cases, except the J-Link port. \r
+ ******************************************************************************/\r
+\r
+/******************************************************************************\r
+ * TRC_STREAM_PORT_USE_INTERNAL_BUFFER\r
+ *\r
+ * There are two kinds of stream ports, those that store the event to the \r
+ * internal buffer (with periodic flushing by the TzCtrl task) and those that\r
+ * write directly to the streaming interface. Most stream ports use the \r
+ * recorder's internal buffer, except for the SEGGER J-Link port (also uses a\r
+ * RAM buffer, but one defined in the SEGGER code).\r
+ *\r
+ * If the stream port (trcStreamingPort.h) defines this as zero (0), it is \r
+ * expected to transmit the data directly using TRC_STREAM_PORT_COMMIT_EVENT.\r
+ * Otherwise it is expected that the trace data is stored in the internal buffer\r
+ * and the TzCtrl task will then send the buffer pages when they become full.\r
+ ******************************************************************************/\r
+#ifndef TRC_STREAM_PORT_USE_INTERNAL_BUFFER\r
+#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 1\r
+#endif\r
+\r
+ /******************************************************************************\r
+ * TRC_STREAM_PORT_ON_TRACE_BEGIN\r
+ *\r
+ * Defining any actions needed in the stream port when the recording is activated.\r
+ *******************************************************************************/\r
+#ifndef TRC_STREAM_PORT_ON_TRACE_BEGIN\r
+       #define TRC_STREAM_PORT_ON_TRACE_BEGIN() /* Do nothing */\r
+#endif\r
+\r
+ /******************************************************************************\r
+ * TRC_STREAM_PORT_ON_TRACE_BEGIN\r
+ *\r
+ * Defining any actions needed in the stream port when the tracing stops.\r
+ * Empty by default.\r
+ *******************************************************************************/\r
+#ifndef TRC_STREAM_PORT_ON_TRACE_END\r
+#define TRC_STREAM_PORT_ON_TRACE_END() /* Do nothing */\r
+#endif\r
+\r
+ /******************************************************************************\r
+ * TRC_STREAM_PORT_ALLOCATE_EVENT\r
+ *\r
+ * This macro is used to allocate memory for each event record, just before\r
+ * assigning the record fields.\r
+ * Depending on "TRC_STREAM_PORT_USE_INTERNAL_BUFFER", this either allocates\r
+ * space in the paged event buffer, or on the local stack. In the latter case,\r
+ * the COMMIT event is used to write the data to the streaming interface.\r
+ ******************************************************************************/\r
+#ifndef TRC_STREAM_PORT_ALLOCATE_EVENT\r
+#if (TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1)\r
+       #define TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) _type* _ptrData; _ptrData = (_type*)prvPagedEventBufferGetWritePointer(_size);\r
+#else\r
+       #define TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) _type _tmpArray[_size / sizeof(_type)]; _type* _ptrData = _tmpArray;\r
+#endif\r
+#endif\r
+\r
+ /******************************************************************************\r
+ * TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT\r
+ *\r
+ * This macro is used to allocate memory for each event record, just before\r
+ * assigning the record fields. \r
+ * This has the same purpose as TRC_STREAM_PORT_ALLOCATE_EVENT and by default\r
+ * it has the same definition as TRC_STREAM_PORT_ALLOCATE_EVENT. This is used\r
+ * for events carrying variable-sized payload, such as strings.\r
+ * In the SEGGER RTT port, we need this in order to make a worst-case\r
+ * allocation on the stack. \r
+ ******************************************************************************/\r
+#ifndef TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT\r
+#if (TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1)\r
+       #define TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT(_type, _ptrData, _size) TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) /* We do the same thing as for non-dynamic event sizes */\r
+#else\r
+       #define TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT(_type, _ptrData, _size) _type _tmpArray[sizeof(largestEventType) / sizeof(_type)]; _type* _ptrData = _tmpArray;\r
+#endif\r
+#endif\r
+\r
+ /******************************************************************************\r
+ * TRC_STREAM_PORT_COMMIT_EVENT\r
+ *\r
+ * The COMMIT macro is used to write a single event record directly to the \r
+ * streaming inteface, without first storing the event in the internal buffer.\r
+ * This is currently only used in the SEGGER J-Link RTT port. \r
+ *\r
+ * This relies on the TRC_STREAM_PORT_WRITE_DATA macro, defined in by the \r
+ * stream port in trcStreamingPort.h. The COMMIT macro calls \r
+ * prvTraceWarning(TRC_STREAM_PORT_WRITE_DATA) if a non-zero value is returned\r
+ * from TRC_STREAM_PORT_WRITE_DATA. If zero (0) is returned, it is assumed \r
+ * that all data was successfully written.\r
+ *\r
+ * In ports using the internal buffer, this macro has no purpose as the events\r
+ * are written to the internal buffer instead. They are then flushed to the\r
+ * streaming interface in the TzCtrl task using TRC_STREAM_PORT_WRITE_DATA.\r
+ ******************************************************************************/\r
+#ifndef TRC_STREAM_PORT_COMMIT_EVENT\r
+#if (TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1)\r
+       #define TRC_STREAM_PORT_COMMIT_EVENT(_ptrData, _size) /* Not used */\r
+#else\r
+       #define TRC_STREAM_PORT_COMMIT_EVENT(_ptrData, _size) \\r
+       { \\r
+        if (TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, 0) != 0)\\r
+               prvTraceWarning(PSF_WARNING_STREAM_PORT_WRITE); \\r
+       }\r
+#endif\r
+#endif\r
+\r
+/******************************************************************************\r
+ * TRC_STREAM_PORT_READ_DATA (defined in trcStreamingPort.h)\r
+ *\r
+ * Defining how to read data from host (commands from Tracealyzer).\r
+ *\r
+ * If there is no direct interface to host (e.g., if streaming to a file\r
+ * system) this should be defined as 0. Instead use vTraceEnable(TRC_START) and\r
+ * vTraceStop() to control the recording from target.\r
+ *\r
+ * Parameters:\r
+ *\r
+ * - _ptrData: a pointer to a data buffer, where the received data shall be \r
+ *             stored (TracealyzerCommandType*).\r
+ *\r
+ * - _size: the number of bytes to read (int).\r
+ *\r
+ * - _ptrBytesRead: a pointer to an integer (int), that should be assigned\r
+ *                                     with the number of bytes that was received.\r
+ *\r
+ * Example:\r
+ * \r
+ *     int32_t myRead(void* ptrData, uint32_t size, int32_t* ptrBytesRead);\r
+ * \r
+ *     #define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) \\r
+ *          myRead(_ptrData, _size, _ptrBytesRead)\r
+ *\r
+ * Your "myRead" function should return 0 if successful, i.e. if at least some \r
+ * bytes were received. A non-zero value should be returned if the streaming\r
+ * interface returned an error (e.g. a closed socket), which results in the\r
+ * recorder calling prvTraceWarning with the error code \r
+ * PSF_WARNING_STREAM_PORT_WRITE.\r
+ *\r
+ * If developing your own custom stream port and using the default internal\r
+ * buffer, it is important that the _ptrBytesRead parameter is assigned\r
+ * correctly by "myRead", i.e. with the number of bytes actually written. \r
+ * Otherwise the data stream may get out of sync in case the streaming interface\r
+ * can't swallow all data at once. \r
+ ******************************************************************************/\r
+#ifndef TRC_STREAM_PORT_READ_DATA\r
+#error "No definition for TRC_STREAM_PORT_READ_DATA (should be in trcStreamingPort.h)"\r
+#endif\r
+\r
+/******************************************************************************\r
+ * TRC_STREAM_PORT_WRITE_DATA (defined in trcStreamingPort.h)\r
+ *\r
+ * Defining how to write trace data to the streaming interface. \r
+ *\r
+ * Parameters:\r
+ *\r
+ * - _ptrData: a pointer (void*) to the data to write.\r
+ *\r
+ * - _size: the number of bytes to write (uint32_t).\r
+ *\r
+ * - _ptrBytesWritten: a pointer to an integer (int32_t), that should be\r
+ *                                             assigned with the number of bytes actually written.\r
+ *\r
+ * Example:\r
+ *\r
+ *     int32_t myWrite(void* ptrData, uint32_t size, int32_t* ptrBytesWritten);\r
+ *\r
+ *     #define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesWritten) \\r
+ *                     myWrite(_ptrData, _size, _ptrBytesWritten) \r
+ *  \r
+ * Your "myWrite" function should return 0 if successful, i.e. if at least some \r
+ * bytes were sent. A non-zero value should be returned if the streaming interface\r
+ * returned an error (e.g. a closed socket), which results in the recorder calling\r
+ * prvTraceWarning with the error code PSF_WARNING_STREAM_PORT_WRITE.\r
+ * \r
+ * If developing your own custom stream port and using the default internal\r
+ * buffer, it is important that the _ptrBytesWritten parameter is assigned\r
+ * correctly by "myWrite", i.e. with the number of bytes actually written. \r
+ * Otherwise the data stream may get out of sync in case the streaming interface\r
+ * can't swallow all data at once.\r
+ *\r
+ * Assuming TRC_STREAM_PORT_USE_INTERNAL_BUFFER is 1 (default), the TzCtrl task\r
+ * will use this macro to send one buffer page at a time. In case all data can't\r
+ * be written at once (if _ptrBytesWritten is less than _size), the TzCtrl task\r
+ * is smart enough to make repeated calls (with updated parameters) in order to \r
+ * send the remaining data.\r
+ * \r
+ * However, if TRC_STREAM_PORT_USE_INTERNAL_BUFFER is 0, this is used from the\r
+ * COMMIT macro, directly in the "event functions". In that case, the\r
+ * _ptrBytesWritten parameter will be NULL and should be ignored by the write\r
+ * function. In this case, it is assumed that all data can be sent in a single\r
+ * call, otherwise the write function should return a non-zero error code.\r
+ ******************************************************************************/\r
+#ifndef TRC_STREAM_PORT_WRITE_DATA\r
+#error "No definition for TRC_STREAM_PORT_WRITE_DATA (should be in trcStreamingPort.h)"\r
+#endif\r
+\r
+/******************************************************************************\r
+* Data structure declaration, depending on  TRC_CFG_RECORDER_BUFFER_ALLOCATION\r
+*******************************************************************************/\r
+#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC)\r
+       \r
+       /* Static allocation. */\r
+       \r
+       /* If not defined in trcStreamingPort.h */\r
+       #ifndef TRC_STREAM_PORT_ALLOCATE_FIELDS\r
+               #define TRC_STREAM_PORT_ALLOCATE_FIELDS() \\r
+               char _TzTraceData[(TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)];            \r
+               extern char _TzTraceData[(TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE)];\r
+       #endif\r
+       \r
+       /* If not defined in trcStreamingPort.h */\r
+       #ifndef TRC_STREAM_PORT_MALLOC\r
+               #define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */\r
+       #endif\r
+#else\r
+       /* For Dynamic or Custom Allocation mode */\r
+       \r
+       /* If not defined in trcStreamingPort.h */\r
+       #ifndef TRC_STREAM_PORT_ALLOCATE_FIELDS\r
+               #define TRC_STREAM_PORT_ALLOCATE_FIELDS() char* _TzTraceData = NULL;\r
+               extern char* _TzTraceData;\r
+       #endif\r
+       \r
+       /* If not defined in trcStreamingPort.h */\r
+       #ifndef TRC_STREAM_PORT_MALLOC\r
+               #if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC)\r
+                       #define TRC_STREAM_PORT_MALLOC() \\r
+                       _TzTraceData = TRC_PORT_MALLOC((TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE));\r
+                       extern char* _TzTraceData;\r
+               #else\r
+                       #define TRC_STREAM_PORT_MALLOC()  /* Custom allocation. Not used. */\r
+               #endif\r
+       #endif\r
+#endif\r
+\r
+#ifndef TRC_STREAM_PORT_INIT\r
+       #define TRC_STREAM_PORT_INIT() \\r
+                       TRC_STREAM_PORT_MALLOC(); /* Empty if static allocation mode */ \\r
+                       prvPagedEventBufferInit(_TzTraceData);\r
+#endif\r
+\r
+\r
+/* Signal an error. */\r
+void prvTraceError(int errCode);\r
+\r
+/* Signal an warning (does not stop the recorder). */\r
+void prvTraceWarning(int errCode);\r
+\r
+/******************************************************************************/\r
+/*** ERROR AND WARNING CODES (check using xTraceGetLastError) *****************/\r
+/******************************************************************************/\r
+\r
+#define PSF_ERROR_NONE 0\r
+#define PSF_ERROR_EVENT_CODE_TOO_LARGE 1\r
+#define PSF_ERROR_ISR_NESTING_OVERFLOW 2\r
+#define PSF_ERROR_DWT_NOT_SUPPORTED 3\r
+#define PSF_ERROR_DWT_CYCCNT_NOT_SUPPORTED 4\r
+#define PSF_ERROR_TZCTRLTASK_NOT_CREATED 5\r
+\r
+#define PSF_WARNING_SYMBOL_TABLE_SLOTS 101\r
+#define PSF_WARNING_SYMBOL_MAX_LENGTH 102\r
+#define PSF_WARNING_OBJECT_DATA_SLOTS 103\r
+#define PSF_WARNING_STRING_TOO_LONG 104\r
+#define PSF_WARNING_STREAM_PORT_READ 105\r
+#define PSF_WARNING_STREAM_PORT_WRITE 106\r
+\r
 /******************************************************************************/\r
 /*** INTERNAL STREAMING FUNCTIONS *********************************************/\r
 /******************************************************************************/\r
@@ -1320,10 +1676,7 @@ void prvPagedEventBufferInit(char* buffer);
 void* prvPagedEventBufferGetWritePointer(int sizeOfEvent);\r
 \r
 /* Transfer a full buffer page */\r
-int32_t prvPagedEventBufferTransfer(int32_t(*writeFunc)(void* data, uint32_t size, int32_t* ptrBytesWritten), int32_t* nofBytes);\r
-\r
-/* Resets the paged event buffer */\r
-void prvPagedEventBufferReset(void);\r
+uint32_t prvPagedEventBufferTransfer(void);\r
 \r
 /* The data structure for commands (a bit overkill) */\r
 typedef struct\r
@@ -1344,6 +1697,7 @@ int prvIsValidCommand(TracealyzerCommandType* cmd);
 /* Executed the received command (Start or Stop) */\r
 void prvProcessCommand(TracealyzerCommandType* cmd);\r
 \r
+#define vTraceSetStopHook(x)\r
 \r
 #endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/\r
 \r
@@ -1363,6 +1717,9 @@ void prvProcessCommand(TracealyzerCommandType* cmd);
 #define vTraceChannelPrint(label)\r
 #define vTraceUBData(label, ...)\r
 \r
+#define vTraceSetFilterGroup(x)\r
+#define vTraceSetFilterMask(x)\r
+\r
 #define prvTraceSetReadyEventsEnabled(status)\r
 \r
 #define vTraceExcludeTask(handle)\r
@@ -1379,6 +1736,10 @@ void prvProcessCommand(TracealyzerCommandType* cmd);
 #define TRC_ALLOC_CUSTOM_BUFFER(bufname)\r
 #endif\r
 \r
+#define xTraceIsRecordingEnabled() (0)\r
+\r
+#define vTraceSetStopHook(x)\r
+\r
 #endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/\r
 \r
 #ifdef __cplusplus\r