Can't evaluate functions while paused at a breakpoint

Issue #8 new
Neil Alexander McQuarrie
created an issue

Hi,

Just started using the Plugin Debugger package and I'm excited about what it can do.

Unfortunately I'm encountering one fairly major snag so far, though -- when Winpdb stops at the "spdb.start() line" (which I've placed in my plugin), I'm not able to evaluate statements in Winpdb involving any kind of sublime function call.

For example, using the test plugin code at the end of this post, when Winpdb stops at spdb.start(), if I enter this into the Winpdb REPL:

eval view.file_name()

then Winpdb waits a few seconds and comes back with:

The operation will continue to run in the background.

I presume this is because, while the plugin is paused, Sublime Text is also effectively blocked and can’t respond to anything?

If I allow Winpdb to continue execution, it will then evaluate these prior statements I’d entered and print results to the REPL. However, I feel this defeats the purpose a bit -- to effectively debug, ideally I'd see eval results while paused at the breakpoint.

Just wondering if anyone else has encountered a similar issue and, if so, if you might have discovered a workaround?

Using ST3 build 3142, Plugin Debugger 2014.04.19.16.30.06, Winpdb 1.4.8 (connected to an Anaconda Python 2.7 environment), Windows 10.

Here's the test plugin for the above example:

import os, sys
import sublime, sublime_plugin

class debugTestCommand(sublime_plugin.WindowCommand):

    # Constructor
    def __init__(self, window):
        sublime_plugin.WindowCommand.__init__(self, window)        

    def run(self):
        view = sublime.active_window().active_view()
        import spdb ; spdb.start()
        print(view.file_name())

Many thanks in advance for the help!

Neil

Comments (3)

  1. Kay-Uwe (Kiwi) Lorenz repo owner

    Hi Neil,

    I have tried to reproduce your issue and I found the reason for this:

    What you can do is:

      import  os,  sys
      import  sublime,  sublime_plugin
    
      class  debugTestCommand(sublime_plugin.WindowCommand):
    
          # Constructor
          def  __init__(self,  window):
              sublime_plugin.WindowCommand.__init__(self,  window)
    
          def  run(self):
              view  =  sublime.active_window().active_view()
              import  spdb  ;  spdb.start()
              fn = view.file_name()
    
      # >>> break here
              print(view.file_name())
    
      #  >>> and eval(fn) wil print the filename.
    

    view.file_name() runs a sublime-text API command, but ST is frozen while the debugger is in break mode and will not respond. You can only eval() on python variables and functions.

    You can use normal console for evaluating such expressions or you do it (as in example above) using a extra variable to store the result of a ST API function.

    Good luck with your debugging session :)

    Best regards,

    Kiwi

    Am 06.09.2017 um 01:39 schrieb Neil Alexander McQuarrie:

  2. Neil Alexander McQuarrie reporter

    Hi Kiwi,

    Thank you so much for the reply and for the idea -- I really appreciate it.

    If I understand you correctly, if I want to make any kind of ST API call from within the debugger, I'll need to have already performed the call and assigned the result to a variable? Hmmm... in most of my own use cases I find that, when I'm debugging, it's an iterative process and I won't know going in what I'll be wanting to evaluate... (Or if I do, I might as well just put the statement into a print command and not bother with a debugger?)

    Just confirming that I understand. Again, many thanks for your help.

    Neil

  3. Neil Alexander McQuarrie reporter

    I wonder if there's a programmatic way to have winpdb temporarily "un-freeze" / release control of ST without also advancing to the next line of code. I'm willing to research this and submit a PR if I can come up with something workable. No chance you'd have any leads / thoughts yourself as to whether this is a viable road to try to go down?

  4. Log in to comment