mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:53:23 +08:00
[0.3.x] added : findSymbol
git-svn-id: https://pykd.svn.codeplex.com/svn@84103 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
0b3beb39a2
commit
8eb0ba0584
@ -1,6 +1,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "kdlib/dbgengine.h"
|
#include "kdlib/dbgengine.h"
|
||||||
|
#include "kdlib/typeinfo.h"
|
||||||
|
|
||||||
#include "dbgengine.h"
|
#include "dbgengine.h"
|
||||||
|
|
||||||
@ -77,4 +78,13 @@ python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset )
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
python::tuple findSymbolAndDisp( ULONG64 offset )
|
||||||
|
{
|
||||||
|
kdlib::MEMDISPLACEMENT displacement = 0;
|
||||||
|
std::wstring symbolName = kdlib::findSymbol( offset, displacement );
|
||||||
|
return python::make_tuple(symbolName,displacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
} //end namespace pykd
|
} //end namespace pykd
|
||||||
|
@ -16,6 +16,8 @@ kdlib::ExecutionStatus targetStepIn();
|
|||||||
|
|
||||||
python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset = 0 );
|
python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset = 0 );
|
||||||
|
|
||||||
|
python::tuple findSymbolAndDisp( ULONG64 offset );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
} //end namespace pykd
|
} //end namespace pykd
|
@ -54,13 +54,13 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( getSourceFile_, kdlib::getSourceFile, 0, 1 );
|
|||||||
|
|
||||||
//BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBp_, setHardwareBp, 3, 4 );
|
//BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBp_, setHardwareBp, 3, 4 );
|
||||||
//
|
//
|
||||||
//BOOST_PYTHON_FUNCTION_OVERLOADS( findSymbol_, TypeInfo::findSymbol, 1, 2 );
|
|
||||||
//
|
|
||||||
//BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( TypeBuilder_createStruct, TypeBuilder::createStruct, 1, 2 );
|
//BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( TypeBuilder_createStruct, TypeBuilder::createStruct, 1, 2 );
|
||||||
//
|
//
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_enumSymbols, ModuleAdapter::enumSymbols, 1, 2 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_enumSymbols, ModuleAdapter::enumSymbols, 1, 2 );
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_findSymbol, ModuleAdapter::findSymbol, 2, 3 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_findSymbol, ModuleAdapter::findSymbol, 2, 3 );
|
||||||
|
|
||||||
|
BOOST_PYTHON_FUNCTION_OVERLOADS( findSymbol_, TypeInfoAdapter::findSymbol, 1, 2 );
|
||||||
|
|
||||||
//BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( Module_findSymbol, Module::getSymbolNameByVa, 1, 2 );
|
//BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( Module_findSymbol, Module::getSymbolNameByVa, 1, 2 );
|
||||||
|
|
||||||
|
|
||||||
@ -223,10 +223,10 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Return source file name, line and displacement by the specified offset" ) );
|
"Return source file name, line and displacement by the specified offset" ) );
|
||||||
python::def( "getOffset", &kdlib::getSymbolOffset,
|
python::def( "getOffset", &kdlib::getSymbolOffset,
|
||||||
"Return traget virtual address for specified symbol" );
|
"Return traget virtual address for specified symbol" );
|
||||||
// python::def( "findSymbol", &TypeInfo::findSymbol, findSymbol_( python::args( "offset", "showDisplacement"),
|
python::def( "findSymbol", &TypeInfoAdapter::findSymbol, findSymbol_( python::args( "offset", "showDisplacement"),
|
||||||
// "Find symbol by the target virtual memory offset" ) );
|
"Find symbol by the target virtual memory offset" ) );
|
||||||
// python::def("findSymbolAndDisp", &pysupport::findSymbolAndDisp,
|
python::def("findSymbolAndDisp", &findSymbolAndDisp,
|
||||||
// "Return tuple(symbol_name, displacement) by virtual address" );
|
"Return tuple(symbol_name, displacement) by virtual address" );
|
||||||
python::def( "sizeof", &kdlib::getSymbolSize,
|
python::def( "sizeof", &kdlib::getSymbolSize,
|
||||||
"Return a size of the type or variable" );
|
"Return a size of the type or variable" );
|
||||||
python::def("typedVarList", &TypedVarAdapter::getTypedVarListByTypeName,
|
python::def("typedVarList", &TypedVarAdapter::getTypedVarListByTypeName,
|
||||||
@ -294,10 +294,10 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
// "Set implicit thread for current process" );
|
// "Set implicit thread for current process" );
|
||||||
// python::def( "getProcessThreads", &pysupport::getProcessThreads,
|
// python::def( "getProcessThreads", &pysupport::getProcessThreads,
|
||||||
// "Get all process's threads ( user mode only )" );
|
// "Get all process's threads ( user mode only )" );
|
||||||
// python::def( "getCurrentProcessId", &getCurrentProcessId,
|
python::def( "getCurrentProcessId", &kdlib::getCurrentProcessId,
|
||||||
// "Return PID of the current process ( user mode only )" );
|
"Return PID of the current process ( user mode only )" );
|
||||||
// python::def( "getCurrentThreadId", &getCurrentThreadId,
|
python::def( "getCurrentThreadId", &kdlib::getCurrentThreadId,
|
||||||
// "Return TID of the current thread ( user mode only )" );
|
"Return TID of the current thread ( user mode only )" );
|
||||||
// python::def( "getCurrentProcessExeName", &getCurrentProcessExecutableName,
|
// python::def( "getCurrentProcessExeName", &getCurrentProcessExecutableName,
|
||||||
// "Return name of executable file loaded in the current process");
|
// "Return name of executable file loaded in the current process");
|
||||||
|
|
||||||
@ -579,7 +579,6 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
// "Return object as a string");
|
// "Return object as a string");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// python::enum_<EVENT_TYPE>("eventType", "Type of debug event")
|
// python::enum_<EVENT_TYPE>("eventType", "Type of debug event")
|
||||||
// .value("Breakpoint", EventTypeBreakpoint)
|
// .value("Breakpoint", EventTypeBreakpoint)
|
||||||
// .value("Exception", EventTypeException)
|
// .value("Exception", EventTypeException)
|
||||||
|
@ -11,6 +11,25 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
|
|||||||
return kdlib::loadType( name );
|
return kdlib::loadType( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::wstring findSymbol( kdlib::MEMOFFSET_64 offset, bool showDisplacement = true )
|
||||||
|
{
|
||||||
|
kdlib::MEMDISPLACEMENT displacement = 0;
|
||||||
|
std::wstring symbolName = kdlib::findSymbol( offset, displacement );
|
||||||
|
if ( !showDisplacement || displacement == 0 )
|
||||||
|
return symbolName;
|
||||||
|
|
||||||
|
std::wstringstream wsstr;
|
||||||
|
|
||||||
|
wsstr << symbolName;
|
||||||
|
|
||||||
|
if ( displacement > 0 )
|
||||||
|
wsstr << L'+' << std::hex << displacement;
|
||||||
|
else
|
||||||
|
wsstr << L'-' << std::hex << -displacement;
|
||||||
|
|
||||||
|
return wsstr.str();
|
||||||
|
}
|
||||||
|
|
||||||
static kdlib::MEMOFFSET_32 getElementOffset( kdlib::TypeInfo &typeInfo, const std::wstring &name ) {
|
static kdlib::MEMOFFSET_32 getElementOffset( kdlib::TypeInfo &typeInfo, const std::wstring &name ) {
|
||||||
return typeInfo.getElementOffset( name );
|
return typeInfo.getElementOffset( name );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user