Debugging multiple threads in eclipse

In the method I am debugging, I create a new thread. I need to debug the execution of this new thread, not the parent thread. How can I do this in eclipse?

+56
java debugging eclipse multithreading
Mar 21 '11 at 9:02
source share
4 answers

Place a breakpoint on the "start" method of the new thread. This will stop execution after the start of the thread.

+32
Mar 21 '11 at 9:08
source share

In addition to Shamit Verma's answer:

When debugging multi-threaded Java applications, it’s best not to use standard breakpoints that only suspend the thread where the breakpoint is set. Defining a standard breakpoint in your application will break only the associated thread. Other threads will still work. In eclipse, the debugger for some reason causes the debugger to skip breakpoints if other threads are already running.

Java debugging solution:

Define a breakpoint in the desired thread (@Run () method, which I expect ..), right-click on the breakpoint -> breakpoint properties.

In the breakpoint properties dialog box, select the Suspend VM check box instead of Pause Stream.

If you do this, your virtual machine will be suspended if a breakpoint is reached.

In C / C ++ CDT, use set-scheduler- lock on :

As @Employed Russian says in an answer to another question , the GDB command:

set scheduler-locking on 

will cause other C / C ++ threads to remain paused while the current thread is running. This command can be executed in Eclipse / CDT Debug, pausing the program and opening the "Debugger Console" perspective and entering: set scheduler-lock on. Later it can be returned to normal with: set scheduler-lock off

See the GDB Documentation for more information on scheduler lock and non-stop mode, which allows other threads to work when one thread stops.

+173
Mar 28 2018-12-12T00:
source share

In addition to Eric Kudge's answer. If you are debugging CDT (this may be applicable for Java, I'm not sure about that), then

  • Place a breakpoint on the run () method (or its equivalent). Or any point at which you are sure that the required threads and the non-required thread (those that will be removed by the filter) will be started.
  • Start a debugging session.
  • When a start breakpoint hits, 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 stream that you want the breakpoint to be on, and you can uncheck the rest of the threads. Thus, this breakpoint will be deleted only for this thread.

The disadvantage is that this procedure must be repeated for each debugging session. If someone can provide a short cut, then that would be good.

+4
Jun 12 '14 at 0:21
source share

in your eclipse debugging window, you can drag and drop threads to land on the desired workflow number and continue your sequential search (F6). enter image description here

+1
Mar 03 '17 at 6:53 on
source share



All Articles