mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:53:23 +08:00
[+] Added dbgModuleClass::print()
[+] Added dbgExtensionClass::print() [+] Added dbgBreakpointClass::print() [+] Added dbgStackFrameClass::print() git-svn-id: https://pykd.svn.codeplex.com/svn@61914 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
f2471ac5a0
commit
a4993db623
@ -1,5 +1,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
#include "dbgext.h"
|
#include "dbgext.h"
|
||||||
#include "dbgcmd.h"
|
#include "dbgcmd.h"
|
||||||
#include "dbgexcept.h"
|
#include "dbgexcept.h"
|
||||||
@ -37,7 +39,7 @@ dbgCommand( const std::string &command )
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
dbgExtensionClass::dbgExtensionClass( const char* path )
|
dbgExtensionClass::dbgExtensionClass( const char* path ) : m_path(path)
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
@ -97,6 +99,29 @@ dbgExtensionClass::call( const std::string &command, const std::string params )
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string
|
||||||
|
dbgExtensionClass::print() const
|
||||||
|
{
|
||||||
|
HRESULT status = S_OK;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return m_handle ? m_path : "";
|
||||||
|
}
|
||||||
|
catch (std::exception & e)
|
||||||
|
{
|
||||||
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -170,6 +195,43 @@ dbgBreakpointClass::remove()
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string
|
||||||
|
dbgBreakpointClass::print() const
|
||||||
|
{
|
||||||
|
HRESULT status = S_OK;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!m_breakpoint)
|
||||||
|
return "not set";
|
||||||
|
|
||||||
|
DEBUG_BREAKPOINT_PARAMETERS params;
|
||||||
|
status = m_breakpoint->GetParameters(¶ms);
|
||||||
|
if (FAILED(status))
|
||||||
|
throw DbgException("IDebugBreakpoint::GetParameters failed");
|
||||||
|
|
||||||
|
boost::format fmt("%1$2d %2%%3% %4%:*** ");
|
||||||
|
fmt % params.Id
|
||||||
|
% (params.Flags & DEBUG_BREAKPOINT_ENABLED ? 'e' : 'd')
|
||||||
|
% 'u'
|
||||||
|
% params.CurrentPassCount;
|
||||||
|
|
||||||
|
return fmt.str();
|
||||||
|
}
|
||||||
|
catch (std::exception & e)
|
||||||
|
{
|
||||||
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ULONG64
|
ULONG64
|
||||||
evaluate( const std::string &expression )
|
evaluate( const std::string &expression )
|
||||||
{
|
{
|
||||||
|
@ -68,9 +68,13 @@ public:
|
|||||||
std::string
|
std::string
|
||||||
call( const std::string &command, const std::string param );
|
call( const std::string &command, const std::string param );
|
||||||
|
|
||||||
|
std::string
|
||||||
|
print() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ULONG64 m_handle;
|
ULONG64 m_handle;
|
||||||
|
std::string m_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -90,6 +94,9 @@ public:
|
|||||||
void
|
void
|
||||||
remove();
|
remove();
|
||||||
|
|
||||||
|
std::string
|
||||||
|
print() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ULONG64 m_offset;
|
ULONG64 m_offset;
|
||||||
|
@ -166,18 +166,21 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.def("image", &dbgModuleClass::getImageSymbolName )
|
.def("image", &dbgModuleClass::getImageSymbolName )
|
||||||
.def("pdb", &dbgModuleClass::getPdbName )
|
.def("pdb", &dbgModuleClass::getPdbName )
|
||||||
.def("addSynSymbol", &dbgModuleClass::addSyntheticSymbol )
|
.def("addSynSymbol", &dbgModuleClass::addSyntheticSymbol )
|
||||||
.def("__getattr__", &dbgModuleClass::getOffset );
|
.def("__getattr__", &dbgModuleClass::getOffset )
|
||||||
|
.def("__str__", &dbgModuleClass::print );
|
||||||
boost::python::class_<dbgExtensionClass>(
|
boost::python::class_<dbgExtensionClass>(
|
||||||
"ext",
|
"ext",
|
||||||
"windbg extension",
|
"windbg extension",
|
||||||
boost::python::init<const char*>( boost::python::args("path"), "__init__ dbgExtensionClass" ) )
|
boost::python::init<const char*>( boost::python::args("path"), "__init__ dbgExtensionClass" ) )
|
||||||
.def("call", &dbgExtensionClass::call );
|
.def("call", &dbgExtensionClass::call )
|
||||||
|
.def("__str__", &dbgExtensionClass::print );
|
||||||
boost::python::class_<dbgStackFrameClass>( "dbgStackFrameClass", "dbgStackFrameClass" )
|
boost::python::class_<dbgStackFrameClass>( "dbgStackFrameClass", "dbgStackFrameClass" )
|
||||||
.def_readonly( "instructionOffset", &dbgStackFrameClass::InstructionOffset )
|
.def_readonly( "instructionOffset", &dbgStackFrameClass::InstructionOffset )
|
||||||
.def_readonly( "returnOffset", &dbgStackFrameClass::ReturnOffset )
|
.def_readonly( "returnOffset", &dbgStackFrameClass::ReturnOffset )
|
||||||
.def_readonly( "frameOffset", &dbgStackFrameClass::FrameOffset )
|
.def_readonly( "frameOffset", &dbgStackFrameClass::FrameOffset )
|
||||||
.def_readonly( "stackOffset", &dbgStackFrameClass::StackOffset )
|
.def_readonly( "stackOffset", &dbgStackFrameClass::StackOffset )
|
||||||
.def_readonly( "frameNumber", &dbgStackFrameClass::FrameNumber );
|
.def_readonly( "frameNumber", &dbgStackFrameClass::FrameNumber )
|
||||||
|
.def( "__str__", &dbgStackFrameClass::print );
|
||||||
boost::python::class_<dbgOut>( "windbgOut", "windbgOut" )
|
boost::python::class_<dbgOut>( "windbgOut", "windbgOut" )
|
||||||
.def( "write", &dbgOut::write );
|
.def( "write", &dbgOut::write );
|
||||||
boost::python::class_<dbgIn>( "windbgIn", "windbgIn" )
|
boost::python::class_<dbgIn>( "windbgIn", "windbgIn" )
|
||||||
@ -187,7 +190,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"break point",
|
"break point",
|
||||||
boost::python::init<ULONG64>( boost::python::args("offset"), "__init__ dbgBreakpointClass" ) )
|
boost::python::init<ULONG64>( boost::python::args("offset"), "__init__ dbgBreakpointClass" ) )
|
||||||
.def( "set", &dbgBreakpointClass::set )
|
.def( "set", &dbgBreakpointClass::set )
|
||||||
.def( "remove", &dbgBreakpointClass::remove );
|
.def( "remove", &dbgBreakpointClass::remove )
|
||||||
|
.def( "__str__", &dbgBreakpointClass::print );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
#include "dbgext.h"
|
#include "dbgext.h"
|
||||||
#include "dbgmodule.h"
|
#include "dbgmodule.h"
|
||||||
#include "dbgexcept.h"
|
#include "dbgexcept.h"
|
||||||
@ -317,6 +319,31 @@ dbgModuleClass::getImagePath()
|
|||||||
delete[] pathBuffer;
|
delete[] pathBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
dbgModuleClass::print() const
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const char * format_string(dbgExt->control->IsPointer64Bit() == S_OK ?
|
||||||
|
"%1$016x %2$016x %3$20s %4$20s" : "%1$08x %2$08x %3$20s %4$20s");
|
||||||
|
boost::format fmt(format_string);
|
||||||
|
std::vector<char> v(MAX_PATH);
|
||||||
|
::WideCharToMultiByte( CP_ACP, 0, m_imageFullName.c_str(), -1, &v[0], v.size(), 0, 0);
|
||||||
|
std::string fullname(&v[0]);
|
||||||
|
fmt % m_base % (m_end - m_base) % m_name % fullname;
|
||||||
|
return fmt.str();
|
||||||
|
}
|
||||||
|
catch (std::exception & e)
|
||||||
|
{
|
||||||
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -61,6 +61,10 @@ public:
|
|||||||
void
|
void
|
||||||
addSyntheticSymbol( ULONG64 offset, ULONG size, const std::string &symName );
|
addSyntheticSymbol( ULONG64 offset, ULONG size, const std::string &symName );
|
||||||
|
|
||||||
|
|
||||||
|
std::string
|
||||||
|
print() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ULONG64 m_base;
|
ULONG64 m_base;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
#include "dbgprocess.h"
|
#include "dbgprocess.h"
|
||||||
#include "dbgext.h"
|
#include "dbgext.h"
|
||||||
#include "dbgexcept.h"
|
#include "dbgexcept.h"
|
||||||
@ -330,6 +332,16 @@ dbgStackFrameClass::dbgStackFrameClass( const DEBUG_STACK_FRAME &stackFrame )
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string
|
||||||
|
dbgStackFrameClass::print() const
|
||||||
|
{
|
||||||
|
boost::format fmt(dbgExt->control->IsPointer64Bit() == S_OK ? "%1$4d %2$16x" : "%1$4d %2$08x");
|
||||||
|
fmt % FrameNumber % ReturnOffset;
|
||||||
|
return fmt.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
boost::python::object
|
boost::python::object
|
||||||
getLocals()
|
getLocals()
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbgStackFrameClass( const DEBUG_STACK_FRAME &stackFrame );
|
dbgStackFrameClass( const DEBUG_STACK_FRAME &stackFrame );
|
||||||
|
|
||||||
|
std::string
|
||||||
|
print() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
boost::python::object
|
boost::python::object
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@set CL=/nologo /EHsc /LD /I%BOOST_ROOT% /I%PYTHON_ROOT%\include /I%DBG_SDK_ROOT%\inc
|
@set CL=/nologo /EHsc /LD /MD /D "NDEBUG" /Ox /I%BOOST_ROOT% /I%PYTHON_ROOT%\include /I%DBG_SDK_ROOT%\inc
|
||||||
@rc /fo resource.res pykd.rc > nul
|
@rc /fo resource.res pykd.rc > nul
|
||||||
@cvtres /out:resource.obj /nologo /machine:x86 resource.res
|
@cvtres /out:resource.obj /nologo /machine:x86 resource.res
|
||||||
@cl pykd.cpp ^
|
@cl pykd.cpp ^
|
||||||
@ -17,7 +17,11 @@
|
|||||||
dbgtype.cpp ^
|
dbgtype.cpp ^
|
||||||
stdafx.cpp ^
|
stdafx.cpp ^
|
||||||
pykd.def ^
|
pykd.def ^
|
||||||
resource.obj ^
|
%DBG_SDK_ROOT%\lib\i386\dbgeng.lib ^
|
||||||
%PYTHON_ROOT%\libs\python26.lib ^
|
/link /out:pykd.pyd
|
||||||
%DBG_SDK_ROOT%\lib\i386\dbgeng.lib
|
@mt -nologo -manifest pykd.pyd.manifest -outputresource:pykd.pyd;1
|
||||||
@if exist *.obj del *.obj
|
@if exist *.obj del *.obj
|
||||||
|
@if exist *.res del *.res
|
||||||
|
@if exist *.lib del *.lib
|
||||||
|
@if exist *.exp del *.exp
|
||||||
|
@if exist *.manifest del *.manifest
|
||||||
|
Loading…
Reference in New Issue
Block a user