Changeset 90553 in vbox
- Timestamp:
- Aug 6, 2021 2:29:11 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 146159
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PDMCritSect.cpp
r90550 r90553 45 45 static int pdmR3CritSectRwDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTRWINT pCritSect, PPDMCRITSECTRWINT pPrev, bool fFinal); 46 46 static FNDBGFINFOARGVINT pdmR3CritSectInfo; 47 static FNDBGFINFOARGVINT pdmR3CritSectRwInfo; 47 48 48 49 … … 76 77 */ 77 78 DBGFR3InfoRegisterInternalArgv(pVM, "critsect", "Show critical section: critsect [-v] [pattern[...]]", pdmR3CritSectInfo, 0); 79 DBGFR3InfoRegisterInternalArgv(pVM, "critsectrw", "Show read/write critical section: critsectrw [-v] [pattern[...]]", 80 pdmR3CritSectRwInfo, 0); 78 81 79 82 return VINF_SUCCESS; … … 1091 1094 || RTStrSimplePatternMultiMatch(pszPatterns, cchPatterns, pCritSect->pszName, RTSTR_MAX, NULL)) 1092 1095 { 1093 pHlp->pfnPrintf(pHlp, "%p: '%s'%s\n", pCritSect, pCritSect->pszName, 1096 uint32_t fFlags = pCritSect->Core.fFlags; 1097 pHlp->pfnPrintf(pHlp, "%p: '%s'%s%s%s%s%s\n", pCritSect, pCritSect->pszName, 1094 1098 pCritSect->fAutomaticDefaultCritsect ? " default" : "", 1095 pCritSect->fUsedByTimerOrSimilar ? " used-by-timer-or-similar" : ""); 1099 pCritSect->fUsedByTimerOrSimilar ? " used-by-timer-or-similar" : "", 1100 fFlags & RTCRITSECT_FLAGS_NO_NESTING ? " no-testing" : "", 1101 fFlags & RTCRITSECT_FLAGS_NO_LOCK_VAL ? " no-lock-val" : "", 1102 fFlags & RTCRITSECT_FLAGS_NOP ? " nop" : ""); 1103 1096 1104 1097 1105 /* … … 1101 1109 int32_t cLockers; 1102 1110 int32_t cNestings; 1103 uint32_t fFlags;1104 1111 uint32_t uMagic; 1105 1112 for (uint32_t iTry = 0; iTry < 16; iTry++) … … 1136 1143 * If locked, print details 1137 1144 */ 1138 if (cLockers != -1 || cNestings != 1|| hOwner != NIL_RTNATIVETHREAD || cVerbosity > 1)1145 if (cLockers != -1 || cNestings > 1 || cNestings < 0 || hOwner != NIL_RTNATIVETHREAD || cVerbosity > 1) 1139 1146 { 1140 1147 /* Translate the owner to a name if we have one and can. */ … … 1158 1165 1159 1166 /** 1160 * @callback_method_impl{FNDBGFINFOARGVINT, critsect} 1161 */ 1162 static DECLCALLBACK(void) pdmR3CritSectInfo(PVM pVM, PCDBGFINFOHLP pHlp, int cArgs, char **papszArgs) 1167 * Display matching read/write critical sections. 1168 */ 1169 static void pdmR3CritSectInfoRwWorker(PUVM pUVM, const char *pszPatterns, PCDBGFINFOHLP pHlp, unsigned cVerbosity) 1170 { 1171 size_t const cchPatterns = pszPatterns ? strlen(pszPatterns) : 0; 1172 RTCritSectEnter(&pUVM->pdm.s.ListCritSect); 1173 1174 for (PPDMCRITSECTRWINT pCritSect = pUVM->pdm.s.pRwCritSects; pCritSect; pCritSect = pCritSect->pNext) 1175 if ( !pszPatterns 1176 || RTStrSimplePatternMultiMatch(pszPatterns, cchPatterns, pCritSect->pszName, RTSTR_MAX, NULL)) 1177 { 1178 uint16_t const fFlags = pCritSect->Core.fFlags; 1179 pHlp->pfnPrintf(pHlp, "%p: '%s'%s%s%s\n", pCritSect, pCritSect->pszName, 1180 pCritSect->Core.fFlags & RTCRITSECT_FLAGS_NO_NESTING ? " no-testing" : "", 1181 pCritSect->Core.fFlags & RTCRITSECT_FLAGS_NO_LOCK_VAL ? " no-lock-val" : "", 1182 pCritSect->Core.fFlags & RTCRITSECT_FLAGS_NOP ? " nop" : ""); 1183 1184 /* 1185 * Get the volatile data: 1186 */ 1187 RTNATIVETHREAD hOwner; 1188 uint64_t u64State; 1189 uint32_t cWriterReads; 1190 uint32_t cWriteRecursions; 1191 bool fNeedReset; 1192 uint32_t uMagic; 1193 unsigned cTries = 16; 1194 do 1195 { 1196 u64State = pCritSect->Core.u64State; 1197 hOwner = pCritSect->Core.hNativeWriter; 1198 cWriterReads = pCritSect->Core.cWriterReads; 1199 cWriteRecursions = pCritSect->Core.cWriteRecursions; 1200 fNeedReset = pCritSect->Core.fNeedReset; 1201 uMagic = pCritSect->Core.u32Magic; 1202 } while ( cTries-- > 0 1203 && ( u64State != pCritSect->Core.u64State 1204 || hOwner != pCritSect->Core.hNativeWriter 1205 || cWriterReads != pCritSect->Core.cWriterReads 1206 || cWriteRecursions != pCritSect->Core.cWriteRecursions 1207 || fNeedReset != pCritSect->Core.fNeedReset 1208 || uMagic != pCritSect->Core.u32Magic)); 1209 1210 /* 1211 * Check and resolve the magic to a string, print if not RTCRITSECT_MAGIC. 1212 */ 1213 const char *pszMagic; 1214 switch (uMagic) 1215 { 1216 case RTCRITSECTRW_MAGIC: pszMagic = NULL; break; 1217 case ~RTCRITSECTRW_MAGIC: pszMagic = " deleted"; break; 1218 case PDMCRITSECTRW_MAGIC_CORRUPT: pszMagic = " PDMCRITSECTRW_MAGIC_CORRUPT!"; break; 1219 default: pszMagic = " !unknown!"; break; 1220 } 1221 if (pszMagic || cVerbosity > 1) 1222 pHlp->pfnPrintf(pHlp, " uMagic=%#x%s\n", uMagic, pszMagic ? pszMagic : ""); 1223 1224 /* 1225 * If locked, print details 1226 */ 1227 if ((u64State & ~RTCSRW_DIR_MASK) || hOwner != NIL_RTNATIVETHREAD || cVerbosity > 1) 1228 { 1229 /* Translate the owner to a name if we have one and can. */ 1230 const char *pszOwner = NULL; 1231 if (hOwner != NIL_RTNATIVETHREAD) 1232 { 1233 RTTHREAD hOwnerThread = RTThreadFromNative(hOwner); /* Note! Does not return a reference (crazy). */ 1234 if (hOwnerThread != NIL_RTTHREAD) 1235 pszOwner = RTThreadGetName(hOwnerThread); 1236 } 1237 else 1238 pszOwner = "<no-owner>"; 1239 1240 pHlp->pfnPrintf(pHlp, " u64State=%#RX64 %s cReads=%u cWrites=%u cWaitingReads=%u\n", 1241 u64State, (u64State & RTCSRW_DIR_MASK) == RTCSRW_DIR_WRITE ? "writing" : "reading", 1242 (unsigned)((u64State & RTCSRW_CNT_RD_MASK) >> RTCSRW_CNT_RD_SHIFT), 1243 (unsigned)((u64State & RTCSRW_CNT_WR_MASK) >> RTCSRW_CNT_RD_SHIFT), 1244 (unsigned)((u64State & RTCSRW_WAIT_CNT_RD_MASK) >> RTCSRW_WAIT_CNT_RD_SHIFT)); 1245 if (hOwner != NIL_RTNATIVETHREAD || cVerbosity > 2) 1246 pHlp->pfnPrintf(pHlp, " cNestings=%u cReadNestings=%u hWriter=%p %s\n", 1247 cWriteRecursions, cWriterReads, hOwner, pszOwner ? pszOwner : "???"); 1248 } 1249 } 1250 RTCritSectLeave(&pUVM->pdm.s.ListCritSect); 1251 } 1252 1253 1254 /** 1255 * Common worker for critsect and critsectrw info items. 1256 */ 1257 static void pdmR3CritSectInfoCommon(PVM pVM, PCDBGFINFOHLP pHlp, int cArgs, char **papszArgs, bool fReadWrite) 1163 1258 { 1164 1259 PUVM pUVM = pVM->pUVM; … … 1188 1283 1189 1284 case VINF_GETOPT_NOT_OPTION: 1190 pdmR3CritSectInfoWorker(pUVM, ValueUnion.psz, pHlp, cVerbosity); 1285 if (!fReadWrite) 1286 pdmR3CritSectInfoWorker(pUVM, ValueUnion.psz, pHlp, cVerbosity); 1287 else 1288 pdmR3CritSectInfoRwWorker(pUVM, ValueUnion.psz, pHlp, cVerbosity); 1191 1289 cProcessed++; 1192 1290 break; … … 1202 1300 */ 1203 1301 if (!cProcessed) 1204 pdmR3CritSectInfoWorker(pUVM, NULL, pHlp, cVerbosity); 1205 } 1206 1207 1302 { 1303 if (!fReadWrite) 1304 pdmR3CritSectInfoWorker(pUVM, NULL, pHlp, cVerbosity); 1305 else 1306 pdmR3CritSectInfoRwWorker(pUVM, NULL, pHlp, cVerbosity); 1307 } 1308 } 1309 1310 1311 /** 1312 * @callback_method_impl{FNDBGFINFOARGVINT, critsect} 1313 */ 1314 static DECLCALLBACK(void) pdmR3CritSectInfo(PVM pVM, PCDBGFINFOHLP pHlp, int cArgs, char **papszArgs) 1315 { 1316 return pdmR3CritSectInfoCommon(pVM, pHlp, cArgs, papszArgs, false); 1317 } 1318 1319 1320 /** 1321 * @callback_method_impl{FNDBGFINFOARGVINT, critsectrw} 1322 */ 1323 static DECLCALLBACK(void) pdmR3CritSectRwInfo(PVM pVM, PCDBGFINFOHLP pHlp, int cArgs, char **papszArgs) 1324 { 1325 return pdmR3CritSectInfoCommon(pVM, pHlp, cArgs, papszArgs, true); 1326 } 1327
Note:
See TracChangeset
for help on using the changeset viewer.