Changeset 86180 in vbox
- Timestamp:
- Sep 20, 2020 9:33:40 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCRemoteKd.cpp
r86167 r86180 631 631 /** Maximum state change type (exclusive). */ 632 632 #define KD_PACKET_STATE_CHANGE_MAX UINT32_C(0x00003033) 633 /** @} */ 634 635 636 /** 637 * Debug I/O payload. 638 */ 639 typedef struct KDPACKETDEBUGIO 640 { 641 /** Debug I/O payload type (KD_PACKET_DEBUG_IO_STRING). */ 642 uint32_t u32Type; 643 /** The processor level. */ 644 uint16_t u16CpuLvl; 645 /** The processor ID generating this packet. */ 646 uint16_t idCpu; 647 /** Type dependent data. */ 648 union 649 { 650 /** Debug string sent. */ 651 struct 652 { 653 /* Length of the string following in bytes. */ 654 uint32_t cbStr; 655 /** Some padding it looks like. */ 656 uint32_t u32Pad; 657 } Str; 658 } u; 659 } KDPACKETDEBUGIO; 660 AssertCompileSize(KDPACKETDEBUGIO, 16); 661 /** Pointer to a Debug I/O payload. */ 662 typedef KDPACKETDEBUGIO *PKDPACKETDEBUGIO; 663 /** Pointer to a const Debug I/O payload. */ 664 typedef const KDPACKETDEBUGIO *PCKDPACKETDEBUGIO; 665 666 667 /** @name Debug I/O types. 668 * @{ */ 669 /** Debug string output (usually DbgPrint() and friends). */ 670 #define KD_PACKET_DEBUG_IO_STRING UINT32_C(0x00003230) 633 671 /** @} */ 634 672 … … 2085 2123 2086 2124 /** 2125 * Sends a Debug I/O string packet. 2126 * 2127 * @returns VBox status code. 2128 * @param pThis The KD context data. 2129 * @param idCpu The CPU ID generating this packet. 2130 * @param pachChars The characters to send (ASCII). 2131 * @param cbChars Number of characters to send. 2132 */ 2133 static int dbgcKdCtxDebugIoStrSend(PKDCTX pThis, VMCPUID idCpu, const char *pachChars, size_t cbChars) 2134 { 2135 KDPACKETDEBUGIO DebugIo; 2136 RT_ZERO(DebugIo); 2137 2138 /* Fix your damn log strings if this exceeds 4GB... */ 2139 if (cbChars != (uint32_t)cbChars) 2140 return VERR_BUFFER_OVERFLOW; 2141 2142 DebugIo.u32Type = KD_PACKET_DEBUG_IO_STRING; 2143 DebugIo.u16CpuLvl = 0x6; 2144 DebugIo.idCpu = (uint16_t)idCpu; 2145 DebugIo.u.Str.cbStr = (uint32_t)cbChars; 2146 2147 RTSGSEG aRespSegs[2]; 2148 2149 aRespSegs[0].pvSeg = &DebugIo; 2150 aRespSegs[0].cbSeg = sizeof(DebugIo); 2151 aRespSegs[1].pvSeg = (void *)pachChars; 2152 aRespSegs[1].cbSeg = cbChars; 2153 2154 return dbgcKdCtxPktSendSg(pThis, KD_PACKET_HDR_SIGNATURE_DATA, KD_PACKET_HDR_SUB_TYPE_DEBUG_IO, 2155 &aRespSegs[0], RT_ELEMENTS(aRespSegs), true /*fAck*/); 2156 } 2157 2158 2159 /** 2087 2160 * Sends a state change event packet. 2088 2161 * 2089 2162 * @returns VBox status code. 2090 * @param pThis The KD context data.2091 * @param enmType The event type.2163 * @param pThis The KD context data. 2164 * @param enmType The event type. 2092 2165 */ 2093 2166 static int dbgcKdCtxStateChangeSend(PKDCTX pThis, DBGFEVENTTYPE enmType) … … 2363 2436 else if (DBGFR3IsHalted(pThis->Dbgc.pUVM, VMCPUID_ALL)) 2364 2437 rc = DBGFR3Resume(pThis->Dbgc.pUVM, VMCPUID_ALL); 2438 2439 pThis->Dbgc.CmdHlp.pfnPrintf(&pThis->Dbgc.CmdHlp, NULL, "TestTestTest\n"); 2365 2440 2366 2441 return rc; … … 3038 3113 * Process the event. 3039 3114 */ 3040 //PDBGC pDbgc = &pThis->Dbgc;3115 PDBGC pDbgc = &pThis->Dbgc; 3041 3116 pThis->Dbgc.pszScratch = &pThis->Dbgc.achInput[0]; 3042 3117 pThis->Dbgc.iArg = 0; 3043 3118 int rc = VINF_SUCCESS; 3119 VMCPUID idCpuOld = pDbgc->idCpu; 3120 pDbgc->idCpu = pEvent->idCpu; 3044 3121 switch (pEvent->enmType) 3045 3122 { … … 3056 3133 * The second part is events which can occur at any time. 3057 3134 */ 3058 #if 03059 3135 case DBGFEVENT_FATAL_ERROR: 3060 3136 { … … 3065 3141 break; 3066 3142 } 3067 #endif3068 3143 3069 3144 case DBGFEVENT_BREAKPOINT: … … 3071 3146 case DBGFEVENT_BREAKPOINT_MMIO: 3072 3147 case DBGFEVENT_BREAKPOINT_HYPER: 3148 { 3149 rc = dbgcBpExec(pDbgc, pEvent->u.Bp.iBp); 3150 switch (rc) 3151 { 3152 case VERR_DBGC_BP_NOT_FOUND: 3153 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\ndbgf event: Unknown breakpoint %u! (%s)\n", 3154 pEvent->u.Bp.iBp, dbgcGetEventCtx(pEvent->enmCtx)); 3155 break; 3156 3157 case VINF_DBGC_BP_NO_COMMAND: 3158 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\ndbgf event: Breakpoint %u! (%s)\n", 3159 pEvent->u.Bp.iBp, dbgcGetEventCtx(pEvent->enmCtx)); 3160 break; 3161 3162 case VINF_BUFFER_OVERFLOW: 3163 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\ndbgf event: Breakpoint %u! Command too long to execute! (%s)\n", 3164 pEvent->u.Bp.iBp, dbgcGetEventCtx(pEvent->enmCtx)); 3165 break; 3166 3167 default: 3168 break; 3169 } 3170 if (RT_SUCCESS(rc) && DBGFR3IsHalted(pDbgc->pUVM, VMCPUID_ALL)) 3171 { 3172 rc = pDbgc->CmdHlp.pfnExec(&pDbgc->CmdHlp, "r"); 3173 3174 /* Set the resume flag to ignore the breakpoint when resuming execution. */ 3175 if ( RT_SUCCESS(rc) 3176 && pEvent->enmType == DBGFEVENT_BREAKPOINT) 3177 rc = pDbgc->CmdHlp.pfnExec(&pDbgc->CmdHlp, "r eflags.rf = 1"); 3178 } 3179 3180 rc = dbgcKdCtxStateChangeSend(pThis, pEvent->enmType); 3181 break; 3182 } 3183 3073 3184 case DBGFEVENT_STEPPED: 3074 3185 case DBGFEVENT_STEPPED_HYPER: … … 3078 3189 } 3079 3190 3080 #if 03081 3191 case DBGFEVENT_ASSERTION_HYPER: 3082 3192 { … … 3121 3231 break; 3122 3232 } 3123 #endif3124 3233 3125 3234 case DBGFEVENT_POWERING_OFF: … … 3131 3240 } 3132 3241 3133 #if 03134 3242 default: 3135 3243 { … … 3190 3298 break; 3191 3299 } 3192 #else 3193 default: 3194 rc = VERR_NOT_IMPLEMENTED; 3195 break; 3196 #endif 3197 } 3198 3300 } 3301 3302 pDbgc->idCpu = idCpuOld; 3199 3303 return rc; 3200 3304 } … … 3230 3334 LogFlowFunc(("rc=%Rrc\n", rc)); 3231 3335 return rc; 3336 } 3337 3338 3339 /** 3340 * @copydoc DBGC::pfnOutput 3341 */ 3342 static DECLCALLBACK(int) dbgcKdOutput(void *pvUser, const char *pachChars, size_t cbChars) 3343 { 3344 PKDCTX pThis = (PKDCTX)pvUser; 3345 3346 return dbgcKdCtxDebugIoStrSend(pThis, pThis->Dbgc.idCpu, pachChars, cbChars); 3232 3347 } 3233 3348 … … 3339 3454 */ 3340 3455 pThis->Dbgc.pBack = pBack; 3341 /*pThis->Dbgc.pfnOutput = dbgcOutputGdb;*/3456 pThis->Dbgc.pfnOutput = dbgcKdOutput; 3342 3457 pThis->Dbgc.pvOutputUser = pThis; 3343 3458 pThis->Dbgc.pVM = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.