简体   繁体   中英

Example of getting C++ call stack on Windows

Can someone give an example of how to get programmatically the call stack of the currently running C++ program on Windows? From some threads (eg print call stack in C or C++ ) I have got a suggestion to use DbgHelp . However the library seems quite large and intended for many more features than just the call stack, so studying the library without an example can take too long time. Also the library seems obsolete because the last version of it, 6.12 , is dated 01 February 2010 (7 years old as of now). Is there something new for getting call stack from C++ now?

If you are giving an example of DbgHelp usage, could you also describe how to install it, add to the project and ship with my program?

I would like to get undecorated names of all functions on the call stack, preferrably with values of the parameters.

通过弹出ebp CaptureStackBackTrace( https://msdn.microsoft.com/en-us/library/windows/desktop/bb204633 ( v= vs.85).aspx)来遍历调用堆栈并不是一件繁重的工作。 )将为您做到这一点,如果您不想自己做。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM