Changeset 12817 in vbox
- Timestamp:
- Sep 30, 2008 1:31:41 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 37172
- Location:
- trunk/src/VBox/Debugger
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/VBoxDbgGui.cpp
r12462 r12817 149 149 if (!m_pDbgStats) 150 150 { 151 #ifdef VBOXDBG_USE_QT4152 m_pDbgStats = new VBoxDbgStats(m_pVM, "*x*"); /// @todo the QTreeWidget/QTreeView sucks big time. it freezes the app for 30+ seconds. Need to write a new item model I fear. 'ing crap!!!153 #else154 151 m_pDbgStats = new VBoxDbgStats(m_pVM); 155 #endif156 152 connect(m_pDbgStats, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *))); 157 153 repositionStatistics(); -
trunk/src/VBox/Debugger/VBoxDbgStatsQt4.cpp
r12706 r12817 198 198 * Nodes not matched by the pattern will become invisible. 199 199 * 200 * @returns true if we reset the model and it's necessary to set the root index. 200 201 * @param a_rPatStr The selection pattern. 201 202 */ 202 virtual void update(const QString &a_rPatStr) = 0;203 virtual bool updateStats(const QString &a_rPatStr) = 0; 203 204 204 205 /** … … 224 225 225 226 /** Creates and insert a node under the given parent. */ 226 static PDBGGUISTATSNODE createAndInsertNode(PDBGGUISTATSNODE pParent, const char *pszName, size_t cchName, uint32_t iPosition = UINT32_MAX);227 static PDBGGUISTATSNODE createAndInsertNode(PDBGGUISTATSNODE pParent, const char *pszName, size_t cchName, uint32_t iPosition/* = UINT32_MAX*/); 227 228 228 229 /** … … 255 256 256 257 /** 257 * Check if the second node is an ancestor to the firstone.258 * Check if the first node is an ancestor to the second one. 258 259 * 259 260 * @returns true/false. 260 * @param pNode The first node. 261 * @param pAncestor The second node, the alleged ancestor. */ 262 static bool isNodeAncestorOf(PCDBGGUISTATSNODE pNode, PCDBGGUISTATSNODE pAncestor); 261 * @param pAncestor The first node, the alleged ancestor. 262 * @param pDescendant The second node, the alleged descendant. 263 */ 264 static bool isNodeAncestorOf(PCDBGGUISTATSNODE pAncestor, PCDBGGUISTATSNODE pDescendant); 263 265 264 266 /** … … 266 268 * 267 269 * @returns Pointer to the next node, NULL if we've reached the end or 268 * was handed a NULL node. .270 * was handed a NULL node. 269 271 * @param pNode The current node. 270 272 */ 271 273 static PDBGGUISTATSNODE nextNode(PDBGGUISTATSNODE pNode); 274 275 /** 276 * Advance to the next node in the tree that contains data. 277 * 278 * @returns Pointer to the next data node, NULL if we've reached the end or 279 * was handed a NULL node. 280 * @param pNode The current node. 281 */ 282 static PDBGGUISTATSNODE nextDataNode(PDBGGUISTATSNODE pNode); 272 283 273 284 /** … … 275 286 * 276 287 * @returns Pointer to the previous node, NULL if we've reached the end or 277 * was handed a NULL node. .288 * was handed a NULL node. 278 289 * @param pNode The current node. 279 290 */ 280 291 static PDBGGUISTATSNODE prevNode(PDBGGUISTATSNODE pNode); 292 293 /** 294 * Advance to the previous node in the tree that contains data. 295 * 296 * @returns Pointer to the previous data node, NULL if we've reached the end or 297 * was handed a NULL node. 298 * @param pNode The current node. 299 */ 300 static PDBGGUISTATSNODE prevDataNode(PDBGGUISTATSNODE pNode); 281 301 282 302 /** … … 429 449 * Nodes not matched by the pattern will become invisible. 430 450 * 451 * @returns true if we reset the model and it's necessary to set the root index. 431 452 * @param a_rPatStr The selection pattern. 432 453 */ 433 virtual void update(const QString &a_rPatStr);454 virtual bool updateStats(const QString &a_rPatStr); 434 455 435 456 protected: 436 457 /** 437 * Enumeration callback used by update .458 * Enumeration callback used by updateStats. 438 459 */ 439 460 static DECLCALLBACK(int) updateCallback(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, … … 666 687 a_pNode->papChildren[i] = NULL; 667 688 } 668 a_pNode->cChildren = 0;669 689 670 690 /* free the resources we're using */ … … 693 713 a_pNode->pDescStr = NULL; 694 714 } 715 716 #ifdef VBOX_STRICT 717 /* poison it. */ 718 a_pNode->pParent++; 719 a_pNode->Data.pStr++; 720 a_pNode->pDescStr++; 721 a_pNode->papChildren++; 722 a_pNode->cChildren = 8442; 723 #endif 695 724 696 725 /* Finally ourselves */ … … 784 813 if (pParent) 785 814 { 786 uint32_t constiPosition = pNode->iSelf;815 uint32_t iPosition = pNode->iSelf; 787 816 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 } 817 uint32_t const cChildren = --pParent->cChildren; 818 for (; iPosition < cChildren; iPosition++) 819 { 820 PDBGGUISTATSNODE pChild = pParent->papChildren[iPosition + 1]; 821 pParent->papChildren[iPosition] = pChild; 822 pChild->iSelf = iPosition; 823 } 824 #ifdef VBOX_STRICT /* poison */ 825 pParent->papChildren[iPosition] = (PDBGGUISTATSNODE)0x42; 826 #endif 795 827 } 796 828 … … 903 935 * Reset and init the node if the type changed. 904 936 */ 905 if ( enmType != pNode->enmType906 && pNode->enmType != STAMTYPE_INVALID)907 {908 resetNode(pNode);937 if (enmType != pNode->enmType) 938 { 939 if (pNode->enmType != STAMTYPE_INVALID) 940 resetNode(pNode); 909 941 initNode(pNode, enmType, pvSample, enmUnit, pszDesc); 910 942 pNode->enmState = kDbgGuiStatsNodeState_kRefresh; … … 1074 1106 else 1075 1107 { 1076 cch -= pNode->cchName -1;1108 cch -= pNode->cchName + 1; 1077 1109 AssertReturn(cch > 0, -1); 1078 1110 off = getNodePath(pNode->pParent, psz, cch); … … 1089 1121 1090 1122 /*static*/ bool 1091 VBoxDbgStatsModel::isNodeAncestorOf(PCDBGGUISTATSNODE p Node, PCDBGGUISTATSNODE pAncestor)1092 { 1093 while (p Node)1094 { 1095 p Node = pNode->pParent;1096 if (p Node== pAncestor)1123 VBoxDbgStatsModel::isNodeAncestorOf(PCDBGGUISTATSNODE pAncestor, PCDBGGUISTATSNODE pDescendant) 1124 { 1125 while (pDescendant) 1126 { 1127 pDescendant = pDescendant->pParent; 1128 if (pDescendant == pAncestor) 1097 1129 return true; 1098 1130 } … … 1133 1165 1134 1166 /*static*/ PDBGGUISTATSNODE 1167 VBoxDbgStatsModel::nextDataNode(PDBGGUISTATSNODE pNode) 1168 { 1169 do 1170 pNode = nextNode(pNode); 1171 while ( pNode 1172 && pNode->enmType == STAMTYPE_INVALID); 1173 return pNode; 1174 } 1175 1176 1177 /*static*/ PDBGGUISTATSNODE 1135 1178 VBoxDbgStatsModel::prevNode(PDBGGUISTATSNODE pNode) 1136 1179 { … … 1141 1184 return NULL; 1142 1185 1143 /* previous sibling's grand-most child(better expression anyone?). */1186 /* previous sibling's latest decendant (better expression anyone?). */ 1144 1187 if (pNode->iSelf > 0) 1145 1188 { … … 1150 1193 } 1151 1194 1152 /* ascend to the parent (if any). */ 1153 return pNode->pParent; 1195 /* ascend to the parent. */ 1196 return pParent; 1197 } 1198 1199 1200 /*static*/ PDBGGUISTATSNODE 1201 VBoxDbgStatsModel::prevDataNode(PDBGGUISTATSNODE pNode) 1202 { 1203 do 1204 pNode = prevNode(pNode); 1205 while ( pNode 1206 && pNode->enmType == STAMTYPE_INVALID); 1207 return pNode; 1154 1208 } 1155 1209 … … 1281 1335 if (!pParent) 1282 1336 { 1283 printf("parent: root\n");1337 // printf("parent: root\n"); 1284 1338 return QModelIndex(); /* we're root */ 1285 1339 } … … 1660 1714 pThis->m_fUpdateInsertRemove = true; 1661 1715 /** @todo optimize insert since that is a normal occurence. */ 1716 Assert(pszName[0] == '/'); 1717 Assert(pThis->m_szUpdateParent[pThis->m_cchUpdateParent - 1] == '/'); 1662 1718 1663 1719 /* Start with the current parent node and look for a common ancestor 1664 hoping that this is faster than going from the root. */ 1665 PDBGGUISTATSNODE const pPrev = prevNode(pNode); 1720 hoping that this is faster than going from the root (saves lookup). */ 1721 PDBGGUISTATSNODE const pPrev = prevDataNode(pNode); 1722 pNode = pNode->pParent; 1666 1723 while (pNode != pThis->m_pRoot) 1667 1724 { … … 1673 1730 pNode = pNode->pParent; 1674 1731 } 1732 Assert(pThis->m_szUpdateParent[pThis->m_cchUpdateParent - 1] == '/'); 1675 1733 1676 1734 /* Decent until we've found/created the node pszName indicates, … … 1679 1737 { 1680 1738 /* Find the end of this component. */ 1681 const char * pszStart= &pszName[pThis->m_cchUpdateParent];1682 const char *pszEnd = strchr(pszS tart, '/');1739 const char *const pszSubName = &pszName[pThis->m_cchUpdateParent]; 1740 const char *pszEnd = strchr(pszSubName, '/'); 1683 1741 if (!pszEnd) 1684 pszEnd = strchr(pszStart, '/'); 1685 char *pszSubName = &pThis->m_szUpdateParent[pThis->m_cchUpdateParent]; 1686 size_t cchSubName = pszEnd - pszStart; 1742 pszEnd = strchr(pszSubName, '\0'); 1743 size_t cchSubName = pszEnd - pszSubName; 1687 1744 1688 1745 /* Add the name to the path. */ 1689 memcpy( pszSubName, pszStart, cchSubName);1746 memcpy(&pThis->m_szUpdateParent[pThis->m_cchUpdateParent], pszSubName, cchSubName); 1690 1747 pThis->m_cchUpdateParent += cchSubName; 1748 pThis->m_szUpdateParent[pThis->m_cchUpdateParent++] = '/'; 1691 1749 pThis->m_szUpdateParent[pThis->m_cchUpdateParent] = '\0'; 1692 1693 if (pNode->cChildren) 1750 Assert(pThis->m_cchUpdateParent < sizeof(pThis->m_szUpdateParent)); 1751 1752 if (!pNode->cChildren) 1694 1753 { 1695 1754 /* first child */ 1696 pNode = createAndInsertNode(pNode, pszSubName, UINT32_MAX);1755 pNode = createAndInsertNode(pNode, pszSubName, cchSubName, UINT32_MAX); 1697 1756 AssertReturn(pNode, VERR_NO_MEMORY); 1698 1757 } … … 1705 1764 { 1706 1765 int32_t i = iStart + (iLast + 1 - iStart) / 2; 1707 int iDiff = strcmp(pszSubName, pNode->papChildren[i]->pszName); 1766 int iDiff = memcmp(pszSubName, pNode->papChildren[i]->pszName, cchSubName); 1767 if (!iDiff) 1768 iDiff = '\0' - pNode->papChildren[i]->pszName[cchSubName]; 1708 1769 if (iDiff > 0) 1709 1770 { … … 1711 1772 if (iStart > iLast) 1712 1773 { 1713 pNode = createAndInsertNode(pNode, pszSubName, iStart);1774 pNode = createAndInsertNode(pNode, pszSubName, cchSubName, iStart); 1714 1775 AssertReturn(pNode, VERR_NO_MEMORY); 1715 1776 break; … … 1721 1782 if (iLast < iStart) 1722 1783 { 1723 pNode = createAndInsertNode(pNode, pszSubName, i);1784 pNode = createAndInsertNode(pNode, pszSubName, cchSubName, i); 1724 1785 AssertReturn(pNode, VERR_NO_MEMORY); 1725 1786 break; … … 1733 1794 } 1734 1795 } 1735 1736 pThis->m_szUpdateParent[pThis->m_cchUpdateParent++] = '/';1737 pThis->m_szUpdateParent[pThis->m_cchUpdateParent] = '\0';1738 Assert(pThis->m_cchUpdateParent < sizeof(pThis->m_szUpdateParent));1739 1796 } 1740 Assert(pszName[pThis->m_cchUpdateParent - 1] == '\0'); 1797 Assert( !memcmp(pszName, pThis->m_szUpdateParent, pThis->m_cchUpdateParent - 2) 1798 && pszName[pThis->m_cchUpdateParent - 1] == '\0'); 1741 1799 1742 1800 /* Remove all the nodes between pNode and pPrev but keep all 1743 1801 of pNode's ancestors (or it'll get orphaned). */ 1744 1802 PDBGGUISTATSNODE pCur = prevNode(pNode); 1745 Assert(pCur != pPrev);1746 1803 while (pCur != pPrev) 1747 1804 { 1748 PDBGGUISTATSNODE pAdv = prevNode(pCur); 1805 PDBGGUISTATSNODE pAdv = prevNode(pCur); Assert(pAdv || !pPrev); 1749 1806 if (!isNodeAncestorOf(pCur, pNode)) 1807 { 1750 1808 removeAndDestroyNode(pCur); 1809 } 1751 1810 pCur = pAdv; 1752 1811 } 1753 1812 1754 1813 /* Removed the data from all ancestors of pNode that it doesn't share them pPrev. */ 1755 pCur = pNode->pParent; 1756 while (!isNodeAncestorOf(pCur, pPrev)) 1814 if (pPrev) 1757 1815 { 1758 resetNode(pNode); 1759 pCur = pCur->pParent; 1816 pCur = pNode->pParent; 1817 while (!isNodeAncestorOf(pCur, pPrev)) 1818 { 1819 resetNode(pNode); 1820 pCur = pCur->pParent; 1821 } 1760 1822 } 1761 1823 1762 1824 /* Finally, adjust the globals (szUpdateParent is one level too deep). */ 1763 Assert(pThis->m_cchUpdateParent > pNode->cchName -1);1764 pThis->m_cchUpdateParent -= pNode->cchName -1;1825 Assert(pThis->m_cchUpdateParent > pNode->cchName + 1); 1826 pThis->m_cchUpdateParent -= pNode->cchName + 1; 1765 1827 pThis->m_szUpdateParent[pThis->m_cchUpdateParent] = '\0'; 1766 1828 pThis->m_pUpdateParent = pNode->pParent; … … 1825 1887 pThis->m_cchUpdateParent += pNode->cchName; 1826 1888 pThis->m_szUpdateParent[pThis->m_cchUpdateParent++] = '/'; 1889 pThis->m_szUpdateParent[pThis->m_cchUpdateParent] = '\0'; 1827 1890 pThis->m_pUpdateParent = pNode; 1828 1891 } … … 1833 1896 Assert(pThis->m_pUpdateParent == pNode->pParent); 1834 1897 } 1835 else 1898 else if (pThis->m_iUpdateChild != UINT32_MAX) 1836 1899 { 1837 1900 /* move up and down- / on-wards */ … … 1850 1913 break; 1851 1914 } 1852 Assert(pThis->m_cchUpdateParent > pNode->cchName); 1853 pThis->m_cchUpdateParent -= pNode->cchName - 1; 1854 pThis->m_szUpdateParent[pThis->m_cchUpdateParent] = '\0'; 1915 Assert(pThis->m_cchUpdateParent > pNode->cchName + 1); 1916 pThis->m_cchUpdateParent -= pNode->cchName + 1; 1855 1917 1856 1918 /* try advance */ … … 1873 1935 } 1874 1936 Assert(pNode->enmType != STAMTYPE_INVALID); 1937 pThis->m_szUpdateParent[pThis->m_cchUpdateParent] = '\0'; 1875 1938 pThis->m_iUpdateChild = pNode->iSelf; 1876 1939 pThis->m_pUpdateParent = pNode->pParent; … … 1878 1941 } 1879 1942 } 1880 1881 } 1943 } 1944 /* else: we're at the end */ 1945 1882 1946 return VINF_SUCCESS; 1883 1947 } 1884 1948 1885 1949 1886 void 1887 VBoxDbgStatsModelVM::update(const QString &a_rPatStr) 1888 { 1950 bool 1951 VBoxDbgStatsModelVM::updateStats(const QString &a_rPatStr) 1952 { 1953 Assert(m_pRoot); 1954 Assert(m_pRoot->enmType == STAMTYPE_INVALID); 1955 1889 1956 /* 1890 1957 * Find the first child with data and set it up as the 'next' 1891 1958 * node to be updated. 1892 1959 */ 1893 PDBGGUISTATSNODE pFirst = m_pRoot; 1894 while (pFirst && pFirst->enmType == STAMTYPE_INVALID) 1895 pFirst = nextNode(pFirst); 1960 PDBGGUISTATSNODE pFirst = nextDataNode(m_pRoot); 1896 1961 if (pFirst) 1897 1962 { 1898 1963 m_iUpdateChild = pFirst->iSelf; 1899 m_pUpdateParent = pFirst ;1964 m_pUpdateParent = pFirst->pParent; Assert(m_pUpdateParent); 1900 1965 m_cchUpdateParent = getNodePath(m_pUpdateParent, m_szUpdateParent, sizeof(m_szUpdateParent) - 1); 1901 AssertReturn Void(m_cchUpdateParent >= 1);1966 AssertReturn(m_cchUpdateParent >= 1, false); 1902 1967 m_szUpdateParent[m_cchUpdateParent++] = '/'; 1903 1968 m_szUpdateParent[m_cchUpdateParent] = '\0'; … … 1920 1985 1921 1986 /** @todo the way we update this stuff is independent of the source (XML, file, STAM), our only 1922 * ASSUMPTION is that the input is strictly ordered by (full) name. So, all this stuff should 1923 * really move up into the parent class. */ 1924 stamEnum(a_rPatStr, updateCallback, this); 1987 * ASSUMPTION is that the input is strictly ordered by (fully slashed) name. So, all this stuff 1988 * should really move up into the parent class. */ 1989 int rc = stamEnum(a_rPatStr, updateCallback, this); 1990 1991 /* Remove any nodes following the last in the update. */ 1992 if ( RT_SUCCESS(rc) 1993 && m_iUpdateChild != UINT32_MAX) 1994 { 1995 PDBGGUISTATSNODE const pLast = prevDataNode(m_pUpdateParent->papChildren[m_iUpdateChild]); 1996 for (;;) 1997 { 1998 PDBGGUISTATSNODE pNode = nextNode(pLast); 1999 if (!pNode) 2000 break; 2001 char szFoo[1024]; 2002 getNodePath(pNode, szFoo, 1024); fprintf(stderr, "removing pNode=%p: %s\n", pNode, szFoo); 2003 if (pLast) getNodePath(pLast, szFoo, 1024); else szFoo[0] = '\0'; 2004 fprintf(stderr, " pLast=%p: %s\n", pLast, szFoo); 2005 removeAndDestroyNode(pNode); 2006 } 2007 m_fUpdateInsertRemove = true; 2008 } 1925 2009 1926 2010 if (m_fUpdateInsertRemove) … … 1984 2068 } 1985 2069 } 2070 2071 return m_fUpdateInsertRemove; 1986 2072 } 1987 2073 … … 2479 2565 2480 2566 2481 void VBoxDbgStatsView::update(const QString &rPatStr) 2482 { 2483 m_pModel->update(rPatStr); 2567 void VBoxDbgStatsView::updateStats(const QString &rPatStr) 2568 { 2569 if (m_pModel->updateStats(rPatStr)) 2570 setRootIndex(m_pModel->getRootIndex()); /// @todo this is a hack? 2484 2571 2485 2572 #if 0 /* later */ … … 2502 2589 } 2503 2590 2504 void VBoxDbgStatsView::reset (const QString &rPatStr)2591 void VBoxDbgStatsView::resetStats(const QString &rPatStr) 2505 2592 { 2506 2593 stamReset(rPatStr); … … 2979 3066 void VBoxDbgStats::refresh() 2980 3067 { 2981 m_pView->update (m_PatStr);3068 m_pView->updateStats(m_PatStr); 2982 3069 } 2983 3070 -
trunk/src/VBox/Debugger/VBoxDbgStatsQt4.h
r12478 r12817 68 68 * @param rPatStr Selection pattern. NULL means everything, see STAM for further details. 69 69 */ 70 void update (const QString &rPatStr);70 void updateStats(const QString &rPatStr); 71 71 72 72 /** … … 76 76 * @param rPatStr Selection pattern. NULL means everything, see STAM for further details. 77 77 */ 78 void reset (const QString &rPatStr);78 void resetStats(const QString &rPatStr); 79 79 80 80 private:
Note:
See TracChangeset
for help on using the changeset viewer.