VirtualBox

Changeset 87781 in vbox for trunk


Ignore:
Timestamp:
Feb 17, 2021 2:02:53 PM (4 years ago)
Author:
vboxsync
Message:

VMM/DBGFR3FlowTrace*: Add new probe type which causes a drop to the debugger when encountered and make use of the new before/after insn execution capabilities of the the underlying breakpoint API, bugref:8650

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/dbgfflowtrace.h

    r87140 r87781  
    9393    /** Callback. */
    9494    DBGFFLOWTRACEPROBEENTRYTYPE_CALLBACK,
     95    /** Halt in the debugger when the entry is collected. */
     96    DBGFFLOWTRACEPROBEENTRYTYPE_DEBUGGER,
    9597    /** 32bit hack. */
    9698    DBGFFLOWTRACEPROBEENTRYTYPE_32BIT_HACK = 0x7fffffff
  • trunk/src/VBox/VMM/VMMR3/DBGFR3FlowTrace.cpp

    r87776 r87781  
    693693 * Collects all the data specified in the given probe.
    694694 *
    695  * @returns nothing.
     695 * @returns Flag whether to enter the debugger.
    696696 * @param   pUVM                    The user mode VM handle.
    697697 * @param   idCpu                   The virtual CPU ID.
     
    702702 * @param   pbBuf                   Poitner to the memory buffer holding additional data.
    703703 */
    704 static void dbgfR3FlowTraceModProbeCollectData(PUVM pUVM, VMCPUID idCpu,
     704static bool dbgfR3FlowTraceModProbeCollectData(PUVM pUVM, VMCPUID idCpu,
    705705                                               PDBGFFLOWTRACEMODINT pTraceMod,
    706706                                               PCDBGFADDRESS pAddrProbe,
     
    708708                                               PDBGFFLOWTRACEPROBEVAL pVal, uint8_t *pbBuf)
    709709{
     710    bool fDbgDefer = false;
     711
    710712    for (uint32_t i = 0; i < pProbe->cEntries; i++)
    711713    {
     
    753755                                                       pEntry->Type.Callback.pvUser);
    754756                break;
     757            case DBGFFLOWTRACEPROBEENTRYTYPE_DEBUGGER:
     758                fDbgDefer = true;
     759                break;
    755760            default:
    756761                AssertFailed();
     
    759764        pVal++;
    760765    }
     766
     767    return fDbgDefer;
    761768}
    762769
     
    775782    PDBGFFLOWTRACEMODINT pTraceMod = pProbeLoc->pTraceMod;
    776783    bool fDisabledModule = false;
     784    bool fDbgDefer = false;
    777785
    778786    /* Check whether the trace module is still active and we are tracing the correct VCPU. */
     
    805813    if (pRecord)
    806814    {
    807         dbgfR3FlowTraceModProbeCollectData(pTraceMod->pUVM, idCpu, pTraceMod, &pProbeLoc->AddrProbe, pProbe,
    808                                            &pRecord->aVal[0], pbBuf);
     815        fDbgDefer = dbgfR3FlowTraceModProbeCollectData(pTraceMod->pUVM, idCpu, pTraceMod, &pProbeLoc->AddrProbe, pProbe,
     816                                                       &pRecord->aVal[0], pbBuf);
    809817        if (pTraceMod->pProbeCmn)
    810             dbgfR3FlowTraceModProbeCollectData(pTraceMod->pUVM, idCpu, pTraceMod, NULL, pTraceMod->pProbeCmn,
    811                                                pRecord->paValCmn, pbBufCmn);
     818            fDbgDefer = dbgfR3FlowTraceModProbeCollectData(pTraceMod->pUVM, idCpu, pTraceMod, NULL, pTraceMod->pProbeCmn,
     819                                                           pRecord->paValCmn, pbBufCmn);
    812820
    813821        RTSemFastMutexRequest(pTraceMod->hMtx);
     
    832840    }
    833841
    834     return VINF_SUCCESS;
     842    return fDbgDefer ? VINF_DBGF_BP_HALT : VINF_SUCCESS;
    835843}
    836844
     
    856864    RTListForEach(&pThis->LstProbes, pProbeLoc, DBGFFLOWTRACEMODPROBELOC, NdProbes)
    857865    {
     866        uint16_t fBpFlags = DBGF_BP_F_ENABLED;
     867
     868        if (pProbeLoc->fFlags & DBGF_FLOW_TRACE_PROBE_ADD_F_BEFORE_EXEC)
     869            fBpFlags |= DBGF_BP_F_HIT_EXEC_BEFORE;
     870        if (pProbeLoc->fFlags & DBGF_FLOW_TRACE_PROBE_ADD_F_AFTER_EXEC)
     871            fBpFlags |= DBGF_BP_F_HIT_EXEC_AFTER;
     872
    858873        rc = DBGFR3BpSetInt3Ex(pThis->pUVM, pThis->hBpOwner, pProbeLoc,
    859874                               0 /*idSrcCpu*/, &pProbeLoc->AddrProbe, DBGF_BP_F_DEFAULT,
     
    976991                pEntry->Type.Callback.pfnCallback = NULL;
    977992                pEntry->Type.Callback.pvUser      = NULL;
     993                break;
     994            case DBGFFLOWTRACEPROBEENTRYTYPE_DEBUGGER:
    978995                break;
    979996            default:
     
    11031120                pDst->Type.Callback.pvUser      = pSrc->Type.Callback.pvUser;
    11041121                break;
     1122            case DBGFFLOWTRACEPROBEENTRYTYPE_DEBUGGER:
     1123                break;
    11051124            default:
    11061125                rc = VERR_INVALID_PARAMETER;
     
    11451164            case DBGFFLOWTRACEPROBEENTRYTYPE_CALLBACK:
    11461165            case DBGFFLOWTRACEPROBEENTRYTYPE_REG:
     1166            case DBGFFLOWTRACEPROBEENTRYTYPE_DEBUGGER:
    11471167                break;
    11481168            default:
     
    12601280                                                        DBGF_FLOW_TRACE_PROBE_ADD_F_BEFORE_EXEC);
    12611281                    }
    1262 
    1263                     if (RT_SUCCESS(rc))
     1282                    else
    12641283                    {
    12651284                        DBGFFLOWBBENDTYPE enmType = DBGFR3FlowBbGetType(hFlowBb);
    1266                         uint32_t cInstr = DBGFR3FlowBbGetInstrCount(hFlowBb);
    1267                         rc = DBGFR3FlowBbQueryInstr(hFlowBb, cInstr - 1, &AddrInstr, NULL, NULL);
     1285                        uint32_t cInstr = enmType == DBGFFLOWBBENDTYPE_EXIT ? DBGFR3FlowBbGetInstrCount(hFlowBb) - 1 : 0;
     1286                        rc = DBGFR3FlowBbQueryInstr(hFlowBb, cInstr, &AddrInstr, NULL, NULL);
    12681287                        if (RT_SUCCESS(rc))
    12691288                        {
Note: See TracChangeset for help on using the changeset viewer.

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