1
Vote

Error after using $attach: "Code can only be executed while stopped in debugger."

description

I'm trying to debug calls I make from the interactive console. There is a built-in $attach command that should do what I want, and when I submit it the IDE does indeed enter debug mode. But I am unable to execute any code: Anything I enter (aside from the special $ commands) is met with this error:
Code can only be executed while stopped in debugger.
Hitting the pause button causes the pause button to grey out but doesn't seem to have any other effect. The IDE window still says "(Running)" and I still get the error.

It doesn't matter whether or not I have any projects open when I use $attach.

I expected the debug session to start up paused, allowing me to type into the Python Debug Interactive window without any fuss.

Edit: this is with PTVS 2.0 Integrated Shell on Win7 x64 and Python 3.3.3 x64

comments

Zooba wrote Dec 19, 2013 at 10:08 PM

The $attach command was added for the normal interactive windows, but clearly there's enough shared code that it looks like it works in the Debug Interactive one, too. Obviously there's some unshared code that blocks it.

I'd suggest using $attach in a normal interactive window, calling into your code (since it's only really useful if you have a breakpoint set), and then using the debug interactive to inspect the live state. It isn't entirely obvious how the two interact, but basically the $attach command is the equivalent of running python.exe and then using Debug-Attach to start debugging it: your "program" is the first interactive window, and the debug interactive one is for when you're stepping/broken in.

Artfunkel wrote Dec 20, 2013 at 9:25 PM

OK, I get it now. My UI had the debug interactive in it already, so I just went ahead and started using it.

Perhaps mentioning this confusion in the error message I mentioned would help others. :)