Changeset 45633 in vbox for trunk/src/VBox/Runtime/r0drv/nt/ntBldSymDb.cpp
- Timestamp:
- Apr 19, 2013 8:56:59 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/nt/ntBldSymDb.cpp
r45443 r45633 112 112 * Global Variables * 113 113 *******************************************************************************/ 114 /** Set if verbose operation(-v, --verbose). */115 static bool g_fOptVerbose = false;114 /** Verbosity level (-v, --verbose). */ 115 static uint32_t g_iOptVerbose = 1; 116 116 /** Set if we should force ahead despite errors. */ 117 117 static bool g_fOptForce = false; … … 146 146 static void MyDbgPrintf(const char *pszFormat, ...) 147 147 { 148 if (g_ fOptVerbose)148 if (g_iOptVerbose > 1) 149 149 { 150 150 va_list va; … … 654 654 * @param uModAddr The module address. 655 655 * @param pszLogTag The log tag. 656 */ 657 static RTEXITCODE findStructures(HANDLE hFake, uint64_t uModAddr, const char *pszLogTag) 656 * @param pszPdb The full PDB path. 657 * @param pOsVerInfo The OS version info for altering the error handling 658 * for older OSes. 659 */ 660 static RTEXITCODE findStructures(HANDLE hFake, uint64_t uModAddr, const char *pszLogTag, const char *pszPdb, 661 PCRTNTSDBOSVER pOsVerInfo) 658 662 { 659 663 RTEXITCODE rcExit = RTEXITCODE_SUCCESS; … … 664 668 pSymInfo->MaxNameLen = 0; 665 669 if (!SymGetTypeFromName(hFake, uModAddr, g_aStructs[iStruct].pszName, pSymInfo)) 666 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s: Failed to find _KPRCB: %u\n", pszLogTag, GetLastError()); 670 { 671 if (!(pOsVerInfo->uMajorVer == 5 && pOsVerInfo->uMinorVer == 0) /* w2k */) 672 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s: Failed to find _KPRCB: %u\n", pszPdb, GetLastError()); 673 RTMsgInfo("%s: Skipping - failed to find _KPRCB: %u\n", pszPdb, GetLastError()); 674 return RTEXITCODE_SKIPPED; 675 } 667 676 668 677 MyDbgPrintf(" %s: TypeIndex=%u\n", g_aStructs[iStruct].pszName, pSymInfo->TypeIndex); … … 756 765 } const s_aSymPacks[] = 757 766 { 767 { RT_STR_TUPLE("w2kSP1SYM"), 5, 0, 1, 2195 }, 768 { RT_STR_TUPLE("w2ksp2srp1"), 5, 0, 2, 2195 }, 769 { RT_STR_TUPLE("w2ksp2sym"), 5, 0, 2, 2195 }, 770 { RT_STR_TUPLE("w2ksp3sym"), 5, 0, 3, 2195 }, 771 { RT_STR_TUPLE("w2ksp4sym"), 5, 0, 4, 2195 }, 772 { RT_STR_TUPLE("Windows2000-KB891861"), 5, 0, 4, 2195 }, 758 773 { RT_STR_TUPLE("windowsxp"), 5, 1, 0, 2600 }, 759 774 { RT_STR_TUPLE("xpsp1sym"), 5, 1, 1, 2600 }, … … 831 846 *penmArch = MYARCH_AMD64; 832 847 } 833 else if (RTStrIStr(pszComp, "DEBUG")) 848 else if ( RTStrIStr(pszComp, "DEBUG") 849 || RTStrIStr(pszComp, "_chk") 850 ) 834 851 { 835 852 pVerInfo->fChecked = true; … … 844 861 } 845 862 846 847 /* 848 * testing only 849 */ 850 if (strIEndsWith(pszPdb, "ntkrnlmp.pdb\\B2DA40502FA744C18B9022FD187ADB592\\ntkrnlmp.pdb")) 851 { 852 pVerInfo->uMajorVer = 6; 853 pVerInfo->uMinorVer = 1; 854 pVerInfo->fChecked = false; 855 pVerInfo->uCsdNo = 1; 856 pVerInfo->uBuildNo = 7601; 857 } 858 else 859 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Giving up on '%s'...\n", pszPdb); 860 861 862 return RTEXITCODE_SUCCESS; 863 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Giving up on '%s'...\n", pszPdb); 863 864 } 864 865 … … 911 912 * Find the structures. 912 913 */ 913 rcExit = findStructures(hFake, uModAddr, szLogTag );914 rcExit = findStructures(hFake, uModAddr, szLogTag, pszPdb, &OsVerInfo); 914 915 if (rcExit == RTEXITCODE_SUCCESS) 915 916 rcExit = checkThatWeFoundEverything(); … … 927 928 if (!SymCleanup(hFake)) 928 929 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "SymCleanup failed: %u\n", GetLastError()); 930 931 if (rcExit == RTEXITCODE_SKIPPED) 932 rcExit = RTEXITCODE_SUCCESS; 929 933 return rcExit; 930 934 } … … 933 937 /** The size of the directory entry buffer we're using. */ 934 938 #define MY_DIRENTRY_BUF_SIZE (sizeof(RTDIRENTRYEX) + RTPATH_MAX) 939 940 /** 941 * Checks if the name is of interest to us. 942 * 943 * @returns true/false. 944 * @param pszName The name. 945 * @param cchName The length of the name. 946 */ 947 static bool isInterestingName(const char *pszName, size_t cchName) 948 { 949 static struct { const char *psz; size_t cch; } const s_aNames[] = 950 { 951 RT_STR_TUPLE("ntoskrnl.pdb"), 952 RT_STR_TUPLE("ntkrnlmp.pdb"), 953 RT_STR_TUPLE("ntkrnlpa.pdb"), 954 RT_STR_TUPLE("ntkrpamp.pdb"), 955 }; 956 957 if ( cchName == s_aNames[0].cch 958 && (pszName[0] == 'n' || pszName[0] == 'N') 959 && (pszName[1] == 't' || pszName[1] == 'T') 960 ) 961 { 962 int i = RT_ELEMENTS(s_aNames); 963 while (i-- > 0) 964 if ( s_aNames[i].cch == cchName 965 && !RTStrICmp(s_aNames[i].psz, pszName)) 966 return true; 967 } 968 return false; 969 } 935 970 936 971 … … 943 978 * @param pDirEntry Pointer to the directory buffer. 944 979 */ 945 static RTEXITCODE processDirSub(char *pszDir, size_t cchDir, PRTDIRENTRYEX pDirEntry )980 static RTEXITCODE processDirSub(char *pszDir, size_t cchDir, PRTDIRENTRYEX pDirEntry, int iLogDepth) 946 981 { 947 982 Assert(cchDir > 0); Assert(pszDir[cchDir] == '\0'); … … 990 1025 if (RTFS_IS_FILE(pDirEntry->Info.Attr.fMode)) 991 1026 { 992 /* Is this a file which might interest us? */ 993 static struct { const char *psz; size_t cch; } const s_aNames[] = 1027 /* 1028 * Process debug info files of interest. 1029 */ 1030 if (isInterestingName(pDirEntry->szName, pDirEntry->cbName)) 994 1031 { 995 RT_STR_TUPLE("ntoskrnl.dbg"), 996 RT_STR_TUPLE("ntoskrnl.pdb"), 997 RT_STR_TUPLE("ntkrnlmp.dbg"), 998 RT_STR_TUPLE("ntkrnlmp.pdb"), 999 RT_STR_TUPLE("ntkrnlpa.pdb"), 1000 RT_STR_TUPLE("ntkrnlpa.dbg"), 1001 RT_STR_TUPLE("ntkrpamp.pdb"), 1002 RT_STR_TUPLE("ntkrpamp.dbg"), 1003 }; 1004 if ( pDirEntry->cbName == sizeof("ntkrpamp.dbg") - 1 1005 && (pDirEntry->szName[0] == 'n' || pDirEntry->szName[0] == 'N') 1006 && (pDirEntry->szName[1] == 't' || pDirEntry->szName[1] == 'T') 1007 ) 1008 { 1009 int i = RT_ELEMENTS(s_aNames); 1010 while (i-- > 0) 1011 if ( s_aNames[i].cch == pDirEntry->cbName 1012 && !RTStrICmp(s_aNames[i].psz, pDirEntry->szName)) 1013 { 1014 /* 1015 * Found debug info file of interest, process it. 1016 */ 1017 memcpy(&pszDir[cchDir], pDirEntry->szName, pDirEntry->cbName + 1); 1018 RTEXITCODE rcExit2 = processPdb(pszDir); 1019 if (rcExit2 != RTEXITCODE_SUCCESS) 1020 rcExit = rcExit2; 1021 break; 1022 } 1032 memcpy(&pszDir[cchDir], pDirEntry->szName, pDirEntry->cbName + 1); 1033 RTEXITCODE rcExit2 = processPdb(pszDir); 1034 if (rcExit2 != RTEXITCODE_SUCCESS) 1035 rcExit = rcExit2; 1023 1036 } 1024 1037 } … … 1026 1039 { 1027 1040 /* 1028 * Recurse into the subdirectory. 1041 * Recurse into the subdirectory. In order to speed up Win7+ 1042 * symbol pack traversals, we skip directories with ".pdb" suffixes 1043 * unless they match any of the .pdb files we're looking for. 1044 * 1029 1045 * Note! When we get back pDirEntry will be invalid. 1030 1046 */ 1031 memcpy(&pszDir[cchDir], pDirEntry->szName, pDirEntry->cbName + 1); 1032 RTEXITCODE rcExit2 = processDirSub(pszDir, cchDir + pDirEntry->cbName, pDirEntry); 1033 if (rcExit2 != RTEXITCODE_SUCCESS) 1034 rcExit = rcExit2; 1047 if ( pDirEntry->cbName <= 4 1048 || RTStrICmp(&pDirEntry->szName[pDirEntry->cbName - 4], ".pdb") 1049 || isInterestingName(pDirEntry->szName, pDirEntry->cbName)) 1050 { 1051 memcpy(&pszDir[cchDir], pDirEntry->szName, pDirEntry->cbName + 1); 1052 if (iLogDepth > 0) 1053 RTMsgInfo("%s%s ...\n", pszDir, RTPATH_SLASH_STR); 1054 RTEXITCODE rcExit2 = processDirSub(pszDir, cchDir + pDirEntry->cbName, pDirEntry, iLogDepth - 1); 1055 if (rcExit2 != RTEXITCODE_SUCCESS) 1056 rcExit = rcExit2; 1057 } 1035 1058 } 1036 1059 } … … 1063 1086 RTDIRENTRYEX DirEntry; 1064 1087 } uBuf; 1065 return processDirSub(szPath, strlen(szPath), &uBuf.DirEntry );1088 return processDirSub(szPath, strlen(szPath), &uBuf.DirEntry, g_iOptVerbose); 1066 1089 } 1067 1090 … … 1083 1106 { "--output", 'o', RTGETOPT_REQ_STRING }, 1084 1107 { "--verbose", 'v', RTGETOPT_REQ_NOTHING }, 1108 { "--quiet", 'q', RTGETOPT_REQ_NOTHING }, 1085 1109 }; 1086 1110 … … 1102 1126 1103 1127 case 'v': 1104 g_fOptVerbose = true; 1128 g_iOptVerbose++; 1129 break; 1130 1131 case 'q': 1132 g_iOptVerbose++; 1105 1133 break; 1106 1134 … … 1114 1142 1115 1143 case 'h': 1116 RTPrintf("usage: %s [-v|--verbose] [- f|--force] [-o|--output <file.h>] <dir1|pdb1> [...]\n"1144 RTPrintf("usage: %s [-v|--verbose] [-q|--quiet] [-f|--force] [-o|--output <file.h>] <dir1|pdb1> [...]\n" 1117 1145 " or: %s [-V|--version]\n" 1118 1146 " or: %s [-h|--help]\n",
Note:
See TracChangeset
for help on using the changeset viewer.