Reputation: 13
Is there any java code, which can make a java program pause in eclipse debugger, just like breakpoint? Then I can check the information of debugger, like values, stack. Someone may misunderstand my question. I often write code for debugging like this
if(some_condition){
print_log();
abort();
}
In Visual Studio, I write abort() function. When I run a program in debug mode, abort() function can make the program pause and I can check the debugger.Is there some function in java like abort() in C++?
Upvotes: 1
Views: 1282
Reputation: 11992
I think you'll want to use conditional breakpoints
. I guess you don't want to define a beakpoint which will block your program each it passes on a given line, but only when specific condition occur.
So define a breakpoint, and add a boolean condition to it. You may for example define some variable like :
boolean must_break = false;
Then later on
if (some_condition) { must_break = true; }
Just set you breakpoint on any line with
must_break=false
That way, you control when you want to break you program's execution, and the must_break
condition is reset for the next time.
Upvotes: 1