1 | /** @file
|
---|
2 | * IPRT - Binary trace log API.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2018 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___iprt_tracelog_h
|
---|
27 | #define ___iprt_tracelog_h
|
---|
28 |
|
---|
29 | #include <iprt/sg.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 | #include <iprt/err.h>
|
---|
32 |
|
---|
33 | RT_C_DECLS_BEGIN
|
---|
34 |
|
---|
35 |
|
---|
36 | /** @defgroup grp_tracelog RTTraceLog - Binary trace log API
|
---|
37 | * @ingroup grp_rt
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Trace log item type.
|
---|
43 | */
|
---|
44 | typedef enum RTTRACELOGTYPE
|
---|
45 | {
|
---|
46 | /** Invalid first value. */
|
---|
47 | RTTRACELOGTYPE_INVALID = 0,
|
---|
48 | /** Boolean item type. */
|
---|
49 | RTTRACELOGTYPE_BOOL,
|
---|
50 | /** Unsigned 8bit integer type. */
|
---|
51 | RTTRACELOGTYPE_UINT8,
|
---|
52 | /** Signed 8bit integer type. */
|
---|
53 | RTTRACELOGTYPE_INT8,
|
---|
54 | /** Unsigned 16bit integer type. */
|
---|
55 | RTTRACELOGTYPE_UINT16,
|
---|
56 | /** Signed 16bit integer type. */
|
---|
57 | RTTRACELOGTYPE_INT16,
|
---|
58 | /** Unsigned 32bit integer type. */
|
---|
59 | RTTRACELOGTYPE_UINT32,
|
---|
60 | /** Signed 32bit integer type. */
|
---|
61 | RTTRACELOGTYPE_INT32,
|
---|
62 | /** Unsigned 64bit integer type. */
|
---|
63 | RTTRACELOGTYPE_UINT64,
|
---|
64 | /** Signed 64bit integer type. */
|
---|
65 | RTTRACELOGTYPE_INT64,
|
---|
66 | /** 32bit floating point type. */
|
---|
67 | RTTRACELOGTYPE_FLOAT32,
|
---|
68 | /** 64bit floating point type. */
|
---|
69 | RTTRACELOGTYPE_FLOAT64,
|
---|
70 | /** Raw binary data type. */
|
---|
71 | RTTRACELOGTYPE_RAWDATA,
|
---|
72 | /** Pointer data type. */
|
---|
73 | RTTRACELOGTYPE_POINTER,
|
---|
74 | /** size_t data type. */
|
---|
75 | RTTRACELOGTYPE_SIZE,
|
---|
76 | /** 32-bit hack. */
|
---|
77 | RTTRACELOGTYPE_32BIT_HACK = 0x7fffffff
|
---|
78 | } RTTRACELOGTYPE;
|
---|
79 | /** Pointer to a trace log item type. */
|
---|
80 | typedef RTTRACELOGTYPE *PRTTRACELOGTYPE;
|
---|
81 | /** Pointer to a const trace log item type. */
|
---|
82 | typedef const RTTRACELOGTYPE *PCRTTRACELOGTYPE;
|
---|
83 |
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Trace log event severity.
|
---|
87 | */
|
---|
88 | typedef enum RTTRACELOGEVTSEVERITY
|
---|
89 | {
|
---|
90 | /** Invalid severity. */
|
---|
91 | RTTRACELOGEVTSEVERITY_INVALID = 0,
|
---|
92 | /** Informational event. */
|
---|
93 | RTTRACELOGEVTSEVERITY_INFO,
|
---|
94 | /** Warning event. */
|
---|
95 | RTTRACELOGEVTSEVERITY_WARNING,
|
---|
96 | /** Error event. */
|
---|
97 | RTTRACELOGEVTSEVERITY_ERROR,
|
---|
98 | /** Fatal event. */
|
---|
99 | RTTRACELOGEVTSEVERITY_FATAL,
|
---|
100 | /** Debug event. */
|
---|
101 | RTTRACELOGEVTSEVERITY_DEBUG,
|
---|
102 | /** 32bit hack.*/
|
---|
103 | RTTRACELOGEVTSEVERITY_32BIT_HACK = 0x7fffffff
|
---|
104 | } RTTRACELOGEVTSEVERITY;
|
---|
105 | /** Pointer to a event severity class. */
|
---|
106 | typedef RTTRACELOGEVTSEVERITY *PRTTRACELOGEVTSEVERITY;
|
---|
107 | /** Pointer to a const event severiy class. */
|
---|
108 | typedef RTTRACELOGEVTSEVERITY *PCRTTRACELOGEVTSEVERITY;
|
---|
109 |
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * Trace log reader event.
|
---|
113 | */
|
---|
114 | typedef enum RTTRACELOGRDRPOLLEVT
|
---|
115 | {
|
---|
116 | /** Invalid event. */
|
---|
117 | RTTRACELOGRDRPOLLEVT_INVALID = 0,
|
---|
118 | /** The header was received and valid. */
|
---|
119 | RTTRACELOGRDRPOLLEVT_HDR_RECVD,
|
---|
120 | /** Event data was fetched. */
|
---|
121 | RTTRACELOGRDRPOLLEVT_TRACE_EVENT_RECVD,
|
---|
122 | /** 32bit hack. */
|
---|
123 | RTTRACELOGRDRPOLLEVT_32BIT_HACK = 0x7fffffff
|
---|
124 | } RTTRACELOGRDRPOLLEVT;
|
---|
125 | /** Pointer to a trace log reader event. */
|
---|
126 | typedef RTTRACELOGRDRPOLLEVT *PRTTRACELOGRDRPOLLEVT;
|
---|
127 |
|
---|
128 |
|
---|
129 | /**
|
---|
130 | * Trace log event item descriptor.
|
---|
131 | */
|
---|
132 | typedef struct RTTRACELOGEVTITEMDESC
|
---|
133 | {
|
---|
134 | /** Event item name. */
|
---|
135 | const char *pszName;
|
---|
136 | /** Event item description. */
|
---|
137 | const char *pszDesc;
|
---|
138 | /** Event item type. */
|
---|
139 | RTTRACELOGTYPE enmType;
|
---|
140 | /** The size of the raw data if static for the item,
|
---|
141 | * 0 otherwise (and given when the event is logged).
|
---|
142 | * Only valid for the RTTRACELOGTYPE_RAWDATA type,
|
---|
143 | * ignored otherwise. */
|
---|
144 | size_t cbRawData;
|
---|
145 | } RTTRACELOGEVTITEMDESC;
|
---|
146 | /** Pointer to an trace log event item descriptor. */
|
---|
147 | typedef RTTRACELOGEVTITEMDESC *PRTTRACELOGEVTITEMDESC;
|
---|
148 | /** Pointer to a const trace log event item descriptor. */
|
---|
149 | typedef const RTTRACELOGEVTITEMDESC *PCRTTRACELOGEVTITEMDESC;
|
---|
150 | /** Pointer to a trace log event item descriptor pointer. */
|
---|
151 | typedef PRTTRACELOGEVTITEMDESC *PPRTTRACELOGEVTITEMDESC;
|
---|
152 | /** Pointer to a const trace log event item descriptor pointer. */
|
---|
153 | typedef PCRTTRACELOGEVTITEMDESC *PPCRTTRACELOGEVTITEMDESC;
|
---|
154 |
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * Trace log event descriptor.
|
---|
158 | */
|
---|
159 | typedef struct RTTRACELOGEVTDESC
|
---|
160 | {
|
---|
161 | /** Event identifier. */
|
---|
162 | const char *pszId;
|
---|
163 | /** Event description. */
|
---|
164 | const char *pszDesc;
|
---|
165 | /** Severity class of the event. */
|
---|
166 | RTTRACELOGEVTSEVERITY enmSeverity;
|
---|
167 | /** Number of items recorded for an event. */
|
---|
168 | uint32_t cEvtItems;
|
---|
169 | /** Pointer to array of event item descriptors. */
|
---|
170 | PCRTTRACELOGEVTITEMDESC paEvtItemDesc;
|
---|
171 | } RTTRACELOGEVTDESC;
|
---|
172 | /** Pointer to a trace log event descriptor. */
|
---|
173 | typedef RTTRACELOGEVTDESC *PRTTRACELOGEVTDESC;
|
---|
174 | /** Pointer to a const trace log event descriptor. */
|
---|
175 | typedef const RTTRACELOGEVTDESC *PCRTTRACELOGEVTDESC;
|
---|
176 |
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Trace log event item value.
|
---|
180 | */
|
---|
181 | typedef struct RTTRACELOGEVTVAL
|
---|
182 | {
|
---|
183 | /** Pointer to the corresponding event item descriptor. */
|
---|
184 | PCRTTRACELOGEVTITEMDESC pItemDesc;
|
---|
185 | /** Value union. */
|
---|
186 | union
|
---|
187 | {
|
---|
188 | bool f;
|
---|
189 | uint8_t u8;
|
---|
190 | int8_t i8;
|
---|
191 | uint16_t u16;
|
---|
192 | int16_t i16;
|
---|
193 | uint32_t u32;
|
---|
194 | int32_t i32;
|
---|
195 | uint64_t u64;
|
---|
196 | int64_t i64;
|
---|
197 | uint64_t sz;
|
---|
198 | uint64_t uPtr;
|
---|
199 | float f32;
|
---|
200 | double f64;
|
---|
201 | struct
|
---|
202 | {
|
---|
203 | size_t cb;
|
---|
204 | const uint8_t *pb;
|
---|
205 | } RawData;
|
---|
206 | } u;
|
---|
207 | } RTTRACELOGEVTVAL;
|
---|
208 | /** Pointer to trace log event item value. */
|
---|
209 | typedef RTTRACELOGEVTVAL *PRTTRACELOGEVTVAL;
|
---|
210 | /** Pointer to a const trace log event item value. */
|
---|
211 | typedef const RTTRACELOGEVTVAL *PCRTTRACELOGEVTVAL;
|
---|
212 |
|
---|
213 |
|
---|
214 | /** Event group ID. */
|
---|
215 | typedef uint64_t RTTRACELOGEVTGRPID;
|
---|
216 | /** Pointer to the event group ID. */
|
---|
217 | typedef RTTRACELOGEVTGRPID *PRTTRACELOGEVTGRPID;
|
---|
218 | /** Trace log event handle. */
|
---|
219 | typedef uint64_t RTRACELOGEVT;
|
---|
220 | /** Pointer to a trace log event handle. */
|
---|
221 | typedef RTRACELOGEVT *PRTRACELOGEVT;
|
---|
222 | /** Trace log writer handle. */
|
---|
223 | typedef struct RTTRACELOGWRINT *RTTRACELOGWR;
|
---|
224 | /** Pointer to a trace log writer handle. */
|
---|
225 | typedef RTTRACELOGWR *PRTTRACELOGWR;
|
---|
226 | /** NIL trace log writer handle value. */
|
---|
227 | #define NIL_RTTRACELOGWR ((RTTRACELOGWR)0)
|
---|
228 | /** Trace log reader handle. */
|
---|
229 | typedef struct RTTRACELOGRDRINT *RTTRACELOGRDR;
|
---|
230 | /** Pointer to a trace log reader handle. */
|
---|
231 | typedef RTTRACELOGRDR *PRTTRACELOGRDR;
|
---|
232 | /** NIL trace log reader handle value. */
|
---|
233 | #define NIL_RTTRACELOGRDR ((RTTRACELOGRDR)0)
|
---|
234 | /** Trace log reader iterator handle. */
|
---|
235 | typedef struct RTTRACELOGRDRITINT *RTTRACELOGRDRIT;
|
---|
236 | /** Pointer to a trace log reader iterator handle. */
|
---|
237 | typedef RTTRACELOGRDRIT *PRTTRACELOGRDRIT;
|
---|
238 | /** NIL trace log reader iterator handle. */
|
---|
239 | #define NIL_RTTRACELOGRDRIT ((RTTRACELOGRDRIT)0)
|
---|
240 | /** Trace log reader event handle. */
|
---|
241 | typedef struct RTTRACELOGRDREVTINT *RTTRACELOGRDREVT;
|
---|
242 | /** Pointer to a trace log reader event handle. */
|
---|
243 | typedef RTTRACELOGRDREVT *PRTTRACELOGRDREVT;
|
---|
244 | /** NIL trace log reader event handle. */
|
---|
245 | #define NIL_RTTRACELOGRDREVT ((RTTRACELOGRDREVT)0)
|
---|
246 |
|
---|
247 | /** A new grouped event is started. */
|
---|
248 | #define RTTRACELOG_WR_ADD_EVT_F_GRP_START RT_BIT_32(0)
|
---|
249 | /** A grouped event is finished. */
|
---|
250 | #define RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH RT_BIT_32(1)
|
---|
251 |
|
---|
252 | /**
|
---|
253 | * Callback to stream out data from the trace log writer.
|
---|
254 | *
|
---|
255 | * @returns IPRT status code.
|
---|
256 | * @param pvUser Opaque user data passed on trace log writer creation.
|
---|
257 | * @param pvBuf Pointer to the buffer to stream out.
|
---|
258 | * @param cbBuf Number of bytes to stream.
|
---|
259 | * @param pcbWritten Where to store the number of bytes written on success, optional.
|
---|
260 | */
|
---|
261 | typedef DECLCALLBACK(int) FNRTTRACELOGWRSTREAM(void *pvUser, const void *pvBuf, size_t cbBuf, size_t *pcbWritten);
|
---|
262 | /** Pointer to a writer stream callback. */
|
---|
263 | typedef FNRTTRACELOGWRSTREAM *PFNRTTRACELOGWRSTREAM;
|
---|
264 |
|
---|
265 |
|
---|
266 | /**
|
---|
267 | * Callback to stream int data to the trace log reader.
|
---|
268 | *
|
---|
269 | * @returns IPRT status code.
|
---|
270 | * @retval VERR_EOF if the stream reached the end.
|
---|
271 | * @retval VERR_INTERRUPTED if waiting for something to arrive was interrupted.
|
---|
272 | * @retval VERR_TIMEOUT if the timeout was reached.
|
---|
273 | * @param pvUser Opaque user data passed on trace log reader creation.
|
---|
274 | * @param pvBuf Where to store the read data.
|
---|
275 | * @param cbBuf Number of bytes the buffer can hold.
|
---|
276 | * @param pcbRead Where to store the number of bytes read on success.
|
---|
277 | * @param cMsTimeout How long to wait for something to arrive
|
---|
278 | */
|
---|
279 | typedef DECLCALLBACK(int) FNRTTRACELOGRDRSTREAM(void *pvUser, void *pvBuf, size_t cbBuf, size_t *pcbRead,
|
---|
280 | RTMSINTERVAL cMsTimeout);
|
---|
281 | /** Pointer to a writer stream callback. */
|
---|
282 | typedef FNRTTRACELOGRDRSTREAM *PFNRTTRACELOGRDRSTREAM;
|
---|
283 |
|
---|
284 |
|
---|
285 | /**
|
---|
286 | * Callback to close the stream.
|
---|
287 | *
|
---|
288 | * @returns IPRT status code.
|
---|
289 | * @param pvUser Opaque user data passed on trace log writer creation.
|
---|
290 | */
|
---|
291 | typedef DECLCALLBACK(int) FNRTTRACELOGSTREAMCLOSE(void *pvUser);
|
---|
292 | /** Pointer to a stream close callback. */
|
---|
293 | typedef FNRTTRACELOGSTREAMCLOSE *PFNRTTRACELOGSTREAMCLOSE;
|
---|
294 |
|
---|
295 |
|
---|
296 | /**
|
---|
297 | * Creates a new trace log writer.
|
---|
298 | *
|
---|
299 | * @returns IPRT status code.
|
---|
300 | * @param phTraceLogWr Where to store the handle to the trace log writer on success.
|
---|
301 | * @param pszDesc Optional description to store in the header.
|
---|
302 | * @param pfnStreamOut The callback to use for streaming the trace log data.
|
---|
303 | * @param pfnStreamClose The callback to use for closing the stream.
|
---|
304 | * @param pvUser Opaque user data to pass to the streaming callback.
|
---|
305 | */
|
---|
306 | RTDECL(int) RTTraceLogWrCreate(PRTTRACELOGWR phTraceLogWr, const char *pszDesc,
|
---|
307 | PFNRTTRACELOGWRSTREAM pfnStreamOut,
|
---|
308 | PFNRTTRACELOGSTREAMCLOSE pfnStreamClose, void *pvUser);
|
---|
309 |
|
---|
310 |
|
---|
311 | /**
|
---|
312 | * Creates a new trace log writer streaming data to the given file.
|
---|
313 | *
|
---|
314 | * @returns IPRT status code.
|
---|
315 | * @param phTraceLogWr Where to store the handle to the trace log writer on success.
|
---|
316 | * @param pszDesc Optional description to store in the header.
|
---|
317 | * @param pszFilename The filename to stream the data to.
|
---|
318 | */
|
---|
319 | RTDECL(int) RTTraceLogWrCreateFile(PRTTRACELOGWR phTraceLogWr, const char *pszDesc,
|
---|
320 | const char *pszFilename);
|
---|
321 |
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * Creates a new TCP server style trace log writer waiting for the other end to connect to it.
|
---|
325 | *
|
---|
326 | * @returns IPRT status code.
|
---|
327 | * @param phTraceLogWr Where to store the handle to the trace log writer on success.
|
---|
328 | * @param pszDesc Optional description to store in the header.
|
---|
329 | * @param pszListen The address to listen on, NULL to listen on all interfaces.
|
---|
330 | * @param uPort The port to listen on.
|
---|
331 | *
|
---|
332 | * @note The writer will block here until a client has connected.
|
---|
333 | */
|
---|
334 | RTDECL(int) RTTraceLogWrCreateTcpServer(PRTTRACELOGWR phTraceLogWr, const char *pszDesc,
|
---|
335 | const char *pszListen, unsigned uPort);
|
---|
336 |
|
---|
337 |
|
---|
338 | /**
|
---|
339 | * Creates a new TCP client style trace log writer connecting to the other end.
|
---|
340 | *
|
---|
341 | * @returns IPRT status code.
|
---|
342 | * @param phTraceLogWr Where to store the handle to the trace log writer on success.
|
---|
343 | * @param pszDesc Optional description to store in the header.
|
---|
344 | * @param pszAddress The address to connect to.
|
---|
345 | * @param uPort The port to connect to.
|
---|
346 | *
|
---|
347 | * @note An error is returned if no connection can be established.
|
---|
348 | */
|
---|
349 | RTDECL(int) RTTraceLogWrCreateTcpClient(PRTTRACELOGWR phTraceLogWr, const char *pszDesc,
|
---|
350 | const char *pszAddress, unsigned uPort);
|
---|
351 |
|
---|
352 |
|
---|
353 | /**
|
---|
354 | * Destroys the given trace log writer instance.
|
---|
355 | *
|
---|
356 | * @returns IPRT status code.
|
---|
357 | * @param hTraceLogWr The trace log writer instance handle.
|
---|
358 | */
|
---|
359 | RTDECL(int) RTTraceLogWrDestroy(RTTRACELOGWR hTraceLogWr);
|
---|
360 |
|
---|
361 |
|
---|
362 | /**
|
---|
363 | * Adds a given event structure descriptor to the given trace log writer instance
|
---|
364 | * (for prepopulation).
|
---|
365 | *
|
---|
366 | * @returns IPRT status code.
|
---|
367 | * @param hTraceLogWr The trace log writer instance handle.
|
---|
368 | * @param pEvtDesc The event structure descriptor to add.
|
---|
369 | *
|
---|
370 | * @note The event descriptor is keyed by the pointer for faster lookup in subsequent calls,
|
---|
371 | * so don't free after this method finishes.
|
---|
372 | */
|
---|
373 | RTDECL(int) RTTraceLogWrAddEvtDesc(RTTRACELOGWR hTraceLogWr, PCRTTRACELOGEVTDESC pEvtDesc);
|
---|
374 |
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * Adds a new event to the trace log.
|
---|
378 | *
|
---|
379 | * @returns IPRT status code.
|
---|
380 | * @param hTraceLogWr The trace log writer instance handle.
|
---|
381 | * @param pEvtDesc The event descriptor to use for formatting.
|
---|
382 | * @param fFlags Flags to use for this event.y
|
---|
383 | * @param uGrpId A unique group ID for grouped events.
|
---|
384 | * @param uParentGrpId A parent group ID this event originated from.
|
---|
385 | * @param pvEvtData Pointer to the raw event data.
|
---|
386 | * @param pacbRawData Pointer to the array of size indicators for non static raw data in the event data stream.
|
---|
387 | *
|
---|
388 | * @note The event descriptor is keyed by the pointer for faster lookup in subsequent calls,
|
---|
389 | * so don't free after this method finishes.
|
---|
390 | */
|
---|
391 | RTDECL(int) RTTraceLogWrEvtAdd(RTTRACELOGWR hTraceLogWr, PCRTTRACELOGEVTDESC pEvtDesc, uint32_t fFlags,
|
---|
392 | RTTRACELOGEVTGRPID uGrpId, RTTRACELOGEVTGRPID uParentGrpId,
|
---|
393 | const void *pvEvtData, size_t *pacbRawData);
|
---|
394 |
|
---|
395 |
|
---|
396 | /**
|
---|
397 | * Adds a new event to the trace log.
|
---|
398 | *
|
---|
399 | * @returns IPRT status code.
|
---|
400 | * @param hTraceLogWr The trace log writer instance handle.
|
---|
401 | * @param pEvtDesc The event descriptor used for formatting the data.
|
---|
402 | * @param fFlags Flags to use for this event.
|
---|
403 | * @param uGrpId A unique group ID for grouped events.
|
---|
404 | * @param uParentGrpId A parent group ID this event originated from.
|
---|
405 | * @param pSgBufEvtData S/G buffer holding the raw event data.
|
---|
406 | * @param pacbRawData Pointer to the array of size indicators for non static raw data in the event data stream.
|
---|
407 | *
|
---|
408 | * @note The event descriptor is keyed by the pointer for faster lookup in subsequent calls,
|
---|
409 | * so don't free after this method finishes.
|
---|
410 | */
|
---|
411 | RTDECL(int) RTTraceLogWrEvtAddSg(RTTRACELOGWR hTraceLogWr, PCRTTRACELOGEVTDESC pEvtDesc, uint32_t fFlags,
|
---|
412 | RTTRACELOGEVTGRPID uGrpId, RTTRACELOGEVTGRPID uParentGrpId,
|
---|
413 | PRTSGBUF *pSgBufEvtData, size_t *pacbRawData);
|
---|
414 |
|
---|
415 |
|
---|
416 | /**
|
---|
417 | * Adds a new event to the trace log - list variant.
|
---|
418 | *
|
---|
419 | * @returns IPRT status code.
|
---|
420 | * @param hTraceLogWr The trace log writer instance handle.
|
---|
421 | * @param pEvtDesc The event descriptor used for formatting the data.
|
---|
422 | * @param fFlags Flags to use for this event.
|
---|
423 | * @param uGrpId A unique group ID for grouped events.
|
---|
424 | * @param uParentGrpId A parent group ID this event originated from.
|
---|
425 | * @param va The event data as single items as described by the descriptor.
|
---|
426 | *
|
---|
427 | * @note The event descriptor is keyed by the pointer for faster lookup in subsequent calls,
|
---|
428 | * so don't free after this method finishes.
|
---|
429 | */
|
---|
430 | RTDECL(int) RTTraceLogWrEvtAddLV(RTTRACELOGWR hTraceLogWr, PCRTTRACELOGEVTDESC pEvtDesc, uint32_t fFlags,
|
---|
431 | RTTRACELOGEVTGRPID uGrpId, RTTRACELOGEVTGRPID uParentGrpId, va_list va);
|
---|
432 |
|
---|
433 |
|
---|
434 | /**
|
---|
435 | * Adds a new event to the trace log - list variant.
|
---|
436 | *
|
---|
437 | * @returns IPRT status code.
|
---|
438 | * @param hTraceLogWr The trace log writer instance handle.
|
---|
439 | * @param pEvtDesc The event descriptor used for formatting the data.
|
---|
440 | * @param fFlags Flags to use for this event.
|
---|
441 | * @param uGrpId A unique group ID for grouped events.
|
---|
442 | * @param uParentGrpId A parent group ID this event originated from.
|
---|
443 | * @param ... The event data as single items as described by the descriptor.
|
---|
444 | *
|
---|
445 | * @note The event descriptor is keyed by the pointer for faster lookup in subsequent calls,
|
---|
446 | * so don't free after this method finishes.
|
---|
447 | */
|
---|
448 | RTDECL(int) RTTraceLogWrEvtAddL(RTTRACELOGWR hTraceLogWr, PCRTTRACELOGEVTDESC pEvtDesc, uint32_t fFlags,
|
---|
449 | RTTRACELOGEVTGRPID uGrpId, RTTRACELOGEVTGRPID uParentGrpId, ...);
|
---|
450 |
|
---|
451 |
|
---|
452 | /**
|
---|
453 | * Creates a new trace log reader instance.
|
---|
454 | *
|
---|
455 | * @returns IPRT status code.
|
---|
456 | * @param phTraceLogRdr Where to store the handle to the trace log reader instance on success.
|
---|
457 | * @param pfnStreamIn Callback to stream the data into the reader.
|
---|
458 | * @param pfnStreamClose The callback to use for closing the stream.
|
---|
459 | * @param pvUser Opaque user data passed to the stream callback.
|
---|
460 | */
|
---|
461 | RTDECL(int) RTTraceLogRdrCreate(PRTTRACELOGRDR phTraceLogRdr, PFNRTTRACELOGRDRSTREAM pfnStreamIn,
|
---|
462 | PFNRTTRACELOGSTREAMCLOSE pfnStreamClose, void *pvUser);
|
---|
463 |
|
---|
464 |
|
---|
465 | /**
|
---|
466 | * Creates a new trace log reader for the given file.
|
---|
467 | *
|
---|
468 | * @returns IPRT status code.
|
---|
469 | * @param phTraceLogRdr Where to store the handle to the trace log reader instance on success.
|
---|
470 | * @param pszFilename The file to read the trace log data from.
|
---|
471 | */
|
---|
472 | RTDECL(int) RTTraceLogRdrCreateFromFile(PRTTRACELOGRDR phTraceLogRdr, const char *pszFilename);
|
---|
473 |
|
---|
474 |
|
---|
475 | /**
|
---|
476 | * Destroys the given trace log reader instance.
|
---|
477 | *
|
---|
478 | * @returns IPRT status code.
|
---|
479 | * @param hTraceLogRdr The trace log reader instance handle.
|
---|
480 | */
|
---|
481 | RTDECL(int) RTTraceLogRdrDestroy(RTTRACELOGRDR hTraceLogRdr);
|
---|
482 |
|
---|
483 |
|
---|
484 | /**
|
---|
485 | * Polls for an event on the trace log reader instance.
|
---|
486 | *
|
---|
487 | * @returns IPRT status code.
|
---|
488 | * @retval VERR_TIMEOUT if the timeout was reached.
|
---|
489 | * @retval VERR_INTERRUPTED if the poll was interrupted.
|
---|
490 | * @param hTraceLogRdr The trace log reader instance handle.
|
---|
491 | * @param penmEvt Where to store the event identifier.
|
---|
492 | * @param cMsTimeout How long to poll for an event.
|
---|
493 | */
|
---|
494 | RTDECL(int) RTTraceLogRdrEvtPoll(RTTRACELOGRDR hTraceLogRdr, RTTRACELOGRDRPOLLEVT *penmEvt, RTMSINTERVAL cMsTimeout);
|
---|
495 |
|
---|
496 | /**
|
---|
497 | * Queries the last received event from the trace log read instance.
|
---|
498 | *
|
---|
499 | * @returns IPRT status code.
|
---|
500 | * @retval VERR_NOT_FOUND if no event was received so far.
|
---|
501 | * @param hTraceLogRdr The trace log reader instance handle.
|
---|
502 | * @param phRdrEvt Where to store the event handle on success.
|
---|
503 | */
|
---|
504 | RTDECL(int) RTTraceLogRdrQueryLastEvt(RTTRACELOGRDR hTraceLogRdr, PRTTRACELOGRDREVT phRdrEvt);
|
---|
505 |
|
---|
506 | /**
|
---|
507 | * Queries a new iterator for walking received events.
|
---|
508 | *
|
---|
509 | * @returns IPRT status code
|
---|
510 | * @param hTraceLogRdr The trace log reader instance handle.
|
---|
511 | * @param phIt Where to store the handle to iterator on success.
|
---|
512 | */
|
---|
513 | RTDECL(int) RTTraceLogRdrQueryIterator(RTTRACELOGRDR hTraceLogRdr, PRTTRACELOGRDRIT phIt);
|
---|
514 |
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Frees a previously created iterator.
|
---|
518 | *
|
---|
519 | * @returns nothing.
|
---|
520 | * @param hIt The iterator handle to free.
|
---|
521 | */
|
---|
522 | RTDECL(void) RTTraceLogRdrIteratorFree(RTTRACELOGRDRIT hIt);
|
---|
523 |
|
---|
524 |
|
---|
525 | /**
|
---|
526 | * Advances to the next event.
|
---|
527 | *
|
---|
528 | * @returns IPRT status code
|
---|
529 | * @retval VERR_TRACELOG_READER_ITERATOR_END if the iterator reached the end.
|
---|
530 | * @param hIt The iterator handle.
|
---|
531 | */
|
---|
532 | RTDECL(int) RTTraceLogRdrIteratorNext(RTTRACELOGRDRIT hIt);
|
---|
533 |
|
---|
534 |
|
---|
535 | /**
|
---|
536 | * Queries the event at the current iterator position.
|
---|
537 | *
|
---|
538 | * @returns IPRT status code.
|
---|
539 | * @param hIt The iterator handle.
|
---|
540 | * @param phRdrEvt Where to store the event handle on success.
|
---|
541 | */
|
---|
542 | RTDECL(int) RTTraceLogRdrIteratorQueryEvent(RTTRACELOGRDRIT hIt, PRTTRACELOGRDREVT phRdrEvt);
|
---|
543 |
|
---|
544 |
|
---|
545 | /**
|
---|
546 | * Returns the sequence number of the given event.
|
---|
547 | *
|
---|
548 | * @returns Sequence number of the given event.
|
---|
549 | * @param hRdrEvt The reader event handle.
|
---|
550 | */
|
---|
551 | RTDECL(uint64_t) RTTraceLogRdrEvtGetSeqNo(RTTRACELOGRDREVT hRdrEvt);
|
---|
552 |
|
---|
553 |
|
---|
554 | /**
|
---|
555 | * Gets the timestamp of the given event.
|
---|
556 | *
|
---|
557 | * @returns Timestamp of the given event.
|
---|
558 | * @param hRdrEvt The reader event handle.
|
---|
559 | */
|
---|
560 | RTDECL(uint64_t) RTTraceLogRdrEvtGetTs(RTTRACELOGRDREVT hRdrEvt);
|
---|
561 |
|
---|
562 |
|
---|
563 | /**
|
---|
564 | * Returns whether the given event is part of an event group.
|
---|
565 | *
|
---|
566 | * @returns Flag whether the event is part of a group.
|
---|
567 | * @param hRdrEvt The reader event handle.
|
---|
568 | */
|
---|
569 | RTDECL(bool) RTTraceLogRdrEvtIsGrouped(RTTRACELOGRDREVT hRdrEvt);
|
---|
570 |
|
---|
571 |
|
---|
572 | /**
|
---|
573 | * Returns the event descriptor associated with the given event.
|
---|
574 | *
|
---|
575 | * @returns The trace log event descriptor associated with this event.
|
---|
576 | * @param hRdrEvt The reader event handle.
|
---|
577 | */
|
---|
578 | RTDECL(PCRTTRACELOGEVTDESC) RTTraceLogRdrEvtGetDesc(RTTRACELOGRDREVT hRdrEvt);
|
---|
579 |
|
---|
580 |
|
---|
581 | /**
|
---|
582 | * Queries an event item by its name returning the value in the supplied buffer.
|
---|
583 | *
|
---|
584 | * @returns IPRT status code.
|
---|
585 | * @retval VERR_NOT_FOUND if the item name was not found for the given event.
|
---|
586 | * @param hRdrEvt The reader event handle.
|
---|
587 | * @param pszName The item name to query.
|
---|
588 | * @param pVal The item value buffer to initialise.
|
---|
589 | */
|
---|
590 | RTDECL(int) RTTraceLogRdrEvtQueryVal(RTTRACELOGRDREVT hRdrEvt, const char *pszName, PRTTRACELOGEVTVAL pVal);
|
---|
591 |
|
---|
592 |
|
---|
593 | /**
|
---|
594 | * Fills the given value array using the values from the given event.
|
---|
595 | *
|
---|
596 | * @returns IPRT status code
|
---|
597 | * @param hRdrEvt The reader event handle.
|
---|
598 | * @param idxItemStart The index of the item to start filling the value in.
|
---|
599 | * @param paVals Array of values to fill.
|
---|
600 | * @param cVals Number of values the array is able to hold.
|
---|
601 | * @param pcVals Where to store the number of values filled on success.
|
---|
602 | */
|
---|
603 | RTDECL(int) RTTraceLogRdrEvtFillVals(RTTRACELOGRDREVT hRdrEvt, unsigned idxItemStart, PRTTRACELOGEVTVAL paVals,
|
---|
604 | unsigned cVals, unsigned *pcVals);
|
---|
605 |
|
---|
606 | RT_C_DECLS_END
|
---|
607 |
|
---|
608 | /** @} */
|
---|
609 |
|
---|
610 | #endif
|
---|
611 |
|
---|