Commit 89d5c3e5 authored by ussrhero's avatar ussrhero
Browse files

added : stackFrame::getSourceLine method

:
parent 877968ca
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment