Debug.ListCallStack /AllThreads
One little known feature of the Visual Studio debugger is how to list the callstacks of all threads.
- Switch to the Command Window Tab. In the general profile, it defaults to a dockable window in the tab group on the bottom right.
- Debug.ListCallStack /AllThreads
- Find the thread you want
- Debug.SetCurrentThread <index>
Example output:
>Debug.ListCallStack /AllThreads
Callstack for Thread 1 (Thread Id: 4440 (0x1158)):
Index Function
--------------------------------------------------------------------------------
*1 Fibonacci.exe!Fibonacci(void * vn=0x00000001)
2 Fibonacci.exe!Fibonacci(void * vn=0x00000003)
3 Fibonacci.exe!Fibonacci(void * vn=0x00000004)
4 Fibonacci.exe!Fibonacci(void * vn=0x00000005)
5 Fibonacci.exe!Fibonacci(void * vn=0x00000007)
6 Fibonacci.exe!Fibonacci(void * vn=0x00000008)
7 Fibonacci.exe!Fibonacci(void * vn=0x0000000a)
8 Fibonacci.exe!Fibonacci(void * vn=0x0000000c)
9 Fibonacci.exe!Fibonacci(void * vn=0x0000000e)
10 Fibonacci.exe!Fibonacci(void * vn=0x00000010)
11 Fibonacci.exe!Fibonacci(void * vn=0x00000012)
12 Fibonacci.exe!Fibonacci(void * vn=0x00000014)
13 Fibonacci.exe!main()
14 Fibonacci.exe!__tmainCRTStartup()
15 Fibonacci.exe!mainCRTStartup()
16 kernel32.dll!7d4e6e1a()
17 [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
Callstack for Thread 2 (Thread Id: 4892 (0x131c)):
Index Function
--------------------------------------------------------------------------------
1 ntdll.dll!7d61f1de()
2 [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
3 ntdll.dll!7d627207()
4 ntdll.dll!7d6271a2()
5 ntdll.dll!7d627372()
6 ntdll.dll!7d621818()
7 ntdll.dll!7d62176f()
8 ntdll.dll!7d62717a()
9 msvcr80d.dll!_heap_alloc_dbg(unsigned int nSize=5503884, int nBlockUse=0, const char * szFileName=0x0053fba0, int nLine=1)
10 ntdll.dll!7d626f58()
11 kernel32.dll!7d4dae28()
12 msvcr80d.dll!_decode_pointer(void * codedptr=0x1cfb4445)
13 msvcr80d.dll!__CRTDLL_INIT(void * hDllHandle=0x10200000, unsigned long dwReason=2, void * lpreserved=0x00000000)
14 msvcr80d.dll!_CRTDLL_INIT(void * hDllHandle=0x10200000, unsigned long dwReason=2, void * lpreserved=0x00000000)
15 ntdll.dll!7d610024()
16 ntdll.dll!7d627be5()
17 ntdll.dll!7d627bbf()
18 ntdll.dll!7d627a6b()
19 ntdll.dll!7d61e99d()
Callstack for Thread 3 (Thread Id: 4444 (0x115c)):
Index Function
--------------------------------------------------------------------------------
1 ntdll.dll!7d61c824()
2 [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
3 ntdll.dll!7d62882f()
4 ntdll.dll!7d62887f()
5 ntdll.dll!7d627b28()
6 ntdll.dll!7d627a6b()
7 ntdll.dll!7d61e99d()
>Debug.SetCurrentThread 1
Comments
- Anonymous
August 02, 2005
> >Debug.ListCallStack /AllThreads
I see you're typing that command into the command window instead of viewing the threads window.
A couple of months ago in VS2003 I tried viewing the threads window but it insisted on remaining blank even though my application had two managed threads running. Some random web searching yielded the opinion that the threads window in VS2003 works for C# and VB# but not for VC++2003. I haven't had time to pursue it any further. I really wish I'd had time to convert the syntax to VC++2005beta2 to see if the threads window there would be more cooperative, but I haven't had time.
Anyway, since you're typing commands into the command window to get thread information, do you agree that the threads window isn't useful in VC++? And do you know if there are plans to change that? - Anonymous
August 15, 2005
Thank you for good tip!