Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break the program being debugged now while it running in Eclipse?

How do you break (pause) a Java program in Eclipse?

I'm not talking about breakpoints. I'm talking about randomly pausing a program without knowing what it's currently executing, like in Visual Studio.

like image 793
user541686 Avatar asked Apr 22 '11 21:04

user541686


2 Answers

Assuming you launched the program in debug mode, you can manually switch to the debug perspective.

From there, in the debug pane (which normally shows you the threads and stack location), press the pause button (which looks like a yellow VCR pause button).

Launching the code via the debug launcher is a requirement, as it initializes the JVM with the arguments to turn on the JDI (or Java Debug Interface). This interface can be routed through networks, which allows for remote debugging on embedded devices.

In the Eclipse scenario, the Eclipse program communicates to the child JVM process via JDI when debugging, which is how you can pause, step, and generally trace your way through a program.

-- Ok, you had problems finding it, I'll give you everything from the "top menu" perspective ---

Run->Debug (or F11)
Window->Open Perspective->Debug
Run->Suspend

If you want a better way to stop just the "main" thread, select (in the debug window at the top left screen) the "Thread [main]" prior to suspending. Otherwise, you'll stop all the threads in the JVM.

like image 113
Edwin Buck Avatar answered Oct 05 '22 07:10

Edwin Buck


Start the program in a debug configuration (well not absolutely necessary), go into the debug view and there just select the thread you want to pause and click suspend.

That'll work just fine, although to be exact I think it'll still only pause at guard points (although that hardly matters since there are more than enough of those anyway)

like image 37
Voo Avatar answered Oct 05 '22 06:10

Voo