vbox的更動 35590 路徑 trunk/src/VBox/VMM/VMMR3
- 時間撮記:
- 2011-1-17 下午03:29:46 (14 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/VMM/VMMR3/DBGFReg.cpp
r35586 r35590 1220 1220 /** 1221 1221 * On CPU worker for the register queries, used by dbgfR3RegNmQueryWorker and 1222 * dbgfR3RegNmPrintfCbFormat .1222 * dbgfR3RegNmPrintfCbFormatNormal. 1223 1223 * 1224 1224 * @returns VBox status code. … … 1843 1843 { 1844 1844 /* 1845 * Format to temporary buffer using worker shared with dbgfR3RegNmPrintfCbFormat .1845 * Format to temporary buffer using worker shared with dbgfR3RegNmPrintfCbFormatNormal. 1846 1846 */ 1847 1847 char szTmp[160]; … … 1905 1905 1906 1906 /** 1907 * Format a register using special hacks as well as sub-field specifications 1908 * (the latter isn't implemented yet). 1909 */ 1910 static size_t 1911 dbgfR3RegNmPrintfCbFormatField(PDBGFR3REGNMPRINTFARGS pThis, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 1912 PCDBGFREGLOOKUP pLookupRec, int cchWidth, int cchPrecision, unsigned fFlags) 1913 { 1914 char szTmp[160]; 1915 1916 /* 1917 * Retrieve the register value. 1918 */ 1919 DBGFREGVAL Value; 1920 DBGFREGVALTYPE enmType; 1921 int rc = dbgfR3RegNmQueryWorkerOnCpu(pThis->pVM, pLookupRec, DBGFREGVALTYPE_END, &Value, &enmType); 1922 if (RT_FAILURE(rc)) 1923 { 1924 PCRTSTATUSMSG pErr = RTErrGet(rc); 1925 if (pErr) 1926 return pfnOutput(pvArgOutput, pErr->pszDefine, strlen(pErr->pszDefine)); 1927 return pfnOutput(pvArgOutput, szTmp, RTStrPrintf(szTmp, sizeof(szTmp), "rc=%d", rc)); 1928 } 1929 1930 char *psz = szTmp; 1931 1932 /* 1933 * Special case: Format eflags. 1934 */ 1935 if ( pLookupRec->pSet->enmType == DBGFREGSETTYPE_CPU 1936 && pLookupRec->pDesc->enmReg == DBGFREG_RFLAGS 1937 && pLookupRec->pSubField == NULL) 1938 { 1939 rc = dbgfR3RegValCast(&Value, enmType, DBGFREGVALTYPE_U32); 1940 AssertRC(rc); 1941 uint32_t const efl = Value.u32; 1942 1943 /* the iopl */ 1944 psz += RTStrPrintf(psz, sizeof(szTmp) / 2, "iopl=%u ", X86_EFL_GET_IOPL(efl)); 1945 1946 /* add flags */ 1947 static const struct 1948 { 1949 const char *pszSet; 1950 const char *pszClear; 1951 uint32_t fFlag; 1952 } aFlags[] = 1953 { 1954 { "vip",NULL, X86_EFL_VIP }, 1955 { "vif",NULL, X86_EFL_VIF }, 1956 { "ac", NULL, X86_EFL_AC }, 1957 { "vm", NULL, X86_EFL_VM }, 1958 { "rf", NULL, X86_EFL_RF }, 1959 { "nt", NULL, X86_EFL_NT }, 1960 { "ov", "nv", X86_EFL_OF }, 1961 { "dn", "up", X86_EFL_DF }, 1962 { "ei", "di", X86_EFL_IF }, 1963 { "tf", NULL, X86_EFL_TF }, 1964 { "ng", "pl", X86_EFL_SF }, 1965 { "zr", "nz", X86_EFL_ZF }, 1966 { "ac", "na", X86_EFL_AF }, 1967 { "po", "pe", X86_EFL_PF }, 1968 { "cy", "nc", X86_EFL_CF }, 1969 }; 1970 for (unsigned i = 0; i < RT_ELEMENTS(aFlags); i++) 1971 { 1972 const char *pszAdd = aFlags[i].fFlag & efl ? aFlags[i].pszSet : aFlags[i].pszClear; 1973 if (pszAdd) 1974 { 1975 *psz++ = *pszAdd++; 1976 *psz++ = *pszAdd++; 1977 if (*pszAdd) 1978 *psz++ = *pszAdd++; 1979 *psz++ = ' '; 1980 } 1981 } 1982 1983 /* drop trailing space */ 1984 psz--; 1985 } 1986 else 1987 { 1988 /* 1989 * General case. 1990 */ 1991 AssertMsgFailed(("Not implemented: %s\n", pLookupRec->Core.pszString)); 1992 return pfnOutput(pvArgOutput, pLookupRec->Core.pszString, pLookupRec->Core.cchString); 1993 } 1994 1995 /* Output the string. */ 1996 return pfnOutput(pvArgOutput, szTmp, psz - &szTmp[0]); 1997 } 1998 1999 2000 /** 2001 * Formats a register having parsed up to the register name. 2002 */ 2003 static size_t 2004 dbgfR3RegNmPrintfCbFormatNormal(PDBGFR3REGNMPRINTFARGS pThis, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2005 PCDBGFREGLOOKUP pLookupRec, unsigned uBase, int cchWidth, int cchPrecision, unsigned fFlags) 2006 { 2007 char szTmp[160]; 2008 2009 /* 2010 * Get the register value. 2011 */ 2012 DBGFREGVAL Value; 2013 DBGFREGVALTYPE enmType; 2014 int rc = dbgfR3RegNmQueryWorkerOnCpu(pThis->pVM, pLookupRec, DBGFREGVALTYPE_END, &Value, &enmType); 2015 if (RT_FAILURE(rc)) 2016 { 2017 PCRTSTATUSMSG pErr = RTErrGet(rc); 2018 if (pErr) 2019 return pfnOutput(pvArgOutput, pErr->pszDefine, strlen(pErr->pszDefine)); 2020 return pfnOutput(pvArgOutput, szTmp, RTStrPrintf(szTmp, sizeof(szTmp), "rc=%d", rc)); 2021 } 2022 2023 /* 2024 * Format the value. 2025 */ 2026 ssize_t cchOutput = dbgfR3RegFormatValueInt(szTmp, sizeof(szTmp), &Value, enmType, uBase, cchWidth, cchPrecision, fFlags); 2027 if (RT_UNLIKELY(cchOutput <= 0)) 2028 { 2029 AssertFailed(); 2030 return pfnOutput(pvArgOutput, "internal-error", sizeof("internal-error") - 1); 2031 } 2032 return pfnOutput(pvArgOutput, szTmp, cchOutput); 2033 } 2034 2035 2036 /** 1907 2037 * @callback_method_impl{FNSTRFORMAT} 1908 2038 */ … … 1912 2042 int cchPrecision, unsigned fFlags, char chArgSize) 1913 2043 { 2044 /* 2045 * Parse the format type and hand the job to the appropriate worker. 2046 */ 1914 2047 PDBGFR3REGNMPRINTFARGS pThis = (PDBGFR3REGNMPRINTFARGS)pvArg; 1915 1916 /*1917 * Parse out the register bits of the register format type. Noisily reject1918 * unknown format types.1919 */1920 2048 const char *pszFormat = *ppszFormat; 1921 2049 if ( pszFormat[0] != 'V' … … 1925 2053 return 0; 1926 2054 } 1927 unsigned uBase; 1928 if (pszFormat[2] == '{') 1929 uBase = 16; 1930 else if ( pszFormat[2] == 'U' 1931 && pszFormat[3] == '{') 1932 uBase = 10; 1933 else if ( pszFormat[2] == 'O' 1934 && pszFormat[3] == '{') 1935 uBase = 8; 1936 else if ( pszFormat[2] == 'B' 1937 && pszFormat[3] == '{') 1938 uBase = 2; 1939 else 1940 { 1941 AssertMsgFailed(("'%s'\n", pszFormat)); 1942 return 0; 1943 } 1944 1945 const char * const pachReg = &pszFormat[3]; 1946 const char *pszEnd = strchr(&pachReg[3], '}'); 2055 unsigned offCurly = 2; 2056 if (pszFormat[offCurly] != '{') 2057 { 2058 AssertMsgReturn(pszFormat[offCurly], ("'%s'\n", pszFormat), 0); 2059 offCurly++; 2060 AssertMsgReturn(pszFormat[offCurly] == '{', ("'%s'\n", pszFormat), 0); 2061 } 2062 const char *pachReg = &pszFormat[offCurly + 1]; 2063 2064 /* 2065 * The end and length of the register. 2066 */ 2067 const char *pszEnd = strchr(&pachReg[3], '}'); 1947 2068 AssertMsgReturn(pszEnd, ("Missing closing curly bracket: '%s'\n", pszFormat), 0); 1948 1949 size_t const cchReg = pachReg - pszEnd; 2069 size_t const cchReg = pszEnd - pachReg; 1950 2070 1951 2071 /* … … 1953 2073 * input string termination. 1954 2074 */ 1955 char szTmp[DBGF_REG_MAX_NAME * 4 + 64];1956 1957 2075 /* Try looking up the name without any case folding or cpu prefixing. */ 1958 2076 PCDBGFREGLOOKUP pLookupRec = (PCDBGFREGLOOKUP)RTStrSpaceGetN(&pThis->pVM->dbgf.s.RegSpace, pachReg, cchReg); … … 1960 2078 { 1961 2079 /* Lower case it and try again. */ 1962 ssize_t cchFolded = dbgfR3RegCopyToLower(pachReg, cchReg, szTmp, sizeof(szTmp) - DBGF_REG_MAX_NAME); 2080 char szName[DBGF_REG_MAX_NAME * 4 + 16]; 2081 ssize_t cchFolded = dbgfR3RegCopyToLower(pachReg, cchReg, szName, sizeof(szName) - DBGF_REG_MAX_NAME); 1963 2082 if (cchFolded > 0) 1964 pLookupRec = (PCDBGFREGLOOKUP)RTStrSpaceGet(&pThis->pVM->dbgf.s.RegSpace, sz Tmp);2083 pLookupRec = (PCDBGFREGLOOKUP)RTStrSpaceGet(&pThis->pVM->dbgf.s.RegSpace, szName); 1965 2084 if ( !pLookupRec 1966 2085 && cchFolded >= 0 … … 1968 2087 { 1969 2088 /* Prefix it with the specified CPU set. */ 1970 size_t cchCpuSet = RTStrPrintf(sz Tmp, sizeof(szTmp), "cpu%u.", pThis->idCpu);1971 dbgfR3RegCopyToLower(pachReg, cchReg, &sz Tmp[cchCpuSet], sizeof(szTmp) - cchCpuSet);1972 pLookupRec = (PCDBGFREGLOOKUP)RTStrSpaceGet(&pThis->pVM->dbgf.s.RegSpace, sz Tmp);2089 size_t cchCpuSet = RTStrPrintf(szName, sizeof(szName), "cpu%u.", pThis->idCpu); 2090 dbgfR3RegCopyToLower(pachReg, cchReg, &szName[cchCpuSet], sizeof(szName) - cchCpuSet); 2091 pLookupRec = (PCDBGFREGLOOKUP)RTStrSpaceGet(&pThis->pVM->dbgf.s.RegSpace, szName); 1973 2092 } 1974 2093 } … … 1979 2098 0); 1980 2099 1981 /* Commit the format type parsing so we can return more freely below. */ 1982 *ppszFormat = pszFormat; 1983 1984 /* 1985 * Get the register value. 1986 */ 1987 DBGFREGVAL Value; 1988 DBGFREGVALTYPE enmType; 1989 int rc = dbgfR3RegNmQueryWorkerOnCpu(pThis->pVM, pLookupRec, DBGFREGVALTYPE_END, &Value, &enmType); 1990 if (RT_FAILURE(rc)) 1991 { 1992 PCRTSTATUSMSG pErr = RTErrGet(rc); 1993 if (pErr) 1994 return pfnOutput(pvArgOutput, pErr->pszDefine, strlen(pErr->pszDefine)); 1995 return pfnOutput(pvArgOutput, szTmp, RTStrPrintf(szTmp, sizeof(szTmp), "rc=%d", rc)); 1996 } 1997 1998 /* 1999 * Format the value. 2000 */ 2001 ssize_t cchOutput = dbgfR3RegFormatValueInt(szTmp, sizeof(szTmp), &Value, enmType, uBase, cchWidth, cchPrecision, fFlags); 2002 if (RT_UNLIKELY(cchOutput <= 0)) 2003 { 2004 AssertFailed(); 2005 return pfnOutput(pvArgOutput, "internal-error", sizeof("internal-error") - 1); 2006 } 2007 return pfnOutput(pvArgOutput, szTmp, cchOutput); 2008 } 2100 /* 2101 * Commit the parsed format string. Up to this point it is nice to know 2102 * what register lookup failed and such, so we've delayed comitting. 2103 */ 2104 *ppszFormat = pszEnd + 1; 2105 2106 /* 2107 * Call the responsible worker. 2108 */ 2109 switch (pszFormat[offCurly - 1]) 2110 { 2111 case 'R': /* %VR{} */ 2112 case 'X': /* %VRX{} */ 2113 return dbgfR3RegNmPrintfCbFormatNormal(pThis, pfnOutput, pvArgOutput, pLookupRec, 2114 16, cchWidth, cchPrecision, fFlags); 2115 case 'U': 2116 return dbgfR3RegNmPrintfCbFormatNormal(pThis, pfnOutput, pvArgOutput, pLookupRec, 2117 10, cchWidth, cchPrecision, fFlags); 2118 case 'O': 2119 return dbgfR3RegNmPrintfCbFormatNormal(pThis, pfnOutput, pvArgOutput, pLookupRec, 2120 8, cchWidth, cchPrecision, fFlags); 2121 case 'B': 2122 return dbgfR3RegNmPrintfCbFormatNormal(pThis, pfnOutput, pvArgOutput, pLookupRec, 2123 2, cchWidth, cchPrecision, fFlags); 2124 case 'F': 2125 return dbgfR3RegNmPrintfCbFormatField(pThis, pfnOutput, pvArgOutput, pLookupRec, cchWidth, cchPrecision, fFlags); 2126 default: 2127 AssertFailed(); 2128 return 0; 2129 } 2130 } 2131 2009 2132 2010 2133
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器