Changeset 80648 in vbox for trunk/src/VBox
- Timestamp:
- Sep 7, 2019 12:58:51 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/STAM.cpp
r80333 r80648 1128 1128 1129 1129 /** 1130 * Look up the first descriptors for starts-with name string. 1131 * 1132 * This is used to optimize deletion. 1133 * 1134 * @returns Pointer to the first descriptor in the range. 1135 * @param pRoot The root node. 1136 * @param pchPrefix The name prefix. 1137 * @param cchPrefix The name prefix length (can be shorter than the 1138 * actual string). 1139 * @sa stamR3LookupFindPatternDescRange 1140 */ 1141 static PSTAMDESC stamR3LookupFindFirstByPrefix(PSTAMLOOKUP pRoot, const char *pchPrefix, uint32_t cchPrefix) 1142 { 1143 Assert(!pRoot->pParent); 1144 1145 /* 1146 * All statistics starts with a slash. 1147 */ 1148 while ( cchPrefix > 0 1149 && *pchPrefix == '/' 1150 && pRoot->cDescsInTree > 0 1151 && pRoot->cChildren > 0) 1152 { 1153 cchPrefix -= 1; 1154 pchPrefix += 1; 1155 1156 const char *pszEnd = (const char *)memchr(pchPrefix, '/', cchPrefix); 1157 if (!pszEnd) 1158 { 1159 /* We've narrowed it down to a sub-tree now. */ 1160 for (size_t i = 0; i < pRoot->cChildren; i++) 1161 { 1162 PSTAMLOOKUP pCur = pRoot->papChildren[i]; 1163 if (pCur->cch >= cchPrefix) 1164 { 1165 int iDiff = memcmp(pCur->szName, pchPrefix, cchPrefix); 1166 if (iDiff == 0) 1167 return stamR3LookupFindFirstDescForRange(pCur, pRoot->papChildren[pRoot->cChildren - 1]); 1168 if (iDiff > 0) 1169 break; 1170 } 1171 } 1172 break; 1173 } 1174 1175 uint32_t cchElement = pszEnd - pchPrefix; 1176 PSTAMLOOKUP pChild = stamR3LookupFindChild(pRoot, pchPrefix, cchElement, NULL); 1177 if (!pChild) 1178 break; 1179 1180 /* Advance */ 1181 cchPrefix -= cchElement; 1182 pchPrefix = pszEnd; 1183 pRoot = pChild; 1184 } 1185 return NULL; 1186 } 1187 1188 1189 /** 1130 1190 * Increments the cDescInTree member of the given node an all ancestors. 1131 1191 * … … 1667 1727 1668 1728 return stamR3DeregisterByPattern(pUVM, szPat); 1729 } 1730 1731 1732 /** 1733 * Deregister zero or more samples given their name prefix. 1734 * 1735 * @returns VBox status code. 1736 * @param pUVM Pointer to the user mode VM structure. 1737 * @param pszPrefix The name prefix of the samples to remove. 1738 * @sa STAMR3Deregister, STAMR3DeregisterF, STAMR3DeregisterV 1739 */ 1740 VMMR3DECL(int) STAMR3DeregisterByPrefix(PUVM pUVM, const char *pszPrefix) 1741 { 1742 UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE); 1743 1744 /* This is a complete waste of time when shutting down. */ 1745 VMSTATE enmState = VMR3GetStateU(pUVM); 1746 if (enmState >= VMSTATE_DESTROYING) 1747 return VINF_SUCCESS; 1748 1749 size_t const cchPrefix = strlen(pszPrefix); 1750 int rc = VWRN_NOT_FOUND; 1751 STAM_LOCK_WR(pUVM); 1752 1753 PSTAMDESC pCur = stamR3LookupFindFirstByPrefix(pUVM->stam.s.pRoot, pszPrefix, (uint32_t)cchPrefix); 1754 while (pCur) 1755 { 1756 PSTAMDESC const pNext = RTListNodeGetNext(&pCur->ListEntry, STAMDESC, ListEntry); 1757 size_t const cchName = strlen(pCur->pszName); 1758 if ( cchName >= cchPrefix 1759 && memcmp(pCur->pszName, pszPrefix, cchPrefix) == 0) 1760 rc = stamR3DestroyDesc(pCur); 1761 else 1762 break; 1763 1764 /* advance. */ 1765 pCur = pNext; 1766 } 1767 1768 STAM_UNLOCK_WR(pUVM); 1769 return rc; 1669 1770 } 1670 1771
Note:
See TracChangeset
for help on using the changeset viewer.