[Pydev-code] Adding New Debug Feature - "Set Next Statement"
Brought to you by:
fabioz
From: Hussain B. <hus...@ya...> - 2011-01-04 07:09:58
|
Hi Fabio, Current Pydev code has a 'Run To Line' feature which effectively works like the 'Set Next Statement' of Visual Studio. While debugging python code we realised that 'Run To Line' feature skips all lines between source line and target line. This is not the case when we do 'Run To Line' in Java code. Also, the pydev debugger breaks if the 'Run To Line' target is within a 'For' or 'While' loop, with following exception: Traceback (most recent call last):File "D:\Sims4\PyDev\pydev_1_6_3-0\aptana-Pydev-e2a3355\plugins\org.python.pydev.debug\pysrc\pydevd.py", line 1148, in <module>debugger.run(setup['file'], None, None)File "D:\Sims4\PyDev\pydev_1_6_3-0\aptana-Pydev-e2a3355\plugins\org.python.pydev.debug\pysrc\pydevd.py", line 948, in runexec(compile(contents+"\n", file, 'exec'), globals, locals) #execute the scriptFile "D:\Sims4\runtime-EclipseApplication\Sims4Projects\src\gamescript.py", line 69, in <module>debug_test() File "D:\Sims4\runtime-EclipseApplication\Sims4Projects\src\gamescript.py", line 44, in debug_testfor j in range(1, 50):File "D:\Sims4\runtime-EclipseApplication\Sims4Projects\src\gamescript.py", line 44, in debug_testfor j in range(1, 50):File "D:\Sims4\PyDev\pydev_1_6_3-0\aptana-Pydev-e2a3355\plugins\org.python.pydev.debug\pysrc\pydevd_frame.py", line 102, in trace_dispatchself.doWaitSuspend(thread, frame, event, arg)File "D:\Sims4\PyDev\pydev_1_6_3-0\aptana-Pydev-e2a3355\plugins\org.python.pydev.debug\pysrc\pydevd_frame.py", line 25, in doWaitSuspendself._args[0].doWaitSuspend(*args, **kwargs)File "D:\Sims4\PyDev\pydev_1_6_3-0\aptana-Pydev-e2a3355\plugins\org.python.pydev.debug\pysrc\pydevd.py", line 732, in doWaitSuspendframe.f_lineno = line ValueError: can't jump into the middle of a block We propose to add a new debugging feature in PyDev i.e. 'Set Next Statement' wherein we will prevent the 'Set Next' target to be within a 'For' or 'While' loop. The approach with which we are developing this is as follows: * Added a new interface i.e. 'org.python.pydev.debug.ui.actions.ISetNextTarget' and concrete implementation class i.e. 'org.python.pydev.debug.model.PySetNextTarget'. * Added a new class 'org.python.pydev.debug.ui.actions.RetargetSetNextAction' that implements 'org.eclipse.debug.internal.ui.actions.RetargetAction' * Added class to adapt PyEdit object into ISetNextTarget i.e. 'org.python.pydev.debug.ui.PyEditSetNextAdapterFactory'. * We have added the extension points for Command, Action, Menu, Key Binding and Adapters in 'org.python.pydev.debug\plugin.xml'. * We have also added the following line in 'org.python.pydev.debug.model.remote.AbstractDebuggerCommand.java' * staticpublicfinalintCMD_SET_NEXT_STATEMENT= 121; On the python side we have changed/added following lines: 1.) Added new variableCMD_SET_NEXT_STATEMENT = Added '121':'CMD_SET_NEXT_STATEMENT', in 'ID_TO_MEANING'.in org.python.pydev.debug\pysrc\pydevd_comm.py 2.) Changed 'elifcmd_id == CMD_RUN_TO_LINE' To 'elifcmd_id == CMD_RUN_TO_LINE orcmd_id == CMD_SET_NEXT_STATEMENT' in PyDB.processNetCommand in 'org.python.pydev.debug\pysrc\pydevd.py' Inspite of making these changes it is not writing the correct command and XML on 'WriterThread'. On 'Run To Line' It writes following on WriterThread: ('received command', '118\t27\tpid4980_seq1\t42\tdebug_test') sending cmd: CMD_THREAD_SUSPEND 105 20 <xml><thread id="pid4980_seq1" stop_reason="111"><frame id="55169480" name="debug_test" file="d%253A%255Csims4%255Cruntime-eclipseapplication%255Csims4projects%255Csrc%255Cgamescript.py" line="42">"</frame><frame id="55571240" name="%26lt%3Bmodule%26gt%3B" file="d%253A%255Csims4%255Cruntime-eclipseapplication%255Csims4projects%255Csrc%255Cgamescript.py" line="62">"</frame><frame id="30904736" name="run" file="d%253A%255Csims4%255Cpydev%255Cpydev_1_6_3-0%255Captana-pydev-e2a3355%255Cplugins%255Corg.python.pydev.debug%255Cpysrc%255Cpydevd.py" line="951">"</frame><frame id="52251784" name="%26lt%3Bmodule%26gt%3B" file="d%253A%255Csims4%255Cpydev%255Cpydev_1_6_3-0%255Captana-pydev-e2a3355%255Cplugins%255Corg.python.pydev.debug%255Cpysrc%255Cpydevd.py" line="1151">"</frame></thread></xml> However in my new command implementation it writes only the following: ('received command ', '121\t29\tpid4980_seq1\t49\tdebug_test') sending cmd: CMD_THREAD_RUN 106 22 pid4980_seq1 121 Please let me know if I am missing some thing. In order to prevent the 'Set Next' target from being set within a 'For' or 'While' loop, We have added new methods i.e. 'VisitFor' and 'VisitWhile' in 'org.python.pydev.parser.visitors.scope.EasyASTIteratorVisitor' which generates atomic node (ASTEntry) for 'For' and 'While'. I also need to modify 'NodeUtils.GetLineEnd' method to get end of line for 'For' and 'While' Loops. Please let us know your views, comments and feedback on my problem and approach. Thanks and Regards, Hussain Bohra 121 and |