1

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++?

umbrella
  • 13
  • 6

1 Answers1

1

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.

Orabîg
  • 11,718
  • 6
  • 38
  • 58
  • This is a method. But I don't know whether configuring the condition breakpoint is as convenient as abort() function in C++. I have edited my question. Thanks for your answer! – umbrella Aug 22 '14 at 15:10