7

Is there a way to tell pyCharm that it should skip framework code? The debugger should skip all lines which are not from me.

In my case it is very easy to tell which code I want to debug and which not:

  • Code in virtualenv lib should be skipped
  • Code in virtualenv src should be debugged.

If I press F7 (Step Into) it should skip all lines which are not from my code base.

guettli
  • 25,042
  • 81
  • 346
  • 663
  • This lack of blackboxing is annoying me, too. I'd suggest submitting a feature request. – outis nihil Nov 19 '14 at 19:10
  • 1
    possible duplicate of [Debugging with pycharm, how to step into project, without entering django libraries](http://stackoverflow.com/questions/15164565/debugging-with-pycharm-how-to-step-into-project-without-entering-django-librar) – Piotr Dobrogost Nov 21 '14 at 00:25

1 Answers1

7

[Update May 2015: introduced in PyCharm 4.5]

There are two new features now, one of which is the one you asked for, but I mention the other one as well because it is topically very close.

From the 4.5 release notes:

Step into My Code

Stay focused on your code by telling the debugger to step only through your project code, as opposed to stepping through the library sources.

[...]

Ignore Library Files

The debugger is improved with the new 'Ignore library files' option. Use it to have the debugger stop inside your code in case the exception is raised in a library module, instead of stopping inside the library code.

[Update after learning about blackboxing libraries in debugging] In this answer it is mentioned that you can add the modules to ignore into "the dict DONT_TRACE in /helpers/pydev/pydevd.py"

And there is an open issue on the issue tracker.

[original answer] It is not possible to skip code like that, but you can flexibly switch between walking through the code line by line and making bigger jumps in a running debug session by simply adding another breakpoint (while debugging - break points can be changed in a running debug session) at the position after the library code you want to skip and press 'Resume Program' in the Debugger. The library code is skipped and you are back in your code.

You might also want to use conditional breakpoints to make sure that the program breaks into the debugger exactly when the program is in the state that you desire: right click on a breakpoint and enter a condition that has to evaluate to True in the context of that line. The conditional breakpoint makes sure that the execution stops when idx has the desired value.

Community
  • 1
  • 1
Oliver Bestwalter
  • 5,219
  • 33
  • 47
  • This is far more work than a simple blackboxing feature would make it. – outis nihil Nov 19 '14 at 19:11
  • @Oliver I know that I can skip the code by hand like you explain. Turbo Pascal had this feature. I think it was around 1993. :-) – guettli Nov 20 '14 at 11:44
  • 1
    @guettli o.k. now I understand. For me your question was just not stated clear enough then and I really did not know about the concept of blackboxing. Nice concept, but then sadly not supported by pycharm yet: http://forum.jetbrains.com/thread/PyCharm-2450 (I guess). – Oliver Bestwalter Nov 20 '14 at 21:45
  • Added hacky way and open issue to the answer to reflect the current situation. – Oliver Bestwalter Nov 21 '14 at 12:08
  • Is this "Ignore Library Files" still an option that exists in PyCharm 5? I can't spot it in the debugging UI . – rakslice Feb 17 '16 at 00:14
  • 2
    It is available as an option for exception breakpoints (on termination; on raise; Ignore library files). See https://www.jetbrains.com/pycharm/help/breakpoints-2.html – Oliver Bestwalter Feb 17 '16 at 16:47