Changeset 84694 in vbox
- Timestamp:
- Jun 5, 2020 12:55:11 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCGdbRemoteStub.cpp
r84691 r84694 27 27 #include <iprt/cdefs.h> 28 28 #include <iprt/err.h> 29 #include <iprt/list.h> 29 30 #include <iprt/mem.h> 30 31 #include <iprt/string.h> … … 95 96 GDBSTUBRECVSTATE_32BIT_HACK = 0x7fffffff 96 97 } GDBSTUBRECVSTATE; 98 99 100 /** 101 * A tracepoint descriptor. 102 */ 103 typedef struct GDBSTUBTP 104 { 105 /** List node for the list of tracepoints. */ 106 RTLISTNODE NdTps; 107 /** The breakpoint number from the DBGF API. */ 108 uint32_t iBp; 109 /** The tracepoint type for identification. */ 110 GDBSTUBTPTYPE enmTpType; 111 /** The tracepoint address for identification. */ 112 uint64_t GdbTgtAddr; 113 /** The tracepoint kind for identification. */ 114 uint64_t uKind; 115 } GDBSTUBTP; 116 /** Pointer to a tracepoint. */ 117 typedef GDBSTUBTP *PGDBSTUBTP; 97 118 98 119 … … 128 149 /** Flag whether was something was output using the 'O' packet since it was reset last. */ 129 150 bool fOutput; 151 /** List of registered trace points. 152 * GDB removes breakpoints/watchpoints using the parameters they were 153 * registered with while we only use the BP number form DBGF internally. 154 * Means we have to track all registration so we can remove them later on. */ 155 RTLISTANCHOR LstTps; 130 156 } GDBSTUBCTX; 131 157 /** Pointer to the GDB stub context data. */ … … 224 250 * Internal Functions * 225 251 *********************************************************************************************************************************/ 252 253 254 /** 255 * Tries to find a trace point with the given parameters in the list of registered trace points. 256 * 257 * @returns Pointer to the trace point registration record if found or NULL if none was found. 258 * @param pThis The GDB stub context. 259 * @param enmTpType The trace point type. 260 * @param GdbTgtAddr Target address given by GDB. 261 * @param uKind Trace point kind. 262 */ 263 static PGDBSTUBTP dbgcGdbStubTpFind(PGDBSTUBCTX pThis, GDBSTUBTPTYPE enmTpType, uint64_t GdbTgtAddr, uint64_t uKind) 264 { 265 PGDBSTUBTP pTpCur = NULL; 266 RTListForEach(&pThis->LstTps, pTpCur, GDBSTUBTP, NdTps) 267 { 268 if ( pTpCur->enmTpType == enmTpType 269 && pTpCur->GdbTgtAddr == GdbTgtAddr 270 && pTpCur->uKind == uKind) 271 return pTpCur; 272 } 273 274 return NULL; 275 } 276 277 278 /** 279 * Registers a new trace point. 280 * 281 * @returns VBox status code. 282 * @param pThis The GDB stub context. 283 * @param enmTpType The trace point type. 284 * @param GdbTgtAddr Target address given by GDB. 285 * @param uKind Trace point kind. 286 * @param iBp The internal DBGF breakpoint ID this trace point was registered with. 287 */ 288 static int dbgcGdbStubTpRegister(PGDBSTUBCTX pThis, GDBSTUBTPTYPE enmTpType, uint64_t GdbTgtAddr, uint64_t uKind, uint32_t iBp) 289 { 290 int rc = VERR_ALREADY_EXISTS; 291 292 /* Can't register a tracepoint with the same parameters twice or we can't decide whom to remove later on. */ 293 PGDBSTUBTP pTp = dbgcGdbStubTpFind(pThis, enmTpType, GdbTgtAddr, uKind); 294 if (!pTp) 295 { 296 pTp = (PGDBSTUBTP)RTMemAllocZ(sizeof(*pTp)); 297 if (pTp) 298 { 299 pTp->enmTpType = enmTpType; 300 pTp->GdbTgtAddr = GdbTgtAddr; 301 pTp->uKind = uKind; 302 pTp->iBp = iBp; 303 RTListAppend(&pThis->LstTps, &pTp->NdTps); 304 rc = VINF_SUCCESS; 305 } 306 else 307 rc = VERR_NO_MEMORY; 308 } 309 310 return rc; 311 } 312 313 314 /** 315 * Deregisters the given trace point (needs to be unregistered from DBGF by the caller before). 316 * 317 * @returns nothing. 318 * @param pTp The trace point to deregister. 319 */ 320 static void dbgcGdbStubTpDeregister(PGDBSTUBTP pTp) 321 { 322 RTListNodeRemove(&pTp->NdTps); 323 RTMemFree(pTp); 324 } 325 226 326 227 327 /** … … 1606 1706 rc = dbgcBpAdd(&pThis->Dbgc, iBp, NULL /*pszCmd*/); 1607 1707 if (RT_SUCCESS(rc)) 1608 rc = dbgcGdbStubCtxReplySendOk(pThis); 1609 else 1708 { 1709 rc = dbgcGdbStubTpRegister(pThis, enmTpType, GdbTgtTpAddr, uKind, iBp); 1710 if (RT_SUCCESS(rc)) 1711 rc = dbgcGdbStubCtxReplySendOk(pThis); 1712 else 1713 dbgcBpDelete(&pThis->Dbgc, iBp); 1714 } 1715 1716 if (RT_FAILURE(rc)) 1610 1717 { 1611 1718 DBGFR3BpClear(pThis->Dbgc.pUVM, iBp); … … 1629 1736 if (RT_SUCCESS(rc)) 1630 1737 { 1631 DBGFADDRESS BpAddr; 1632 DBGFR3AddrFromFlat(pThis->Dbgc.pUVM, &BpAddr, GdbTgtTpAddr); 1633 1634 uint32_t iBp = 0; /** @todo Need to keep track which breakpoint number belongs to which breakpoint. */ 1635 int rc2 = DBGFR3BpClear(pThis->Dbgc.pUVM, iBp); 1636 if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND) 1637 dbgcBpDelete(&pThis->Dbgc, iBp); 1638 1639 if (RT_SUCCESS(rc2)) 1640 rc = dbgcGdbStubCtxReplySendOk(pThis); 1738 PGDBSTUBTP pTp = dbgcGdbStubTpFind(pThis, enmTpType, GdbTgtTpAddr, uKind); 1739 if (pTp) 1740 { 1741 int rc2 = DBGFR3BpClear(pThis->Dbgc.pUVM, pTp->iBp); 1742 if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND) 1743 dbgcBpDelete(&pThis->Dbgc, pTp->iBp); 1744 1745 if (RT_SUCCESS(rc2)) 1746 { 1747 dbgcGdbStubTpDeregister(pTp); 1748 rc = dbgcGdbStubCtxReplySendOk(pThis); 1749 } 1750 else 1751 rc = dbgcGdbStubCtxReplySendErrSts(pThis, rc); 1752 } 1641 1753 else 1642 rc = dbgcGdbStubCtxReplySendErrSts(pThis, rc);1754 rc = dbgcGdbStubCtxReplySendErrSts(pThis, VERR_NOT_FOUND); 1643 1755 } 1644 1756 else … … 2320 2432 pThis->fExtendedMode = false; 2321 2433 pThis->fOutput = false; 2434 RTListInit(&pThis->LstTps); 2322 2435 dbgcGdbStubCtxReset(pThis); 2323 2436
Note:
See TracChangeset
for help on using the changeset viewer.