Can I pause a thread while debugging on intellij? What I want to have is something similiar to other ID - right click on a thread and pause it.
You either use a standard breakpoint which will pause all threads when hit or you can use a breakpoint with the suspend policy = thread.
Related
When I attach to a process, or when a breakpoint is hit, all the threads are paused. I can't find out how to pause one thread, and let other threads continue running.
I can't find out how to pause one thread, and let other threads continue running.
Besides the non-stop mode mentioned in this answer, and scheduler locking mentioned here, you could do this:
# arrange for GDB to stop in the thread you want to suspend.
(gdb) call sleep(1000) # current thread will sleep, all others will continue running
When I step over (F10) in the debugger, I am staying on the thread I am currently in.
Therefore, when I step over a line of code, and the process crash in an over thread, I am not able to see in which thread it went.
As I don't know in which thread the crash is happening, I can not simply click on it in the thread window.
Do you know how to switch to "guilty" thread ?
Thanks
You can go into Debug >> Windows >> threads to see all your threads. You can also right lick on thread and select 'switch thread'.
I have a background thread that polls UI thread every 200ms. If there is a hang for 2 seconds, I would like to get the call stack from UI thread at that point. When I call [NSThread callStackSymbols], it is executed on background thread since I check If the hang is more than 2 secs in background thread.
is there an easy way to get call stack on main thread from bg thread?
Here is how to do it "manually".
Well, if I understand you right one of the threads is doing some heavy lifting which takes too long time. For these cases I just hit the pause button in xcode to pause the debugger. Then it is easy to inspect the callstack and see which method is blocking from continuing.
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 ?
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)
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.
Since you didn't tag your question with a specific language/platform, I'll give a Java-related answer.
In most IDEs you can set properties on your breakpoints, specifically conditional properties. So, if you know the name of your thread, you can do something like this:
"ThreadName".equals(Thread.currentThread().getName())
...and all other threads utilising the same class (where you set the breakpoint) will carry on unhindered.
I've found some good questions and with good answers for naming threads in Delphi.
Like this one Named threads in Delphi - what is that for?.
But how, while debugging, I get to see the name of the thread?
And also, even with that, I cannot see the thread name in utilities like Process Explorer right?
When the execution is paused (because you trigger the pause by clicking the "pause" icon or selecting menu Run, Program Pause; or because the breakpoint is hit), the thread names are visible in the Threads window (View, Debug Windows, Threads; or Ctrl-Alt-T).
No, Process Explorer cannot show thread names.