Percepio Trace Recorder v4.11.0
Loading...
Searching...
No Matches
trcRecorder.h
Go to the documentation of this file.
1/*
2 * Trace Recorder for Tracealyzer v4.11.0
3 * Copyright 2025 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
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
28
29#define TRC_ACKNOWLEDGED (0xABC99123)
30
31#include <trcDefines.h>
32#include <trcConfig.h>
33
34#ifndef TRC_CFG_ENTRY_SLOTS
35#error TRC_CFG_ENTRY_SLOTS not defined. Please ensure you are using updated config files.
36#endif
37
38#include <trcKernelPortConfig.h>
39
40#include <trcTypes.h>
41
42#ifndef TRC_CFG_TEST_MODE
43#define TRC_CFG_TEST_MODE 0
44#endif
45
46/* Unless specified in trcConfig.h we assume this is a single core target */
47#ifndef TRC_CFG_CORE_COUNT
48#define TRC_CFG_CORE_COUNT 1
49#endif
50
51/* Unless specified in trcConfig.h we assume this is a single core target */
52#ifndef TRC_CFG_GET_CURRENT_CORE
53#define TRC_CFG_GET_CURRENT_CORE() 0
54#endif
55
56/* Unless specified in trcConfig.h or trcKernelPortConfig.h we assume
57 * GCC statement expressions aren't supported. */
58#ifndef TRC_CFG_USE_GCC_STATEMENT_EXPR
59#define TRC_CFG_USE_GCC_STATEMENT_EXPR 0
60#endif
61
62/* Backwards compatibility */
63#undef traceHandle
64#define traceHandle TraceISRHandle_t
65
66/* Maximum event size */
67#define TRC_MAX_BLOB_SIZE (16UL * sizeof(TraceUnsignedBaseType_t))
68
69/* Platform name length */
70#define TRC_PLATFORM_CFG_LENGTH 8UL
71
72/* Header size */
73#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)))
74
75typedef struct TraceHeaderBuffer /* Aligned */
76{
77 uint8_t buffer[TRC_HEADER_BUFFER_SIZE];
78} TraceHeaderBuffer_t;
79
80#include <trcHardwarePort.h>
81#include <trcKernelPort.h>
82#include <trcString.h>
83#include <trcStaticBuffer.h>
84#include <trcError.h>
85#include <trcEvent.h>
86#include <trcEventBuffer.h>
88#include <trcTimestamp.h>
89#include <trcEntryTable.h>
90#include <trcStreamPort.h>
91#include <trcISR.h>
92#include <trcTask.h>
93#include <trcObject.h>
94#include <trcPrint.h>
95#include <trcHeap.h>
96#include <trcExtension.h>
97#include <trcUtility.h>
98#include <trcStackMonitor.h>
100#include <trcDiagnostics.h>
101#include <trcAssert.h>
102#include <trcRunnable.h>
103#include <trcDependency.h>
104#include <trcProcess.h>
105#include <trcThread.h>
106#include <trcInterval.h>
107#include <trcStateMachine.h>
108#include <trcCounter.h>
109#include <trcTaskMonitor.h>
110
111#if (TRC_USE_TRACEALYZER_RECORDER == 1)
112
127traceResult xTraceInitialize(void);
128
200traceResult xTraceEnable(uint32_t uiStartOption);
201
208traceResult xTraceDisable(void);
209
210#ifndef TRC_EXTERNAL_BUFFERS
211#define TRC_EXTERNAL_BUFFERS 0
212#endif
213
214typedef struct TraceRecorderData /* Aligned */
215{
216 uint32_t uiSessionCounter;
217 uint32_t uiRecorderEnabled;
218 TraceUnsignedBaseType_t uxTraceSystemStates[TRC_CFG_CORE_COUNT];
219 uint32_t reserved; /* alignment */
220
221 TraceAssertData_t xAssertBuffer; /* aligned */
222 TraceEntryIndexTable_t xEntryIndexTableBuffer; /* aligned */
223#if (TRC_EXTERNAL_BUFFERS == 0)
224 TraceHeaderBuffer_t xHeaderBuffer; /* aligned */
225 TraceEntryTable_t xEntryTable; /* aligned */
226 TraceTimestampData_t xTimestampBuffer; /* aligned */
227#endif
228#if (TRC_USE_INTERNAL_BUFFER == 1)
229 TraceInternalEventBufferData_t xInternalEventBuffer; /* aligned */
230#endif
231 TraceStreamPortBuffer_t xStreamPortBuffer; /* verify alignment in xTraceInitialize() */
232 TraceStaticBufferTable_t xStaticBufferBuffer; /* aligned */
233 TraceEventDataTable_t xEventDataBuffer; /* verify alignment in xTraceInitialize() */
234 TracePrintData_t xPrintBuffer; /* aligned */
235 TraceErrorData_t xErrorBuffer; /* aligned */
236 TraceISRData_t xISRBuffer; /* aligned */
237 TraceKernelPortDataBuffer_t xKernelPortBuffer; /* verify alignment in xTraceInitialize() */
238 TraceTaskData_t xTaskInfoBuffer; /* aligned */
239 TraceStackMonitorData_t xStackMonitorBuffer; /* aligned */
240 TraceDiagnosticsData_t xDiagnosticsBuffer; /* aligned */
241 TraceExtensionData_t xExtensionBuffer; /* aligned */
242 TraceCounterData_t xCounterBuffer; /* aligned */
243 TraceTaskMonitorData_t xTaskMonitorBuffer; /* aligned */
244} TraceRecorderData_t;
245
246extern TraceRecorderData_t* pxTraceRecorderData;
247extern uint32_t RecorderInitialized;
248
257traceResult xTraceHeaderInitialize(TraceHeaderBuffer_t* pxBuffer);
258
265#define xTraceIsRecorderEnabled() (xTraceIsRecorderInitialized() && pxTraceRecorderData->uiRecorderEnabled)
266
273#define xTraceIsRecorderInitialized() xTraceIsComponentInitialized(TRC_RECORDER_COMPONENT_CORE)
274
283#define xTraceSetComponentInitialized(uiComponentBit) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(RecorderInitialized |= (uiComponentBit), TRC_SUCCESS)
284
293#define xTraceIsComponentInitialized(uiComponentBit) (RecorderInitialized & (uiComponentBit))
294
303#define xTraceStateSet(uxState) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(pxTraceRecorderData->uxTraceSystemStates[TRC_CFG_GET_CURRENT_CORE()] = (uxState), TRC_SUCCESS)
304
313#define xTraceStateGet(puxState) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(*(puxState) = pxTraceRecorderData->uxTraceSystemStates[TRC_CFG_GET_CURRENT_CORE()], TRC_SUCCESS)
314
321traceResult xTraceTzCtrl(void);
322
323/******************************************************************************/
324/*** INTERNAL STREAMING FUNCTIONS *********************************************/
325/******************************************************************************/
326
327#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM)
336traceResult xTraceSetBuffer(TraceRecorderData_t *pxBuffer);
337#else
338#define xTraceSetBuffer(p) (TRC_SUCCESS)
339#endif
340
350traceResult xTraceGetEventBuffer(void** ppvBuffer, TraceUnsignedBaseType_t * puiSize);
351
352#else /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
353
354#define xTraceInitialize() (TRC_SUCCESS)
355#define xTraceEnable(x) ((void)(x), TRC_SUCCESS)
356#define xTraceDisable() (TRC_SUCCESS)
357
358#define prvTraceSetReadyEventsEnabled(status) (void)(status)
359
360#define vTraceExcludeTask(handle) (void)(handle)
361
362#define vTraceConsoleChannelPrintF(fmt, ...) (void)(fmt)
363
364#ifndef TRC_ALLOC_CUSTOM_BUFFER
365#define TRC_ALLOC_CUSTOM_BUFFER(bufname)
366#endif
367
368#define xTraceIsRecorderEnabled() (0)
369#define xTraceIsRecorderInitialized() (0)
370
371#define xTraceSetBuffer(p) (TRC_SUCCESS)
372#define xTraceGetEventBuffer(p) (TRC_FAIL)
373
374#define vTraceSetStopHook(x) (void)(x)
375
376#define TraceRecorderData_t uint32_t
377
378#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
379
383#define vTraceInitialize (void)xTraceInitialize
384
388#define vTraceEnable (void)xTraceEnable
389
393#define vTraceStop (void)xTraceDisable
394
398#define vTraceInstanceFinishedNow (void)xTraceTaskInstanceFinishedNow
399
403#define vTraceInstanceFinishedNext (void)xTraceTaskInstanceFinishedNext
404
408#define vTracePrintF (void)xTracePrintF
409
413#define vTraceVPrintF (void)xTraceVPrintF
414
418#define vTracePrint (void)xTracePrint
419
423#define vTraceSetRecorderDataBuffer(pxBuffer) xTraceSetBuffer((TraceRecorderData_t*)(pxBuffer))
424
425#ifdef __cplusplus
426}
427#endif
428
429#endif
struct TraceTimestampData TraceTimestampData_t
Trace Timestamp Structure.
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.
struct TraceInternalEventBufferData TraceInternalEventBufferData_t
A structure representing the trace stream port buffer.
Public trace interval APIs.
Public trace object APIs.
Public trace print APIs.
Public trace process APIs.
traceResult xTraceTzCtrl(void)
Call this function periodically.
Definition trcStreamingRecorder.c:457
traceResult xTraceHeaderInitialize(TraceHeaderBuffer_t *pxBuffer)
Initializes the header data.
Definition trcStreamingRecorder.c:286
traceResult xTraceInitialize(void)
Initializes the recorder data. xTraceInitialize() or xTraceEnable(...) must be called before any atte...
Definition trcStreamingRecorder.c:141
traceResult xTraceDisable(void)
Disables tracing.
Definition trcStreamingRecorder.c:420
traceResult xTraceGetEventBuffer(void **ppvBuffer, TraceUnsignedBaseType_t *puiSize)
Retrieve the event buffer and event buffer size.
Definition trcStreamingRecorder.c:443
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 monitor APIs.
Public trace task APIs.
Public trace thread APIs.
Public trace timestamp APIs.