1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32
33 34 35
36 import xdc.runtime.Types;
37 import xdc.runtime.Diags;
38 import ti.uia.events.IUIACtx;
39
40 /*!
41 * UIA Frame Context Instrumentation
42 *
43 * The UIAFrameCtx module defines context change events
44 * and methods that allow tooling to identify frame context
45 * switches and to enable frame-aware filtering, trace and
46 * analysis.
47 *
48 * It inherits IUIACtx, which defines a function pointer to
49 * an isLoggingEnabled function which, if configured to point to
50 * a function, will evaluate the function prior to logging the context
51 * change event and will determine whether to log the event based on the
52 * return value of the function. If the function is not configured,
53 * logging will be conditional upon ti_uia_runtime_CtxFilter_gIsLoggingEnabled.
54 *
55 * The generation of UIAFrameCtx events is also controlled by a module's diagnostics
56 * mask, which is described in details in `{@link xdc.runtime.Diags}`.
57 * UIAFrameCtx` events are generated only when the Diags.ANALYSIS bit is set
58 * in the module's diagnostics mask.
59 *
60 * The following configuration script demonstrates how the application might
61 * control the logging of ANALYSIS events embedded in the `Mod` module at configuration
62 * time. In this case, the configuration script arranges for the `Log`
63 * statements within modules to always generate ANALYSIS events.
64 * Without these configuration statements, no ANALYSIS events would be generated
65 * by any modules.
66 *
67 * @a(Examples)
68 * Example 1: This is part of the XDC configuration file for the application:
69 *
70 * @p(code)
71 * var LogCtxChg = xdc.useModule('ti.uia.runtime.LogCtxChg');
72 * var Diags = xdc.useModule('xdc.runtime.Diags');
73 * var LoggerSys = xdc.useModule('xdc.runtime.LoggerSys');
74 * var Defaults = xdc.useModule('xdc.runtime.Defaults');
75 * var logger = LoggerSys.create();
76 *
77 * Defaults.common$.diags_ANALYSIS = Diags.ALWAYS_ON;
78 * Defaults.common$.logger = logger;
79 * @p
80 *
81 * @p(html)
82 * <hr />
83 * @p
84 *
85 * Example 2: The following example configures a module to support logging
86 * of ANALYSIS events, but defers the actual activation and deactivation of the
87 * logging until runtime. See the `{@link Diags#setMask Diags_setMask()}`
88 * function for details on specifying the control string.
89 *
90 * This is a part of the XDC configuration file for the application:
91 *
92 * @p(code)
93 * var LogCtxChg = xdc.useModule('ti.uia.runtime.LogCtxChg');
94 * var Diags = xdc.useModule('xdc.runtime.Diags');
95 * var Mod = xdc.useModule('my.pkg.Mod');
96 *
97 * Mod.common$.diags_ANALYSIS = Diags.RUNTIME_OFF;
98 * @p
99 *
100 * This is a part of the C code for the application:
101 *
102 * @p(code)
103 * // turn on logging of ANALYSIS events in the module
104 * Diags_setMask("my.pkg.Mod+Z");
105 *
106 * // turn off logging of ANALYSIS events in the module
107 * Diags_setMask("my.pkg.Mod-Z");
108 * @p
109 */
110
111 @CustomHeader
112 module UIAFrameCtx inherits IUIACtx {
113
114 /*!
115 * ======== ctxChg ========
116 * Frame Context Change event
117 *
118 * Used to log the start of a new frame
119 * If ti_uia_events_UIAFrameCtx_isLoggingEnabledFxn is not NULL
120 * it is called and its return value determines whether logging is enabled or not.
121 *
122 * @a(Example)
123 * The following C code shows how to log a Context Change
124 * event that identifies a new Frame ID
125 *
126 * @p(code)
127 * #include <ti/uia/runtime/LogCtxChg.h>
128 * ...
129 * Void processFrame(Int frameId){
130 * ...
131 * LogCtxChg_frame("New Frame ID=0x%x",frameId);
132 * ...
133 * }
134 * @p
135 * This event prints the Log call site (%$F) and a format string (%$S)
136 * which is recursively formatted with any addition arguments.
137 * The following text is an example of what will be displayed for the event:
138 * @p(code)
139 * "Frame Ctx Change at Line 123 in demo.c [Prev. Frame ID=0x1234] New Frame ID=0x1235"
140 *
141 * @param(fmt) a constant string that describes the context change and provides a format specifier for newFrameId
142 * @param(newFrameId) an integer which uniquely identifies the new context
143 */
144 config xdc.runtime.Log.Event ctxChg = {
145 mask: Diags.ANALYSIS,
146 msg: "Frame Ctx Change at %$F [prev. Frame ID=0x%x] %$S"};
147
148 /*!
149 * ======== metaEventFrameCtxChg ========
150 * Metadata description of the Frame Context Change event
151 *
152 * @_nodoc
153 */
154 metaonly config DvtTypes.MetaEventDescriptor metaEventFrameCtxChg = {
155 versionId: "2.0",
156 analysisType: DvtTypes.DvtAnalysisType_CONTEXTCHANGE,
157 displayText: "Frame Ctx Change",
158 tooltipText: "Frame ID Context Change",
159 numParameters: 5,
160 paramInfo: [
161 { name: '__FILE__',
162 dataDesc: DvtTypes.DvtDataDesc_FILENAMESTR,
163 dataTypeName: 'String',
164 units: 'none',
165 isHidden: false
166 },
167 { name: '__LINE__',
168 dataDesc: DvtTypes.DvtDataDesc_LINENUM,
169 dataTypeName: 'Int',
170 units: 'none',
171 isHidden: false
172 },
173 { name: 'Prev. Frame ID',
174 dataDesc: DvtTypes.DvtDataDesc_FRAMEID,
175 dataTypeName: 'Int',
176 units: 'none',
177 isHidden: false
178 },
179 { name: 'fmt',
180 dataDesc: DvtTypes.DvtDataDesc_FMTSTR,
181 dataTypeName: 'String',
182 units: 'none',
183 isHidden: false
184 },
185 { name: 'New Frame ID',
186 dataDesc: DvtTypes.DvtDataDesc_FRAMEID,
187 dataTypeName: 'Int',
188 units: 'none',
189 isHidden: false
190 }]
191
192 };
193 /*!
194 * ======== getCtxId ========
195 * Get the ID for the current frame
196 *
197 * @a(returns)
198 * returns the frame ID logged by the last call to UIAFrameCtx_logCtxChg.
199 */
200 @Macro UInt getCtxId();
201
202 /*!
203 * ======== isLoggingEnabled ========
204 * returns true if the new context matches the value to enable logging with.
205 *
206 * Default implementation of the IUIACtx_IsLoggingEnabledFxn for user context.
207 * To enable context-aware filtering, assign UIAFrameCtx_isLoggingEnabledFxn = &UIAFrameCtx_isLoggingEnabled
208 * in the config script or programmatically, or assign your own implementation of this
209 * function.
210 * @param(newFrameId) the new frame ID
211 * @a(returns) true if logging is enabled
212 */
213 @DirectCall
214 Bool isLoggingEnabled(UInt newFrameId);
215
216 /*!
217 * ======== setOldValue =========
218 * sets the ti_uia_events_UIAFrameCtx_gLastValue to the new value and returns the old value before it was updated.
219 *
220 * @param(newValue) the new value to save in the global variable
221 * @a(return0 the original value of the global variable before it was updated.
222 */
223 @DirectCall
224 UInt setOldValue(UInt newValue);
225 }