- Timestamp:
- Sep 24, 2008 10:25:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/VBoxDbgStatsQt4.cpp
r12705 r12706 71 71 /** The node is visible. */ 72 72 kDbgGuiStatsNodeState_kVisible, 73 /** The node is invisible. */74 kDbgGuiStatsNodeState_kInvisible,75 /** The node should be made visble. */76 kDbgGuiStatsNodeState_kMakeVisible,77 /** The node should be made invisble. */78 kDbgGuiStatsNodeState_kMakeInvisible,79 73 /** The node should be refreshed. */ 80 74 kDbgGuiStatsNodeState_kRefresh, … … 114 108 /** The unit. */ 115 109 STAMUNIT enmUnit; 116 /** The data type. */ 110 /** The data type. 111 * For filler nodes not containing data, this will be set to STAMTYPE_INVALID. */ 117 112 STAMTYPE enmType; 118 113 /** The data at last update. */ … … 135 130 /** STAMTYPE_U64 & STAMTYPE_U64_RESET. */ 136 131 uint64_t u64; 137 /** STAMTYPE_CALLBACK - buffer of 256 bytes. */138 char *psz;132 /** STAMTYPE_CALLBACK. */ 133 QString *pStr; 139 134 } Data; 135 /** The delta. */ 136 int64_t i64Delta; 140 137 /** The name. */ 141 138 char *pszName; … … 146 143 /** The node state. */ 147 144 DBGGUISTATENODESTATE enmState; 148 /** The delta. */149 char szDelta[32];150 145 } DBGGUISTATSNODE; 151 146 … … 231 226 static PDBGGUISTATSNODE createAndInsertNode(PDBGGUISTATSNODE pParent, const char *pszName, size_t cchName, uint32_t iPosition = UINT32_MAX); 232 227 228 /** 229 * Resets the node to a pristine state. 230 * 231 * @param pNode The node. 232 */ 233 233 static void resetNode(PDBGGUISTATSNODE pNode); 234 static void updateNode(PDBGGUISTATSNODE pNode, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, 235 STAMVISIBILITY enmVisibility, const char *pszDesc, void *pvUser); 234 235 /** 236 * Initializes a pristine node. 237 */ 238 static int initNode(PDBGGUISTATSNODE pNode, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, const char *pszDesc); 239 240 /** 241 * Updates (or reinitializes if you like) a node. 242 */ 243 static void updateNode(PDBGGUISTATSNODE pNode, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, const char *pszDesc); 244 245 /** 246 * Calculates the full path of a node. 247 * 248 * @returns Number of bytes returned, negative value on buffer overflow 249 * 250 * @param pNode The node. 251 * @param psz The output buffer. 252 * @param cch The size of the buffer. 253 */ 236 254 static int32_t getNodePath(PCDBGGUISTATSNODE pNode, char *psz, ssize_t cch); 255 256 /** 257 * Check if the second node is an ancestor to the first one. 258 * 259 * @returns true/false. 260 * @param pNode The first node. 261 * @param pAncestor The second node, the alleged ancestor. */ 237 262 static bool isNodeAncestorOf(PCDBGGUISTATSNODE pNode, PCDBGGUISTATSNODE pAncestor); 263 264 /** 265 * Advance to the next node in the tree. 266 * 267 * @returns Pointer to the next node, NULL if we've reached the end or 268 * was handed a NULL node.. 269 * @param pNode The current node. 270 */ 238 271 static PDBGGUISTATSNODE nextNode(PDBGGUISTATSNODE pNode); 272 273 /** 274 * Advance to the previous node in the tree. 275 * 276 * @returns Pointer to the previous node, NULL if we've reached the end or 277 * was handed a NULL node.. 278 * @param pNode The current node. 279 */ 239 280 static PDBGGUISTATSNODE prevNode(PDBGGUISTATSNODE pNode); 240 static void removeAndDeleteNode(PDBGGUISTATSNODE pNode); 281 282 /** 283 * Removes a node from the tree and destroys it and all its decentands. 284 * 285 * @param pNode The node. 286 */ 287 static void removeAndDestroyNode(PDBGGUISTATSNODE pNode); 241 288 242 289 /** 243 290 * Destroys a statistics tree. 244 291 * 245 * @param a_pRoot 292 * @param a_pRoot The root of the tree. NULL is fine. 246 293 */ 247 294 static void destroyTree(PDBGGUISTATSNODE a_pRoot); … … 317 364 /** Gets the maximum value. */ 318 365 static QString strMaxValue(PCDBGGUISTATSNODE pNode); 319 /** Gets the total value count. */366 /** Gets the total value. */ 320 367 static QString strTotalValue(PCDBGGUISTATSNODE pNode); 368 /** Gets the delta value. */ 369 static QString strDeltaValue(PCDBGGUISTATSNODE pNode); 321 370 322 371 /** … … 392 441 393 442 /** 394 * Initializes a new node.395 */396 static int initNode(PDBGGUISTATSNODE pNode, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, STAMVISIBILITY enmVisibility, const char *pszDesc);397 398 /**399 443 * Enumeration callback used by createNewTree. 400 444 */ … … 454 498 455 499 456 #if 0457 500 /** 458 501 * Formats a number into a 64-byte buffer. … … 482 525 return psz; 483 526 } 484 #endif485 527 486 528 … … 510 552 511 553 554 #if 0/* unused */ 512 555 /** 513 556 * Formats a sort key number. … … 534 577 } 535 578 } 579 #endif 536 580 537 581 … … 629 673 RTMemFree(a_pNode->papChildren); 630 674 a_pNode->papChildren = NULL; 675 676 if (a_pNode->enmType == STAMTYPE_CALLBACK) 677 { 678 delete a_pNode->Data.pStr; 679 a_pNode->Data.pStr = NULL; 680 } 631 681 632 682 a_pNode->cChildren = 0; … … 726 776 727 777 /*static*/ void 728 VBoxDbgStatsModel::removeAndDeleteNode(PDBGGUISTATSNODE pNode) 729 { 730 /* frees stuff up */ 731 resetNode(pNode); 732 778 VBoxDbgStatsModel::removeAndDestroyNode(PDBGGUISTATSNODE pNode) 779 { 780 /* 781 * Unlink it. 782 */ 783 PDBGGUISTATSNODE pParent = pNode->pParent; 784 if (pParent) 785 { 786 uint32_t const iPosition = pNode->iSelf; 787 Assert(pParent->papChildren[iPosition] == pNode); 788 uint32_t iShift = --pParent->cChildren; 789 while (iShift-- > iPosition) 790 { 791 PDBGGUISTATSNODE pChild = pParent->papChildren[iShift + 1]; 792 pParent->papChildren[iShift] = pChild; 793 pChild->iSelf = iShift; 794 } 795 } 796 797 /* 798 * Delete it. 799 */ 800 destroyNode(pNode); 733 801 } 734 802 … … 737 805 VBoxDbgStatsModel::resetNode(PDBGGUISTATSNODE pNode) 738 806 { 739 /** @todo */ 740 } 807 /* free and reinit the data. */ 808 if (pNode->enmType == STAMTYPE_CALLBACK) 809 { 810 delete pNode->Data.pStr; 811 pNode->Data.pStr = NULL; 812 } 813 pNode->enmType = STAMTYPE_INVALID; 814 815 /* free the description. */ 816 if (pNode->pDescStr) 817 { 818 delete pNode->pDescStr; 819 pNode->pDescStr = NULL; 820 } 821 } 822 823 824 /*static*/ int 825 VBoxDbgStatsModel::initNode(PDBGGUISTATSNODE pNode, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, const char *pszDesc) 826 { 827 /* 828 * Copy the data. 829 */ 830 pNode->enmUnit = enmUnit; 831 Assert(pNode->enmType == STAMTYPE_INVALID); 832 pNode->enmType = enmType; 833 if (pszDesc) 834 pNode->pDescStr = new QString(pszDesc); /* ignore allocation failure (well, at least up to the point we can ignore it) */ 835 836 switch (enmType) 837 { 838 case STAMTYPE_COUNTER: 839 pNode->Data.Counter = *(PSTAMCOUNTER)pvSample; 840 break; 841 842 case STAMTYPE_PROFILE: 843 case STAMTYPE_PROFILE_ADV: 844 pNode->Data.Profile = *(PSTAMPROFILE)pvSample; 845 break; 846 847 case STAMTYPE_RATIO_U32: 848 case STAMTYPE_RATIO_U32_RESET: 849 pNode->Data.RatioU32 = *(PSTAMRATIOU32)pvSample; 850 break; 851 852 case STAMTYPE_CALLBACK: 853 { 854 const char *pszString = (const char *)pvSample; 855 pNode->Data.pStr = new QString(pszString); 856 break; 857 } 858 859 case STAMTYPE_U8: 860 case STAMTYPE_U8_RESET: 861 case STAMTYPE_X8: 862 case STAMTYPE_X8_RESET: 863 pNode->Data.u8 = *(uint8_t *)pvSample; 864 break; 865 866 case STAMTYPE_U16: 867 case STAMTYPE_U16_RESET: 868 case STAMTYPE_X16: 869 case STAMTYPE_X16_RESET: 870 pNode->Data.u16 = *(uint16_t *)pvSample; 871 break; 872 873 case STAMTYPE_U32: 874 case STAMTYPE_U32_RESET: 875 case STAMTYPE_X32: 876 case STAMTYPE_X32_RESET: 877 pNode->Data.u32 = *(uint32_t *)pvSample; 878 break; 879 880 case STAMTYPE_U64: 881 case STAMTYPE_U64_RESET: 882 case STAMTYPE_X64: 883 case STAMTYPE_X64_RESET: 884 pNode->Data.u64 = *(uint64_t *)pvSample; 885 break; 886 887 default: 888 AssertMsgFailed(("%d\n", enmType)); 889 break; 890 } 891 892 return VINF_SUCCESS; 893 } 894 895 741 896 742 897 743 898 /*static*/ void 744 VBoxDbgStatsModel::updateNode(PDBGGUISTATSNODE pNode, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, 745 STAMVISIBILITY enmVisibility, const char *pszDesc, void *pvUser) 746 { 747 /** @todo */ 899 VBoxDbgStatsModel::updateNode(PDBGGUISTATSNODE pNode, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, const char *pszDesc) 900 { 901 902 /* 903 * Reset and init the node if the type changed. 904 */ 905 if ( enmType != pNode->enmType 906 && pNode->enmType != STAMTYPE_INVALID) 907 { 908 resetNode(pNode); 909 initNode(pNode, enmType, pvSample, enmUnit, pszDesc); 910 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 911 } 912 else 913 { 914 /* 915 * ASSUME that only the sample value will change and that the unit, visibility 916 * and description remains the same. 917 */ 918 919 int64_t iDelta; 920 switch (enmType) 921 { 922 case STAMTYPE_COUNTER: 923 { 924 uint64_t cPrev = pNode->Data.Counter.c; 925 pNode->Data.Counter = *(PSTAMCOUNTER)pvSample; 926 iDelta = pNode->Data.Counter.c - cPrev; 927 if (iDelta || pNode->i64Delta) 928 { 929 pNode->i64Delta = iDelta; 930 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 931 } 932 break; 933 } 934 935 case STAMTYPE_PROFILE: 936 case STAMTYPE_PROFILE_ADV: 937 { 938 uint64_t cPrevPeriods = pNode->Data.Profile.cPeriods; 939 pNode->Data.Profile = *(PSTAMPROFILE)pvSample; 940 iDelta = pNode->Data.Profile.cPeriods - cPrevPeriods; 941 if (iDelta || pNode->i64Delta) 942 { 943 pNode->i64Delta = iDelta; 944 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 945 } 946 break; 947 } 948 949 case STAMTYPE_RATIO_U32: 950 case STAMTYPE_RATIO_U32_RESET: 951 { 952 STAMRATIOU32 Prev = pNode->Data.RatioU32; 953 pNode->Data.RatioU32 = *(PSTAMRATIOU32)pvSample; 954 int32_t iDeltaA = pNode->Data.RatioU32.u32A - Prev.u32A; 955 int32_t iDeltaB = pNode->Data.RatioU32.u32B - Prev.u32B; 956 if (iDeltaA == 0 && iDeltaB == 0) 957 { 958 if (pNode->i64Delta) 959 { 960 pNode->i64Delta = 0; 961 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 962 } 963 } 964 else 965 { 966 if (iDeltaA >= 0) 967 pNode->i64Delta = iDeltaA + (iDeltaB >= 0 ? iDeltaB : -iDeltaB); 968 else 969 pNode->i64Delta = iDeltaA + (iDeltaB < 0 ? iDeltaB : -iDeltaB); 970 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 971 } 972 break; 973 } 974 975 case STAMTYPE_CALLBACK: 976 { 977 const char *pszString = (const char *)pvSample; 978 if (!pNode->Data.pStr) 979 { 980 pNode->Data.pStr = new QString(pszString); 981 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 982 } 983 else if (*pNode->Data.pStr == pszString) 984 { 985 delete pNode->Data.pStr; 986 pNode->Data.pStr = new QString(pszString); 987 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 988 } 989 break; 990 } 991 992 case STAMTYPE_U8: 993 case STAMTYPE_U8_RESET: 994 case STAMTYPE_X8: 995 case STAMTYPE_X8_RESET: 996 { 997 uint8_t uPrev = pNode->Data.u8; 998 pNode->Data.u8 = *(uint8_t *)pvSample; 999 iDelta = pNode->Data.u8 - uPrev; 1000 if (iDelta || pNode->i64Delta) 1001 { 1002 pNode->i64Delta = iDelta; 1003 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 1004 } 1005 break; 1006 } 1007 1008 case STAMTYPE_U16: 1009 case STAMTYPE_U16_RESET: 1010 case STAMTYPE_X16: 1011 case STAMTYPE_X16_RESET: 1012 { 1013 uint16_t uPrev = pNode->Data.u16; 1014 pNode->Data.u16 = *(uint16_t *)pvSample; 1015 iDelta = pNode->Data.u16 - uPrev; 1016 if (iDelta || pNode->i64Delta) 1017 { 1018 pNode->i64Delta = iDelta; 1019 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 1020 } 1021 break; 1022 } 1023 1024 case STAMTYPE_U32: 1025 case STAMTYPE_U32_RESET: 1026 case STAMTYPE_X32: 1027 case STAMTYPE_X32_RESET: 1028 { 1029 uint32_t uPrev = pNode->Data.u32; 1030 pNode->Data.u8 = *(uint32_t *)pvSample; 1031 iDelta = pNode->Data.u32 - uPrev; 1032 if (iDelta || pNode->i64Delta) 1033 { 1034 pNode->i64Delta = iDelta; 1035 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 1036 } 1037 break; 1038 } 1039 1040 case STAMTYPE_U64: 1041 case STAMTYPE_U64_RESET: 1042 case STAMTYPE_X64: 1043 case STAMTYPE_X64_RESET: 1044 { 1045 uint64_t uPrev = pNode->Data.u64; 1046 pNode->Data.u64 = *(uint64_t *)pvSample; 1047 iDelta = pNode->Data.u64 - uPrev; 1048 if (iDelta || pNode->i64Delta) 1049 { 1050 pNode->i64Delta = iDelta; 1051 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; 1052 } 1053 break; 1054 } 1055 default: 1056 AssertMsgFailed(("%d\n", enmType)); 1057 break; 1058 } 1059 } 748 1060 } 749 1061 … … 896 1208 { 897 1209 Qt::ItemFlags fFlags = QAbstractItemModel::flags(a_rIndex); 898 1210 #if 0 899 1211 PDBGGUISTATSNODE pNode = nodeFromIndex(a_rIndex); 900 1212 if (pNode) 901 1213 { 902 if (pNode->enmState == kDbgGuiStatsNodeState_kInvisible) 903 fFlags &= ~(Qt::ItemIsEnabled | Qt::ItemIsSelectable); 904 } 1214 } 1215 #endif 905 1216 return fFlags; 906 1217 } … … 910 1221 VBoxDbgStatsModel::columnCount(const QModelIndex &a_rParent) const 911 1222 { 912 PDBGGUISTATSNODE pParent = nodeFromIndex(a_rParent); 913 if ( pParent 914 && pParent->enmState == kDbgGuiStatsNodeState_kInvisible) 915 return 0; 1223 NOREF(a_rParent); 916 1224 return DBGGUI_STATS_COLUMNS; 917 1225 } … … 922 1230 { 923 1231 PDBGGUISTATSNODE pParent = nodeFromIndex(a_rParent); 924 if ( !pParent925 || pParent->enmState == kDbgGuiStatsNodeState_kInvisible)926 return 0;927 1232 return pParent->cChildren; 928 1233 } … … 934 1239 PDBGGUISTATSNODE pParent = nodeFromIndex(a_rParent); 935 1240 return pParent 936 && pParent->cChildren > 0 937 && pParent->enmState != kDbgGuiStatsNodeState_kInvisible; 1241 && pParent->cChildren > 0; 938 1242 } 939 1243 … … 959 1263 } 960 1264 PDBGGUISTATSNODE pChild = pParent->papChildren[iRow]; 961 if (pChild->enmState == kDbgGuiStatsNodeState_kInvisible) 962 { 963 printf("index: invisible (iColumn=%d iRow=%d)\n", iColumn, iRow); 964 return QModelIndex(); 965 } 966 967 //printf("index: iRow=%d iColumn=%d %p %s/%s\n", iRow, iColumn, pParent->papChildren[iRow], pParent->pszName, pParent->papChildren[iRow]->pszName); 968 return createIndex(iRow, iColumn, pParent->papChildren[iRow]); 1265 1266 //printf("index: iRow=%d iColumn=%d %p %s/%s\n", iRow, iColumn, pChild, pParent->pszName, pChild->pszName); 1267 return createIndex(iRow, iColumn, pChild); 969 1268 } 970 1269 … … 1051 1350 1052 1351 case STAMTYPE_CALLBACK: 1053 return pNode->Data.psz;1352 return *pNode->Data.pStr; 1054 1353 1055 1354 case STAMTYPE_U8: … … 1165 1464 1166 1465 1466 /*static*/ QString 1467 VBoxDbgStatsModel::strDeltaValue(PCDBGGUISTATSNODE pNode) 1468 { 1469 char sz[128]; 1470 1471 switch (pNode->enmType) 1472 { 1473 case STAMTYPE_PROFILE: 1474 case STAMTYPE_PROFILE_ADV: 1475 if (!pNode->Data.Profile.cPeriods) 1476 return "0"; 1477 return formatNumberSigned(sz, pNode->i64Delta); 1478 default: 1479 return ""; 1480 } 1481 } 1482 1483 1167 1484 QVariant 1168 1485 VBoxDbgStatsModel::data(const QModelIndex &a_rIndex, int a_eRole) const … … 1175 1492 1176 1493 PDBGGUISTATSNODE pNode = nodeFromIndex(a_rIndex); 1177 if ( !pNode 1178 || pNode->enmState == kDbgGuiStatsNodeState_kInvisible) 1494 if (!pNode) 1179 1495 return QVariant(); 1180 1496 … … 1196 1512 return strTotalValue(pNode); 1197 1513 case 7: 1198 return pNode->szDelta;1514 return strDeltaValue(pNode); 1199 1515 case 8: 1200 1516 return pNode->pDescStr ? QString(*pNode->pDescStr) : QString(""); … … 1203 1519 } 1204 1520 } 1521 1205 1522 1206 1523 /*static*/ void … … 1342 1659 */ 1343 1660 pThis->m_fUpdateInsertRemove = true; 1661 /** @todo optimize insert since that is a normal occurence. */ 1344 1662 1345 1663 /* Start with the current parent node and look for a common ancestor … … 1430 1748 PDBGGUISTATSNODE pAdv = prevNode(pCur); 1431 1749 if (!isNodeAncestorOf(pCur, pNode)) 1432 removeAndDe leteNode(pCur);1750 removeAndDestroyNode(pCur); 1433 1751 pCur = pAdv; 1434 1752 } … … 1453 1771 { 1454 1772 /* 1455 * Insert it at the end of the tree 1456 * .1457 * Do the same as we're doing down in createNewTreeCallback, walk from the .1773 * Insert it at the end of the tree. 1774 * 1775 * Do the same as we're doing down in createNewTreeCallback, walk from the 1458 1776 * root and create whatever we need. 1459 1777 */ … … 1492 1810 * Perform the update. 1493 1811 */ 1494 updateNode(pNode, enmType, pvSample, enmUnit, enmVisibility, pszDesc, pvUser);1812 updateNode(pNode, enmType, pvSample, enmUnit, pszDesc); 1495 1813 1496 1814 /* … … 1642 1960 /* skip to the first needing updating. */ 1643 1961 while ( iChild < pNode->cChildren 1644 && ( pNode->papChildren[iChild]->enmState != kDbgGuiStatsNodeState_kMakeVisible 1645 && pNode->papChildren[iChild]->enmState != kDbgGuiStatsNodeState_kMakeInvisible 1646 && pNode->papChildren[iChild]->enmState != kDbgGuiStatsNodeState_kRefresh)) 1962 && pNode->papChildren[iChild]->enmState != kDbgGuiStatsNodeState_kRefresh) 1647 1963 iChild++; 1648 1964 if (iChild >= pNode->cChildren) … … 1654 1970 { 1655 1971 DBGGUISTATENODESTATE enmState = pNode->papChildren[iChild]->enmState; 1656 if ( enmState == kDbgGuiStatsNodeState_kRefresh 1657 || enmState == kDbgGuiStatsNodeState_kMakeVisible) 1972 if (enmState == kDbgGuiStatsNodeState_kRefresh) 1658 1973 enmState = kDbgGuiStatsNodeState_kVisible; 1659 else if (enmState == kDbgGuiStatsNodeState_kMakeInvisible)1660 enmState = kDbgGuiStatsNodeState_kInvisible;1661 1974 else 1662 1975 break; … … 1674 1987 1675 1988 1676 /*static*/ int1677 VBoxDbgStatsModelVM::initNode(PDBGGUISTATSNODE pNode, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, STAMVISIBILITY enmVisibility, const char *pszDesc)1678 {1679 /*1680 * Copy the data.1681 */1682 bool fVisible = true;1683 pNode->enmUnit = enmUnit;1684 Assert(pNode->enmType == STAMTYPE_INVALID);1685 pNode->enmType = enmType;1686 if (pszDesc)1687 pNode->pDescStr = new QString(pszDesc); /* ignore allocation failure (well, at least up to the point we can ignore it) */1688 1689 switch (enmType)1690 {1691 case STAMTYPE_COUNTER:1692 pNode->Data.Counter = *(PSTAMCOUNTER)pvSample;1693 fVisible = enmVisibility != STAMVISIBILITY_NOT_GUI1694 && (enmVisibility == STAMVISIBILITY_ALWAYS || pNode->Data.Counter.c);1695 break;1696 1697 case STAMTYPE_PROFILE:1698 case STAMTYPE_PROFILE_ADV:1699 pNode->Data.Profile = *(PSTAMPROFILE)pvSample;1700 fVisible = enmVisibility != STAMVISIBILITY_NOT_GUI1701 && (enmVisibility == STAMVISIBILITY_ALWAYS || pNode->Data.Profile.cPeriods);1702 break;1703 1704 case STAMTYPE_RATIO_U32:1705 case STAMTYPE_RATIO_U32_RESET:1706 pNode->Data.RatioU32 = *(PSTAMRATIOU32)pvSample;1707 fVisible = enmVisibility != STAMVISIBILITY_NOT_GUI1708 && (enmVisibility == STAMVISIBILITY_ALWAYS || pNode->Data.RatioU32.u32A || pNode->Data.RatioU32.u32B);1709 break;1710 1711 case STAMTYPE_CALLBACK:1712 {1713 const char *pszString = (const char *)pvSample;1714 size_t cchString = strlen(pszString);1715 pNode->Data.psz = (char *)RTMemAlloc(256);1716 if (pNode->Data.psz)1717 return VERR_NO_MEMORY;1718 memcpy(pNode->Data.psz, pszString, RT_MIN(256, cchString + 1));1719 1720 fVisible = enmVisibility != STAMVISIBILITY_NOT_GUI1721 && (enmVisibility == STAMVISIBILITY_ALWAYS || cchString);1722 break;1723 }1724 1725 case STAMTYPE_U8:1726 case STAMTYPE_U8_RESET:1727 case STAMTYPE_X8:1728 case STAMTYPE_X8_RESET:1729 pNode->Data.u8 = *(uint8_t *)pvSample;1730 fVisible = enmVisibility != STAMVISIBILITY_NOT_GUI1731 && (enmVisibility == STAMVISIBILITY_ALWAYS || pNode->Data.u8);1732 break;1733 1734 case STAMTYPE_U16:1735 case STAMTYPE_U16_RESET:1736 case STAMTYPE_X16:1737 case STAMTYPE_X16_RESET:1738 pNode->Data.u16 = *(uint16_t *)pvSample;1739 fVisible = enmVisibility != STAMVISIBILITY_NOT_GUI1740 && (enmVisibility == STAMVISIBILITY_ALWAYS || pNode->Data.u16);1741 break;1742 1743 case STAMTYPE_U32:1744 case STAMTYPE_U32_RESET:1745 case STAMTYPE_X32:1746 case STAMTYPE_X32_RESET:1747 pNode->Data.u32 = *(uint32_t *)pvSample;1748 fVisible = enmVisibility != STAMVISIBILITY_NOT_GUI1749 && (enmVisibility == STAMVISIBILITY_ALWAYS || pNode->Data.u32);1750 break;1751 1752 case STAMTYPE_U64:1753 case STAMTYPE_U64_RESET:1754 case STAMTYPE_X64:1755 case STAMTYPE_X64_RESET:1756 pNode->Data.u64 = *(uint64_t *)pvSample;1757 fVisible = enmVisibility != STAMVISIBILITY_NOT_GUI1758 && (enmVisibility == STAMVISIBILITY_ALWAYS || pNode->Data.u64);1759 break;1760 1761 default:1762 AssertMsgFailed(("%d\n", enmType));1763 break;1764 }1765 1766 /*1767 * Set the state according to the visibility.1768 */1769 pNode->enmState = fVisible1770 ? kDbgGuiStatsNodeState_kVisible1771 : kDbgGuiStatsNodeState_kInvisible;1772 return VINF_SUCCESS;1773 }1774 1775 1776 1989 /*static*/ DECLCALLBACK(int) 1777 1990 VBoxDbgStatsModelVM::createNewTreeCallback(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, … … 1822 2035 * Save the data. 1823 2036 */ 1824 return initNode(pNode, enmType, pvSample, enmUnit, enmVisibility,pszDesc);2037 return initNode(pNode, enmType, pvSample, enmUnit, pszDesc); 1825 2038 } 1826 2039 … … 2335 2548 if (enmVisibility == STAMVISIBILITY_NOT_GUI) 2336 2549 return 0; 2550 /** @todo !STAMVISIBILITY_USED */ 2551 2337 2552 2338 2553 /*
Note:
See TracChangeset
for help on using the changeset viewer.