pdb is the basis for Python IDE debugging, and there's no reason why it couldn't be supported easily in Autoplot. Right now, calling pdb.set_trace() will hang the editor, and this should be corrected as well.
For example:
import pdb pdb.set_trace() aa= [1,2,3,4,5] for a1 in aa: print a1
should allow the user to step through the code by issuing commands through the console.
See sftp://jfaden.net/home/jbf/ct/autoplot/script/demos/pythonDebugger/first.jy
I think the problem is that there's no connection to stdin. This script more clearly demonstrates the problem:
Running this script will hang the "Execute" button, because there is no way to communicate with the Python interpreter.
I had a hunch that running from the command line might work, and it does. Running the above script accepts stdin from the unix shell that started Autoplot.
Last edit: Jeremy Faden 2014-10-15
I verified this works with pdb. pdb output goes to the console tab.
I've been playing with this a bit and it's getting somewhat usable. It plugs in a new stdin and has buttons to step through the code. Users can now evaluate variables by highlite and hover, though expressions are not supported while debugging.
Last edit: Jeremy Faden 2014-10-22
I played with this a little as I was working on Masafumi's script for parsing radar files.
Here are the instructions which were never published:
1. Start Autoplot
2. In the console:
3. from java.lang import System
4. System.setProperty("jythonDebugger","true")
5. In your script, have where you want to stop:
6. import pdb
7. pdb.set_trace()
8.run the script. The dialog "Jython Debugger" (org.virbo.autoplot.scriptconsole.DebuggerConsole) will pop up. (This will stop immediately after the set_trace command.
9.The Jython Debugger will become enabled, and you can see the interaction it has with pdb.
10. when execution is finished, the Jython Debugger will go insensitive.
11. running the script again will re-enable the Jython Debugger.
I decided to play with this over the weekend, just to remind myself where things were at. Also it would be nice if Autoplot would handle insertion of breakpoints so the code doesn't need to be modified, but I couldn't get this to work. I'll try with native Python to see if that works as documented.
I noticed a couple of odd behaviors. First "c" should continue but only advances to the next line. "l" doesn't list but instead says "[EOF]".
Last edit: Jeremy Faden 2018-10-01
I'm not having any luck with this, trying to use it to debug another script. It's getting stuck immediately, and I can't get even the simplest demos of debugging to work.
This is not working for me (20191221a). I need to go back an ID a version where this works. See also https://github.com/autoplot/dev/tree/master/demos/2019/20191223
Still not working. Need to ID a version.
I confirmed this works with 20161121a:
Bracking the problem, works for 20190427a, not for 20190504a. There's no obvious change which causes the problem, so I'll have to check out both versions and walk through with the debugger.
Last edit: Jeremy Faden 2020-07-04