Menu

#381 pdb should be supported in jython editor

Someday
open
nobody
None
5
2020-07-01
2014-09-01
No

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.

Discussion

  • Jeremy Faden

    Jeremy Faden - 2014-10-15

    See sftp://jfaden.net/home/jbf/ct/autoplot/script/demos/pythonDebugger/first.jy

     
  • Jeremy Faden

    Jeremy Faden - 2014-10-15

    I think the problem is that there's no connection to stdin. This script more clearly demonstrates the problem:

    import sys
    
    for line in sys.stdin:
        print line
        print 'line entered: ', line
    

    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
  • Jeremy Faden

    Jeremy Faden - 2014-10-15

    I verified this works with pdb. pdb output goes to the console tab.

     
  • Jeremy Faden

    Jeremy Faden - 2014-10-22

    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
  • Jeremy Faden

    Jeremy Faden - 2016-05-30

    I played with this a little as I was working on Masafumi's script for parsing radar files.

     
  • Jeremy Faden

    Jeremy Faden - 2016-11-22

    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.

     
  • Jeremy Faden

    Jeremy Faden - 2018-10-01

    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
  • Jeremy Faden

    Jeremy Faden - 2019-06-27

    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.

     
  • Jeremy Faden

    Jeremy Faden - 2019-12-23

    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

     
  • Jeremy Faden

    Jeremy Faden - 2020-07-01

    Still not working. Need to ID a version.

     
  • Jeremy Faden

    Jeremy Faden - 2020-07-01

    I confirmed this works with 20161121a:

    1. download and start 20161121a
    2. set the environment variable.
    3. open /home/jbf/ct/git/scripts/u/jbf/2020/20200627/testPdb.jy
    4. run with "Execute" in the editor.
     
  • Jeremy Faden

    Jeremy Faden - 2020-07-01

    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