VirtualBox

Changeset 104920 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jun 14, 2024 12:02:03 PM (9 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/src/VBox/Devices/Trace/VBoxTraceLogDecoders.cpp

    r104919 r104920  
    4646/**
    4747 */
    48 typedef DECLCALLBACKTYPE(void, FNDECODETPM2CC, (PCTPMREQHDR pHdr, size_t cb));
     48typedef DECLCALLBACKTYPE(void, FNDECODETPM2CC, (PRTTRACELOGDECODERHLP pHlp, PCTPMREQHDR pHdr, size_t cb));
    4949/** Pointer to an event decode callback. */
    5050typedef FNDECODETPM2CC *PFNFNDECODETPM2CC;
     
    6060*********************************************************************************************************************************/
    6161
    62 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartupShutdown(PCTPMREQHDR pHdr, size_t cb)
     62static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartupShutdown(PRTTRACELOGDECODERHLP pHlp, PCTPMREQHDR pHdr, size_t cb)
    6363{
    6464    if (cb >= sizeof(uint16_t))
     
    7474    }
    7575
    76     RTMsgError("Malformed TPM2_CC_STARTUP/TPM2_CC_SHUTDOWN command, not enough room for TPM_SU constant\n");
     76    pHlp->pfnErrorMsg(pHlp, "Malformed TPM2_CC_STARTUP/TPM2_CC_SHUTDOWN command, not enough room for TPM_SU constant\n");
    7777}
    7878
     
    9797};
    9898
    99 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetCapability(PCTPMREQHDR pHdr, size_t cb)
     99static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetCapability(PRTTRACELOGDECODERHLP pHlp, PCTPMREQHDR pHdr, size_t cb)
    100100{
    101101    if (cb >= sizeof(TPM2REQGETCAPABILITY))
     
    118118    }
    119119
    120     RTMsgError("Malformed TPM2_CC_GET_CAPABILITY command, not enough room for the input\n");
    121 }
    122 
    123 
    124 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeReadPublic(PCTPMREQHDR pHdr, size_t cb)
     120    pHlp->pfnErrorMsg(pHlp, "Malformed TPM2_CC_GET_CAPABILITY command, not enough room for the input\n");
     121}
     122
     123
     124static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeReadPublic(PRTTRACELOGDECODERHLP pHlp, PCTPMREQHDR pHdr, size_t cb)
    125125{
    126126    if (cb >= sizeof(TPM2REQREADPUBLIC))
     
    132132    }
    133133
    134     RTMsgError("Malformed TPM2_CC_READ_PUBLIC command, not enough room for the input\n");
     134    pHlp->pfnErrorMsg(pHlp, "Malformed TPM2_CC_READ_PUBLIC command, not enough room for the input\n");
    135135}
    136136
     
    271271};
    272272
    273 static void vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(const uint8_t *pbCmd, size_t cbCmd)
     273static void vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(PRTTRACELOGDECODERHLP pHlp, const uint8_t *pbCmd, size_t cbCmd)
    274274{
    275275    PCTPMREQHDR pHdr = (PCTPMREQHDR)pbCmd;
     
    283283                RTMsgInfo("    %s:\n", s_aTpmCmdCodes[i].pszCmdCode);
    284284                if (s_aTpmCmdCodes[i].pfnDecode)
    285                     s_aTpmCmdCodes[i].pfnDecode(pHdr, RT_BE2H_U32(pHdr->cbReq));
     285                    s_aTpmCmdCodes[i].pfnDecode(pHlp, pHdr, RT_BE2H_U32(pHdr->cbReq));
    286286                return;
    287287            }
     
    294294
    295295
    296 static void vboxTraceLogDecodeEvtTpmDecodeRespBuffer(const uint8_t *pbResp, size_t cbResp)
    297 {
     296static void vboxTraceLogDecodeEvtTpmDecodeRespBuffer(PRTTRACELOGDECODERHLP pHlp, const uint8_t *pbResp, size_t cbResp)
     297{
     298    RT_NOREF(pHlp);
     299
    298300    PCTPMRESPHDR pHdr = (PCTPMRESPHDR)pbResp;
    299301    if (cbResp >= sizeof(*pHdr))
     
    306308
    307309
    308 static DECLCALLBACK(int) vboxTraceLogDecodeEvtTpmCmdExecReq(RTTRACELOGRDREVT hTraceLogEvt, PCRTTRACELOGEVTDESC pEvtDesc,
    309                                                             PRTTRACELOGEVTVAL paVals, uint32_t cVals)
     310static DECLCALLBACK(int) vboxTraceLogDecodeEvtTpm(PRTTRACELOGDECODERHLP pHlp, uint32_t idDecodeEvt, RTTRACELOGRDREVT hTraceLogEvt,
     311                                                  PCRTTRACELOGEVTDESC pEvtDesc, PRTTRACELOGEVTVAL paVals, uint32_t cVals)
    310312{
    311313    RT_NOREF(hTraceLogEvt, pEvtDesc);
    312     for (uint32_t i = 0; i < cVals; i++)
    313     {
    314         /* Look for the pvCmd item which stores the command buffer. */
    315         if (   !strcmp(paVals[i].pItemDesc->pszName, "pvCmd")
    316             && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA)
     314    if (idDecodeEvt == 0)
     315    {
     316        for (uint32_t i = 0; i < cVals; i++)
    317317        {
    318             vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(paVals[i].u.RawData.pb, paVals[i].u.RawData.cb);
    319             return VINF_SUCCESS;
     318            /* Look for the pvCmd item which stores the command buffer. */
     319            if (   !strcmp(paVals[i].pItemDesc->pszName, "pvCmd")
     320                && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA)
     321            {
     322                vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(pHlp, paVals[i].u.RawData.pb, paVals[i].u.RawData.cb);
     323                return VINF_SUCCESS;
     324            }
    320325        }
    321     }
    322     RTMsgError("Failed to find the TPM command data buffer for the given event\n");
     326
     327        pHlp->pfnErrorMsg(pHlp, "Failed to find the TPM command data buffer for the given event\n");
     328    }
     329    else if (idDecodeEvt == 1)
     330    {
     331        for (uint32_t i = 0; i < cVals; i++)
     332        {
     333            /* Look for the pvCmd item which stores the response buffer. */
     334            if (   !strcmp(paVals[i].pItemDesc->pszName, "pvResp")
     335                && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA)
     336            {
     337                vboxTraceLogDecodeEvtTpmDecodeRespBuffer(pHlp, paVals[i].u.RawData.pb, paVals[i].u.RawData.cb);
     338                return VINF_SUCCESS;
     339            }
     340        }
     341        pHlp->pfnErrorMsg(pHlp, "Failed to find the TPM command response buffer for the given event\n");
     342    }
     343
     344    pHlp->pfnErrorMsg(pHlp, "Decode event ID %u is not known to this decoder\n", idDecodeEvt);
    323345    return VERR_NOT_FOUND;
    324346}
    325347
    326348
    327 static DECLCALLBACK(int) vboxTraceLogDecodeEvtTpmCmdExecResp(RTTRACELOGRDREVT hTraceLogEvt, PCRTTRACELOGEVTDESC pEvtDesc,
    328                                                              PRTTRACELOGEVTVAL paVals, uint32_t cVals)
    329 {
    330     RT_NOREF(hTraceLogEvt, pEvtDesc);
    331     for (uint32_t i = 0; i < cVals; i++)
    332     {
    333         /* Look for the pvCmd item which stores the response buffer. */
    334         if (   !strcmp(paVals[i].pItemDesc->pszName, "pvResp")
    335             && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA)
    336         {
    337             vboxTraceLogDecodeEvtTpmDecodeRespBuffer(paVals[i].u.RawData.pb, paVals[i].u.RawData.cb);
    338             return VINF_SUCCESS;
    339         }
    340     }
    341     RTMsgError("Failed to find the TPM command data buffer for the given event\n");
    342     return VERR_NOT_FOUND;
    343 }
    344 
    345 
    346349/**
    347  * Filter plugin interface.
    348  */
    349 const RTTRACELOGDECODERDECODEEVENT g_aTraceLogDecode[] =
    350 {
    351     { "ITpmConnector.CmdExecReq",  vboxTraceLogDecodeEvtTpmCmdExecReq  },
    352     { "ITpmConnector.CmdExecResp", vboxTraceLogDecodeEvtTpmCmdExecResp },
     350 * TPM decoder event IDs.
     351 */
     352static const RTTRACELOGDECODEEVT s_aDecodeEvtTpm[] =
     353{
     354    { "ITpmConnector.CmdExecReq",  0          },
     355    { "ITpmConnector.CmdExecResp", 1          },
     356    { NULL,                        UINT32_MAX }
     357};
     358
     359
     360/**
     361 * Decoder plugin interface.
     362 */
     363static const RTTRACELOGDECODERREG g_TraceLogDecoderTpm =
     364{
     365    /** pszName */
     366    "TPM",
     367    /** pszDesc */
     368    "Decodes events from the ITpmConnector interface generated with the IfTrace driver.",
     369    /** paEvtIds */
     370    s_aDecodeEvtTpm,
     371    /** pfnDecode */
     372    vboxTraceLogDecodeEvtTpm,
    353373};
    354374
     
    364384                          VERR_VERSION_MISMATCH);
    365385
    366     return pRegisterCallbacks->pfnRegisterDecoders(pvUser, &g_aTraceLogDecode[0], RT_ELEMENTS(g_aTraceLogDecode));
    367 }
    368 
     386    return pRegisterCallbacks->pfnRegisterDecoders(pvUser, &g_TraceLogDecoderTpm, 1);
     387}
     388
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