Is it possible to skip a statement in Eclipse while debugging? Suppose the process stopped at breakpoint and I want to skip the breakpoint line ( or maybe a few lines below), can I do it? On the debug tab, it开发者_如何学Go only has "Step into", "Step over" and "Step return" buttons.
I did google around but couldn't find anything, hopefully I can find an answer here.
If you are debugging, you can comment out the line you want to skip and then recompile, which will hotswap the code and keep you within the method you are currently in, allowing you to skip the line.
Depending on what you want to have happen, you could simply execute the line after the one you want to skip, select the code and choose Display from the r-click menu. This will execute the selected code and provide the result in a popup.
You can set breakpoint conditions that will determine whether or not this breakpoint will stop or will continue on. I don't know of any way for you to tell it to skip the next few line without changing the code to something like:
if ( !skip ) {
// contents to be skipped
}
and then at the breakpoint set skip
to true.
For the breakpoint conditions, if you return true
will stop and return false
will continue. In here you can actually execute code and do whatever you want (including setting the value of skip
).
I had a similar problem in that I wanted skip some code so that I can get the result of the method call happening later in the code. I forgot that when you are debugging, you can create expressions and evaluate them at anytime. In Eclipse there is an "Expression" tab where you can enter any expressions (i.e. method calls) that you want evaluated.
This meant that I did not have to skip the lines, as I was able to evaluate what I wanted as soon as I entered the appropriate method.
You could always change the value of the class that is about to have a method called to a Mock version of it.
You can do this by right clicking on it in the Variables panel and selecting Change Value
. In the window you can then enter something like:
new SomeClassMock()
Of course this assumes that you have Mock classes already in your classpath (and it sounds like you don't.) However you could certainly create a JAR full of the Mock classes that you need and shove it in the Tomcat shared lib so that you can access it. Not sure if this works but you get the idea.
精彩评论