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:
parent
4afc8eb3dc
commit
c12aea02be
3 changed files with 62 additions and 2 deletions
|
@ -234,6 +234,7 @@ COFF::COFF(DebugTarget* debugTarget) : DbgModule(debugTarget)
|
||||||
mCvIPIMaxTag = -1;
|
mCvIPIMaxTag = -1;
|
||||||
mMasterCompileUnit = NULL;
|
mMasterCompileUnit = NULL;
|
||||||
mTempBufIdx = 0;
|
mTempBufIdx = 0;
|
||||||
|
mIs64Bit = false;
|
||||||
|
|
||||||
mCvPageSize = 0;
|
mCvPageSize = 0;
|
||||||
mCvPageBits = 31;
|
mCvPageBits = 31;
|
||||||
|
@ -4891,6 +4892,9 @@ bool COFF::CvParseDBI(int wantAge)
|
||||||
BP_ZONE("CvParseDBI");
|
BP_ZONE("CvParseDBI");
|
||||||
|
|
||||||
uint8* data = CvReadStream(3);
|
uint8* data = CvReadStream(3);
|
||||||
|
if (data == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
uint8* sectionData = data;
|
uint8* sectionData = data;
|
||||||
defer
|
defer
|
||||||
(
|
(
|
||||||
|
@ -4935,6 +4939,13 @@ bool COFF::CvParseDBI(int wantAge)
|
||||||
GET_INTO(uint16, machine);
|
GET_INTO(uint16, machine);
|
||||||
GET_INTO(uint32, reserved); //resvd4
|
GET_INTO(uint32, reserved); //resvd4
|
||||||
|
|
||||||
|
if (machine == 0x8664)
|
||||||
|
mIs64Bit = true;
|
||||||
|
else if (machine == 0x014C)
|
||||||
|
mIs64Bit = false;
|
||||||
|
else // Unknown machine
|
||||||
|
return false;
|
||||||
|
|
||||||
uint8* headerEnd = data;
|
uint8* headerEnd = data;
|
||||||
|
|
||||||
// Skip to debug header
|
// Skip to debug header
|
||||||
|
@ -5023,6 +5034,10 @@ bool COFF::CvParseDBI(int wantAge)
|
||||||
BP_ALLOC_T(DbgCompileUnitContrib);
|
BP_ALLOC_T(DbgCompileUnitContrib);
|
||||||
auto contribEntry = mAlloc.Alloc<DbgCompileUnitContrib>();
|
auto contribEntry = mAlloc.Alloc<DbgCompileUnitContrib>();
|
||||||
contribEntry->mAddress = GetSectionAddr(contrib.mSection, contrib.mOffset) + contribOffset;
|
contribEntry->mAddress = GetSectionAddr(contrib.mSection, contrib.mOffset) + contribOffset;
|
||||||
|
|
||||||
|
if ((contribEntry->mAddress & 0xFFFF0000'00000000) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
contribEntry->mLength = curSize;
|
contribEntry->mLength = curSize;
|
||||||
contribEntry->mDbgModule = this;
|
contribEntry->mDbgModule = this;
|
||||||
contribEntry->mCompileUnitId = contrib.mModule;
|
contribEntry->mCompileUnitId = contrib.mModule;
|
||||||
|
@ -5560,10 +5575,13 @@ uint8* COFF::HandleSymStreamEntries(CvSymStreamType symStreamType, uint8* data,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mIsFastLink)
|
if (mIsFastLink)
|
||||||
return dataEnd; // FOrmat changed
|
return dataEnd; // Format changed
|
||||||
|
|
||||||
|
if (sizeBuckets == 0)
|
||||||
|
return dataEnd; // No hash
|
||||||
|
|
||||||
std::multimap<addr_target, int> checkAddrMap;
|
std::multimap<addr_target, int> checkAddrMap;
|
||||||
|
|
||||||
int bitCount = 0;
|
int bitCount = 0;
|
||||||
for (int blockIdx = 0; blockIdx < 0x81; blockIdx++)
|
for (int blockIdx = 0; blockIdx < 0x81; blockIdx++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -222,6 +222,7 @@ public:
|
||||||
int mDebugAge;
|
int mDebugAge;
|
||||||
ParseKind mParseKind;
|
ParseKind mParseKind;
|
||||||
bool mPDBLoaded;
|
bool mPDBLoaded;
|
||||||
|
bool mIs64Bit;
|
||||||
|
|
||||||
int mCvPageSize;
|
int mCvPageSize;
|
||||||
int mCvPageBits;
|
int mCvPageBits;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "BeefySysLib/util/UTF8.h"
|
#include "BeefySysLib/util/UTF8.h"
|
||||||
#include "BeefySysLib/FileStream.h"
|
#include "BeefySysLib/FileStream.h"
|
||||||
#include "BeefySysLib/FileHandleStream.h"
|
#include "BeefySysLib/FileHandleStream.h"
|
||||||
|
#include "BeefySysLib/util/FileEnumerator.h"
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "DbgExprEvaluator.h"
|
#include "DbgExprEvaluator.h"
|
||||||
|
@ -9387,6 +9388,42 @@ void WinDebugger::EvaluateContinueKeep()
|
||||||
mDebugPendingExpr->mIdleTicks = 0;
|
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)
|
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()));
|
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;
|
mDbgBreak = true;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
else if (cmd == "!pdbtest")
|
||||||
|
{
|
||||||
|
PdbTest(this, "c:\\");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue