Search code examples
c++winapistack-tracecallstackdebug-symbols

print callstack of a thread (c++), StackWalker or not?


Needing to print callstacks of C++ application thread by thread handle, I turned to StackWalker which is mentioned in previous stackoverflow answers.

However, the StakWalker code is dated 2005. I suspect something changed since then.

When I compile and run it, I get error (below), and output seems to be incomplete, truncated at error. Test shall print more testcases.

Does anybody have an updated or different working callstack-printing published code ?

e:\boris\stackwalker\stackwalker\main.cpp (31): Func5
e:\boris\stackwalker\stackwalker\main.cpp (32): Func4
e:\boris\stackwalker\stackwalker\main.cpp (33): Func3
e:\boris\stackwalker\stackwalker\main.cpp (34): Func2
e:\boris\stackwalker\stackwalker\main.cpp (35): TestCurrentThread
e:\boris\stackwalker\stackwalker\main.cpp (139): main
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (582): __tmainCRTStartup
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (399): mainCRTStartup  
VVVVV  
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 7C817077)  
^^^^^  
7C817077 (kernel32): (filename not available): RegisterWaitForInputIdle

Solution

  • This is not a bug from StackWalker sample provided on CodeProject. It is because of missing symbol files. Download and install the the symbol files (debugging symbols) for your OS and then retry.

    http://msdn.microsoft.com/en-us/windows/hardware/gg463028