Debugging multiple threads in eclipse

后端 未结 4 2114
無奈伤痛
無奈伤痛 2020-12-02 12:53

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

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 13:16

    In addition to Erik Kaju's answer. If you are debugging CDT (this might be applicable for Java as well, I am not sure about that) then

    1. Put a breakpoint on run() method (or its equivalent). Or any point at which you are sure that the required threads and the not-required thread (the ones which will be removed by the filter) both are running.
    2. Start debug session.
    3. 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. So this breakpoint will only be hit for that particular thread.

    The drawback is this procedure has to be repeated for every debug session. If anyone can provide short cut for it then that would be nice.

提交回复
热议问题