1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

!pdbtest, extra PDB reading robustness

This commit is contained in:
Brian Fiete 2020-08-11 09:26:21 -07:00
parent 4afc8eb3dc
commit c12aea02be
3 changed files with 62 additions and 2 deletions

View file

@ -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<DbgCompileUnitContrib>();
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<addr_target, int> checkAddrMap;
int bitCount = 0;
for (int blockIdx = 0; blockIdx < 0x81; blockIdx++)
{

View file

@ -222,6 +222,7 @@ public:
int mDebugAge;
ParseKind mParseKind;
bool mPDBLoaded;
bool mIs64Bit;
int mCvPageSize;
int mCvPageBits;

View file

@ -18,6 +18,7 @@
#include "BeefySysLib/util/UTF8.h"
#include "BeefySysLib/FileStream.h"
#include "BeefySysLib/FileHandleStream.h"
#include "BeefySysLib/util/FileEnumerator.h"
#include <inttypes.h>
#include <windows.h>
#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:\\");
}
}
}