15

How to dump or search in call stacks of ALL threads in Visual Studio? We have a server process to debug and it has hundreds of threads running, so it should be hard to manually check each threads.

I know "thread apply" in gdb can do this kind of things. So I was wondering is there anything similar available in visual studio's debugger.

Also I was using visual studio 2005, so please give a solution for VS 2005 ( search in all call stack is provided in VS 2010...).

superb
  • 963
  • 1
  • 10
  • 21

3 Answers3

22

I just had the same problem, also in VS2005. I found a simpler solution: While debugging open the command window of VS and use the command: Debug.ListCallStack /AllThreads

I found this on: https://web.archive.org/web/20150627064016/http://blogs.msdn.com/b/greggm/archive/2005/08/02/446899.aspx

sarh
  • 6,371
  • 4
  • 25
  • 29
Jakob
  • 221
  • 2
  • 3
  • Good, but be warned it only seems to print out threads with a managed ID. It doesn't include pure native threads. – Weeble May 27 '11 at 09:04
  • Hmmm. I think I'm wrong there, but I don't understand why it didn't print out all of my threads the first time... – Weeble May 27 '11 at 10:01
  • 2
    If your command window disappeared on you, you can find it here: `View -> Other Windows -> Command Window` – Tim Lewis Nov 18 '15 at 22:35
  • 4
    `Debug.ListCallStack /ShowLineOffset /AllThreads` to include showing the line numbers – solstice333 Nov 21 '16 at 05:56
8

Later I found the answer by using WinDbg,

First save a minidump in VS debug session, say, myapp.dmp

Then using the following command to dump all callstack to out.txt

cdb -z c:\myapp.dmp -logo out.txt -lines -c "~*kb;q" -y c:\symbols

superb
  • 963
  • 1
  • 10
  • 21
3

In VS 2019 (and may be in others)

Main menu: Debug -> Windows -> Threads

Shows Threads tab which lists all threads, for each thread you can expand stack trace and there is a search which can cover stack traces - so that after search you'll get only threads which include required words:

enter image description here

sarh
  • 6,371
  • 4
  • 25
  • 29