[0.3.x] fixed : targetProcess.breakpoint method raises execption

git-svn-id: https://pykd.svn.codeplex.com/svn@89674 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\ussrhero_cp 2015-01-22 20:10:08 +00:00 committed by Mikhail I. Izmestev
parent 4aeefd3ec5
commit 4561d67d21
3 changed files with 15 additions and 4 deletions

View File

@ -521,7 +521,7 @@ BOOST_PYTHON_MODULE( pykd )
"Return current thread" )
.def("getNumberBreakpoints", TargetProcessAdapter::getNumberBreakpoints,
"Return number of breakpoints for this process" )
.def("breakpoint", TargetProcessAdapter::getBreakpointByIndex,
.def("breakpoint", TargetProcessAdapter::getBreakpointByIndex, python::return_value_policy<python::manage_new_object>(),
"Return a breakpoint by it's index" )
;

View File

@ -3,6 +3,7 @@
#include <kdlib/process.h>
#include "pythreadstate.h"
#include "pyeventhandler.h"
namespace pykd {
@ -68,10 +69,16 @@ struct TargetProcessAdapter {
return process.getNumberBreakpoints();
}
static kdlib::BreakpointPtr getBreakpointByIndex(kdlib::TargetProcess& process, unsigned long index)
static Breakpoint* getBreakpointByIndex(kdlib::TargetProcess& process, unsigned long index)
{
kdlib::BreakpointPtr bp;
{
AutoRestorePyState pystate;
return process.getBreakpoint(index);
bp = process.getBreakpoint(index);
}
return new Breakpoint(bp);
}
};

View File

@ -42,6 +42,10 @@ class ProcessTest(unittest.TestCase):
thread = proc.thread(i)
thread.setCurrent()
def testGetBreakpoint(self):
proc = pykd.targetProcess.getCurrent()
self.assertEqual(0, proc.getNumberBreakpoints())