Update SPDB handling to use cvinfo, and store more/better data

* This gives us local ranges accurately, as well as fixes bugs with not
  getting inline sites. Closes #969
This commit is contained in:
baldurk
2018-05-17 13:41:34 +01:00
parent e4a15d0ecb
commit f8ced4c0ee
2 changed files with 529 additions and 539 deletions
File diff suppressed because it is too large Load Diff
+63 -94
View File
@@ -42,6 +42,8 @@ namespace DXBC
class PageMapping
{
public:
PageMapping() = default;
PageMapping(const byte **pages, uint32_t PageSize, uint32_t *indices, uint32_t numIndices)
{
direct = NULL;
@@ -97,6 +99,33 @@ struct GuidPageHeader
char Strings[1];
};
struct OffsetLength
{
uint32_t offset;
uint32_t byteLength;
};
struct TPIHash
{
uint16_t streamNumber;
uint16_t pad;
uint32_t hashSize;
uint32_t numBucket;
OffsetLength hashVals;
OffsetLength tiOffs;
OffsetLength hashAdj;
};
struct TPIHeader
{
uint32_t version;
uint32_t headerSize;
uint32_t typeMin;
uint32_t typeMax;
uint32_t dataSize;
TPIHash hash;
};
struct DBIHeader
{
uint32_t sig;
@@ -168,113 +197,52 @@ struct CompilandDetails
string CompilerSig;
};
struct LineNumbersHeader
struct FileChecksum
{
uint32_t offset;
uint16_t sec;
uint16_t flags;
uint32_t cod;
uint32_t nameIndex;
uint8_t hashLength;
uint8_t hashType;
uint8_t hashData[1];
};
struct FileLineNumbers
struct LineColumnInfo
{
uint32_t fileIdx; // index = byte offset in hash chunk
uint32_t numLines;
uint32_t size;
};
int32_t fileIndex = -1;
uint32_t funcIndex = 0;
uint32_t lineStart = 0, lineEnd = 0;
uint32_t colStart = 0, colEnd = 0;
bool statement = true;
#pragma pack(push, 1)
struct ProcHeader
{
uint32_t Parent;
uint32_t End;
uint32_t Next;
uint32_t Length;
uint32_t DebugStart;
uint32_t DebugEnd;
uint32_t Type;
uint32_t Offset;
byte Unknown[3];
std::vector<std::string> stack;
};
#pragma pack(pop)
struct InstructionLocation
{
InstructionLocation() : funcEnd(false), offset(0), line(0), colStart(0), colEnd(0) {}
bool funcEnd;
uint32_t offset;
uint32_t line;
uint32_t colStart;
uint32_t colEnd;
bool statement = true;
uint32_t offsetStart = 0;
uint32_t offsetEnd = 0;
uint32_t lineStart = 0;
uint32_t lineEnd = 0;
uint32_t colStart = 0;
uint32_t colEnd = 0;
};
struct FuncCallLineNumbers
struct Inlinee
{
uint32_t id;
uint64_t ptr;
uint64_t parentPtr;
uint32_t fileOffs;
uint32_t baseLineNum;
vector<InstructionLocation> locations;
std::vector<InstructionLocation> locations;
};
struct Function
{
uint8_t unkA;
uint32_t unkB;
uint16_t unkC;
uint16_t unkD;
uint16_t unkE;
string funcName;
vector<int8_t> things;
uint32_t type = 0;
std::string name;
};
enum FuncCallBytestreamOpcodes
{
EndStream = 0x0,
SetByteOffset = 0x1,
// 0x2
AdvanceBytes = 0x3,
FunctionEndNoAdvance = 0x4,
// 0x5
AdvanceLines = 0x6,
PrologueEnd = 0x7,
EpilogueBegin = 0x8,
ColumnStart = 0x9,
// 0xa
AdvanceBytesAndLines = 0xb,
EndOfFunction = 0xc,
ColumnEnd = 0xd,
};
#pragma pack(push, 1)
struct RegisterVariableAssign
{
uint32_t func;
uint16_t unkflags;
char name[1];
};
#pragma pack(pop)
#pragma pack(push, 1)
struct RegisterVariableAssignComponent
{
uint16_t type;
OperandType Type() { return (OperandType)type; }
uint16_t unkA;
uint16_t srcComp;
uint16_t unkB;
uint32_t instrOffset;
uint16_t unkC;
uint16_t unkD;
uint16_t destComp;
uint16_t unkE; // destComp for len == 24
};
#pragma pack(pop)
struct PDBStream
{
uint32_t byteLength;
@@ -286,9 +254,9 @@ class SPDBChunk : public DXBCDebugChunk
public:
SPDBChunk(void *data);
string GetCompilerSig() const { return m_CompilandDetails.CompilerSig; }
string GetEntryFunction() const { return m_Entry; }
string GetShaderProfile() const { return m_Profile; }
std::string GetCompilerSig() const { return m_CompilerSig; }
std::string GetEntryFunction() const { return m_Entry; }
std::string GetShaderProfile() const { return m_Profile; }
uint32_t GetShaderCompileFlags() const { return m_ShaderFlags; }
void GetFileLine(size_t instruction, uintptr_t offset, int32_t &fileIdx, int32_t &lineNum) const;
@@ -298,13 +266,14 @@ private:
bool m_HasDebugInfo;
CompilandDetails m_CompilandDetails;
std::string m_CompilerSig;
string m_Entry;
string m_Profile;
std::string m_Entry;
std::string m_Profile;
uint32_t m_ShaderFlags;
map<uint32_t, pair<int32_t, uint32_t> > m_LineNumbers;
std::map<uint32_t, Function> m_Functions;
std::map<uint32_t, LineColumnInfo> m_Lines;
};
};