diff --git a/IDEHelper/COFF.cpp b/IDEHelper/COFF.cpp index aefb4faf..4d86c464 100644 --- a/IDEHelper/COFF.cpp +++ b/IDEHelper/COFF.cpp @@ -234,6 +234,7 @@ COFF::COFF(DebugTarget* debugTarget) : DbgModule(debugTarget) mCvIPIMaxTag = -1; mMasterCompileUnit = NULL; mTempBufIdx = 0; + mIs64Bit = false; mCvPageSize = 0; mCvPageBits = 31; @@ -4891,6 +4892,9 @@ bool COFF::CvParseDBI(int wantAge) BP_ZONE("CvParseDBI"); uint8* data = CvReadStream(3); + if (data == NULL) + return false; + uint8* sectionData = data; defer ( @@ -4935,6 +4939,13 @@ bool COFF::CvParseDBI(int wantAge) GET_INTO(uint16, machine); GET_INTO(uint32, reserved); //resvd4 + if (machine == 0x8664) + mIs64Bit = true; + else if (machine == 0x014C) + mIs64Bit = false; + else // Unknown machine + return false; + uint8* headerEnd = data; // Skip to debug header @@ -5023,6 +5034,10 @@ bool COFF::CvParseDBI(int wantAge) BP_ALLOC_T(DbgCompileUnitContrib); auto contribEntry = mAlloc.Alloc(); contribEntry->mAddress = GetSectionAddr(contrib.mSection, contrib.mOffset) + contribOffset; + + if ((contribEntry->mAddress & 0xFFFF0000'00000000) != 0) + continue; + contribEntry->mLength = curSize; contribEntry->mDbgModule = this; contribEntry->mCompileUnitId = contrib.mModule; @@ -5560,10 +5575,13 @@ uint8* COFF::HandleSymStreamEntries(CvSymStreamType symStreamType, uint8* data, #endif if (mIsFastLink) - return dataEnd; // FOrmat changed + return dataEnd; // Format changed + + if (sizeBuckets == 0) + return dataEnd; // No hash std::multimap checkAddrMap; - + int bitCount = 0; for (int blockIdx = 0; blockIdx < 0x81; blockIdx++) { diff --git a/IDEHelper/COFF.h b/IDEHelper/COFF.h index aeb22fa3..471b6475 100644 --- a/IDEHelper/COFF.h +++ b/IDEHelper/COFF.h @@ -222,6 +222,7 @@ public: int mDebugAge; ParseKind mParseKind; bool mPDBLoaded; + bool mIs64Bit; int mCvPageSize; int mCvPageBits; diff --git a/IDEHelper/WinDebugger.cpp b/IDEHelper/WinDebugger.cpp index dffb180e..5c4e3cdb 100644 --- a/IDEHelper/WinDebugger.cpp +++ b/IDEHelper/WinDebugger.cpp @@ -18,6 +18,7 @@ #include "BeefySysLib/util/UTF8.h" #include "BeefySysLib/FileStream.h" #include "BeefySysLib/FileHandleStream.h" +#include "BeefySysLib/util/FileEnumerator.h" #include #include #include "DbgExprEvaluator.h" @@ -9387,6 +9388,42 @@ void WinDebugger::EvaluateContinueKeep() mDebugPendingExpr->mIdleTicks = 0; } +static void PdbTestFile(WinDebugger* debugger, const StringImpl& path) +{ + if (!path.EndsWith(".PDB", StringImpl::CompareKind_OrdinalIgnoreCase)) + return; + + OutputDebugStrF("Testing %s\n", path.c_str()); + COFF coffFile(debugger->mDebugTarget); + uint8 wantGuid[16] = { 0 }; + if (!coffFile.TryLoadPDB(path, wantGuid, -1)) + return; + if (!coffFile.mIs64Bit) + return; + coffFile.ParseTypeData(); + coffFile.ParseSymbolData(); + coffFile.ParseGlobalsData(); +} + +static void PdbTest(WinDebugger* debugger, const StringImpl& path) +{ + for (auto& fileEntry : FileEnumerator(path, FileEnumerator::Flags_Files)) + { + String filePath = fileEntry.GetFilePath(); + + PdbTestFile(debugger, filePath); + } + + for (auto& fileEntry : FileEnumerator(path, FileEnumerator::Flags_Directories)) + { + String childPath = fileEntry.GetFilePath(); + String dirName; + dirName = GetFileName(childPath); + + PdbTest(debugger, childPath); + } +} + String WinDebugger::Evaluate(const StringImpl& expr, DwFormatInfo formatInfo, int callStackIdx, int cursorPos, int language, DwEvalExpressionFlags expressionFlags) { BP_ZONE_F("WinDebugger::Evaluate %s", BP_DYN_STR(expr.c_str())); @@ -9471,6 +9508,10 @@ String WinDebugger::Evaluate(const StringImpl& expr, DwFormatInfo formatInfo, in mDbgBreak = true; return ""; } + else if (cmd == "!pdbtest") + { + PdbTest(this, "c:\\"); + } } }