Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop other threads stealing focus when debugging in Eclipse?

I'm debugging a server process running in Eclipse 3.4.1. There are 20 threads or so, waking up at various interval after sleeping.

I set a breakpoint in one method on one thread, and Eclipse stops there properly. The thread is expanded with a stack trace in the Debug view, and I can use the various buttons to step through. This is all what I expect.

My problem is that it seems like when another running thread wakes up while I am stepping through, it steals the focus in the Debug view. My suspended thread is not selected or expanded anymore (it has a + next to it) and all the buttons are disabled. I have to click back on the suspended thread to continue debugging.

Has anyone seen this before and know any workarounds or settings I could change?

like image 824
Scott McIntyre Avatar asked Jul 23 '09 16:07

Scott McIntyre


People also ask

How do I debug multiple threads in Eclipse?

Start debug session. When the breakpoint in run is hit, you can go to another breakpoint, enable that breakpoint if it was disabled. Then right click on the breakpoint -> go to Filters, now you can select the thread you want the breakpoint to be remain enabled for and you can uncheck the rest of the threads.

Do breakpoints stop all threads?

By default only the thread that hits the breakpoint stops. However, you can modify the behavior by changing the breakpopint properties. Save this answer.

How do I get out of loop while debugging in Eclipse?

As a user I would suggest the following: make a hotkey to exit the loop in debugging mode, for example ctrl-shift-F11.


2 Answers

You could suspend the entire Java VM not only the executing thread to get rid of the focus problems.

Select a breakpoint in the breakpoints view and choose "Suspend VM" instead of "Suspend Thread". Under Preferences->Java->Debug you can make "Suspend VM" the default option.

like image 142
Felix Avatar answered Nov 15 '22 17:11

Felix


I have had the same problem when debugging Play!Framework 2 applications. What seems to have finally solved it is to uncheck Java -> Monitors in the debug perspective/thread view panel context menu.

like image 34
Nils Weinander Avatar answered Nov 15 '22 16:11

Nils Weinander