]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/WIN32-MSVC/Trace_Recorder_Configuration/trcSnapshotConfig.h
aa22293465d9bce4d89679ef5c5a65c083a7ce93
[freertos] / FreeRTOS / Demo / WIN32-MSVC / Trace_Recorder_Configuration / trcSnapshotConfig.h
1 /*******************************************************************************\r
2  * Trace Recorder Library for Tracealyzer v4.1.4\r
3  * Percepio AB, www.percepio.com\r
4  *\r
5  * trcSnapshotConfig.h\r
6  *\r
7  * Configuration parameters for trace recorder library in snapshot mode.\r
8  * Read more at http://percepio.com/2016/10/05/rtos-tracing/\r
9  *\r
10  * Terms of Use\r
11  * This file is part of the trace recorder library (RECORDER), which is the\r
12  * intellectual property of Percepio AB (PERCEPIO) and provided under a\r
13  * license as follows.\r
14  * The RECORDER may be used free of charge for the purpose of recording data\r
15  * intended for analysis in PERCEPIO products. It may not be used or modified\r
16  * for other purposes without explicit permission from PERCEPIO.\r
17  * You may distribute the RECORDER in its original source code form, assuming\r
18  * this text (terms of use, disclaimer, copyright notice) is unchanged. You are\r
19  * allowed to distribute the RECORDER with minor modifications intended for\r
20  * configuration or porting of the RECORDER, e.g., to allow using it on a\r
21  * specific processor, processor family or with a specific communication\r
22  * interface. Any such modifications should be documented directly below\r
23  * this comment block.\r
24  *\r
25  * Disclaimer\r
26  * The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty\r
27  * as to its use or performance. PERCEPIO does not and cannot warrant the\r
28  * performance or results you may obtain by using the RECORDER or documentation.\r
29  * PERCEPIO make no warranties, express or implied, as to noninfringement of\r
30  * third party rights, merchantability, or fitness for any particular purpose.\r
31  * In no event will PERCEPIO, its technology partners, or distributors be liable\r
32  * to you for any consequential, incidental or special damages, including any\r
33  * lost profits or lost savings, even if a representative of PERCEPIO has been\r
34  * advised of the possibility of such damages, or for any claim by any third\r
35  * party. Some jurisdictions do not allow the exclusion or limitation of\r
36  * incidental, consequential or special damages, or the exclusion of implied\r
37  * warranties or limitations on how long an implied warranty may last, so the\r
38  * above limitations may not apply to you.\r
39  *\r
40  * Tabs are used for indent in this file (1 tab = 4 spaces)\r
41  *\r
42  * Copyright Percepio AB, 2018.\r
43  * www.percepio.com\r
44  ******************************************************************************/\r
45 \r
46 #ifndef TRC_SNAPSHOT_CONFIG_H\r
47 #define TRC_SNAPSHOT_CONFIG_H\r
48 \r
49 #define TRC_SNAPSHOT_MODE_RING_BUFFER           (0x01)\r
50 #define TRC_SNAPSHOT_MODE_STOP_WHEN_FULL        (0x02)\r
51 \r
52 /******************************************************************************\r
53  * TRC_CFG_SNAPSHOT_MODE\r
54  *\r
55  * Macro which should be defined as one of:\r
56  * - TRC_SNAPSHOT_MODE_RING_BUFFER\r
57  * - TRC_SNAPSHOT_MODE_STOP_WHEN_FULL\r
58  * Default is TRC_SNAPSHOT_MODE_RING_BUFFER.\r
59  *\r
60  * With TRC_CFG_SNAPSHOT_MODE set to TRC_SNAPSHOT_MODE_RING_BUFFER, the\r
61  * events are stored in a ring buffer, i.e., where the oldest events are\r
62  * overwritten when the buffer becomes full. This allows you to get the last\r
63  * events leading up to an interesting state, e.g., an error, without having\r
64  * to store the whole run since startup.\r
65  *\r
66  * When TRC_CFG_SNAPSHOT_MODE is TRC_SNAPSHOT_MODE_STOP_WHEN_FULL, the\r
67  * recording is stopped when the buffer becomes full. This is useful for\r
68  * recording events following a specific state, e.g., the startup sequence.\r
69  *****************************************************************************/\r
70 #define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER\r
71 \r
72 /*******************************************************************************\r
73  * TRC_CFG_EVENT_BUFFER_SIZE\r
74  *\r
75  * Macro which should be defined as an integer value.\r
76  *\r
77  * This defines the capacity of the event buffer, i.e., the number of records\r
78  * it may store. Most events use one record (4 byte), although some events\r
79  * require multiple 4-byte records. You should adjust this to the amount of RAM\r
80  * available in the target system.\r
81  *\r
82  * Default value is 1000, which means that 4000 bytes is allocated for the\r
83  * event buffer.\r
84  ******************************************************************************/\r
85 #define TRC_CFG_EVENT_BUFFER_SIZE 15000\r
86 \r
87 /*******************************************************************************\r
88  * TRC_CFG_NTASK, TRC_CFG_NISR, TRC_CFG_NQUEUE, TRC_CFG_NSEMAPHORE...\r
89  *\r
90  * A group of macros which should be defined as integer values, zero or larger.\r
91  *\r
92  * These define the capacity of the Object Property Table, i.e., the maximum\r
93  * number of objects active at any given point, within each object class (e.g.,\r
94  * task, queue, semaphore, ...).\r
95  *\r
96  * If tasks or other objects are deleted in your system, this\r
97  * setting does not limit the total amount of objects created, only the number\r
98  * of objects that have been successfully created but not yet deleted.\r
99  *\r
100  * Using too small values will cause vTraceError to be called, which stores an\r
101  * error message in the trace that is shown when opening the trace file. The\r
102  * error message can also be retrieved using xTraceGetLastError.\r
103  *\r
104  * It can be wise to start with large values for these constants,\r
105  * unless you are very confident on these numbers. Then do a recording and\r
106  * check the actual usage by selecting View menu -> Trace Details ->\r
107  * Resource Usage -> Object Table.\r
108  ******************************************************************************/\r
109 #define TRC_CFG_NTASK                   150\r
110 #define TRC_CFG_NISR                    90\r
111 #define TRC_CFG_NQUEUE                  90\r
112 #define TRC_CFG_NSEMAPHORE              90\r
113 #define TRC_CFG_NMUTEX                  90\r
114 #define TRC_CFG_NTIMER                  250\r
115 #define TRC_CFG_NEVENTGROUP             90\r
116 #define TRC_CFG_NSTREAMBUFFER   50\r
117 #define TRC_CFG_NMESSAGEBUFFER  50\r
118 \r
119 \r
120 /******************************************************************************\r
121  * TRC_CFG_INCLUDE_FLOAT_SUPPORT\r
122  *\r
123  * Macro which should be defined as either zero (0) or one (1).\r
124  *\r
125  * If this is zero (0), the support for logging floating point values in\r
126  * vTracePrintF is stripped out, in case floating point values are not used or\r
127  * supported by the platform used.\r
128  *\r
129  * Floating point values are only used in vTracePrintF and its subroutines, to\r
130  * allow for storing float (%f) or double (%lf) arguments.\r
131  *\r
132  * vTracePrintF can be used with integer and string arguments in either case.\r
133  *\r
134  * Default value is 0.\r
135  *****************************************************************************/\r
136 #define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0\r
137 \r
138 /*******************************************************************************\r
139  * TRC_CFG_SYMBOL_TABLE_SIZE\r
140  *\r
141  * Macro which should be defined as an integer value.\r
142  *\r
143  * This defines the capacity of the symbol table, in bytes. This symbol table\r
144  * stores User Events labels and names of deleted tasks, queues, or other kernel\r
145  * objects. If you don't use User Events or delete any kernel\r
146  * objects you set this to a very low value. The minimum recommended value is 4.\r
147  * A size of zero (0) is not allowed since a zero-sized array may result in a\r
148  * 32-bit pointer, i.e., using 4 bytes rather than 0.\r
149  *\r
150  * Default value is 800.\r
151  ******************************************************************************/\r
152 #define TRC_CFG_SYMBOL_TABLE_SIZE 5000\r
153 \r
154 #if (TRC_CFG_SYMBOL_TABLE_SIZE == 0)\r
155 #error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!"\r
156 #endif\r
157 \r
158 /******************************************************************************\r
159  * TRC_CFG_NAME_LEN_TASK, TRC_CFG_NAME_LEN_QUEUE, ...\r
160  *\r
161  * Macros that specify the maximum lengths (number of characters) for names of\r
162  * kernel objects, such as tasks and queues. If longer names are used, they will\r
163  * be truncated when stored in the recorder.\r
164  *****************************************************************************/\r
165 #define TRC_CFG_NAME_LEN_TASK                   15\r
166 #define TRC_CFG_NAME_LEN_ISR                    15\r
167 #define TRC_CFG_NAME_LEN_QUEUE                  15\r
168 #define TRC_CFG_NAME_LEN_SEMAPHORE              15\r
169 #define TRC_CFG_NAME_LEN_MUTEX                  15\r
170 #define TRC_CFG_NAME_LEN_TIMER                  15\r
171 #define TRC_CFG_NAME_LEN_EVENTGROUP     15\r
172 #define TRC_CFG_NAME_LEN_STREAMBUFFER   15\r
173 #define TRC_CFG_NAME_LEN_MESSAGEBUFFER  15\r
174 \r
175 /******************************************************************************\r
176  *** ADVANCED SETTINGS ********************************************************\r
177  ******************************************************************************\r
178  * The remaining settings are not necessary to modify but allows for optimizing\r
179  * the recorder setup for your specific needs, e.g., to exclude events that you\r
180  * are not interested in, in order to get longer traces.\r
181  *****************************************************************************/\r
182 \r
183 /******************************************************************************\r
184 * TRC_CFG_HEAP_SIZE_BELOW_16M\r
185 *\r
186 * An integer constant that can be used to reduce the buffer usage of memory\r
187 * allocation events (malloc/free). This value should be 1 if the heap size is\r
188 * below 16 MB (2^24 byte), and you can live with reported addresses showing the\r
189 * lower 24 bits only. If 0, you get the full 32-bit addresses.\r
190 *\r
191 * Default value is 0.\r
192 ******************************************************************************/\r
193 #define TRC_CFG_HEAP_SIZE_BELOW_16M 0\r
194 \r
195 /******************************************************************************\r
196  * TRC_CFG_USE_IMPLICIT_IFE_RULES\r
197  *\r
198  * Macro which should be defined as either zero (0) or one (1).\r
199  * Default is 1.\r
200  *\r
201  * Tracealyzer groups the events into "instances" based on Instance Finish\r
202  * Events (IFEs), produced either by default rules or calls to the recorder\r
203  * functions vTraceInstanceFinishedNow and vTraceInstanceFinishedNext.\r
204  *\r
205  * If TRC_CFG_USE_IMPLICIT_IFE_RULES is one (1), the default IFE rules is\r
206  * used, resulting in a "typical" grouping of events into instances.\r
207  * If these rules don't give appropriate instances in your case, you can\r
208  * override the default rules using vTraceInstanceFinishedNow/Next for one\r
209  * or several tasks. The default IFE rules are then disabled for those tasks.\r
210  *\r
211  * If TRC_CFG_USE_IMPLICIT_IFE_RULES is zero (0), the implicit IFE rules are\r
212  * disabled globally. You must then call vTraceInstanceFinishedNow or\r
213  * vTraceInstanceFinishedNext to manually group the events into instances,\r
214  * otherwise the tasks will appear a single long instance.\r
215  *\r
216  * The default IFE rules count the following events as "instance finished":\r
217  * - Task delay, delay until\r
218  * - Task suspend\r
219  * - Blocking on "input" operations, i.e., when the task is waiting for the\r
220  *   next a message/signal/event. But only if this event is blocking.\r
221  *\r
222  * For details, see trcSnapshotKernelPort.h and look for references to the\r
223  * macro trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED.\r
224  *****************************************************************************/\r
225 #define TRC_CFG_USE_IMPLICIT_IFE_RULES 1\r
226 \r
227 /******************************************************************************\r
228  * TRC_CFG_USE_16BIT_OBJECT_HANDLES\r
229  *\r
230  * Macro which should be defined as either zero (0) or one (1).\r
231  *\r
232  * If set to 0 (zero), the recorder uses 8-bit handles to identify kernel\r
233  * objects such as tasks and queues. This limits the supported number of\r
234  * concurrently active objects to 255 of each type (tasks, queues, mutexes,\r
235  * etc.) Note: 255, not 256, since handle 0 is reserved.\r
236  *\r
237  * If set to 1 (one), the recorder uses 16-bit handles to identify kernel\r
238  * objects such as tasks and queues. This limits the supported number of\r
239  * concurrent objects to 65535 of each type (object class). However, since the\r
240  * object property table is limited to 64 KB, the practical limit is about\r
241  * 3000 objects in total.\r
242  *\r
243  * Default is 0 (8-bit handles)\r
244  *\r
245  * NOTE: An object with handle above 255 will use an extra 4-byte record in\r
246  * the event buffer whenever the object is referenced. Moreover, some internal\r
247  * tables in the recorder gets slightly larger when using 16-bit handles.\r
248  *****************************************************************************/\r
249 #define TRC_CFG_USE_16BIT_OBJECT_HANDLES 0\r
250 \r
251 /******************************************************************************\r
252  * TRC_CFG_USE_TRACE_ASSERT\r
253  *\r
254  * Macro which should be defined as either zero (0) or one (1).\r
255  * Default is 1.\r
256  *\r
257  * If this is one (1), the TRACE_ASSERT macro (used at various locations in the\r
258  * trace recorder) will verify that a relevant condition is true.\r
259  * If the condition is false, prvTraceError() will be called, which stops the\r
260  * recording and stores an error message that is displayed when opening the\r
261  * trace in Tracealyzer.\r
262  *\r
263  * This is used on several places in the recorder code for sanity checks on\r
264  * parameters. Can be switched off to reduce the footprint of the tracing, but\r
265  * we recommend to have it enabled initially.\r
266  *****************************************************************************/\r
267 #define TRC_CFG_USE_TRACE_ASSERT 1\r
268 \r
269 /*******************************************************************************\r
270  * TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER\r
271  *\r
272  * Macro which should be defined as an integer value.\r
273  *\r
274  * Set TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER to 1 to enable the\r
275  * separate user event buffer (UB).\r
276  * In this mode, user events are stored separately from other events,\r
277  * e.g., RTOS events. Thereby you can get a much longer history of\r
278  * user events as they don't need to share the buffer space with more\r
279  * frequent events.\r
280  *\r
281  * The UB is typically used with the snapshot ring-buffer mode, so the\r
282  * recording can continue when the main buffer gets full. And since the\r
283  * main buffer then overwrites the earliest events, Tracealyzer displays\r
284  * "Unknown Actor" instead of task scheduling for periods with UB data only.\r
285  *\r
286  * In UB mode, user events are structured as UB channels, which contains\r
287  * a channel name and a default format string. Register a UB channel using\r
288  * xTraceRegisterUBChannel.\r
289  *\r
290  * Events and data arguments are written using vTraceUBEvent and\r
291  * vTraceUBData. They are designed to provide efficient logging of\r
292  * repeating events, using the same format string within each channel.\r
293  *\r
294  * Examples:\r
295  *\r
296  *  traceString chn1 = xTraceRegisterString("Channel 1");\r
297  *  traceString fmt1 = xTraceRegisterString("Event!");\r
298  *  traceUBChannel UBCh1 = xTraceRegisterUBChannel(chn1, fmt1);\r
299  *\r
300  *  traceString chn2 = xTraceRegisterString("Channel 2");\r
301  *  traceString fmt2 = xTraceRegisterString("X: %d, Y: %d");\r
302  *      traceUBChannel UBCh2 = xTraceRegisterUBChannel(chn2, fmt2);\r
303  *\r
304  *  // Result in "[Channel 1] Event!"\r
305  *      vTraceUBEvent(UBCh1);\r
306  *\r
307  *  // Result in "[Channel 2] X: 23, Y: 19"\r
308  *      vTraceUBData(UBCh2, 23, 19);\r
309  *\r
310  * You can also use the other user event functions, like vTracePrintF.\r
311  * as they are then rerouted to the UB instead of the main event buffer.\r
312  * vTracePrintF then looks up the correct UB channel based on the\r
313  * provided channel name and format string, or creates a new UB channel\r
314  * if no match is found. The format string should therefore not contain\r
315  * "random" messages but mainly format specifiers. Random strings should\r
316  * be stored using %s and with the string as an argument.\r
317  *\r
318  *  // Creates a new UB channel ("Channel 2", "%Z: %d")\r
319  *  vTracePrintF(chn2, "%Z: %d", value1);\r
320  *\r
321  *  // Finds the existing UB channel\r
322  *  vTracePrintF(chn2, "%Z: %d", value2);\r
323 \r
324  ******************************************************************************/\r
325 #define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 0\r
326 \r
327 /*******************************************************************************\r
328  * TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE\r
329  *\r
330  * Macro which should be defined as an integer value.\r
331  *\r
332  * This defines the capacity of the user event buffer (UB), in number of slots.\r
333  * A single user event can use multiple slots, depending on the arguments.\r
334  *\r
335  * Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.\r
336  ******************************************************************************/\r
337 #define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200\r
338 \r
339 /*******************************************************************************\r
340  * TRC_CFG_UB_CHANNELS\r
341  *\r
342  * Macro which should be defined as an integer value.\r
343  *\r
344  * This defines the number of User Event Buffer Channels (UB channels).\r
345  * These are used to structure the events when using the separate user\r
346  * event buffer, and contains both a User Event Channel (the name) and\r
347  * a default format string for the channel.\r
348  *\r
349  * Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.\r
350  ******************************************************************************/\r
351 #define TRC_CFG_UB_CHANNELS 32\r
352 \r
353 /*******************************************************************************\r
354  * TRC_CFG_ISR_TAILCHAINING_THRESHOLD\r
355  *\r
356  * Macro which should be defined as an integer value.\r
357  *\r
358  * If tracing multiple ISRs, this setting allows for accurate display of the\r
359  * context-switching also in cases when the ISRs execute in direct sequence.\r
360  *\r
361  * vTraceStoreISREnd normally assumes that the ISR returns to the previous\r
362  * context, i.e., a task or a preempted ISR. But if another traced ISR\r
363  * executes in direct sequence, Tracealyzer may incorrectly display a minimal\r
364  * fragment of the previous context in between the ISRs.\r
365  *\r
366  * By using TRC_CFG_ISR_TAILCHAINING_THRESHOLD you can avoid this. This is\r
367  * however a threshold value that must be measured for your specific setup.\r
368  * See http://percepio.com/2014/03/21/isr_tailchaining_threshold/\r
369  *\r
370  * The default setting is 0, meaning "disabled" and that you may get an\r
371  * extra fragments of the previous context in between tail-chained ISRs.\r
372  *\r
373  * Note: This setting has separate definitions in trcSnapshotConfig.h and\r
374  * trcStreamingConfig.h, since it is affected by the recorder mode.\r
375  ******************************************************************************/\r
376 #define TRC_CFG_ISR_TAILCHAINING_THRESHOLD 0\r
377 \r
378 #endif /*TRC_SNAPSHOT_CONFIG_H*/\r