VirtualBox

Changeset 86144 in vbox for trunk/src


Ignore:
Timestamp:
Sep 17, 2020 7:37:46 AM (4 years ago)
Author:
vboxsync
Message:

Debugger/DBGCRemoteKd: Implement basic breakpoint handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGCRemoteKd.cpp

    r86143 r86144  
    590590    /** The breakpoint handle to restore. */
    591591    uint32_t                    u32HndBkpt;
     592    /** Blows up the request to the required size. */
     593    uint8_t                     abPad[36];
    592594} KDPACKETMANIPULATE_RESTOREBKPT64;
    593 AssertCompileSize(KDPACKETMANIPULATE_RESTOREBKPT64, 4);
     595AssertCompileSize(KDPACKETMANIPULATE_RESTOREBKPT64, 40);
    594596/** Pointer to a 64bit restore breakpoint manipulate payload. */
    595597typedef KDPACKETMANIPULATE_RESTOREBKPT64 *PKDPACKETMANIPULATE_RESTOREBKPT64;
    596598/** Pointer to a const 64bit restore breakpoint manipulate payload. */
    597599typedef const KDPACKETMANIPULATE_RESTOREBKPT64 *PCKDPACKETMANIPULATE_RESTOREBKPT64;
     600
     601
     602/**
     603 * 64bit write breakpoint manipulate payload.
     604 */
     605typedef struct KDPACKETMANIPULATE_WRITEBKPT64
     606{
     607    /** Where to write the breakpoint. */
     608    uint64_t                    u64PtrBkpt;
     609    /** The breakpoint handle returned in the response. */
     610    uint32_t                    u32HndBkpt;
     611    /** Blows up the request to the required size. */
     612    uint8_t                     abPad[28];
     613} KDPACKETMANIPULATE_WRITEBKPT64;
     614AssertCompileSize(KDPACKETMANIPULATE_WRITEBKPT64, 40);
     615/** Pointer to a 64bit write breakpoint manipulate payload. */
     616typedef KDPACKETMANIPULATE_WRITEBKPT64 *PKDPACKETMANIPULATE_WRITEBKPT64;
     617/** Pointer to a const 64bit write breakpoint manipulate payload. */
     618typedef const KDPACKETMANIPULATE_WRITEBKPT64 *PCKDPACKETMANIPULATE_WRITEBKPT64;
    598619
    599620
     
    630651} KDPACKETMANIPULATE_CONTINUE;
    631652AssertCompileSize(KDPACKETMANIPULATE_CONTINUE, 40);
    632 /** Pointer to a context extended manipulate payload. */
     653/** Pointer to a continue manipulate payload. */
    633654typedef KDPACKETMANIPULATE_CONTINUE *PKDPACKETMANIPULATE_CONTINUE;
    634 /** Pointer to a const context extended manipulate payload. */
     655/** Pointer to a const continue manipulate payload. */
    635656typedef const KDPACKETMANIPULATE_CONTINUE *PCKDPACKETMANIPULATE_CONTINUE;
    636657
     
    671692} KDPACKETMANIPULATE_CONTINUE2;
    672693AssertCompileSize(KDPACKETMANIPULATE_CONTINUE2, 40);
    673 /** Pointer to a context extended manipulate payload. */
     694/** Pointer to a continue 2 manipulate payload. */
    674695typedef KDPACKETMANIPULATE_CONTINUE2 *PKDPACKETMANIPULATE_CONTINUE2;
    675 /** Pointer to a const context extended manipulate payload. */
     696/** Pointer to a const continue 2 manipulate payload. */
    676697typedef const KDPACKETMANIPULATE_CONTINUE2 *PCKDPACKETMANIPULATE_CONTINUE2;
    677698
     
    722743        /** Restore breakpoint. */
    723744        KDPACKETMANIPULATE_RESTOREBKPT64   RestoreBkpt;
     745        /** Write breakpoint. */
     746        KDPACKETMANIPULATE_WRITEBKPT64     WriteBkpt;
    724747        /** Context extended. */
    725748        KDPACKETMANIPULATE_CONTEXTEX       ContextEx;
     
    973996                break;
    974997            }
     998            case KD_PACKET_MANIPULATE_REQ_RESTORE_BKPT:
     999            {
     1000                KDPACKETMANIPULATE_RESTOREBKPT64 RestoreBkpt64;
     1001                cbCopied = RTSgBufCopyToBuf(pSgBuf, &RestoreBkpt64, sizeof(RestoreBkpt64));
     1002                if (cbCopied == sizeof(RestoreBkpt64))
     1003                    Log3(("        u32HndBkpt:   %RX32\n", RestoreBkpt64.u32HndBkpt));
     1004                else
     1005                    Log3(("        Payload to small, expected %u, got %zu\n", sizeof(RestoreBkpt64), cbCopied));
     1006                break;
     1007            }
     1008            case KD_PACKET_MANIPULATE_REQ_WRITE_BKPT:
     1009            {
     1010                KDPACKETMANIPULATE_WRITEBKPT64 WriteBkpt64;
     1011                cbCopied = RTSgBufCopyToBuf(pSgBuf, &WriteBkpt64, sizeof(WriteBkpt64));
     1012                if (cbCopied == sizeof(WriteBkpt64))
     1013                    Log3(("        u64PtrBkpt:   %RX64\n"
     1014                          "        u32HndBkpt:   %RX32\n",
     1015                          WriteBkpt64.u64PtrBkpt, WriteBkpt64.u32HndBkpt));
     1016                else
     1017                    Log3(("        Payload to small, expected %u, got %zu\n", sizeof(WriteBkpt64), cbCopied));
     1018                break;
     1019            }
    9751020            case KD_PACKET_MANIPULATE_REQ_CONTINUE:
    9761021            {
     
    19531998    aRespSegs[1].cbSeg = sizeof(RestoreBkpt64);
    19541999
    1955     /** @todo */
     2000    int rc = DBGFR3BpClear(pThis->Dbgc.pUVM, pPktManip->u.RestoreBkpt.u32HndBkpt);
     2001    if (   RT_FAILURE(rc)
     2002        && rc != VERR_DBGF_BP_NOT_FOUND)
     2003        RespHdr.u32NtStatus = NTSTATUS_UNSUCCESSFUL;
     2004
     2005    return dbgcKdCtxPktSendSg(pThis, KD_PACKET_HDR_SIGNATURE_DATA, KD_PACKET_HDR_SUB_TYPE_STATE_MANIPULATE,
     2006                              &aRespSegs[0], RT_ELEMENTS(aRespSegs), true /*fAck*/);
     2007}
     2008
     2009
     2010/**
     2011 * Processes a write breakpoint 64 request.
     2012 *
     2013 * @returns VBox status code.
     2014 * @param   pThis               The KD context.
     2015 * @param   pPktManip           The manipulate packet request.
     2016 */
     2017static int dbgcKdCtxPktManipulate64WriteBkpt(PKDCTX pThis, PCKDPACKETMANIPULATE64 pPktManip)
     2018{
     2019    KDPACKETMANIPULATEHDR RespHdr;
     2020    KDPACKETMANIPULATE_WRITEBKPT64 WriteBkpt64;
     2021    RT_ZERO(RespHdr); RT_ZERO(WriteBkpt64);
     2022
     2023    RTSGSEG aRespSegs[2];
     2024    RespHdr.idReq       = KD_PACKET_MANIPULATE_REQ_WRITE_BKPT;
     2025    RespHdr.u16CpuLvl   = pPktManip->Hdr.u16CpuLvl;
     2026    RespHdr.idCpu       = pPktManip->Hdr.idCpu;
     2027    RespHdr.u32NtStatus = NTSTATUS_SUCCESS;
     2028
     2029    aRespSegs[0].pvSeg = &RespHdr;
     2030    aRespSegs[0].cbSeg = sizeof(RespHdr);
     2031    aRespSegs[1].pvSeg = &WriteBkpt64;
     2032    aRespSegs[1].cbSeg = sizeof(WriteBkpt64);
     2033
     2034    WriteBkpt64.u64PtrBkpt = pPktManip->u.WriteBkpt.u64PtrBkpt;
     2035
     2036    DBGFADDRESS BpAddr;
     2037    DBGFR3AddrFromFlat(pThis->Dbgc.pUVM, &BpAddr, pPktManip->u.WriteBkpt.u64PtrBkpt);
     2038    int rc = DBGFR3BpSetInt3(pThis->Dbgc.pUVM, pThis->Dbgc.idCpu, &BpAddr,
     2039                             1 /*iHitTrigger*/, UINT64_MAX /*iHitDisable*/, &WriteBkpt64.u32HndBkpt);
     2040    if (RT_FAILURE(rc))
     2041        RespHdr.u32NtStatus = NTSTATUS_UNSUCCESSFUL;
    19562042
    19572043    return dbgcKdCtxPktSendSg(pThis, KD_PACKET_HDR_SIGNATURE_DATA, KD_PACKET_HDR_SUB_TYPE_STATE_MANIPULATE,
     
    20492135        {
    20502136            rc = dbgcKdCtxPktManipulate64RestoreBkpt(pThis, pPktManip);
     2137            break;
     2138        }
     2139        case KD_PACKET_MANIPULATE_REQ_WRITE_BKPT:
     2140        {
     2141            rc = dbgcKdCtxPktManipulate64WriteBkpt(pThis, pPktManip);
    20512142            break;
    20522143        }
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