Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breakpoint a multi thread application

What happens if I breakpoint a multi thread application.

does it stop all the threads, just the one that is break pointed or does the whole program just crash ?

If it is possible would I want to stop just one thread or would this mess up my application ?

If I cannot break point a multi tread application what are the debug techniques available to me ?

like image 866
Skeith Avatar asked Apr 28 '11 12:04

Skeith


2 Answers

JAVA: As far as personal experience goes, you can debug multi-threaded applications by stopping all threads or individual threads. It would most likely depend on what IDE you are using, and what application you are connecting to, but for me its:

  • Eclipse connecting in debug mode to a Tomcat server running in jpda
  • Place a breakpoint in the code, go to Eclipse's debug perspective (sometimes it pauses but doesn't switch perspective)

  • In the breakpoints window, you will see a list of breakpoints. Each one you can right-click and set properties on... if you want to stop all threads on one breakpoint, hit the Suspend VM radio button. If you only want to stop a single thread, click suspend thread.

I'm not sure you're able at this point to select which thread you want to pause if using the single thread stop option. In Suspend VM, you can look at the Debug pane and see your thread... scroll down and you can jump between the threads (Daemon thread 10 vs Daemon thread 9, something like that)

like image 112
tehemperorer Avatar answered Oct 03 '22 17:10

tehemperorer


It stops all threads.

It is not normally possible to just stop one thread. For more information on debugging threads with GDB see this part of the manual.

like image 42
James Avatar answered Oct 03 '22 19:10

James