Changeset 105718 in vbox for trunk/src/VBox/VMM/VMMR3/IEMR3.cpp
- Timestamp:
- Aug 19, 2024 2:20:25 AM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/IEMR3.cpp
r105716 r105718 1778 1778 1779 1779 /** 1780 * Get get compile time flat PC for the TB. 1781 */ 1782 DECL_FORCE_INLINE(RTGCPTR) iemR3GetTbFlatPc(PCIEMTB pTb) 1783 { 1784 #ifdef IEMNATIVE_WITH_TB_DEBUG_INFO 1785 if (pTb->fFlags & IEMTB_F_TYPE_NATIVE) 1786 { 1787 PCIEMTBDBG const pDbgInfo = pTb->pDbgInfo; 1788 return pDbgInfo ? pDbgInfo->FlatPc : RTGCPTR_MAX; 1789 } 1790 #endif 1791 return pTb->FlatPc; 1792 } 1793 1794 1795 /** 1780 1796 * @callback_method_impl{FNDBGFINFOARGVINT, tb} 1781 1797 */ … … 1797 1813 { "--physical-address", 'p', RTGETOPT_REQ_UINT64 | RTGETOPT_FLAG_HEX }, 1798 1814 { "--flags", 'f', RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX }, 1815 { "--tb", 't', RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX }, 1816 { "--tb-id", 't', RTGETOPT_REQ_UINT32 }, 1799 1817 }; 1800 1818 … … 1808 1826 RTGCPHYS GCVirt = NIL_RTGCPTR; 1809 1827 uint32_t fFlags = UINT32_MAX; 1828 uint32_t idTb = UINT32_MAX; 1810 1829 1811 1830 RTGETOPTUNION ValueUnion; … … 1824 1843 GCVirt = ValueUnion.u64; 1825 1844 GCPhysPc = NIL_RTGCPHYS; 1845 idTb = UINT32_MAX; 1826 1846 break; 1827 1847 … … 1829 1849 GCVirt = NIL_RTGCPHYS; 1830 1850 GCPhysPc = ValueUnion.u64; 1851 idTb = UINT32_MAX; 1831 1852 break; 1832 1853 1833 1854 case 'f': 1834 fFlags = ValueUnion.u32; 1835 break; 1855 fFlags = ValueUnion.u32; 1856 break; 1857 1858 case 't': 1859 GCVirt = NIL_RTGCPHYS; 1860 GCPhysPc = NIL_RTGCPHYS; 1861 idTb = ValueUnion.u32; 1862 break; 1863 1864 case VINF_GETOPT_NOT_OPTION: 1865 { 1866 if ( (ValueUnion.psz[0] == 'T' || ValueUnion.psz[0] == 't') 1867 && (ValueUnion.psz[1] == 'B' || ValueUnion.psz[1] == 'b') 1868 && ValueUnion.psz[2] == '#') 1869 { 1870 rc = RTStrToUInt32Full(&ValueUnion.psz[3], 0, &idTb); 1871 if (RT_SUCCESS(rc)) 1872 { 1873 GCVirt = NIL_RTGCPHYS; 1874 GCPhysPc = NIL_RTGCPHYS; 1875 break; 1876 } 1877 pHlp->pfnPrintf(pHlp, "error: failed to convert '%s' to TD ID: %Rrc\n", ValueUnion.psz, rc); 1878 } 1879 else 1880 pHlp->pfnGetOptError(pHlp, rc, &ValueUnion, &State); 1881 return; 1882 } 1836 1883 1837 1884 case 'h': … … 1846 1893 " -p<phys>, --phys=<phys>, --phys-addr=<phys>\n" 1847 1894 " Shows the TB for the specified guest physical address.\n" 1895 " -t<id>, --tb=<id>, --tb-id=<id>, TD#<id>\n" 1896 " Show the TB specified by the identifier/number (from tbtop).\n" 1848 1897 " -f<flags>,--flags=<flags>\n" 1849 1898 " The TB flags value (hex) to use when looking up the TB.\n" … … 1869 1918 * Defaults. 1870 1919 */ 1871 if (GCPhysPc == NIL_RTGCPHYS )1920 if (GCPhysPc == NIL_RTGCPHYS && idTb == UINT32_MAX) 1872 1921 { 1873 1922 if (GCVirt == NIL_RTGCPTR) … … 1880 1929 } 1881 1930 } 1882 if (fFlags == UINT32_MAX )1931 if (fFlags == UINT32_MAX && idTb == UINT32_MAX) 1883 1932 { 1884 1933 /* Note! This is duplicating code in IEMAllThrdRecompiler. */ … … 1898 1947 } 1899 1948 1900 /* 1901 * Do the lookup... 1902 * 1903 * Note! This is also duplicating code in IEMAllThrdRecompiler. We don't 1904 * have much choice since we don't want to increase use counters and 1905 * trigger native recompilation. 1906 */ 1907 fFlags &= IEMTB_F_KEY_MASK; 1908 IEMTBCACHE const * const pTbCache = pVCpu->iem.s.pTbCacheR3; 1909 uint32_t const idxHash = IEMTBCACHE_HASH(pTbCache, fFlags, GCPhysPc); 1910 PCIEMTB pTb = IEMTBCACHE_PTR_GET_TB(pTbCache->apHash[idxHash]); 1911 while (pTb) 1912 { 1913 if (pTb->GCPhysPc == GCPhysPc) 1949 PCIEMTB pTb; 1950 if (idTb == UINT32_MAX) 1951 { 1952 /* 1953 * Do the lookup... 1954 * 1955 * Note! This is also duplicating code in IEMAllThrdRecompiler. We don't 1956 * have much choice since we don't want to increase use counters and 1957 * trigger native recompilation. 1958 */ 1959 fFlags &= IEMTB_F_KEY_MASK; 1960 IEMTBCACHE const * const pTbCache = pVCpu->iem.s.pTbCacheR3; 1961 uint32_t const idxHash = IEMTBCACHE_HASH(pTbCache, fFlags, GCPhysPc); 1962 pTb = IEMTBCACHE_PTR_GET_TB(pTbCache->apHash[idxHash]); 1963 while (pTb) 1914 1964 { 1915 if ( (pTb->fFlags & IEMTB_F_KEY_MASK) == fFlags)1965 if (pTb->GCPhysPc == GCPhysPc) 1916 1966 { 1917 /// @todo if (pTb->x86.fAttr == (uint16_t)pVCpu->cpum.GstCtx.cs.Attr.u) 1918 break; 1967 if ((pTb->fFlags & IEMTB_F_KEY_MASK) == fFlags) 1968 { 1969 /// @todo if (pTb->x86.fAttr == (uint16_t)pVCpu->cpum.GstCtx.cs.Attr.u) 1970 break; 1971 } 1919 1972 } 1973 pTb = pTb->pNext; 1920 1974 } 1921 pTb = pTb->pNext; 1975 if (!pTb) 1976 pHlp->pfnPrintf(pHlp, "PC=%RGp fFlags=%#x - no TB found on #%u\n", GCPhysPc, fFlags, pVCpu->idCpu); 1922 1977 } 1923 if (!pTb)1924 pHlp->pfnPrintf(pHlp, "PC=%RGp fFlags=%#x - no TB found on #%u\n", GCPhysPc, fFlags, pVCpu->idCpu);1925 1978 else 1979 { 1980 /* 1981 * Use the TB ID for indexing. 1982 */ 1983 pTb = NULL; 1984 PIEMTBALLOCATOR const pTbAllocator = pVCpu->iem.s.pTbAllocatorR3; 1985 if (pTbAllocator) 1986 { 1987 size_t const idxTbChunk = idTb / pTbAllocator->cTbsPerChunk; 1988 size_t const idxTbInChunk = idTb % pTbAllocator->cTbsPerChunk; 1989 if (idxTbChunk < pTbAllocator->cAllocatedChunks) 1990 pTb = &pTbAllocator->aChunks[idxTbChunk].paTbs[idxTbInChunk]; 1991 else 1992 pHlp->pfnPrintf(pHlp, "Invalid TB ID: %u (%#x)\n", idTb, idTb); 1993 } 1994 } 1995 1996 if (pTb) 1926 1997 { 1927 1998 /* 1928 1999 * Disassemble according to type. 1929 2000 */ 2001 size_t const idxTbChunk = pTb->idxAllocChunk; 2002 size_t const idxTbNo = (pTb - &pVCpu->iem.s.pTbAllocatorR3->aChunks[idxTbChunk].paTbs[0]) 2003 + idxTbChunk * pVCpu->iem.s.pTbAllocatorR3->cTbsPerChunk; 1930 2004 switch (pTb->fFlags & IEMTB_F_TYPE_MASK) 1931 2005 { 1932 2006 # ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER 1933 2007 case IEMTB_F_TYPE_NATIVE: 1934 pHlp->pfnPrintf(pHlp, "PC=%RGp fFlags=%#x on #%u: %p - native\n", GCPhysPc, fFlags, pVCpu->idCpu, pTb); 2008 pHlp->pfnPrintf(pHlp, "PC=%RGp (%%%RGv) fFlags=%#x on #%u: TB#%#zx/%p - native\n", 2009 GCPhysPc, iemR3GetTbFlatPc(pTb), fFlags, pVCpu->idCpu, idxTbNo, pTb); 1935 2010 iemNativeDisassembleTb(pVCpu, pTb, pHlp); 1936 2011 break; … … 1938 2013 1939 2014 case IEMTB_F_TYPE_THREADED: 1940 pHlp->pfnPrintf(pHlp, "PC=%RGp fFlags=%#x on #%u: %p - threaded\n", GCPhysPc, fFlags, pVCpu->idCpu, pTb); 2015 pHlp->pfnPrintf(pHlp, "PC=%RGp (%%%RGv) fFlags=%#x on #%u: TB#%#zx/%p - threaded\n", 2016 GCPhysPc, pTb->FlatPc, fFlags, pVCpu->idCpu, idxTbNo, pTb); 1941 2017 iemThreadedDisassembleTb(pTb, pHlp); 1942 2018 break; 1943 2019 1944 2020 default: 1945 pHlp->pfnPrintf(pHlp, "PC=%RGp fFlags=%#x on #%u:%p - ??? %#x\n",1946 GCPhysPc, fFlags, pVCpu->idCpu, pTb, pTb->fFlags);2021 pHlp->pfnPrintf(pHlp, "PC=%RGp (%%%RGv) fFlags=%#x on #%u: TB#%#zx/%p - ??? %#x\n", 2022 GCPhysPc, pTb->FlatPc, fFlags, pVCpu->idCpu, idxTbNo, pTb, pTb->fFlags); 1947 2023 break; 1948 2024 } … … 2200 2276 pHlp->pfnPrintf(pHlp, "\n------------------------------- %u -------------------------------\n", idx); 2201 2277 2202 PCIEMTB pTb = aTop[idx].pTb; 2278 PCIEMTB const pTb = aTop[idx].pTb; 2279 size_t const idxTbChunk = pTb->idxAllocChunk; 2280 Assert(idxTbChunk < pTbAllocator->cAllocatedChunks); 2281 size_t const idxTbNo = (pTb - &pTbAllocator->aChunks[idxTbChunk].paTbs[0]) 2282 + idxTbChunk * pTbAllocator->cTbsPerChunk; 2203 2283 switch (pTb->fFlags & IEMTB_F_TYPE_MASK) 2204 2284 { 2205 2285 # ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER 2206 2286 case IEMTB_F_TYPE_NATIVE: 2207 pHlp->pfnPrintf(pHlp, " PC=%RGpcUsed=%u msLastUsed=%u fFlags=%#010x - native\n",2208 pTb->GCPhysPc, pTb->cUsed, pTb->msLastUsed, pTb->fFlags);2287 pHlp->pfnPrintf(pHlp, "TB#%#zx: PC=%RGp (%%%RGv) cUsed=%u msLastUsed=%u fFlags=%#010x - native\n", 2288 idxTbNo, pTb->GCPhysPc, iemR3GetTbFlatPc(pTb), pTb->cUsed, pTb->msLastUsed, pTb->fFlags); 2209 2289 if (fDisassemble) 2210 2290 iemNativeDisassembleTb(pVCpu, pTb, pHlp); … … 2213 2293 2214 2294 case IEMTB_F_TYPE_THREADED: 2215 pHlp->pfnPrintf(pHlp, " PC=%RGpcUsed=%u msLastUsed=%u fFlags=%#010x - threaded\n",2216 pTb->GCPhysPc, pTb->cUsed, pTb->msLastUsed, pTb->fFlags);2295 pHlp->pfnPrintf(pHlp, "TB#%#zx: PC=%RGp (%%%RGv) cUsed=%u msLastUsed=%u fFlags=%#010x - threaded\n", 2296 idxTbNo, pTb->GCPhysPc, pTb->FlatPc, pTb->cUsed, pTb->msLastUsed, pTb->fFlags); 2217 2297 if (fDisassemble) 2218 2298 iemThreadedDisassembleTb(pTb, pHlp); … … 2220 2300 2221 2301 default: 2222 pHlp->pfnPrintf(pHlp, " PC=%RGpcUsed=%u msLastUsed=%u fFlags=%#010x - ???\n",2223 pTb->GCPhysPc, pTb->cUsed, pTb->msLastUsed, pTb->fFlags);2302 pHlp->pfnPrintf(pHlp, "TB#%#zx:%zu: PC=%RGp (%%%RGv) cUsed=%u msLastUsed=%u fFlags=%#010x - ???\n", 2303 idxTbNo, pTb->GCPhysPc, pTb->FlatPc, pTb->cUsed, pTb->msLastUsed, pTb->fFlags); 2224 2304 break; 2225 2305 }
Note:
See TracChangeset
for help on using the changeset viewer.