mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-19 02:53:22 +08:00
added : stackFrame::getSourceLine method
:
This commit is contained in:
parent
877968ca92
commit
89d5c3e5f9
@ -259,6 +259,20 @@ python::tuple StackFrameAdapter::findSymbol(kdlib::StackFramePtr& frame)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
python::tuple StackFrameAdapter::getSourceLine(kdlib::StackFramePtr& frame)
|
||||
{
|
||||
std::wstring fileName;
|
||||
unsigned long lineno;
|
||||
|
||||
do {
|
||||
AutoRestorePyState pystate;
|
||||
frame->getSourceLine(fileName, lineno);
|
||||
} while (false);
|
||||
|
||||
return python::make_tuple(fileName, lineno);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
python::tuple CPUContextAdapter::getRegisterByIndex(unsigned long index)
|
||||
{
|
||||
|
||||
|
@ -78,6 +78,8 @@ public:
|
||||
AutoRestorePyState pystate;
|
||||
return frame->isInline();
|
||||
}
|
||||
|
||||
static python::tuple getSourceLine(kdlib::StackFramePtr& frame);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1121,9 +1121,9 @@ void pykd_init()
|
||||
"this virtual frame of inlined function" )
|
||||
.def( "findSymbol", StackFrameAdapter::findSymbol,
|
||||
"return symbol for frame's instruction pointer")
|
||||
//.def( "getSourceLine", StackFrameAdapter::getSourceLine,
|
||||
// "return source line for stack frame's function" )
|
||||
.def( "__str__", StackFrameAdapter::print );
|
||||
.def( "getSourceLine", StackFrameAdapter::getSourceLine,
|
||||
"return source line for stack frame's function" )
|
||||
.def( "__str__", StackFrameAdapter::print );
|
||||
|
||||
python::class_<CPUContextAdapter>("cpu", "class for CPU context representation" )
|
||||
//.def("__init__", python::make_constructor(CPUContextAdapter::getCPUContext) )
|
||||
|
@ -147,5 +147,4 @@ class ModuleTest( unittest.TestCase ):
|
||||
|
||||
def testPrint(self):
|
||||
modAsStr = str(target.module)
|
||||
pass
|
||||
|
||||
|
@ -87,5 +87,20 @@ class InlineStackTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual( expectedStack, realStack[0:4])
|
||||
|
||||
def testFrameIsInline(self):
|
||||
self.assertEqual([True, True, False, True],
|
||||
[fr.isInline() for fr in pykd.getStack(inlineFrames = True)][:4]
|
||||
)
|
||||
|
||||
def testGetSourceLine(self):
|
||||
|
||||
expectedStack = ['targetapp.cpp+129', 'targetapp.cpp+144', 'targetapp.cpp+172', 'targetapp.cpp+185']
|
||||
|
||||
realStack = []
|
||||
for frame in pykd.getStack(inlineFrames = True)[:4]:
|
||||
fileName, lineNo = frame.getSourceLine()
|
||||
realStack.append("%s+%s" % ( os.path.basename(fileName), lineNo ) )
|
||||
|
||||
self.assertEqual( expectedStack, realStack)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user