- Timestamp:
- Apr 11, 2012 8:44:41 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv-dtrace.cpp
r40867 r40878 397 397 { 398 398 memcpy(pArgDesc->dtargd_native, pszType, cchType + 1); 399 /** @todo mapping */399 /** @todo mapping? */ 400 400 pArgDesc->dtargd_ndx = uArg; 401 401 LOG_DTRACE(("supdrvDtPOps_GetArgVal: returns dtargd_native = %s\n", pArgDesc->dtargd_native)); … … 449 449 AssertReturn(!pProv->TracerData.DTrace.fZombie, UINT64_MAX); 450 450 AssertPtrReturn(pProv->TracerData.DTrace.idProvider, UINT64_MAX); 451 PVTGPROBELOC pProbeLoc = (PVTGPROBELOC)pvProbe; 452 AssertPtrReturn(pProbeLoc, UINT64_MAX); 453 PVTGDESCPROBE pProbe = (PVTGDESCPROBE)pProbeLoc->pbProbe 454 AssertPtrReturn(pProbe, UINT64_MAX); 455 PVTGDESCARGLIST pArgList = (PVTGDESCPROBE)((uintptr_t)pProv->pHdr->paArgLists + pProbe->offArgList); 456 AssertPtrReturn(pArgList, UINT64_MAX); 451 457 452 458 /* Locate the caller of probe_dtrace, . */ … … 464 470 465 471 /* Get the stack data. */ 466 LOG_DTRACE(("supdrvDtPOps_GetArgVal: returns %#llx\n", (uint64_t)pData->pauStackArgs[iArg - 5])); 467 return pData->pauStackArgs[iArg - 5]; 472 #if ARCH_BITS == 64 473 uint64_t u64Ret = pData->pauStackArgs[iArg - 5]; 474 #else 475 uint64_t u64Ret; 476 if ( !pArgList->fHaveLargeArgs 477 || pArgList->cArgs <= iArg) 478 u64Ret = pData->pauStackArgs[iArg - 5]; 479 else 480 { 481 /* wonder if this will work... */ 482 uint32_t off = 0; 483 for (uint32_t i = 5; i < iArg; i++) 484 if ( (pArgList->aArgs[i].fType & VTG_TYPE_FIXED_SIZED) 485 && (pArgList->aArgs[i].fType & VTG_TYPE_SIZE_MASK) == 8) 486 off++; 487 u64Ret = pData->pauStackArgs[iArg - 5 + off]; 488 if ( (pArgList->aArgs[iArg].fType & VTG_TYPE_FIXED_SIZED) 489 && (pArgList->aArgs[iArg].fType & VTG_TYPE_SIZE_MASK) == 8 490 u64Ret |= (uint64_t)pData->pauStackArgs[iArg - 5 + off + 1] << 32; 491 } 492 #endif 493 494 LOG_DTRACE(("supdrvDtPOps_GetArgVal: returns %#llx\n", u64Ret)); 495 return u64Ret; 468 496 } 469 497 -
trunk/src/VBox/HostDrivers/Support/SUPDrvTracer.cpp
r40867 r40878 299 299 PVTGDESCARGLIST pArgList; 300 300 unsigned iArg; 301 bool fHaveLargeArgs; 301 302 302 303 MY_VALIDATE_STR(pVtgHdr->paProbes[i].offName); … … 319 320 if (pArgList->cArgs > 16) 320 321 return VERR_SUPDRV_VTG_BAD_ARGLIST; 322 if (pArgList->fHaveLargeArgs >= 2) 323 return VERR_SUPDRV_VTG_BAD_ARGLIST; 321 324 if ( pArgList->abReserved[0] 322 || pArgList->abReserved[1] 323 || pArgList->abReserved[2]) 325 || pArgList->abReserved[1]) 324 326 return VERR_SUPDRV_VTG_BAD_ARGLIST; 327 fHaveLargeArgs = false; 325 328 iArg = pArgList->cArgs; 326 329 while (iArg-- > 0) 327 330 { 331 rc = VINF_SUCCESS; 328 332 MY_VALIDATE_STR(pArgList->aArgs[iArg].offType); 329 MY_VALIDATE_STR(pArgList->aArgs[iArg].offName); 330 } 333 switch (pArgList->aArgs[iArg].fType & VTG_TYPE_SIZE_MASK) 334 { 335 case 0: 336 if (!(pArgList->aArgs[iArg].fType & VTG_TYPE_FIXED_SIZED)) 337 rc = VERR_SUPDRV_TRACER_BAD_ARG_FLAGS; 338 break; 339 case 1: case 2: case 4: case 8: 340 break; 341 default: 342 rc = VERR_SUPDRV_TRACER_BAD_ARG_FLAGS; 343 } 344 if (RT_FAILURE(rc)) 345 { 346 SUPR0Printf("supdrvVtgValidate: VERR_SUPDRV_TRACER_BAD_ARG_FLAGS - fType=%#x iArg=%u iProbe=%u\n", 347 pArgList->aArgs[iArg].fType, iArg, i); 348 return rc; 349 } 350 if (VTG_TYPE_IS_LARGE(pArgList->aArgs[iArg].fType)) 351 fHaveLargeArgs = true; 352 } 353 if ((uint8_t)fHaveLargeArgs != pArgList->fHaveLargeArgs) 354 return VERR_SUPDRV_VTG_BAD_PROBE; 331 355 } 332 356 -
trunk/src/bldprogs/VBoxTpG.cpp
r40860 r40878 57 57 { 58 58 RTLISTNODE ListEntry; 59 c onst char*pszName;59 char *pszName; 60 60 const char *pszType; 61 uint32_t fType; 61 62 } VTGARG; 62 63 typedef VTGARG *PVTGARG; … … 69 70 RTLISTANCHOR ArgHead; 70 71 uint32_t cArgs; 72 bool fHaveLargeArgs; 71 73 uint32_t offArgList; 72 74 uint32_t iProbe; … … 116 118 /** List of providers created by the parser. */ 117 119 static RTLISTANCHOR g_ProviderHead; 120 121 /** The number of type errors. */ 122 static uint32_t g_cTypeErrors = 0; 118 123 119 124 /** @name Options … … 179 184 static bool g_fProbeFnImported = true; 180 185 /** @} */ 186 187 181 188 182 189 … … 509 516 " ;0 1 2 3\n" 510 517 " ;012345678901234567890123456789012\n" 511 " db 'VTG Object Header v1. 2', 0, 0\n"518 " db 'VTG Object Header v1.3', 0, 0\n" 512 519 " dd %u\n" 513 520 " dd 0\n" … … 607 614 { 608 615 ScmStreamPrintf(pStrm, 609 " dd %6u ; type '%s' \n"610 " dd %6u ; name '%s'\n",611 strtabGetOff(pArg->pszType), pArg->pszType, 612 strtabGetOff(pArg->pszName), pArg->pszName);616 " dd %6u ; type '%s' (name '%s')\n" 617 " dd 0%08xh ; type flags\n", 618 strtabGetOff(pArg->pszType), pArg->pszType, pArg->pszName, 619 pArg->fType); 613 620 off += 8; 614 621 } … … 631 638 int32_t cArgs = pProbe->cArgs; 632 639 while ( cArgs-- > 0 633 && pArg2->psz Name == pArg2->pszName634 && pArg2-> pszType == pArg2->pszType)640 && pArg2->pszType == pArg2->pszType 641 && pArg2->fType == pArg2->fType ) 635 642 { 636 643 pArg = RTListNodeGetNext(&pArg->ListEntry, VTGARG, ListEntry); … … 963 970 " } \\\n" 964 971 " { \\\n" ); 972 uint32_t iArg = 0; 965 973 RTListForEach(&pProbe->ArgHead, pArg, VTGARG, ListEntry) 966 974 { 967 ScmStreamPrintf(pStrm, 968 " AssertCompile(sizeof(%s) <= sizeof(uintptr_t)); \\\n" 969 " AssertCompile(sizeof(%s) <= sizeof(uintptr_t)); \\\n", 970 pArg->pszName, 971 pArg->pszType); 975 if (iArg < 5) 976 { 977 if (pArg->fType & VTG_TYPE_FIXED_SIZED) 978 ScmStreamPrintf(pStrm, 979 " AssertCompile(sizeof(%s) <= sizeof(uint32_t)); \\\n" 980 " AssertCompile(sizeof(%s) <= sizeof(uint32_t)); \\\n", 981 pArg->pszName, 982 pArg->pszType); 983 else 984 ScmStreamPrintf(pStrm, 985 " AssertCompile(sizeof(%s) <= sizeof(uintptr_t)); \\\n" 986 " AssertCompile(sizeof(%s) <= sizeof(uintptr_t)); \\\n", 987 pArg->pszName, 988 pArg->pszType); 989 } 990 iArg++; 972 991 } 973 992 ScmStreamPrintf(pStrm, … … 1548 1567 1549 1568 /** 1569 * Classifies the given type expression. 1570 * 1571 * @return Type flags. 1572 * @param pszType The type expression. 1573 */ 1574 static uint32_t parseTypeExpression(const char *pszType) 1575 { 1576 size_t cchType = strlen(pszType); 1577 #define MY_STRMATCH(a_sz) (cchType == sizeof(a_sz) - 1 && !memcmp(a_sz, pszType, sizeof(a_sz) - 1)) 1578 1579 /* 1580 * Try detect pointers. 1581 */ 1582 if (pszType[cchType - 1] == '*') return VTG_TYPE_POINTER; 1583 if (pszType[cchType - 1] == '&') 1584 { 1585 RTMsgWarning("Please avoid using references like '%s' for probe arguments!", pszType); 1586 return VTG_TYPE_POINTER; 1587 } 1588 1589 /* 1590 * Standard integer types and IPRT variants. 1591 * It's important that we catch all types larger than 32-bit here or we'll 1592 * screw up the probe argument handling. 1593 */ 1594 //if (MY_STRMATCH("uint128_t")) return VTG_TYPE_FIXED_SIZED | sizeof(uint128_t) | VTG_TYPE_UNSIGNED; 1595 if (MY_STRMATCH("uint64_t")) return VTG_TYPE_FIXED_SIZED | sizeof(uint64_t) | VTG_TYPE_UNSIGNED; 1596 if (MY_STRMATCH("uint32_t")) return VTG_TYPE_FIXED_SIZED | sizeof(uint32_t) | VTG_TYPE_UNSIGNED; 1597 if (MY_STRMATCH("uint16_t")) return VTG_TYPE_FIXED_SIZED | sizeof(uint16_t) | VTG_TYPE_UNSIGNED; 1598 if (MY_STRMATCH("uint8_t")) return VTG_TYPE_FIXED_SIZED | sizeof(uint8_t) | VTG_TYPE_UNSIGNED; 1599 1600 //if (MY_STRMATCH("int128_t")) return VTG_TYPE_FIXED_SIZED | sizeof(int128_t) | VTG_TYPE_SIGNED; 1601 if (MY_STRMATCH("int64_t")) return VTG_TYPE_FIXED_SIZED | sizeof(int64_t) | VTG_TYPE_SIGNED; 1602 if (MY_STRMATCH("int32_t")) return VTG_TYPE_FIXED_SIZED | sizeof(int32_t) | VTG_TYPE_SIGNED; 1603 if (MY_STRMATCH("int16_t")) return VTG_TYPE_FIXED_SIZED | sizeof(int16_t) | VTG_TYPE_SIGNED; 1604 if (MY_STRMATCH("int8_t")) return VTG_TYPE_FIXED_SIZED | sizeof(int8_t) | VTG_TYPE_SIGNED; 1605 1606 if (MY_STRMATCH("RTUINT64U")) return VTG_TYPE_FIXED_SIZED | sizeof(uint64_t) | VTG_TYPE_UNSIGNED; 1607 if (MY_STRMATCH("RTUINT32U")) return VTG_TYPE_FIXED_SIZED | sizeof(uint32_t) | VTG_TYPE_UNSIGNED; 1608 if (MY_STRMATCH("RTUINT16U")) return VTG_TYPE_FIXED_SIZED | sizeof(uint16_t) | VTG_TYPE_UNSIGNED; 1609 1610 if (MY_STRMATCH("RTMSINTERVAL")) return VTG_TYPE_FIXED_SIZED | sizeof(RTMSINTERVAL) | VTG_TYPE_UNSIGNED; 1611 if (MY_STRMATCH("RTTIMESPEC")) return VTG_TYPE_FIXED_SIZED | sizeof(RTTIMESPEC) | VTG_TYPE_SIGNED; 1612 if (MY_STRMATCH("RTHCPHYS")) return VTG_TYPE_FIXED_SIZED | sizeof(RTHCPHYS) | VTG_TYPE_UNSIGNED | VTG_TYPE_PHYS; 1613 1614 if (MY_STRMATCH("RTR3PTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R3; 1615 if (MY_STRMATCH("RTR0PTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R0; 1616 if (MY_STRMATCH("RTRCPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_RC; 1617 if (MY_STRMATCH("RTHCPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R3 | VTG_TYPE_CTX_R0; 1618 1619 if (MY_STRMATCH("RTR3UINTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R3 | VTG_TYPE_UNSIGNED; 1620 if (MY_STRMATCH("RTR0UINTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R0 | VTG_TYPE_UNSIGNED; 1621 if (MY_STRMATCH("RTRCUINTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_RC | VTG_TYPE_UNSIGNED; 1622 if (MY_STRMATCH("RTHCUINTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R3 | VTG_TYPE_CTX_R0 | VTG_TYPE_UNSIGNED; 1623 1624 if (MY_STRMATCH("RTR3INTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R3 | VTG_TYPE_SIGNED; 1625 if (MY_STRMATCH("RTR0INTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R0 | VTG_TYPE_SIGNED; 1626 if (MY_STRMATCH("RTRCINTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_RC | VTG_TYPE_SIGNED; 1627 if (MY_STRMATCH("RTHCINTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R3 | VTG_TYPE_CTX_R0 | VTG_TYPE_SIGNED; 1628 1629 if (MY_STRMATCH("RTUINTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R3 | VTG_TYPE_CTX_R0 | VTG_TYPE_CTX_RC | VTG_TYPE_UNSIGNED; 1630 if (MY_STRMATCH("RTINTPTR")) return VTG_TYPE_CTX_POINTER | VTG_TYPE_CTX_R3 | VTG_TYPE_CTX_R0 | VTG_TYPE_CTX_RC | VTG_TYPE_SIGNED; 1631 1632 if (MY_STRMATCH("RTHCUINTREG")) return VTG_TYPE_HC_ARCH_SIZED | VTG_TYPE_CTX_R3 | VTG_TYPE_CTX_R0 | VTG_TYPE_UNSIGNED; 1633 if (MY_STRMATCH("RTR3UINTREG")) return VTG_TYPE_HC_ARCH_SIZED | VTG_TYPE_CTX_R3 | VTG_TYPE_UNSIGNED; 1634 if (MY_STRMATCH("RTR0UINTREG")) return VTG_TYPE_HC_ARCH_SIZED | VTG_TYPE_CTX_R3 | VTG_TYPE_UNSIGNED; 1635 1636 if (MY_STRMATCH("RTGCUINTREG")) return VTG_TYPE_FIXED_SIZED | sizeof(RTGCUINTREG) | VTG_TYPE_UNSIGNED | VTG_TYPE_CTX_GST; 1637 if (MY_STRMATCH("RTGCPTR")) return VTG_TYPE_FIXED_SIZED | sizeof(RTGCPTR) | VTG_TYPE_UNSIGNED | VTG_TYPE_CTX_GST; 1638 if (MY_STRMATCH("RTGCINTPTR")) return VTG_TYPE_FIXED_SIZED | sizeof(RTGCUINTPTR) | VTG_TYPE_SIGNED | VTG_TYPE_CTX_GST; 1639 if (MY_STRMATCH("RTGCPTR32")) return VTG_TYPE_FIXED_SIZED | sizeof(RTGCPTR32) | VTG_TYPE_SIGNED | VTG_TYPE_CTX_GST; 1640 if (MY_STRMATCH("RTGCPTR64")) return VTG_TYPE_FIXED_SIZED | sizeof(RTGCPTR64) | VTG_TYPE_SIGNED | VTG_TYPE_CTX_GST; 1641 if (MY_STRMATCH("RTGCPHYS")) return VTG_TYPE_FIXED_SIZED | sizeof(RTGCPHYS) | VTG_TYPE_UNSIGNED | VTG_TYPE_PHYS | VTG_TYPE_CTX_GST; 1642 if (MY_STRMATCH("RTGCPHYS32")) return VTG_TYPE_FIXED_SIZED | sizeof(RTGCPHYS32) | VTG_TYPE_UNSIGNED | VTG_TYPE_PHYS | VTG_TYPE_CTX_GST; 1643 if (MY_STRMATCH("RTGCPHYS64")) return VTG_TYPE_FIXED_SIZED | sizeof(RTGCPHYS64) | VTG_TYPE_UNSIGNED | VTG_TYPE_PHYS | VTG_TYPE_CTX_GST; 1644 1645 /* 1646 * The special VBox types. 1647 */ 1648 if (MY_STRMATCH("PVM")) return VTG_TYPE_CTX_POINTER; 1649 if (MY_STRMATCH("PVMCPU")) return VTG_TYPE_CTX_POINTER; 1650 1651 /* 1652 * Preaching time. 1653 */ 1654 if ( MY_STRMATCH("unsigned long") 1655 || MY_STRMATCH("unsigned long long") 1656 || MY_STRMATCH("signed long") 1657 || MY_STRMATCH("signed long long") 1658 || MY_STRMATCH("long") 1659 || MY_STRMATCH("long long") 1660 || MY_STRMATCH("char") 1661 || MY_STRMATCH("signed char") 1662 || MY_STRMATCH("unsigned char") 1663 || MY_STRMATCH("double") 1664 || MY_STRMATCH("long double") 1665 || MY_STRMATCH("float") 1666 ) 1667 { 1668 RTMsgError("Please do NOT use the type '%s' for probe arguments!", pszType); 1669 g_cTypeErrors++; 1670 return 0; 1671 } 1672 1673 if ( MY_STRMATCH("unsigned") 1674 || MY_STRMATCH("signed") 1675 || MY_STRMATCH("int") 1676 || MY_STRMATCH("signed int") 1677 || MY_STRMATCH("unsigned int") 1678 || MY_STRMATCH("short") 1679 || MY_STRMATCH("signed short") 1680 || MY_STRMATCH("unsigned short") 1681 ) 1682 RTMsgWarning("Please avoid using the type '%s' for probe arguments!", pszType); 1683 if (MY_STRMATCH("unsigned")) return VTG_TYPE_FIXED_SIZED | sizeof(int) | VTG_TYPE_UNSIGNED; 1684 if (MY_STRMATCH("unsigned int")) return VTG_TYPE_FIXED_SIZED | sizeof(int) | VTG_TYPE_UNSIGNED; 1685 if (MY_STRMATCH("int")) return VTG_TYPE_FIXED_SIZED | sizeof(int) | VTG_TYPE_SIGNED; 1686 if (MY_STRMATCH("signed")) return VTG_TYPE_FIXED_SIZED | sizeof(int) | VTG_TYPE_SIGNED; 1687 if (MY_STRMATCH("signed int")) return VTG_TYPE_FIXED_SIZED | sizeof(int) | VTG_TYPE_SIGNED; 1688 if (MY_STRMATCH("short")) return VTG_TYPE_FIXED_SIZED | sizeof(short) | VTG_TYPE_SIGNED; 1689 if (MY_STRMATCH("signed short")) return VTG_TYPE_FIXED_SIZED | sizeof(short) | VTG_TYPE_SIGNED; 1690 if (MY_STRMATCH("unsigned short")) return VTG_TYPE_FIXED_SIZED | sizeof(short) | VTG_TYPE_UNSIGNED; 1691 1692 /* 1693 * What we haven't caught by now is either unknown to us or wrong. 1694 */ 1695 if (pszType[0] == 'P') 1696 { 1697 RTMsgError("Type '%s' looks like a pointer typedef, please do NOT use those " 1698 "but rather the non-pointer typedef or struct with '*'", 1699 pszType); 1700 g_cTypeErrors++; 1701 return VTG_TYPE_POINTER; 1702 } 1703 1704 RTMsgError("Don't know '%s' - please change or fix VBoxTpG", pszType); 1705 g_cTypeErrors++; 1706 1707 #undef MY_STRCMP 1708 return 0; 1709 } 1710 1711 1712 /** 1550 1713 * Unmangles the probe name. 1551 1714 * … … 1637 1800 return parseError(pStrm, 1, "Argument type too long"); 1638 1801 pArg->pszType = strtabInsertN(szArg, cchArg - cchName - 1); 1639 pArg->pszName = strtabInsertN(&szArg[cchArg - cchName], cchName);1802 pArg->pszName = RTStrDupN(&szArg[cchArg - cchName], cchName); 1640 1803 if (!pArg->pszType || !pArg->pszName) 1641 1804 return parseError(pStrm, 1, "Out of memory"); 1805 pArg->fType = parseTypeExpression(pArg->pszType); 1806 if (VTG_TYPE_IS_LARGE(pArg->fType)) 1807 pProbe->fHaveLargeArgs = true; 1642 1808 pArg = NULL; 1643 1809 cchName = cchArg = 0; … … 2073 2239 } 2074 2240 2241 if (rcExit == RTEXITCODE_SUCCESS && g_cTypeErrors > 0) 2242 rcExit = RTEXITCODE_FAILURE; 2075 2243 return rcExit; 2076 2244 }
Note:
See TracChangeset
for help on using the changeset viewer.