VirtualBox

Changeset 104920 in vbox for trunk/include


Ignore:
Timestamp:
Jun 14, 2024 12:02:03 PM (11 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163522
Message:

Runtime/tools/RTTraceLogTool,Devices/VBoxTraceLogDecoders.cpp: Allow attaching a state for a decoder to enable analysis spanning multiple events, bugref:10701

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/tracelog-decoder-plugin.h

    r104892 r104920  
    11/** @file
    2  * VD: Plugin support API.
     2 * IPRT: Tracelog decoder plugin API for RTTraceLogTool.
    33 */
    44
     
    4343#include <iprt/tracelog.h>
    4444#include <iprt/types.h>
     45
     46
     47/** Pointer to helper functions for decoders. */
     48typedef struct RTTRACELOGDECODERHLP *PRTTRACELOGDECODERHLP;
     49
     50
     51/**
     52 * Decoder state free callback.
     53 *
     54 * @param   pHlp        Pointer to the callback structure.
     55 * @param   pvState     Pointer to the decoder state.
     56 */
     57typedef DECLCALLBACKTYPE(void, FNTRACELOGDECODERSTATEFREE,(PRTTRACELOGDECODERHLP pHlp, void *pvState));
     58/** Pointer to an event decode callback. */
     59typedef FNTRACELOGDECODERSTATEFREE *PFNTRACELOGDECODERSTATEFREE;
     60
     61
     62/**
     63 * Helper functions for decoders.
     64 */
     65typedef struct RTTRACELOGDECODERHLP
     66{
     67    /** Magic value (RTTRACELOGDECODERHLP_MAGIC). */
     68    uint32_t                u32Magic;
     69
     70    /**
     71     * Helper for writing formatted text to the output.
     72     *
     73     * @returns IPRT status.
     74     * @param   pHlp        Pointer to the callback structure.
     75     * @param   pszFormat   The format string.  This may use all IPRT extensions as
     76     *                      well as the debugger ones.
     77     * @param   ...         Arguments specified in the format string.
     78     */
     79    DECLCALLBACKMEMBER(int, pfnPrintf, (PRTTRACELOGDECODERHLP pHlp, const char *pszFormat, ...)) RT_IPRT_FORMAT_ATTR(3, 4);
     80
     81
     82    /**
     83     * Helper for writing formatted error message to the output.
     84     *
     85     * @returns IPRT status.
     86     * @param   pHlp        Pointer to the callback structure.
     87     * @param   pszFormat   The format string.  This may use all IPRT extensions as
     88     *                      well as the debugger ones.
     89     * @param   ...         Arguments specified in the format string.
     90     */
     91    DECLCALLBACKMEMBER(int, pfnErrorMsg, (PRTTRACELOGDECODERHLP pHlp, const char *pszFormat, ...)) RT_IPRT_FORMAT_ATTR(3, 4);
     92
     93
     94    /**
     95     * Creates a new decoder state and associates it with the given helper structure.
     96     *
     97     * @returns IPRT status.
     98     * @param   pHlp        Pointer to the callback structure.
     99     * @param   cbState     Size of the state in bytes.
     100     * @param   pfnFree     Callback which is called before the decoder state is freed to give the decoder
     101     *                      a chance to do some necessary cleanup, optional.
     102     * @param   ppvState    Where to return the pointer to the state on success.
     103     *
     104     * @note This will destroy and free any previously created decoder state as there can be only one currently for
     105     *       a decoder.
     106     */
     107    DECLCALLBACKMEMBER(int, pfnDecoderStateCreate, (PRTTRACELOGDECODERHLP pHlp, size_t cbState, PFNTRACELOGDECODERSTATEFREE pfnFree,
     108                                                    void **ppvState));
     109
     110
     111    /**
     112     * Destroys any currently attached decoder state.
     113     *
     114     * @param   pHlp        Pointer to the callback structure.
     115     */
     116    DECLCALLBACKMEMBER(void, pfnDecoderStateDestroy, (PRTTRACELOGDECODERHLP pHlp));
     117
     118
     119    /**
     120     * Returns any decoder state created previously with RTTRACELOGDECODERHLP::pfnDecoderStateCreate().
     121     *
     122     * @returns Pointer to the decoder state or NULL if none was created yet.
     123     * @param   pHlp        Pointer to the callback structure.
     124     */
     125    DECLCALLBACKMEMBER(void*, pfnDecoderStateGet, (PRTTRACELOGDECODERHLP pHlp));
     126
     127
     128    /** End marker (DBGCCMDHLP_MAGIC). */
     129    uint32_t                u32EndMarker;
     130} RTTRACELOGDECODERHLP;
     131
     132/** Magic value for RTTRACELOGDECODERHLP::u32Magic and RTTRACELOGDECODERHLP::u32EndMarker. (Bernhard-Viktor Christoph-Carl von Buelow) */
     133#define DBGCCMDHLP_MAGIC    UINT32_C(0x19231112)
    45134
    46135
     
    82171 *
    83172 * @returns IPRT status code.
     173 * @param   pHlp                The decoder helper callback table.
     174 * @param   idDecodeEvt         Event decoder ID given in RTTRACELOGDECODEEVT::idDecodeEvt for the particular event ID.
    84175 * @param   hTraceLogEvt        The tracelog event handle called for decoding.
    85176 * @param   pEvtDesc            The event descriptor.
     
    87178 * @param   cVals               Number of values in the array.
    88179 */
    89 typedef DECLCALLBACKTYPE(int, FNTRACELOGDECODEREVENTDECODE,(RTTRACELOGRDREVT hTraceLogEvt, PCRTTRACELOGEVTDESC pEvtDesc,
     180typedef DECLCALLBACKTYPE(int, FNTRACELOGDECODEREVENTDECODE,(PRTTRACELOGDECODERHLP pHlp, uint32_t idDecodeEvt,
     181                                                            RTTRACELOGRDREVT hTraceLogEvt, PCRTTRACELOGEVTDESC pEvtDesc,
    90182                                                            PRTTRACELOGEVTVAL paVals, uint32_t cVals));
    91183/** Pointer to an event decode callback. */
     
    93185
    94186
    95 typedef struct RTTRACELOGDECODERDECODEEVENT
    96 {
    97     /** The event ID to register the decoder for. */
    98     const char                    *pszId;
     187/**
     188 * Event decoder entry.
     189 */
     190typedef struct RTTRACELOGDECODEEVT
     191{
     192    /** The event ID name. */
     193    const char *pszEvtId;
     194    /** The decoder event ID ordinal to pass to in the decode callback for
     195     * faster lookup. */
     196    uint32_t   idDecodeEvt;
     197} RTTRACELOGDECODEEVT;
     198/** Pointer to an event decoder entry. */
     199typedef RTTRACELOGDECODEEVT *PRTTRACELOGDECODEEVT;
     200/** Pointer to a const event decoder entry. */
     201typedef const RTTRACELOGDECODEEVT *PCRTTRACELOGDECODEEVT;
     202
     203
     204/**
     205 * A decoder registration structure.
     206 */
     207typedef struct RTTRACELOGDECODERREG
     208{
     209    /** Decoder name. */
     210    const char                    *pszName;
     211    /** Decoder description. */
     212    const char                    *pszDesc;
     213    /** The event IDs to register the decoder for. */
     214    PCRTTRACELOGDECODEEVT         paEvtIds;
    99215    /** The decode callback. */
    100216    PFNTRACELOGDECODEREVENTDECODE pfnDecode;
    101 } RTTRACELOGDECODERDECODEEVENT;
    102 typedef RTTRACELOGDECODERDECODEEVENT *PRTTRACELOGDECODERDECODEEVENT;
    103 typedef const RTTRACELOGDECODERDECODEEVENT *PCRTTRACELOGDECODERDECODEEVENT;
     217} RTTRACELOGDECODERREG;
     218/** Pointer to a decoder registration structure. */
     219typedef RTTRACELOGDECODERREG *PRTTRACELOGDECODERREG;
     220/** Pointer to a const decoder registration structure. */
     221typedef const RTTRACELOGDECODERREG *PCRTTRACELOGDECODERREG;
    104222
    105223
     
    121239     * @param   cDecoders   Number of entries in the array.
    122240     */
    123     DECLR3CALLBACKMEMBER(int, pfnRegisterDecoders, (void *pvUser, PCRTTRACELOGDECODERDECODEEVENT paDecoders, uint32_t cDecoders));
     241    DECLR3CALLBACKMEMBER(int, pfnRegisterDecoders, (void *pvUser, PCRTTRACELOGDECODERREG paDecoders, uint32_t cDecoders));
    124242
    125243} RTTRACELOGDECODERREGISTER;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette