Visual Studio调试器技巧&技巧(C / C ++项目) [英] Visual Studio debugger tips & tricks (for C/C++ projects)

查看:139
本文介绍了Visual Studio调试器技巧&技巧(C / C ++项目)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣在Visual Studio的调试器中调试C / C ++项目的提示和技巧。我最近发现,如果你有一个指向某个数据类型的指针,我们假设char * ptr,那么你可以使用如下语法在watch窗口中看到它作为一个数组:

I'm interested in tips and tricks regarding debugging a C/C++ project in Visual Studio's debugger. I recently found out that if you have a pointer to a certain data type, let's say char* ptr, then you can see it as an array in the watch window using a syntax such as:


ptr,10

这将显示ptr地址中的前10个元素,定义如下:

This will display the first 10 elements from the ptr address, in the same way as it would be displayed if the definition would be:


char ptr[10];

您对Visual Studio调试器有什么其他提示和技巧?

What other tips and tricks do you know about Visual Studio debugger?

PS:我希望这个话题还没有被讨论过。如果您找到类似的帖子,请让我知道。

PS: I hope this subject wasn't already discussed. Should you find a similar post, please let me know.

推荐答案

我真的很喜欢调整Debugger类型和结构通过 AutoExp.dat 。该文件位于

I really like the possibility to tweak the Debugger display of types and structures through AutoExp.dat. The file is located at


.. \Microsoft Visual Studio
9.0\Common7\Packages\Debugger\ autoexp.dat

..\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\autoexp.dat

,并允许在调试期间定义自己的模板显示数据:

and allows to define own templates for the display of data during debugging:


调试时,Watch和Variable窗口中的数据提示和项目
自动扩展为显示其
最重要的元素。扩展
遵循此文件中的规则
给出的格式。您可以添加
您的类型的规则或更改预定义的
规则。

While debugging, Data Tips and items in the Watch and Variable windows are automatically expanded to show their most important elements. The expansion follows the format given by the rules in this file. You can add rules for your types or change the predefined rules.

该文件已满示例,您可以轻松地根据自己的需要调整某些模板,或为自己的课程添加新的模板。

The file is full of good examples and you can easily adapt certain templates to your own needs or add new ones for your own classes.

这篇关于Visual Studio调试器技巧&技巧(C / C ++项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆