Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force IntelliJ to only step into my source code?

I have a Spring MVC project that I'm trying to debug using IntelliJ.

If I set a breakpoint in my Controller code, the debug stops at the appropriate place. That particular line has more of my own code in another bean. I'd like to be able to step into the code. If I "step into" immediately after the breakpoint riggers, it steps into Spring's AOP framework code.

enter image description here

If I trigger the same breakpoint and "smart step into" immediately, it puts me at line -1 of the source file (apparent in the graphic above). What is this line -1 signify? If I do "smart step into" again, I end up at the line after my original breakpoint, but never having been placed inside the method I wanted to step into.

I have tried putting the Spring AOP package into the Debugger setting Do not step into the classes. However, I also ended up having to put in transaction classes as well as several others. In the end, I put all of Spring into the list ... and SLF4J and some JDBC drivers.

How can I just get IntelliJ to only stop in my project source code unless I use something like "force step into"?

like image 678
dbrown0708 Avatar asked Dec 13 '13 20:12

dbrown0708


People also ask

What is force step into Intellij?

Force step overSteps over the current line of code and takes you to the next line even if the highlighted line has method calls in it. If there are breakpoints in the called methods, they are ignored.

How do I skip a step while debugging in Intellij?

If you press and hold the Ctrl / ⌘ button while dragging the arrow, the IDE will highlight all the lines in green. When you drop the arrow, you won't jump to the line of code. Instead, the IDE will act as if you have used the Run to Cursor (⌥F9) action.


4 Answers

Currently there is no overall option to only target user code (like Visual Studio's 'Just My Code').

The best way to have the same behavior is to exclude specific code classes or packages (it is possible to setup filter patterns for class packages via wildcards) that will not be 'stepped into'.

This can be achieved within the Settings/Preferences, in the Debugger/Stepping options.

like image 109
acoelhosantos Avatar answered Oct 20 '22 18:10

acoelhosantos


Spring's AOP may be among the worst offenders.

The OP suggested that they had already done this, but here's how you can disable stepping into specified classes (IntelliJ ULTIMATE 2018.2):

File -> Settings... -> Build, Execution, Deployment -> Debugger -> Stepping

... Do not step into the classes -> Add Pattern -> Enter the filter pattern:

... ... org.springframework.aop.*

Notice that you can use wildcards to disable entire namespaces -- so for example, assuming that your organization's namespace starts with com, you can get most of the way there by blacklisting org.*.

like image 25
Brent Bradburn Avatar answered Oct 20 '22 18:10

Brent Bradburn


IntelliJ ULTIMATE 2018.3 Using File -> Settings -> search 'Step' as follow: enter image description here

like image 9
huoxudong125 Avatar answered Oct 20 '22 19:10

huoxudong125


Another way in "Ultimate 2019.1" (may be also in previous versions):

When you're right now debugging you can make a right mouse click on a class in the view "Debugger" - "Frames". Then you can select "Add stepping filter..." and adding for that class a new step filter. Of course you can here also change the new step filter, using place holder "*" and so on ...

like image 5
Steffen Avatar answered Oct 20 '22 18:10

Steffen