Visual Studio 函数调试
我正在开发VS 2008。我希望获得所有方法的以下信息:
1)调用进入的时间
2)调用退出的时间和返回值。
GDB 允许我在每个函数入口和出口处设置断点,并在断点处运行脚本,然后继续调试。我厌倦了寻找在 VS 上做类似事情的解决方案。我什至想过编写一个脚本来解析我的整个代码并在入口和出口处编写 fprintf,但这非常复杂。迫切寻求帮助。
I am working on VS 2008. I wish to get the following information for all my methods:
1) Time at call entry
2) Time at call exit and the return value.
GDB allows me to set a break point at each function entry and exit and run a script at the breakpoint and then continue debugging. I am tired of looking for solutions to do something similar on VS. I even thought of writing a script to parse my entire code and write fprintf's at entry and exit but this is very complex. Desperately looking for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用windbg,您还可以在每个函数入口处设置并运行脚本。
例如,以下命令将在模块的所有函数上添加断点,显示函数名称、当前时间,运行直到函数退出,显示时间并继续。
using windbg, you can also set at each function entry and run a script.
For instance the following command will add a breakpoint on all functions of your module, display the name of the function, the current time, run until the function exit, display the time and continue.
基本上,这是一个功能级别的基于时间的分析 (TBP)。有几种工具可以在这方面为您提供帮助:
我建议您先尝试使用 AMD CodeAnalyst。如果您没有 Visual Studio Premium 或 Ultimate 版本。
Basically this is a function level Time-Based Profiling (TBP). Several tools can help you on this:
I suggest you to try with AMD CodeAnalyst first. If you don't have Visual Studio Premium or Ultimate edition.
我假设你正在起诉c++。您可以定义一个显示时间戳的时间跟踪类。
level_ 应单独在 CPP 文件中声明。
在你的代码中,你可以做
如果你不想再跟踪计时器,你可以定义 NO_TRACE_TIMER
I assume you are suing c++. You can define a time trace class which display the timestamps
The level_ should be declared in a CPP file separately.
In your code, you can do
If you don't want to trace timer any longer, you can just define NO_TRACE_TIMER
Visual Studio 不适合这样做;你必须使用WinDbg。它有自己的脚本语言,可以让您完成您想要的事情。不幸的是我对它的脚本语言一无所知;您必须阅读帮助文件(实际上或多或少有用一次)。
Visual Studio is not suited for this; you would have to use WinDbg. It has its own scripting language that would allow you to do what you are seeking. Unfortunately I don't know the first thing about it's scripting language; you will have to read the help file (which is actually more-or-less useful, for once).