{+ prev commit}

[+]  DIA symbol wrapper
[+]  DIA exception

git-svn-id: https://pykd.svn.codeplex.com/svn@69805 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2011-09-16 18:07:00 +00:00 committed by Mikhail I. Izmestev
parent b63e923b3e
commit 586995de47
2 changed files with 70 additions and 70 deletions

View File

@ -1,6 +1,8 @@
#include "stdafx.h" #include "stdafx.h"
#include <dbgeng.h> #include <dbgeng.h>
#include <dia2.h>
#include <cvconst.h> #include <cvconst.h>
#include "module.h" #include "module.h"
@ -72,14 +74,11 @@ pycmd( PDEBUG_CLIENT4 client, PCSTR args )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define DEF_PY_CONST(x) \ #define DEF_PY_CONST_ULONG(x) \
python::scope().attr(#x) = ##x python::scope().attr(#x) = ULONG(##x)
BOOST_PYTHON_MODULE( pykd ) BOOST_PYTHON_MODULE( pykd )
{ {
python::def( "diaOpenPdb", &pyDia::GlobalScope::openPdb,
"Open pdb file for quering debug symbols. Return DiaSymbol of global scope");
python::class_<pykd::DebugClient>("dbgClient", "Class representing a debugging session" ) python::class_<pykd::DebugClient>("dbgClient", "Class representing a debugging session" )
.def( "loadDump", &pykd::DebugClient::loadDump, "Load crash dump" ) .def( "loadDump", &pykd::DebugClient::loadDump, "Load crash dump" )
.def( "startProcess", &pykd::DebugClient::startProcess, "Start process for debugging" ) .def( "startProcess", &pykd::DebugClient::startProcess, "Start process for debugging" )
@ -89,15 +88,23 @@ BOOST_PYTHON_MODULE( pykd )
python::class_<pykd::Module>("module", "Class representing executable module", python::no_init ) python::class_<pykd::Module>("module", "Class representing executable module", python::no_init )
.def( python::init<std::string>( "constructor" ) ); .def( python::init<std::string>( "constructor" ) );
python::def( "diaOpenPdb", &pyDia::GlobalScope::openPdb,
"Open pdb file for quering debug symbols. Return DiaSymbol of global scope");
python::class_<pyDia::Symbol>("DiaSymbol", "class wrapper for MS DIA Symbol" ) python::class_<pyDia::Symbol>("DiaSymbol", "class wrapper for MS DIA Symbol" )
.def( "findChildrenNoCase", &pyDia::Symbol::findChildrenNoCase, .def( "findEx", &pyDia::Symbol::findChildrenImpl,
"Retrieves the children of the symbol. Case Insensitive. SymTagNull for all symbols" ) "Retrieves the children of the symbol" )
.def( "findChildren", &pyDia::Symbol::findChildren, .def( "find", &pyDia::Symbol::findChildren,
"Retrieves the children of the symbol. SymTagNull for all symbols" ) "Retrieves the children of the symbol" )
.def( "size", &pyDia::Symbol::getSize, .def( "size", &pyDia::Symbol::getSize,
"Retrieves the number of bits or bytes of memory used by the object represented by this symbol" ) "Retrieves the number of bits or bytes of memory used by the object represented by this symbol" )
.def( "symTag", &pyDia::Symbol::getSymTag, //.def( "getName", &pyDia::Symbol::getName,
// "Retrieves the name of the symbol" )
//.def( "getType", &pyDia::Symbol::getType,
// "Retrieves the symbol that represents the type for this symbol" )
.def( "getSymTag", &pyDia::Symbol::getSymTag,
"Retrieves the symbol type classifier: SymTagXxx" ) "Retrieves the symbol type classifier: SymTagXxx" )
//__str__ &pyDia::Symbol::print
.def("__getattr__", &pyDia::Symbol::getChildByName) .def("__getattr__", &pyDia::Symbol::getChildByName)
.def("__len__", &pyDia::Symbol::getChildCount ) .def("__len__", &pyDia::Symbol::getChildCount )
.def("__getitem__", &pyDia::Symbol::getChildByIndex); .def("__getitem__", &pyDia::Symbol::getChildByIndex);
@ -105,40 +112,51 @@ BOOST_PYTHON_MODULE( pykd )
python::class_<pyDia::GlobalScope, python::bases<pyDia::Symbol> >("DiaScope", "class wrapper for MS DIA Symbol" ); python::class_<pyDia::GlobalScope, python::bases<pyDia::Symbol> >("DiaScope", "class wrapper for MS DIA Symbol" );
// type of symbol // type of symbol
DEF_PY_CONST(SymTagNull); DEF_PY_CONST_ULONG(SymTagNull);
DEF_PY_CONST(SymTagExe); DEF_PY_CONST_ULONG(SymTagExe);
DEF_PY_CONST(SymTagCompiland); DEF_PY_CONST_ULONG(SymTagCompiland);
DEF_PY_CONST(SymTagCompilandDetails); DEF_PY_CONST_ULONG(SymTagCompilandDetails);
DEF_PY_CONST(SymTagCompilandEnv); DEF_PY_CONST_ULONG(SymTagCompilandEnv);
DEF_PY_CONST(SymTagFunction); DEF_PY_CONST_ULONG(SymTagFunction);
DEF_PY_CONST(SymTagBlock); DEF_PY_CONST_ULONG(SymTagBlock);
DEF_PY_CONST(SymTagData); DEF_PY_CONST_ULONG(SymTagData);
DEF_PY_CONST(SymTagAnnotation); DEF_PY_CONST_ULONG(SymTagAnnotation);
DEF_PY_CONST(SymTagLabel); DEF_PY_CONST_ULONG(SymTagLabel);
DEF_PY_CONST(SymTagPublicSymbol); DEF_PY_CONST_ULONG(SymTagPublicSymbol);
DEF_PY_CONST(SymTagUDT); DEF_PY_CONST_ULONG(SymTagUDT);
DEF_PY_CONST(SymTagEnum); DEF_PY_CONST_ULONG(SymTagEnum);
DEF_PY_CONST(SymTagFunctionType); DEF_PY_CONST_ULONG(SymTagFunctionType);
DEF_PY_CONST(SymTagPointerType); DEF_PY_CONST_ULONG(SymTagPointerType);
DEF_PY_CONST(SymTagArrayType); DEF_PY_CONST_ULONG(SymTagArrayType);
DEF_PY_CONST(SymTagBaseType); DEF_PY_CONST_ULONG(SymTagBaseType);
DEF_PY_CONST(SymTagTypedef); DEF_PY_CONST_ULONG(SymTagTypedef);
DEF_PY_CONST(SymTagBaseClass); DEF_PY_CONST_ULONG(SymTagBaseClass);
DEF_PY_CONST(SymTagFriend); DEF_PY_CONST_ULONG(SymTagFriend);
DEF_PY_CONST(SymTagFunctionArgType); DEF_PY_CONST_ULONG(SymTagFunctionArgType);
DEF_PY_CONST(SymTagFuncDebugStart); DEF_PY_CONST_ULONG(SymTagFuncDebugStart);
DEF_PY_CONST(SymTagFuncDebugEnd); DEF_PY_CONST_ULONG(SymTagFuncDebugEnd);
DEF_PY_CONST(SymTagUsingNamespace); DEF_PY_CONST_ULONG(SymTagUsingNamespace);
DEF_PY_CONST(SymTagVTableShape); DEF_PY_CONST_ULONG(SymTagVTableShape);
DEF_PY_CONST(SymTagVTable); DEF_PY_CONST_ULONG(SymTagVTable);
DEF_PY_CONST(SymTagCustom); DEF_PY_CONST_ULONG(SymTagCustom);
DEF_PY_CONST(SymTagThunk); DEF_PY_CONST_ULONG(SymTagThunk);
DEF_PY_CONST(SymTagCustomType); DEF_PY_CONST_ULONG(SymTagCustomType);
DEF_PY_CONST(SymTagManagedType); DEF_PY_CONST_ULONG(SymTagManagedType);
DEF_PY_CONST(SymTagDimension); DEF_PY_CONST_ULONG(SymTagDimension);
// search options for symbol and file names
DEF_PY_CONST_ULONG(nsfCaseSensitive);
DEF_PY_CONST_ULONG(nsfCaseInsensitive);
DEF_PY_CONST_ULONG(nsfFNameExt);
DEF_PY_CONST_ULONG(nsfRegularExpression);
DEF_PY_CONST_ULONG(nsfUndecoratedName);
DEF_PY_CONST_ULONG(nsCaseSensitive);
DEF_PY_CONST_ULONG(nsCaseInsensitive);
DEF_PY_CONST_ULONG(nsFNameExt);
DEF_PY_CONST_ULONG(nsRegularExpression);
DEF_PY_CONST_ULONG(nsCaseInRegularExpression);
// exception: // exception:
// base exception // base exception
python::class_<DbgException> dbgExceptionClass( "BaseException", python::class_<DbgException> dbgExceptionClass( "BaseException",
"Pykd base exception class", "Pykd base exception class",
@ -159,7 +177,7 @@ BOOST_PYTHON_MODULE( pykd )
&pyDia::Exception::exceptionTranslate ); &pyDia::Exception::exceptionTranslate );
} }
#undef DEF_PY_CONST #undef DEF_PY_CONST_ULONG
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -41,29 +41,17 @@ class Symbol {
public: public:
Symbol() {} Symbol() {}
python::list findChildrenImpl(
ULONG symTag,
const std::string &name,
DWORD nameCmpFlags
);
python::list findChildren( python::list findChildren(
ULONG symTag, const std::string &name
const std::string &name,
bool fnMatch
) )
{ {
return return findChildrenImpl(SymTagNull, name, nsfCaseSensitive);
findChildrenImpl(
symTag,
name,
fnMatch ? nsCaseSensitive : nsRegularExpression);
}
python::list findChildrenNoCase(
ULONG symTag,
const std::string &name,
bool fnMatch
)
{
return
findChildrenImpl(
symTag,
name,
fnMatch ? nsCaseInsensitive : nsCaseInRegularExpression);
} }
ULONGLONG getSize(); ULONGLONG getSize();
@ -82,16 +70,10 @@ protected:
throw Exception(desc, S_FALSE); throw Exception(desc, S_FALSE);
} }
Symbol(__inout CComPtr< IDiaSymbol > _symbol) { Symbol(__inout CComPtr< IDiaSymbol > &_symbol) {
m_symbol = _symbol.Detach(); m_symbol = _symbol.Detach();
} }
python::list findChildrenImpl(
ULONG symTag,
const std::string &name,
DWORD nameCmpFlags
);
CComPtr< IDiaSymbol > m_symbol; CComPtr< IDiaSymbol > m_symbol;
}; };