mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.2.x] ~ dia files refactoring
git-svn-id: https://pykd.svn.codeplex.com/svn@83439 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
00aa7d2e6b
commit
b4442b7383
@ -1,5 +1,5 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "diawrapper.h"
|
#include "diasymbol.h"
|
||||||
|
|
||||||
namespace pykd {
|
namespace pykd {
|
||||||
|
|
||||||
@ -32,532 +32,49 @@ const size_t DiaSymbol::cntBasicTypeName = _countof(DiaSymbol::basicTypeName);
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
const struct DiaRegToRegRelativeAmd64 : DiaRegToRegRelativeBase
|
||||||
|
{
|
||||||
|
typedef std::map<ULONG, ULONG> Base;
|
||||||
|
DiaRegToRegRelativeAmd64();
|
||||||
|
} g_DiaRegToRegRelativeAmd64;
|
||||||
|
|
||||||
|
DiaRegToRegRelativeAmd64::DiaRegToRegRelativeAmd64()
|
||||||
|
{
|
||||||
|
(*this)[CV_AMD64_RIP] = rriInstructionPointer;
|
||||||
|
(*this)[CV_AMD64_RBP] = rriStackFrame;
|
||||||
|
(*this)[CV_AMD64_RSP] = rriStackPointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const DiaRegToRegRelativeBase &DiaSymbol::regToRegRelativeAmd64 = g_DiaRegToRegRelativeAmd64;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
const struct DiaRegToRegRelativeI386 : DiaRegToRegRelativeBase
|
||||||
|
{
|
||||||
|
typedef std::map<ULONG, ULONG> Base;
|
||||||
|
DiaRegToRegRelativeI386();
|
||||||
|
} g_DiaRegToRegRelativeI386;
|
||||||
|
|
||||||
|
DiaRegToRegRelativeI386::DiaRegToRegRelativeI386()
|
||||||
|
{
|
||||||
|
(*this)[CV_REG_EIP] = rriInstructionPointer;
|
||||||
|
(*this)[CV_REG_EBP] = rriStackFrame;
|
||||||
|
(*this)[CV_REG_ESP] = rriStackPointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const DiaRegToRegRelativeBase &DiaSymbol::regToRegRelativeI386 = g_DiaRegToRegRelativeI386;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
} //pykd namespace end
|
} //pykd namespace end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
//#include "diawrapper.h"
|
|
||||||
//#include "utils.h"
|
|
||||||
//
|
|
||||||
//namespace pyDia {
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//#define _DEF_SYM_TAG_VAL(x) Symbol::ValueNameEntry(SymTag##x, #x)
|
|
||||||
//const Symbol::ValueNameEntry Symbol::symTagName[SymTagMax] = {
|
|
||||||
// _DEF_SYM_TAG_VAL(Null),
|
|
||||||
// _DEF_SYM_TAG_VAL(Exe),
|
|
||||||
// _DEF_SYM_TAG_VAL(Compiland),
|
|
||||||
// _DEF_SYM_TAG_VAL(CompilandDetails),
|
|
||||||
// _DEF_SYM_TAG_VAL(CompilandEnv),
|
|
||||||
// _DEF_SYM_TAG_VAL(Function),
|
|
||||||
// _DEF_SYM_TAG_VAL(Block),
|
|
||||||
// _DEF_SYM_TAG_VAL(Data),
|
|
||||||
// _DEF_SYM_TAG_VAL(Annotation),
|
|
||||||
// _DEF_SYM_TAG_VAL(Label),
|
|
||||||
// _DEF_SYM_TAG_VAL(PublicSymbol),
|
|
||||||
// _DEF_SYM_TAG_VAL(UDT),
|
|
||||||
// _DEF_SYM_TAG_VAL(Enum),
|
|
||||||
// _DEF_SYM_TAG_VAL(FunctionType),
|
|
||||||
// _DEF_SYM_TAG_VAL(PointerType),
|
|
||||||
// _DEF_SYM_TAG_VAL(ArrayType),
|
|
||||||
// _DEF_SYM_TAG_VAL(BaseType),
|
|
||||||
// _DEF_SYM_TAG_VAL(Typedef),
|
|
||||||
// _DEF_SYM_TAG_VAL(BaseClass),
|
|
||||||
// _DEF_SYM_TAG_VAL(Friend),
|
|
||||||
// _DEF_SYM_TAG_VAL(FunctionArgType),
|
|
||||||
// _DEF_SYM_TAG_VAL(FuncDebugStart),
|
|
||||||
// _DEF_SYM_TAG_VAL(FuncDebugEnd),
|
|
||||||
// _DEF_SYM_TAG_VAL(UsingNamespace),
|
|
||||||
// _DEF_SYM_TAG_VAL(VTableShape),
|
|
||||||
// _DEF_SYM_TAG_VAL(VTable),
|
|
||||||
// _DEF_SYM_TAG_VAL(Custom),
|
|
||||||
// _DEF_SYM_TAG_VAL(Thunk),
|
|
||||||
// _DEF_SYM_TAG_VAL(CustomType),
|
|
||||||
// _DEF_SYM_TAG_VAL(ManagedType),
|
|
||||||
// _DEF_SYM_TAG_VAL(Dimension)
|
|
||||||
//};
|
|
||||||
//#undef _DEF_SYM_TAG_VAL
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//#define _DEF_DATA_KIND_VAL(x) Symbol::ValueNameEntry(DataIs##x, #x)
|
|
||||||
//const Symbol::ValueNameEntry Symbol::dataKindName[DataIsConstant + 1] = {
|
|
||||||
// _DEF_DATA_KIND_VAL(Unknown),
|
|
||||||
// _DEF_DATA_KIND_VAL(Local),
|
|
||||||
// _DEF_DATA_KIND_VAL(StaticLocal),
|
|
||||||
// _DEF_DATA_KIND_VAL(Param),
|
|
||||||
// _DEF_DATA_KIND_VAL(ObjectPtr),
|
|
||||||
// _DEF_DATA_KIND_VAL(FileStatic),
|
|
||||||
// _DEF_DATA_KIND_VAL(Global),
|
|
||||||
// _DEF_DATA_KIND_VAL(Member),
|
|
||||||
// _DEF_DATA_KIND_VAL(StaticMember),
|
|
||||||
// _DEF_DATA_KIND_VAL(Constant)
|
|
||||||
//};
|
|
||||||
//#undef _DEF_DATA_KIND_VAL
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//#define _DEF_LOC_TYPE(x) Symbol::ValueNameEntry(LocIs##x, #x)
|
|
||||||
//const Symbol::ValueNameEntry Symbol::locTypeName[LocTypeMax] = {
|
|
||||||
// _DEF_LOC_TYPE(Null),
|
|
||||||
// _DEF_LOC_TYPE(Static),
|
|
||||||
// _DEF_LOC_TYPE(TLS),
|
|
||||||
// _DEF_LOC_TYPE(RegRel),
|
|
||||||
// _DEF_LOC_TYPE(ThisRel),
|
|
||||||
// _DEF_LOC_TYPE(Enregistered),
|
|
||||||
// _DEF_LOC_TYPE(BitField),
|
|
||||||
// _DEF_LOC_TYPE(Slot),
|
|
||||||
// _DEF_LOC_TYPE(IlRel),
|
|
||||||
// Symbol::ValueNameEntry(LocInMetaData, "InMetaData"),
|
|
||||||
// _DEF_LOC_TYPE(Constant)
|
|
||||||
//};
|
|
||||||
//#undef _DEF_LOC_TYPE
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//#define _DEF_BASIC_TYPE(x) Symbol::ValueNameEntry(bt##x, #x)
|
|
||||||
//const Symbol::ValueNameEntry Symbol::basicTypeName[] = {
|
|
||||||
// _DEF_BASIC_TYPE(NoType),
|
|
||||||
// _DEF_BASIC_TYPE(Void),
|
|
||||||
// _DEF_BASIC_TYPE(Char),
|
|
||||||
// _DEF_BASIC_TYPE(WChar),
|
|
||||||
// _DEF_BASIC_TYPE(Int),
|
|
||||||
// _DEF_BASIC_TYPE(UInt),
|
|
||||||
// _DEF_BASIC_TYPE(Float),
|
|
||||||
// _DEF_BASIC_TYPE(BCD),
|
|
||||||
// _DEF_BASIC_TYPE(Bool),
|
|
||||||
// _DEF_BASIC_TYPE(Long),
|
|
||||||
// _DEF_BASIC_TYPE(ULong),
|
|
||||||
// _DEF_BASIC_TYPE(Currency),
|
|
||||||
// _DEF_BASIC_TYPE(Date),
|
|
||||||
// _DEF_BASIC_TYPE(Variant),
|
|
||||||
// _DEF_BASIC_TYPE(Complex),
|
|
||||||
// _DEF_BASIC_TYPE(Bit),
|
|
||||||
// _DEF_BASIC_TYPE(BSTR),
|
|
||||||
// _DEF_BASIC_TYPE(Hresult)
|
|
||||||
//};
|
|
||||||
//#undef _DEF_BASIC_TYPE
|
|
||||||
//
|
|
||||||
//const size_t Symbol::cntBasicTypeName = _countof(Symbol::basicTypeName);
|
|
||||||
//
|
|
||||||
//std::string Symbol::getBasicTypeName( ULONG basicType )
|
|
||||||
//{
|
|
||||||
// for ( size_t i = 0; i < Symbol::cntBasicTypeName; ++i )
|
|
||||||
// {
|
|
||||||
// if ( basicType == Symbol::basicTypeName[i].first )
|
|
||||||
// return std::string( Symbol::basicTypeName[i].second );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// std::stringstream sstr;
|
|
||||||
//
|
|
||||||
// sstr << "faild to find basic type with index %d" << basicType;
|
|
||||||
//
|
|
||||||
// throw Exception( sstr.str() );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//#define _DEF_UDT_KIND(x) Symbol::ValueNameEntry(Udt##x, #x)
|
|
||||||
//const Symbol::ValueNameEntry Symbol::udtKindName[] = {
|
|
||||||
// _DEF_UDT_KIND(Struct),
|
|
||||||
// _DEF_UDT_KIND(Class),
|
|
||||||
// _DEF_UDT_KIND(Union)
|
|
||||||
//};
|
|
||||||
//#undef _DEF_UDT_KIND
|
|
||||||
//
|
|
||||||
//const size_t Symbol::cntUdtKindName = _countof(udtKindName);
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//#define _DEF_I386_REG(x) Symbol::ValueNameEntry(CV_REG_##x, #x)
|
|
||||||
//const Symbol::ValueNameEntry Symbol::i386RegName[] = {
|
|
||||||
// _DEF_I386_REG(AL),
|
|
||||||
// _DEF_I386_REG(CL),
|
|
||||||
// _DEF_I386_REG(DL),
|
|
||||||
// _DEF_I386_REG(BL),
|
|
||||||
// _DEF_I386_REG(AH),
|
|
||||||
// _DEF_I386_REG(CH),
|
|
||||||
// _DEF_I386_REG(DH),
|
|
||||||
// _DEF_I386_REG(BH),
|
|
||||||
// _DEF_I386_REG(AX),
|
|
||||||
// _DEF_I386_REG(CX),
|
|
||||||
// _DEF_I386_REG(DX),
|
|
||||||
// _DEF_I386_REG(BX),
|
|
||||||
// _DEF_I386_REG(SP),
|
|
||||||
// _DEF_I386_REG(BP),
|
|
||||||
// _DEF_I386_REG(SI),
|
|
||||||
// _DEF_I386_REG(DI),
|
|
||||||
// _DEF_I386_REG(EAX),
|
|
||||||
// _DEF_I386_REG(ECX),
|
|
||||||
// _DEF_I386_REG(EDX),
|
|
||||||
// _DEF_I386_REG(EBX),
|
|
||||||
// _DEF_I386_REG(ESP),
|
|
||||||
// _DEF_I386_REG(EBP),
|
|
||||||
// _DEF_I386_REG(ESI),
|
|
||||||
// _DEF_I386_REG(EDI),
|
|
||||||
// _DEF_I386_REG(ES),
|
|
||||||
// _DEF_I386_REG(CS),
|
|
||||||
// _DEF_I386_REG(SS),
|
|
||||||
// _DEF_I386_REG(DS),
|
|
||||||
// _DEF_I386_REG(FS),
|
|
||||||
// _DEF_I386_REG(GS),
|
|
||||||
// _DEF_I386_REG(IP),
|
|
||||||
// _DEF_I386_REG(FLAGS ),
|
|
||||||
// _DEF_I386_REG(EIP),
|
|
||||||
// _DEF_I386_REG(EFLAGS),
|
|
||||||
// _DEF_I386_REG(TEMP),
|
|
||||||
// _DEF_I386_REG(TEMPH),
|
|
||||||
// _DEF_I386_REG(QUOTE),
|
|
||||||
// _DEF_I386_REG(PCDR3),
|
|
||||||
// _DEF_I386_REG(PCDR4),
|
|
||||||
// _DEF_I386_REG(PCDR5),
|
|
||||||
// _DEF_I386_REG(PCDR6),
|
|
||||||
// _DEF_I386_REG(PCDR7),
|
|
||||||
// _DEF_I386_REG(CR0),
|
|
||||||
// _DEF_I386_REG(CR1),
|
|
||||||
// _DEF_I386_REG(CR2),
|
|
||||||
// _DEF_I386_REG(CR3),
|
|
||||||
// _DEF_I386_REG(CR4),
|
|
||||||
// _DEF_I386_REG(DR0),
|
|
||||||
// _DEF_I386_REG(DR1),
|
|
||||||
// _DEF_I386_REG(DR2),
|
|
||||||
// _DEF_I386_REG(DR3),
|
|
||||||
// _DEF_I386_REG(DR4),
|
|
||||||
// _DEF_I386_REG(DR5),
|
|
||||||
// _DEF_I386_REG(DR6),
|
|
||||||
// _DEF_I386_REG(DR7),
|
|
||||||
// _DEF_I386_REG(GDTR),
|
|
||||||
// _DEF_I386_REG(GDTL),
|
|
||||||
// _DEF_I386_REG(IDTR),
|
|
||||||
// _DEF_I386_REG(IDTL),
|
|
||||||
// _DEF_I386_REG(LDTR),
|
|
||||||
// _DEF_I386_REG(TR)
|
|
||||||
//};
|
|
||||||
//#undef _DEF_I386_REG
|
|
||||||
//
|
|
||||||
//const size_t Symbol::cntI386RegName = _countof(i386RegName);
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//#define _DEF_AMD64_REG(x) Symbol::ValueNameEntry(CV_AMD64_##x, #x)
|
|
||||||
//const Symbol::ValueNameEntry Symbol::amd64RegName[] = {
|
|
||||||
// _DEF_AMD64_REG(AL),
|
|
||||||
// _DEF_AMD64_REG(CL),
|
|
||||||
// _DEF_AMD64_REG(DL),
|
|
||||||
// _DEF_AMD64_REG(BL),
|
|
||||||
// _DEF_AMD64_REG(AH),
|
|
||||||
// _DEF_AMD64_REG(CH),
|
|
||||||
// _DEF_AMD64_REG(DH),
|
|
||||||
// _DEF_AMD64_REG(BH),
|
|
||||||
// _DEF_AMD64_REG(AX),
|
|
||||||
// _DEF_AMD64_REG(CX),
|
|
||||||
// _DEF_AMD64_REG(DX),
|
|
||||||
// _DEF_AMD64_REG(BX),
|
|
||||||
// _DEF_AMD64_REG(SP),
|
|
||||||
// _DEF_AMD64_REG(BP),
|
|
||||||
// _DEF_AMD64_REG(SI),
|
|
||||||
// _DEF_AMD64_REG(DI),
|
|
||||||
// _DEF_AMD64_REG(EAX),
|
|
||||||
// _DEF_AMD64_REG(ECX),
|
|
||||||
// _DEF_AMD64_REG(EDX),
|
|
||||||
// _DEF_AMD64_REG(EBX),
|
|
||||||
// _DEF_AMD64_REG(ESP),
|
|
||||||
// _DEF_AMD64_REG(EBP),
|
|
||||||
// _DEF_AMD64_REG(ESI),
|
|
||||||
// _DEF_AMD64_REG(EDI),
|
|
||||||
// _DEF_AMD64_REG(ES),
|
|
||||||
// _DEF_AMD64_REG(CS),
|
|
||||||
// _DEF_AMD64_REG(SS),
|
|
||||||
// _DEF_AMD64_REG(DS),
|
|
||||||
// _DEF_AMD64_REG(FS),
|
|
||||||
// _DEF_AMD64_REG(GS),
|
|
||||||
// _DEF_AMD64_REG(FLAGS),
|
|
||||||
// _DEF_AMD64_REG(RIP),
|
|
||||||
// _DEF_AMD64_REG(EFLAGS),
|
|
||||||
// _DEF_AMD64_REG(CR0),
|
|
||||||
// _DEF_AMD64_REG(CR1),
|
|
||||||
// _DEF_AMD64_REG(CR2),
|
|
||||||
// _DEF_AMD64_REG(CR3),
|
|
||||||
// _DEF_AMD64_REG(CR4),
|
|
||||||
// _DEF_AMD64_REG(CR8),
|
|
||||||
// _DEF_AMD64_REG(DR0),
|
|
||||||
// _DEF_AMD64_REG(DR1),
|
|
||||||
// _DEF_AMD64_REG(DR2),
|
|
||||||
// _DEF_AMD64_REG(DR3),
|
|
||||||
// _DEF_AMD64_REG(DR4),
|
|
||||||
// _DEF_AMD64_REG(DR5),
|
|
||||||
// _DEF_AMD64_REG(DR6),
|
|
||||||
// _DEF_AMD64_REG(DR7),
|
|
||||||
// _DEF_AMD64_REG(DR8),
|
|
||||||
// _DEF_AMD64_REG(DR9),
|
|
||||||
// _DEF_AMD64_REG(DR10),
|
|
||||||
// _DEF_AMD64_REG(DR11),
|
|
||||||
// _DEF_AMD64_REG(DR12),
|
|
||||||
// _DEF_AMD64_REG(DR13),
|
|
||||||
// _DEF_AMD64_REG(DR14),
|
|
||||||
// _DEF_AMD64_REG(DR15),
|
|
||||||
// _DEF_AMD64_REG(GDTR),
|
|
||||||
// _DEF_AMD64_REG(GDTL),
|
|
||||||
// _DEF_AMD64_REG(IDTR),
|
|
||||||
// _DEF_AMD64_REG(IDTL),
|
|
||||||
// _DEF_AMD64_REG(LDTR),
|
|
||||||
// _DEF_AMD64_REG(TR),
|
|
||||||
// _DEF_AMD64_REG(ST0),
|
|
||||||
// _DEF_AMD64_REG(ST1),
|
|
||||||
// _DEF_AMD64_REG(ST2),
|
|
||||||
// _DEF_AMD64_REG(ST3),
|
|
||||||
// _DEF_AMD64_REG(ST4),
|
|
||||||
// _DEF_AMD64_REG(ST5),
|
|
||||||
// _DEF_AMD64_REG(ST6),
|
|
||||||
// _DEF_AMD64_REG(ST7),
|
|
||||||
// _DEF_AMD64_REG(CTRL),
|
|
||||||
// _DEF_AMD64_REG(STAT),
|
|
||||||
// _DEF_AMD64_REG(TAG),
|
|
||||||
// _DEF_AMD64_REG(FPIP),
|
|
||||||
// _DEF_AMD64_REG(FPCS),
|
|
||||||
// _DEF_AMD64_REG(FPDO),
|
|
||||||
// _DEF_AMD64_REG(FPDS),
|
|
||||||
// _DEF_AMD64_REG(ISEM),
|
|
||||||
// _DEF_AMD64_REG(FPEIP),
|
|
||||||
// _DEF_AMD64_REG(FPEDO),
|
|
||||||
// _DEF_AMD64_REG(MM0),
|
|
||||||
// _DEF_AMD64_REG(MM1),
|
|
||||||
// _DEF_AMD64_REG(MM2),
|
|
||||||
// _DEF_AMD64_REG(MM3),
|
|
||||||
// _DEF_AMD64_REG(MM4),
|
|
||||||
// _DEF_AMD64_REG(MM5),
|
|
||||||
// _DEF_AMD64_REG(MM6),
|
|
||||||
// _DEF_AMD64_REG(MM7),
|
|
||||||
// _DEF_AMD64_REG(XMM0),
|
|
||||||
// _DEF_AMD64_REG(XMM1),
|
|
||||||
// _DEF_AMD64_REG(XMM2),
|
|
||||||
// _DEF_AMD64_REG(XMM3),
|
|
||||||
// _DEF_AMD64_REG(XMM4),
|
|
||||||
// _DEF_AMD64_REG(XMM5),
|
|
||||||
// _DEF_AMD64_REG(XMM6),
|
|
||||||
// _DEF_AMD64_REG(XMM7),
|
|
||||||
// _DEF_AMD64_REG(XMM0_0),
|
|
||||||
// _DEF_AMD64_REG(XMM0_1),
|
|
||||||
// _DEF_AMD64_REG(XMM0_2),
|
|
||||||
// _DEF_AMD64_REG(XMM0_3),
|
|
||||||
// _DEF_AMD64_REG(XMM1_0),
|
|
||||||
// _DEF_AMD64_REG(XMM1_1),
|
|
||||||
// _DEF_AMD64_REG(XMM1_2),
|
|
||||||
// _DEF_AMD64_REG(XMM1_3),
|
|
||||||
// _DEF_AMD64_REG(XMM2_0),
|
|
||||||
// _DEF_AMD64_REG(XMM2_1),
|
|
||||||
// _DEF_AMD64_REG(XMM2_2),
|
|
||||||
// _DEF_AMD64_REG(XMM2_3),
|
|
||||||
// _DEF_AMD64_REG(XMM3_0),
|
|
||||||
// _DEF_AMD64_REG(XMM3_1),
|
|
||||||
// _DEF_AMD64_REG(XMM3_2),
|
|
||||||
// _DEF_AMD64_REG(XMM3_3),
|
|
||||||
// _DEF_AMD64_REG(XMM4_0),
|
|
||||||
// _DEF_AMD64_REG(XMM4_1),
|
|
||||||
// _DEF_AMD64_REG(XMM4_2),
|
|
||||||
// _DEF_AMD64_REG(XMM4_3),
|
|
||||||
// _DEF_AMD64_REG(XMM5_0),
|
|
||||||
// _DEF_AMD64_REG(XMM5_1),
|
|
||||||
// _DEF_AMD64_REG(XMM5_2),
|
|
||||||
// _DEF_AMD64_REG(XMM5_3),
|
|
||||||
// _DEF_AMD64_REG(XMM6_0),
|
|
||||||
// _DEF_AMD64_REG(XMM6_1),
|
|
||||||
// _DEF_AMD64_REG(XMM6_2),
|
|
||||||
// _DEF_AMD64_REG(XMM6_3),
|
|
||||||
// _DEF_AMD64_REG(XMM7_0),
|
|
||||||
// _DEF_AMD64_REG(XMM7_1),
|
|
||||||
// _DEF_AMD64_REG(XMM7_2),
|
|
||||||
// _DEF_AMD64_REG(XMM7_3),
|
|
||||||
// _DEF_AMD64_REG(XMM0L),
|
|
||||||
// _DEF_AMD64_REG(XMM1L),
|
|
||||||
// _DEF_AMD64_REG(XMM2L),
|
|
||||||
// _DEF_AMD64_REG(XMM3L),
|
|
||||||
// _DEF_AMD64_REG(XMM4L),
|
|
||||||
// _DEF_AMD64_REG(XMM5L),
|
|
||||||
// _DEF_AMD64_REG(XMM6L),
|
|
||||||
// _DEF_AMD64_REG(XMM7L),
|
|
||||||
// _DEF_AMD64_REG(XMM0H),
|
|
||||||
// _DEF_AMD64_REG(XMM1H),
|
|
||||||
// _DEF_AMD64_REG(XMM2H),
|
|
||||||
// _DEF_AMD64_REG(XMM3H),
|
|
||||||
// _DEF_AMD64_REG(XMM4H),
|
|
||||||
// _DEF_AMD64_REG(XMM5H),
|
|
||||||
// _DEF_AMD64_REG(XMM6H),
|
|
||||||
// _DEF_AMD64_REG(XMM7H),
|
|
||||||
// _DEF_AMD64_REG(MXCSR),
|
|
||||||
// _DEF_AMD64_REG(EMM0L),
|
|
||||||
// _DEF_AMD64_REG(EMM1L),
|
|
||||||
// _DEF_AMD64_REG(EMM2L),
|
|
||||||
// _DEF_AMD64_REG(EMM3L),
|
|
||||||
// _DEF_AMD64_REG(EMM4L),
|
|
||||||
// _DEF_AMD64_REG(EMM5L),
|
|
||||||
// _DEF_AMD64_REG(EMM6L),
|
|
||||||
// _DEF_AMD64_REG(EMM7L),
|
|
||||||
// _DEF_AMD64_REG(EMM0H),
|
|
||||||
// _DEF_AMD64_REG(EMM1H),
|
|
||||||
// _DEF_AMD64_REG(EMM2H),
|
|
||||||
// _DEF_AMD64_REG(EMM3H),
|
|
||||||
// _DEF_AMD64_REG(EMM4H),
|
|
||||||
// _DEF_AMD64_REG(EMM5H),
|
|
||||||
// _DEF_AMD64_REG(EMM6H),
|
|
||||||
// _DEF_AMD64_REG(EMM7H),
|
|
||||||
// _DEF_AMD64_REG(MM00),
|
|
||||||
// _DEF_AMD64_REG(MM01),
|
|
||||||
// _DEF_AMD64_REG(MM10),
|
|
||||||
// _DEF_AMD64_REG(MM11),
|
|
||||||
// _DEF_AMD64_REG(MM20),
|
|
||||||
// _DEF_AMD64_REG(MM21),
|
|
||||||
// _DEF_AMD64_REG(MM30),
|
|
||||||
// _DEF_AMD64_REG(MM31),
|
|
||||||
// _DEF_AMD64_REG(MM40),
|
|
||||||
// _DEF_AMD64_REG(MM41),
|
|
||||||
// _DEF_AMD64_REG(MM50),
|
|
||||||
// _DEF_AMD64_REG(MM51),
|
|
||||||
// _DEF_AMD64_REG(MM60),
|
|
||||||
// _DEF_AMD64_REG(MM61),
|
|
||||||
// _DEF_AMD64_REG(MM70),
|
|
||||||
// _DEF_AMD64_REG(MM71),
|
|
||||||
// _DEF_AMD64_REG(XMM8),
|
|
||||||
// _DEF_AMD64_REG(XMM9),
|
|
||||||
// _DEF_AMD64_REG(XMM10),
|
|
||||||
// _DEF_AMD64_REG(XMM11),
|
|
||||||
// _DEF_AMD64_REG(XMM12),
|
|
||||||
// _DEF_AMD64_REG(XMM13),
|
|
||||||
// _DEF_AMD64_REG(XMM14),
|
|
||||||
// _DEF_AMD64_REG(XMM15),
|
|
||||||
// _DEF_AMD64_REG(XMM8_0),
|
|
||||||
// _DEF_AMD64_REG(XMM8_1),
|
|
||||||
// _DEF_AMD64_REG(XMM8_2),
|
|
||||||
// _DEF_AMD64_REG(XMM8_3),
|
|
||||||
// _DEF_AMD64_REG(XMM9_0),
|
|
||||||
// _DEF_AMD64_REG(XMM9_1),
|
|
||||||
// _DEF_AMD64_REG(XMM9_2),
|
|
||||||
// _DEF_AMD64_REG(XMM9_3),
|
|
||||||
// _DEF_AMD64_REG(XMM10_0),
|
|
||||||
// _DEF_AMD64_REG(XMM10_1),
|
|
||||||
// _DEF_AMD64_REG(XMM10_2),
|
|
||||||
// _DEF_AMD64_REG(XMM10_3),
|
|
||||||
// _DEF_AMD64_REG(XMM11_0),
|
|
||||||
// _DEF_AMD64_REG(XMM11_1),
|
|
||||||
// _DEF_AMD64_REG(XMM11_2),
|
|
||||||
// _DEF_AMD64_REG(XMM11_3),
|
|
||||||
// _DEF_AMD64_REG(XMM12_0),
|
|
||||||
// _DEF_AMD64_REG(XMM12_1),
|
|
||||||
// _DEF_AMD64_REG(XMM12_2),
|
|
||||||
// _DEF_AMD64_REG(XMM12_3),
|
|
||||||
// _DEF_AMD64_REG(XMM13_0),
|
|
||||||
// _DEF_AMD64_REG(XMM13_1),
|
|
||||||
// _DEF_AMD64_REG(XMM13_2),
|
|
||||||
// _DEF_AMD64_REG(XMM13_3),
|
|
||||||
// _DEF_AMD64_REG(XMM14_0),
|
|
||||||
// _DEF_AMD64_REG(XMM14_1),
|
|
||||||
// _DEF_AMD64_REG(XMM14_2),
|
|
||||||
// _DEF_AMD64_REG(XMM14_3),
|
|
||||||
// _DEF_AMD64_REG(XMM15_0),
|
|
||||||
// _DEF_AMD64_REG(XMM15_1),
|
|
||||||
// _DEF_AMD64_REG(XMM15_2),
|
|
||||||
// _DEF_AMD64_REG(XMM15_3),
|
|
||||||
// _DEF_AMD64_REG(XMM8L),
|
|
||||||
// _DEF_AMD64_REG(XMM9L),
|
|
||||||
// _DEF_AMD64_REG(XMM10L),
|
|
||||||
// _DEF_AMD64_REG(XMM11L),
|
|
||||||
// _DEF_AMD64_REG(XMM12L),
|
|
||||||
// _DEF_AMD64_REG(XMM13L),
|
|
||||||
// _DEF_AMD64_REG(XMM14L),
|
|
||||||
// _DEF_AMD64_REG(XMM15L),
|
|
||||||
// _DEF_AMD64_REG(XMM8H),
|
|
||||||
// _DEF_AMD64_REG(XMM9H),
|
|
||||||
// _DEF_AMD64_REG(XMM10H),
|
|
||||||
// _DEF_AMD64_REG(XMM11H),
|
|
||||||
// _DEF_AMD64_REG(XMM12H),
|
|
||||||
// _DEF_AMD64_REG(XMM13H),
|
|
||||||
// _DEF_AMD64_REG(XMM14H),
|
|
||||||
// _DEF_AMD64_REG(XMM15H),
|
|
||||||
// _DEF_AMD64_REG(EMM8L),
|
|
||||||
// _DEF_AMD64_REG(EMM9L),
|
|
||||||
// _DEF_AMD64_REG(EMM10L),
|
|
||||||
// _DEF_AMD64_REG(EMM11L),
|
|
||||||
// _DEF_AMD64_REG(EMM12L),
|
|
||||||
// _DEF_AMD64_REG(EMM13L),
|
|
||||||
// _DEF_AMD64_REG(EMM14L),
|
|
||||||
// _DEF_AMD64_REG(EMM15L),
|
|
||||||
// _DEF_AMD64_REG(EMM8H),
|
|
||||||
// _DEF_AMD64_REG(EMM9H),
|
|
||||||
// _DEF_AMD64_REG(EMM10H),
|
|
||||||
// _DEF_AMD64_REG(EMM11H),
|
|
||||||
// _DEF_AMD64_REG(EMM12H),
|
|
||||||
// _DEF_AMD64_REG(EMM13H),
|
|
||||||
// _DEF_AMD64_REG(EMM14H),
|
|
||||||
// _DEF_AMD64_REG(EMM15H),
|
|
||||||
// _DEF_AMD64_REG(SIL),
|
|
||||||
// _DEF_AMD64_REG(DIL),
|
|
||||||
// _DEF_AMD64_REG(BPL),
|
|
||||||
// _DEF_AMD64_REG(SPL),
|
|
||||||
// _DEF_AMD64_REG(RAX),
|
|
||||||
// _DEF_AMD64_REG(RBX),
|
|
||||||
// _DEF_AMD64_REG(RCX),
|
|
||||||
// _DEF_AMD64_REG(RDX),
|
|
||||||
// _DEF_AMD64_REG(RSI),
|
|
||||||
// _DEF_AMD64_REG(RDI),
|
|
||||||
// _DEF_AMD64_REG(RBP),
|
|
||||||
// _DEF_AMD64_REG(RSP),
|
|
||||||
// _DEF_AMD64_REG(R8),
|
|
||||||
// _DEF_AMD64_REG(R9),
|
|
||||||
// _DEF_AMD64_REG(R10),
|
|
||||||
// _DEF_AMD64_REG(R11),
|
|
||||||
// _DEF_AMD64_REG(R12),
|
|
||||||
// _DEF_AMD64_REG(R13),
|
|
||||||
// _DEF_AMD64_REG(R14),
|
|
||||||
// _DEF_AMD64_REG(R15),
|
|
||||||
// _DEF_AMD64_REG(R8B),
|
|
||||||
// _DEF_AMD64_REG(R9B),
|
|
||||||
// _DEF_AMD64_REG(R10B),
|
|
||||||
// _DEF_AMD64_REG(R11B),
|
|
||||||
// _DEF_AMD64_REG(R12B),
|
|
||||||
// _DEF_AMD64_REG(R13B),
|
|
||||||
// _DEF_AMD64_REG(R14B),
|
|
||||||
// _DEF_AMD64_REG(R15B),
|
|
||||||
// _DEF_AMD64_REG(R8W),
|
|
||||||
// _DEF_AMD64_REG(R9W),
|
|
||||||
// _DEF_AMD64_REG(R10W),
|
|
||||||
// _DEF_AMD64_REG(R11W),
|
|
||||||
// _DEF_AMD64_REG(R12W),
|
|
||||||
// _DEF_AMD64_REG(R13W),
|
|
||||||
// _DEF_AMD64_REG(R14W),
|
|
||||||
// _DEF_AMD64_REG(R15W),
|
|
||||||
// _DEF_AMD64_REG(R8D),
|
|
||||||
// _DEF_AMD64_REG(R9D),
|
|
||||||
// _DEF_AMD64_REG(R10D),
|
|
||||||
// _DEF_AMD64_REG(R11D),
|
|
||||||
// _DEF_AMD64_REG(R12D),
|
|
||||||
// _DEF_AMD64_REG(R13D),
|
|
||||||
// _DEF_AMD64_REG(R14D),
|
|
||||||
// _DEF_AMD64_REG(R15D)
|
|
||||||
//};
|
|
||||||
//#undef _DEF_AMD64_REG
|
|
||||||
//
|
|
||||||
//const size_t Symbol::cntAmd64RegName= _countof(amd64RegName);
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
25
pykd/dia/diadecls.h
Normal file
25
pykd/dia/diadecls.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <dia2.h>
|
||||||
|
|
||||||
|
#include "symengine.h"
|
||||||
|
|
||||||
|
#include "dia\diaexcept.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
typedef CComPtr< IDiaSymbol > DiaSymbolPtr;
|
||||||
|
typedef CComPtr< IDiaEnumSymbols > DiaEnumSymbolsPtr;
|
||||||
|
typedef CComPtr< IDiaDataSource > DiaDataSourcePtr;
|
||||||
|
typedef CComPtr< IDiaSession > DiaSessionPtr;
|
||||||
|
typedef CComPtr< IDiaEnumSymbolsByAddr > DiaEnumSymbolsByAddrPtr;
|
||||||
|
typedef CComPtr< IDiaEnumLineNumbers > DiaEnumLineNumbersPtr;
|
||||||
|
typedef CComPtr< IDiaLineNumber> DiaLineNumberPtr;
|
||||||
|
typedef CComPtr< IDiaSourceFile > DiaSourceFilePtr;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
} // end pykd namespace
|
121
pykd/dia/diaexcept.cpp
Normal file
121
pykd/dia/diaexcept.cpp
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "dia\diadecls.h"
|
||||||
|
#include "win\utils.h"
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const std::string DiaException::descPrefix("pyDia: ");
|
||||||
|
|
||||||
|
std::string DiaException::makeFullDesc(const std::string &desc, HRESULT hres, IDiaSymbol *symbol /*= NULL*/)
|
||||||
|
{
|
||||||
|
std::stringstream sstream;
|
||||||
|
sstream << descPrefix << desc << " failed" << std::endl;
|
||||||
|
if (symbol)
|
||||||
|
{
|
||||||
|
BSTR bstrName = NULL;
|
||||||
|
HRESULT locRes = symbol->get_undecoratedName(&bstrName);
|
||||||
|
if (S_OK == locRes && bstrName)
|
||||||
|
{
|
||||||
|
autoBstr freeBstr(bstrName);
|
||||||
|
sstream << "Symbol name: \"" << autoBstr::asStr(bstrName) << "\"";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
locRes = symbol->get_name(&bstrName);
|
||||||
|
if (S_OK == locRes && bstrName)
|
||||||
|
{
|
||||||
|
autoBstr freeBstr(bstrName);
|
||||||
|
sstream << "Symbol name: " << autoBstr::asStr(bstrName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sstream << "Symbol: ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD dwValue;
|
||||||
|
locRes = symbol->get_relativeVirtualAddress(&dwValue);
|
||||||
|
if (S_OK == locRes)
|
||||||
|
{
|
||||||
|
sstream << ", RVA= 0x" << std::hex << dwValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
locRes = symbol->get_symTag(&dwValue);
|
||||||
|
if (S_OK == locRes)
|
||||||
|
{
|
||||||
|
sstream << ", tag= " << std::dec << dwValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
locRes = symbol->get_locationType(&dwValue);
|
||||||
|
if (S_OK == locRes)
|
||||||
|
{
|
||||||
|
sstream << ", location: " << std::dec << dwValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sstream << std::endl;
|
||||||
|
}
|
||||||
|
sstream << "Return value is 0x" << std::hex << hres;
|
||||||
|
|
||||||
|
switch (hres)
|
||||||
|
{
|
||||||
|
#define _CASE_DIA_ERROR(x) case E_PDB_##x: sstream << ": E_PDB_" #x << std::endl; break
|
||||||
|
|
||||||
|
_CASE_DIA_ERROR(USAGE);
|
||||||
|
_CASE_DIA_ERROR(OUT_OF_MEMORY);
|
||||||
|
_CASE_DIA_ERROR(FILE_SYSTEM);
|
||||||
|
_CASE_DIA_ERROR(NOT_FOUND);
|
||||||
|
_CASE_DIA_ERROR(INVALID_SIG);
|
||||||
|
_CASE_DIA_ERROR(INVALID_AGE);
|
||||||
|
_CASE_DIA_ERROR(PRECOMP_REQUIRED);
|
||||||
|
_CASE_DIA_ERROR(OUT_OF_TI);
|
||||||
|
_CASE_DIA_ERROR(NOT_IMPLEMENTED);
|
||||||
|
_CASE_DIA_ERROR(V1_PDB);
|
||||||
|
_CASE_DIA_ERROR(FORMAT);
|
||||||
|
_CASE_DIA_ERROR(LIMIT);
|
||||||
|
_CASE_DIA_ERROR(CORRUPT);
|
||||||
|
_CASE_DIA_ERROR(TI16);
|
||||||
|
_CASE_DIA_ERROR(ACCESS_DENIED);
|
||||||
|
_CASE_DIA_ERROR(ILLEGAL_TYPE_EDIT);
|
||||||
|
_CASE_DIA_ERROR(INVALID_EXECUTABLE);
|
||||||
|
_CASE_DIA_ERROR(DBG_NOT_FOUND);
|
||||||
|
_CASE_DIA_ERROR(NO_DEBUG_INFO);
|
||||||
|
_CASE_DIA_ERROR(INVALID_EXE_TIMESTAMP);
|
||||||
|
_CASE_DIA_ERROR(RESERVED);
|
||||||
|
_CASE_DIA_ERROR(DEBUG_INFO_NOT_IN_PDB);
|
||||||
|
_CASE_DIA_ERROR(SYMSRV_BAD_CACHE_PATH);
|
||||||
|
_CASE_DIA_ERROR(SYMSRV_CACHE_FULL);
|
||||||
|
|
||||||
|
#undef _CASE_DIA_ERROR
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
PCHAR errMessage = NULL;
|
||||||
|
FormatMessageA(
|
||||||
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL,
|
||||||
|
hres,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
(PCHAR)&errMessage,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if (errMessage)
|
||||||
|
{
|
||||||
|
sstream << ": " << std::endl;
|
||||||
|
sstream << errMessage;
|
||||||
|
LocalFree(errMessage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sstream << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sstream.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}; // pykd namespace end
|
39
pykd/dia/diaexcept.h
Normal file
39
pykd/dia/diaexcept.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dbgexcept.h"
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class DiaException : public SymbolException {
|
||||||
|
public:
|
||||||
|
DiaException(const std::string &desc, HRESULT hres, IDiaSymbol *symbol = NULL)
|
||||||
|
: SymbolException( makeFullDesc(desc, hres, symbol) )
|
||||||
|
, m_hres(hres)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DiaException(const std::string &desc)
|
||||||
|
: SymbolException(descPrefix + desc)
|
||||||
|
, m_hres(S_FALSE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT getRes() const {
|
||||||
|
return m_hres;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
|
||||||
|
static const std::string descPrefix;
|
||||||
|
|
||||||
|
static std::string makeFullDesc(const std::string &desc, HRESULT hres, IDiaSymbol *symbol = NULL);
|
||||||
|
|
||||||
|
HRESULT m_hres;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
} // end pykd namespace
|
||||||
|
|
@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "dbghelp.h"
|
#include "dbghelp.h"
|
||||||
#include "dia/diawrapper.h"
|
#include "dbgmem.h"
|
||||||
#include "win/utils.h"
|
|
||||||
#include "dbgengine.h"
|
#include "dbgengine.h"
|
||||||
#include "diacallback.h"
|
#include "win/utils.h"
|
||||||
|
#include "dia/diasession.h"
|
||||||
|
#include "dia/diacallback.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -217,7 +218,7 @@ protected:
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SymbolSessionPtr loadSymbolFile(const std::string &filePath, ULONGLONG loadBase )
|
SymbolSessionPtr loadSymbolFile(const std::string &filePath, ULONGLONG loadBase )
|
||||||
{
|
{
|
||||||
diaLoad::DataFromPdb dataFromPdb(filePath);
|
diaLoad::DataFromPdb dataFromPdb(filePath);
|
||||||
return diaLoad::createSession(dataFromPdb, loadBase, filePath);
|
return diaLoad::createSession(dataFromPdb, loadBase, filePath);
|
||||||
|
77
pykd/dia/diasession.cpp
Normal file
77
pykd/dia/diasession.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include "dbghelp.h"
|
||||||
|
#include "dia\diasession.h"
|
||||||
|
#include "win\utils.h"
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
SymbolPtr DiaSession::findByRva( ULONG rva, ULONG symTag, LONG* pdisplacement )
|
||||||
|
{
|
||||||
|
DiaSymbolPtr child;
|
||||||
|
LONG displacement;
|
||||||
|
|
||||||
|
HRESULT hres =
|
||||||
|
m_session->findSymbolByRVAEx(
|
||||||
|
rva,
|
||||||
|
static_cast<enum ::SymTagEnum>(symTag),
|
||||||
|
&child,
|
||||||
|
&displacement);
|
||||||
|
|
||||||
|
if (S_OK != hres)
|
||||||
|
throw DiaException("Call IDiaSession::findSymbolByRVAEx", hres);
|
||||||
|
if (!child)
|
||||||
|
throw DiaException("Call IDiaSession::findSymbolByRVAEx", E_UNEXPECTED);
|
||||||
|
if ( !pdisplacement && displacement)
|
||||||
|
throw DiaException("Call IDiaSession::findSymbolByRVAEx failed to find suymbol" );
|
||||||
|
|
||||||
|
if (pdisplacement)
|
||||||
|
*pdisplacement = displacement;
|
||||||
|
|
||||||
|
return SymbolPtr( new DiaSymbol(child, m_globalSymbol->getMachineType() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void DiaSession::getSourceLine( ULONG64 offset, std::string &fileName, ULONG &lineNo, LONG &displacement )
|
||||||
|
{
|
||||||
|
DiaEnumLineNumbersPtr lines;
|
||||||
|
|
||||||
|
HRESULT hres = m_session->findLinesByVA( offset, 1, &lines );
|
||||||
|
if (S_OK != hres)
|
||||||
|
throw DiaException("failed to find source line");
|
||||||
|
|
||||||
|
DiaLineNumberPtr sourceLine;
|
||||||
|
hres = lines->Item( 0, &sourceLine );
|
||||||
|
if (S_OK != hres)
|
||||||
|
throw DiaException("failed to find source line");
|
||||||
|
|
||||||
|
DiaSourceFilePtr sourceFile;
|
||||||
|
hres = sourceLine->get_sourceFile( &sourceFile );
|
||||||
|
if (S_OK != hres)
|
||||||
|
throw DiaException("failed to find source line");
|
||||||
|
|
||||||
|
autoBstr fileNameBstr;
|
||||||
|
hres = sourceFile->get_fileName ( &fileNameBstr );
|
||||||
|
if (S_OK != hres)
|
||||||
|
throw DiaException("failed to find source line");
|
||||||
|
fileName = fileNameBstr.asStr();
|
||||||
|
|
||||||
|
hres = sourceLine->get_lineNumber( &lineNo );
|
||||||
|
if (S_OK != hres)
|
||||||
|
throw DiaException("failed to find source line");
|
||||||
|
|
||||||
|
ULONGLONG va;
|
||||||
|
hres = sourceLine->get_virtualAddress ( &va );
|
||||||
|
if (S_OK != hres)
|
||||||
|
throw DiaException("failed to find source line");
|
||||||
|
|
||||||
|
displacement = (LONG)( (LONGLONG)offset - (LONGLONG)va );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}; // pykd namespace end
|
48
pykd/dia/diasession.h
Normal file
48
pykd/dia/diasession.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dia\diadecls.h"
|
||||||
|
#include "dia\diasymbol.h"
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class DiaSession : public SymbolSession
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
DiaSession( IDiaSession* session, IDiaSymbol *globalScope, const std::string symbolFile ) :
|
||||||
|
m_globalScope( globalScope ),
|
||||||
|
m_globalSymbol( DiaSymbol::fromGlobalScope( globalScope ) ),
|
||||||
|
m_session( session ),
|
||||||
|
m_symbolFileName( symbolFile )
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual SymbolPtr getSymbolScope() {
|
||||||
|
return m_globalSymbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual SymbolPtr findByRva( ULONG rva, ULONG symTag = SymTagNull, LONG* displacement = NULL );
|
||||||
|
|
||||||
|
virtual void getSourceLine( ULONG64 offset, std::string &fileName, ULONG &lineNo, LONG &displacement );
|
||||||
|
|
||||||
|
virtual std::string getSymbolFileName() {
|
||||||
|
return m_symbolFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
ULONG findRvaByName( const std::string &name );
|
||||||
|
|
||||||
|
DiaSymbolPtr m_globalScope;
|
||||||
|
SymbolPtr m_globalSymbol;
|
||||||
|
DiaSessionPtr m_session;
|
||||||
|
std::string m_symbolFileName;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
} // end pykd namespace
|
||||||
|
|
@ -1,152 +1,12 @@
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "dbghelp.h"
|
#include "dbghelp.h"
|
||||||
#include "dia/diawrapper.h"
|
#include "dia/diasymbol.h"
|
||||||
#include "win/utils.h"
|
#include "win/utils.h"
|
||||||
|
|
||||||
namespace pykd {
|
namespace pykd {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static const struct DiaRegToRegRelativeAmd64 : DiaRegToRegRelativeBase
|
|
||||||
{
|
|
||||||
typedef std::map<ULONG, ULONG> Base;
|
|
||||||
DiaRegToRegRelativeAmd64();
|
|
||||||
} g_DiaRegToRegRelativeAmd64;
|
|
||||||
|
|
||||||
DiaRegToRegRelativeAmd64::DiaRegToRegRelativeAmd64()
|
|
||||||
{
|
|
||||||
(*this)[CV_AMD64_RIP] = rriInstructionPointer;
|
|
||||||
(*this)[CV_AMD64_RBP] = rriStackFrame;
|
|
||||||
(*this)[CV_AMD64_RSP] = rriStackPointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static const struct DiaRegToRegRelativeI386 : DiaRegToRegRelativeBase
|
|
||||||
{
|
|
||||||
typedef std::map<ULONG, ULONG> Base;
|
|
||||||
DiaRegToRegRelativeI386();
|
|
||||||
} g_DiaRegToRegRelativeI386;
|
|
||||||
|
|
||||||
DiaRegToRegRelativeI386::DiaRegToRegRelativeI386()
|
|
||||||
{
|
|
||||||
(*this)[CV_REG_EIP] = rriInstructionPointer;
|
|
||||||
(*this)[CV_REG_EBP] = rriStackFrame;
|
|
||||||
(*this)[CV_REG_ESP] = rriStackPointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
const std::string DiaException::descPrefix("pyDia: ");
|
|
||||||
|
|
||||||
std::string DiaException::makeFullDesc(const std::string &desc, HRESULT hres, IDiaSymbol *symbol /*= NULL*/)
|
|
||||||
{
|
|
||||||
std::stringstream sstream;
|
|
||||||
sstream << descPrefix << desc << " failed" << std::endl;
|
|
||||||
if (symbol)
|
|
||||||
{
|
|
||||||
BSTR bstrName = NULL;
|
|
||||||
HRESULT locRes = symbol->get_undecoratedName(&bstrName);
|
|
||||||
if (S_OK == locRes && bstrName)
|
|
||||||
{
|
|
||||||
autoBstr freeBstr(bstrName);
|
|
||||||
sstream << "Symbol name: \"" << autoBstr::asStr(bstrName) << "\"";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
locRes = symbol->get_name(&bstrName);
|
|
||||||
if (S_OK == locRes && bstrName)
|
|
||||||
{
|
|
||||||
autoBstr freeBstr(bstrName);
|
|
||||||
sstream << "Symbol name: " << autoBstr::asStr(bstrName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sstream << "Symbol: ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD dwValue;
|
|
||||||
locRes = symbol->get_relativeVirtualAddress(&dwValue);
|
|
||||||
if (S_OK == locRes)
|
|
||||||
{
|
|
||||||
sstream << ", RVA= 0x" << std::hex << dwValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
locRes = symbol->get_symTag(&dwValue);
|
|
||||||
if (S_OK == locRes)
|
|
||||||
{
|
|
||||||
sstream << ", tag= " << std::dec << dwValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
locRes = symbol->get_locationType(&dwValue);
|
|
||||||
if (S_OK == locRes)
|
|
||||||
{
|
|
||||||
sstream << ", location: " << std::dec << dwValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sstream << std::endl;
|
|
||||||
}
|
|
||||||
sstream << "Return value is 0x" << std::hex << hres;
|
|
||||||
|
|
||||||
switch (hres)
|
|
||||||
{
|
|
||||||
#define _CASE_DIA_ERROR(x) case E_PDB_##x: sstream << ": E_PDB_" #x << std::endl; break
|
|
||||||
|
|
||||||
_CASE_DIA_ERROR(USAGE);
|
|
||||||
_CASE_DIA_ERROR(OUT_OF_MEMORY);
|
|
||||||
_CASE_DIA_ERROR(FILE_SYSTEM);
|
|
||||||
_CASE_DIA_ERROR(NOT_FOUND);
|
|
||||||
_CASE_DIA_ERROR(INVALID_SIG);
|
|
||||||
_CASE_DIA_ERROR(INVALID_AGE);
|
|
||||||
_CASE_DIA_ERROR(PRECOMP_REQUIRED);
|
|
||||||
_CASE_DIA_ERROR(OUT_OF_TI);
|
|
||||||
_CASE_DIA_ERROR(NOT_IMPLEMENTED);
|
|
||||||
_CASE_DIA_ERROR(V1_PDB);
|
|
||||||
_CASE_DIA_ERROR(FORMAT);
|
|
||||||
_CASE_DIA_ERROR(LIMIT);
|
|
||||||
_CASE_DIA_ERROR(CORRUPT);
|
|
||||||
_CASE_DIA_ERROR(TI16);
|
|
||||||
_CASE_DIA_ERROR(ACCESS_DENIED);
|
|
||||||
_CASE_DIA_ERROR(ILLEGAL_TYPE_EDIT);
|
|
||||||
_CASE_DIA_ERROR(INVALID_EXECUTABLE);
|
|
||||||
_CASE_DIA_ERROR(DBG_NOT_FOUND);
|
|
||||||
_CASE_DIA_ERROR(NO_DEBUG_INFO);
|
|
||||||
_CASE_DIA_ERROR(INVALID_EXE_TIMESTAMP);
|
|
||||||
_CASE_DIA_ERROR(RESERVED);
|
|
||||||
_CASE_DIA_ERROR(DEBUG_INFO_NOT_IN_PDB);
|
|
||||||
_CASE_DIA_ERROR(SYMSRV_BAD_CACHE_PATH);
|
|
||||||
_CASE_DIA_ERROR(SYMSRV_CACHE_FULL);
|
|
||||||
|
|
||||||
#undef _CASE_DIA_ERROR
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
PCHAR errMessage = NULL;
|
|
||||||
FormatMessageA(
|
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
||||||
NULL,
|
|
||||||
hres,
|
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
||||||
(PCHAR)&errMessage,
|
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
if (errMessage)
|
|
||||||
{
|
|
||||||
sstream << ": " << std::endl;
|
|
||||||
sstream << errMessage;
|
|
||||||
LocalFree(errMessage);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sstream << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sstream.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define callSymbol(method) \
|
#define callSymbol(method) \
|
||||||
@ -415,22 +275,22 @@ ULONG DiaSymbol::getRegRealativeId()
|
|||||||
switch (m_machineType)
|
switch (m_machineType)
|
||||||
{
|
{
|
||||||
case IMAGE_FILE_MACHINE_AMD64:
|
case IMAGE_FILE_MACHINE_AMD64:
|
||||||
return getRegRealativeIdImpl(g_DiaRegToRegRelativeAmd64);
|
return getRegRealativeIdImpl(regToRegRelativeAmd64);
|
||||||
case IMAGE_FILE_MACHINE_I386:
|
case IMAGE_FILE_MACHINE_I386:
|
||||||
return getRegRealativeIdImpl(g_DiaRegToRegRelativeI386);
|
return getRegRealativeIdImpl(regToRegRelativeI386);
|
||||||
}
|
}
|
||||||
throw DiaException("Unsupported machine type");
|
throw DiaException("Unsupported machine type");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ULONG DiaSymbol::getRegRealativeIdImpl(const DiaRegToRegRelativeBase &DiaRegToRegRelative)
|
ULONG DiaSymbol::getRegRealativeIdImpl(const DiaRegToRegRelativeBase ®ToRegRelative)
|
||||||
{
|
{
|
||||||
DiaRegToRegRelativeBase::const_iterator it =
|
DiaRegToRegRelativeBase::const_iterator it =
|
||||||
DiaRegToRegRelative.find(callSymbol(get_registerId));
|
regToRegRelative.find(callSymbol(get_registerId));
|
||||||
|
|
||||||
if (it == DiaRegToRegRelative.end())
|
if (it == regToRegRelative.end())
|
||||||
throw DiaException("Cannot convert DAI register ID to relative register ID");
|
throw DiaException("Cannot convert DIA register ID to relative register ID");
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
@ -678,70 +538,5 @@ bool DiaSymbol::isVirtualBaseClass()
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SymbolPtr DiaSession::findByRva( ULONG rva, ULONG symTag, LONG* pdisplacement )
|
}; // pykd namespace end
|
||||||
{
|
|
||||||
DiaSymbolPtr child;
|
|
||||||
LONG displacement;
|
|
||||||
|
|
||||||
HRESULT hres =
|
|
||||||
m_session->findSymbolByRVAEx(
|
|
||||||
rva,
|
|
||||||
static_cast<enum ::SymTagEnum>(symTag),
|
|
||||||
&child,
|
|
||||||
&displacement);
|
|
||||||
|
|
||||||
if (S_OK != hres)
|
|
||||||
throw DiaException("Call IDiaSession::findSymbolByRVAEx", hres);
|
|
||||||
if (!child)
|
|
||||||
throw DiaException("Call IDiaSession::findSymbolByRVAEx", E_UNEXPECTED);
|
|
||||||
if ( !pdisplacement && displacement)
|
|
||||||
throw DiaException("Call IDiaSession::findSymbolByRVAEx failed to find suymbol" );
|
|
||||||
|
|
||||||
if (pdisplacement)
|
|
||||||
*pdisplacement = displacement;
|
|
||||||
|
|
||||||
return SymbolPtr( new DiaSymbol(child, m_globalSymbol->getMachineType() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void DiaSession::getSourceLine( ULONG64 offset, std::string &fileName, ULONG &lineNo, LONG &displacement )
|
|
||||||
{
|
|
||||||
DiaEnumLineNumbersPtr lines;
|
|
||||||
|
|
||||||
HRESULT hres = m_session->findLinesByVA( offset, 1, &lines );
|
|
||||||
if (S_OK != hres)
|
|
||||||
throw DiaException("failed to find source line");
|
|
||||||
|
|
||||||
DiaLineNumberPtr sourceLine;
|
|
||||||
hres = lines->Item( 0, &sourceLine );
|
|
||||||
if (S_OK != hres)
|
|
||||||
throw DiaException("failed to find source line");
|
|
||||||
|
|
||||||
DiaSourceFilePtr sourceFile;
|
|
||||||
hres = sourceLine->get_sourceFile( &sourceFile );
|
|
||||||
if (S_OK != hres)
|
|
||||||
throw DiaException("failed to find source line");
|
|
||||||
|
|
||||||
autoBstr fileNameBstr;
|
|
||||||
hres = sourceFile->get_fileName ( &fileNameBstr );
|
|
||||||
if (S_OK != hres)
|
|
||||||
throw DiaException("failed to find source line");
|
|
||||||
fileName = fileNameBstr.asStr();
|
|
||||||
|
|
||||||
hres = sourceLine->get_lineNumber( &lineNo );
|
|
||||||
if (S_OK != hres)
|
|
||||||
throw DiaException("failed to find source line");
|
|
||||||
|
|
||||||
ULONGLONG va;
|
|
||||||
hres = sourceLine->get_virtualAddress ( &va );
|
|
||||||
if (S_OK != hres)
|
|
||||||
throw DiaException("failed to find source line");
|
|
||||||
|
|
||||||
displacement = (LONG)( (LONGLONG)offset - (LONGLONG)va );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
}; // pykd nemaspace end
|
|
||||||
|
|
139
pykd/dia/diasymbol.h
Normal file
139
pykd/dia/diasymbol.h
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dia\diadecls.h"
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
typedef std::map<ULONG, ULONG> DiaRegToRegRelativeBase;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class DiaSymbol : public Symbol {
|
||||||
|
public:
|
||||||
|
DiaSymbol( DiaSymbolPtr &_symbol, DWORD machineType );
|
||||||
|
|
||||||
|
static SymbolPtr fromGlobalScope( IDiaSymbol *_symbol );
|
||||||
|
|
||||||
|
SymbolPtr getChildByName(const std::string &_name );
|
||||||
|
|
||||||
|
ULONG getRva();
|
||||||
|
|
||||||
|
SymbolPtrList findChildren(
|
||||||
|
ULONG symTag,
|
||||||
|
const std::string &name = "",
|
||||||
|
bool caseSensitive = FALSE
|
||||||
|
);
|
||||||
|
|
||||||
|
ULONGLONG getSize();
|
||||||
|
|
||||||
|
std::string getName();
|
||||||
|
|
||||||
|
SymbolPtr getType();
|
||||||
|
|
||||||
|
SymbolPtr getIndexType();
|
||||||
|
|
||||||
|
ULONG getSymTag();
|
||||||
|
|
||||||
|
ULONGLONG getVa();
|
||||||
|
|
||||||
|
ULONG getLocType();
|
||||||
|
|
||||||
|
LONG getOffset();
|
||||||
|
|
||||||
|
ULONG getCount();
|
||||||
|
|
||||||
|
void getValue( BaseTypeVariant &vtValue );
|
||||||
|
|
||||||
|
bool isBasicType();
|
||||||
|
|
||||||
|
bool isIndirectVirtualBaseClass();
|
||||||
|
|
||||||
|
bool isVirtualBaseClass();
|
||||||
|
|
||||||
|
ULONG getBaseType();
|
||||||
|
|
||||||
|
ULONG getBitPosition();
|
||||||
|
|
||||||
|
ULONG getIndexId();
|
||||||
|
|
||||||
|
ULONG getUdtKind();
|
||||||
|
|
||||||
|
ULONG getDataKind();
|
||||||
|
|
||||||
|
//ULONG getRegisterId();
|
||||||
|
virtual ULONG getRegRealativeId() override;
|
||||||
|
|
||||||
|
ULONG getMachineType() {
|
||||||
|
return m_machineType;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SymbolPtr getChildByName(const std::string &_name);
|
||||||
|
|
||||||
|
ULONG getChildCount( ULONG symTag );
|
||||||
|
|
||||||
|
ULONG getChildCount() {
|
||||||
|
return getChildCount(SymTagNull);
|
||||||
|
}
|
||||||
|
|
||||||
|
SymbolPtr getChildByIndex(ULONG symTag, ULONG _index );
|
||||||
|
|
||||||
|
SymbolPtr getChildByIndex(ULONG _index ) {
|
||||||
|
return getChildByIndex( SymTagNull, _index );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isConstant();
|
||||||
|
|
||||||
|
//std::string print();
|
||||||
|
|
||||||
|
//bool eq(Symbol &rhs);
|
||||||
|
|
||||||
|
int getVirtualBasePointerOffset();
|
||||||
|
|
||||||
|
ULONG getVirtualBaseDispIndex();
|
||||||
|
|
||||||
|
ULONG getVirtualBaseDispSize();
|
||||||
|
|
||||||
|
//ULONG getSection();
|
||||||
|
|
||||||
|
void setLoadAddress( ULONGLONG baseAddress );
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef std::pair<ULONG, const char *> ValueNameEntry;
|
||||||
|
|
||||||
|
static const ValueNameEntry basicTypeName[];
|
||||||
|
static const size_t cntBasicTypeName;
|
||||||
|
|
||||||
|
static std::string getBasicTypeName( ULONG basicType );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static const DiaRegToRegRelativeBase ®ToRegRelativeAmd64;
|
||||||
|
static const DiaRegToRegRelativeBase ®ToRegRelativeI386;
|
||||||
|
ULONG getRegRealativeIdImpl(const DiaRegToRegRelativeBase &DiaRegToRegRelative);
|
||||||
|
|
||||||
|
template <typename TRet>
|
||||||
|
TRet callSymbolT(
|
||||||
|
HRESULT(STDMETHODCALLTYPE IDiaSymbol::*method)(TRet *),
|
||||||
|
const char *methodName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
TRet retValue;
|
||||||
|
HRESULT hres = (m_symbol->*method)(&retValue);
|
||||||
|
if (S_OK != hres)
|
||||||
|
throw DiaException(std::string("Call IDiaSymbol::") + methodName, hres, m_symbol);
|
||||||
|
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DiaSymbolPtr m_symbol;
|
||||||
|
|
||||||
|
DWORD m_machineType;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
} // end pykd namespace
|
||||||
|
|
@ -1,258 +0,0 @@
|
|||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "symengine.h"
|
|
||||||
#include "dbgexcept.h"
|
|
||||||
|
|
||||||
#include <dia2.h>
|
|
||||||
|
|
||||||
namespace pykd {
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
typedef CComPtr< IDiaSymbol > DiaSymbolPtr;
|
|
||||||
typedef CComPtr< IDiaEnumSymbols > DiaEnumSymbolsPtr;
|
|
||||||
typedef CComPtr< IDiaDataSource > DiaDataSourcePtr;
|
|
||||||
typedef CComPtr< IDiaSession > DiaSessionPtr;
|
|
||||||
typedef CComPtr< IDiaEnumSymbolsByAddr > DiaEnumSymbolsByAddrPtr;
|
|
||||||
typedef CComPtr< IDiaEnumLineNumbers > DiaEnumLineNumbersPtr;
|
|
||||||
typedef CComPtr< IDiaLineNumber> DiaLineNumberPtr;
|
|
||||||
typedef CComPtr< IDiaSourceFile > DiaSourceFilePtr;
|
|
||||||
|
|
||||||
typedef std::map<ULONG, ULONG> DiaRegToRegRelativeBase;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class DiaException : public SymbolException {
|
|
||||||
public:
|
|
||||||
DiaException(const std::string &desc, HRESULT hres, IDiaSymbol *symbol = NULL)
|
|
||||||
: SymbolException( makeFullDesc(desc, hres, symbol) )
|
|
||||||
, m_hres(hres)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DiaException(const std::string &desc)
|
|
||||||
: SymbolException(descPrefix + desc)
|
|
||||||
, m_hres(S_FALSE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT getRes() const {
|
|
||||||
return m_hres;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
|
|
||||||
static const std::string descPrefix;
|
|
||||||
|
|
||||||
static std::string makeFullDesc(const std::string &desc, HRESULT hres, IDiaSymbol *symbol = NULL);
|
|
||||||
|
|
||||||
HRESULT m_hres;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class DiaSymbol : public Symbol {
|
|
||||||
public:
|
|
||||||
DiaSymbol( DiaSymbolPtr &_symbol, DWORD machineType );
|
|
||||||
|
|
||||||
static SymbolPtr fromGlobalScope( IDiaSymbol *_symbol );
|
|
||||||
|
|
||||||
SymbolPtr getChildByName(const std::string &_name );
|
|
||||||
|
|
||||||
ULONG getRva();
|
|
||||||
|
|
||||||
SymbolPtrList findChildren(
|
|
||||||
ULONG symTag,
|
|
||||||
const std::string &name = "",
|
|
||||||
bool caseSensitive = FALSE
|
|
||||||
);
|
|
||||||
|
|
||||||
ULONGLONG getSize();
|
|
||||||
|
|
||||||
std::string getName();
|
|
||||||
|
|
||||||
SymbolPtr getType();
|
|
||||||
|
|
||||||
SymbolPtr getIndexType();
|
|
||||||
|
|
||||||
ULONG getSymTag();
|
|
||||||
|
|
||||||
ULONGLONG getVa();
|
|
||||||
|
|
||||||
ULONG getLocType();
|
|
||||||
|
|
||||||
LONG getOffset();
|
|
||||||
|
|
||||||
ULONG getCount();
|
|
||||||
|
|
||||||
void getValue( BaseTypeVariant &vtValue );
|
|
||||||
|
|
||||||
bool isBasicType();
|
|
||||||
|
|
||||||
bool isIndirectVirtualBaseClass();
|
|
||||||
|
|
||||||
bool isVirtualBaseClass();
|
|
||||||
|
|
||||||
ULONG getBaseType();
|
|
||||||
|
|
||||||
ULONG getBitPosition();
|
|
||||||
|
|
||||||
ULONG getIndexId();
|
|
||||||
|
|
||||||
ULONG getUdtKind();
|
|
||||||
|
|
||||||
ULONG getDataKind();
|
|
||||||
|
|
||||||
//ULONG getRegisterId();
|
|
||||||
virtual ULONG getRegRealativeId() override;
|
|
||||||
|
|
||||||
ULONG getMachineType() {
|
|
||||||
return m_machineType;
|
|
||||||
}
|
|
||||||
|
|
||||||
//SymbolPtr getChildByName(const std::string &_name);
|
|
||||||
|
|
||||||
ULONG getChildCount( ULONG symTag );
|
|
||||||
|
|
||||||
ULONG getChildCount() {
|
|
||||||
return getChildCount(SymTagNull);
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolPtr getChildByIndex(ULONG symTag, ULONG _index );
|
|
||||||
|
|
||||||
SymbolPtr getChildByIndex(ULONG _index ) {
|
|
||||||
return getChildByIndex( SymTagNull, _index );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isConstant();
|
|
||||||
|
|
||||||
//std::string print();
|
|
||||||
|
|
||||||
//bool eq(Symbol &rhs);
|
|
||||||
|
|
||||||
int getVirtualBasePointerOffset();
|
|
||||||
|
|
||||||
ULONG getVirtualBaseDispIndex();
|
|
||||||
|
|
||||||
ULONG getVirtualBaseDispSize();
|
|
||||||
|
|
||||||
//ULONG getSection();
|
|
||||||
|
|
||||||
void setLoadAddress( ULONGLONG baseAddress );
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef std::pair<ULONG, const char *> ValueNameEntry;
|
|
||||||
|
|
||||||
//static const ValueNameEntry dataKindName[DataIsConstant + 1];
|
|
||||||
|
|
||||||
//static const ValueNameEntry symTagName[SymTagMax];
|
|
||||||
|
|
||||||
//static const ValueNameEntry locTypeName[LocTypeMax];
|
|
||||||
|
|
||||||
static const ValueNameEntry basicTypeName[];
|
|
||||||
static const size_t cntBasicTypeName;
|
|
||||||
|
|
||||||
//static const ValueNameEntry udtKindName[];
|
|
||||||
//static const size_t cntUdtKindName;
|
|
||||||
|
|
||||||
//static const ValueNameEntry i386RegName[];
|
|
||||||
//static const size_t cntI386RegName;
|
|
||||||
|
|
||||||
//static const ValueNameEntry amd64RegName[];
|
|
||||||
//static const size_t cntAmd64RegName;
|
|
||||||
|
|
||||||
static std::string getBasicTypeName( ULONG basicType );
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
//// Check symbols loop
|
|
||||||
//class checkSymLoop
|
|
||||||
//{
|
|
||||||
//public:
|
|
||||||
// checkSymLoop(checkSymLoop *prev)
|
|
||||||
// : m_symSetPtr( prev ? prev->m_symSetPtr : symSetPtr(new symSet) )
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// bool check(IDiaSymbol *_symbol)
|
|
||||||
// {
|
|
||||||
// DWORD symIndexId = 0;
|
|
||||||
// _symbol->get_symIndexId(&symIndexId);
|
|
||||||
// return !m_symSetPtr->insert(symIndexId).second;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//private:
|
|
||||||
// typedef std::set<DWORD> symSet;
|
|
||||||
// typedef boost::shared_ptr<symSet> symSetPtr;
|
|
||||||
// symSetPtr m_symSetPtr;
|
|
||||||
//};
|
|
||||||
|
|
||||||
//static std::string printImpl(
|
|
||||||
// IDiaSymbol *_symbol,
|
|
||||||
// DWORD machineType,
|
|
||||||
// ULONG indent = 0,
|
|
||||||
// checkSymLoop *checkLoopPrev = NULL,
|
|
||||||
// const char *prefix = NULL
|
|
||||||
//);
|
|
||||||
|
|
||||||
ULONG getRegRealativeIdImpl(const DiaRegToRegRelativeBase &DiaRegToRegRelative);
|
|
||||||
|
|
||||||
template <typename TRet>
|
|
||||||
TRet callSymbolT(
|
|
||||||
HRESULT(STDMETHODCALLTYPE IDiaSymbol::*method)(TRet *),
|
|
||||||
const char *methodName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
TRet retValue;
|
|
||||||
HRESULT hres = (m_symbol->*method)(&retValue);
|
|
||||||
if (S_OK != hres)
|
|
||||||
throw DiaException(std::string("Call IDiaSymbol::") + methodName, hres, m_symbol);
|
|
||||||
|
|
||||||
return retValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DiaSymbolPtr m_symbol;
|
|
||||||
|
|
||||||
DWORD m_machineType;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class DiaSession : public SymbolSession
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
DiaSession( IDiaSession* session, IDiaSymbol *globalScope, const std::string symbolFile ) :
|
|
||||||
m_globalScope( globalScope ),
|
|
||||||
m_globalSymbol( DiaSymbol::fromGlobalScope( globalScope ) ),
|
|
||||||
m_session( session ),
|
|
||||||
m_symbolFileName( symbolFile )
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual SymbolPtr getSymbolScope() {
|
|
||||||
return m_globalSymbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual SymbolPtr findByRva( ULONG rva, ULONG symTag = SymTagNull, LONG* displacement = NULL );
|
|
||||||
|
|
||||||
virtual void getSourceLine( ULONG64 offset, std::string &fileName, ULONG &lineNo, LONG &displacement );
|
|
||||||
|
|
||||||
virtual std::string getSymbolFileName() {
|
|
||||||
return m_symbolFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
ULONG findRvaByName( const std::string &name );
|
|
||||||
|
|
||||||
DiaSymbolPtr m_globalScope;
|
|
||||||
SymbolPtr m_globalSymbol;
|
|
||||||
DiaSessionPtr m_session;
|
|
||||||
std::string m_symbolFileName;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
} // end pykd namespace
|
|
||||||
|
|
@ -625,16 +625,36 @@
|
|||||||
RelativePath=".\dia\diadata.cpp"
|
RelativePath=".\dia\diadata.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\dia\diadecls.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\dia\diaexcept.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\dia\diaexcept.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dia\diaload.cpp"
|
RelativePath=".\dia\diaload.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dia\diawrapper.cpp"
|
RelativePath=".\dia\diasession.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dia\diawrapper.h"
|
RelativePath=".\dia\diasession.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\dia\diasymbol.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\dia\diasymbol.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
Loading…
Reference in New Issue
Block a user