简体   繁体   English

在Windows上获取C ++调用堆栈的示例

[英]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? 有人可以举例说明如何以编程方式获取Windows上当前正在运行的C ++程序的调用堆栈吗? From some threads (eg print call stack in C or C++ ) I have got a suggestion to use DbgHelp . 从某些线程(例如,C或C ++中的打印调用堆栈 ),我得到了使用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). 另外,该库似乎已过时,因为它的最新版本6.12的日期为2010年2月1日(截止目前为7年)。 Is there something new for getting call stack from C++ now? 现在有什么新东西可以用来从C ++获取调用堆栈吗?

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? 如果您要举例说明DbgHelp的用法,是否还可以描述如何安装它,将其添加到项目中并随程序一起提供?

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)来遍历调用堆栈并不是一件繁重的工作。 )将为您做到这一点,如果您不想自己做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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