Visual Studio Debugger观察问题 [英] Visual Studio Debugger Watch problems

查看:161
本文介绍了Visual Studio Debugger观察问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Visual Studio调试器监视窗口(或其他地方)中找到堆栈上的变量地址



读取变量的工作正常:

/ p>

  streets streets [11790](0x1c66a690 [...] std :: vector< Street *,std :: allocator< >>>> 

但是在前面加上&不能给我一个地址:

 & streets streets [11790](0x1c66a690 [...] std :: vector< Street *,std :: allocator< Street * ;> 



此外,尝试读取大小不起作用, p>

  streets.size()CXX0075:错误:无法设置函数评估
解决方案

程序是以调试模式编译的。 Studio Debugger通过 autoexp.dat 文件中的模式定义的转换来驱动调试器监视,快速观察,自动和局部变量视图(取决于您的VS版本,其中的内容可能会显着不同) 。该文件位于您的VS-InstallDir / Common7 / Packages / Debugger文件夹(至少它是VS2010和VS2012)。



知道这一点,您可以尝试/考虑几个想法:



方法一:库知识



要访问向量I中的第一个元素的实际地址最终只需这样做:

  streets._Myfirst 

如果您知道要查看的元素数量,可以使用数组扩展扩展:

  streets._Myfirst,N 

其中 N 是元素的数量



注意:这只适用于上面的向量。实践根据您使用的容器而有所不同。有没有怀疑更简单的方法可能较少依赖于std :: vector<>的实现,但这是最简单的,我知道如何让你快速调试和调试。






方法二:烧焦的地球



General是一个可以打开和关闭的功能列表。其中一个你会发现这个问题特别有用:


在变量窗口中显示对象的原始结构。


打开 ON 可查看所有结构和容器的原始成员变量,包括标准容器,如std: :vector>。这会有效地禁止在 autoexp.dat


中使用模板

How can I find out the address of a variable on the stack in the visual studio debugger watch window (or elsewhere?)

Reading the variable works fine:

streets     streets [11790](0x1c66a690 [...] std::vector<Street *,std::allocator<Street *> >

But prefixing with & doesn't give me an address:

&streets        streets [11790](0x1c66a690 [...] std::vector<Street *,std::allocator<Street *> >

Also, trying to read the size doesn't work, why is that?

streets.size()  CXX0075: Error: Cannot set up Function Evaluation   

The program is compiled in debug mode.

解决方案

The Visual Studio Debugger drives debugger watch, quick-watch, auto, and local variable views through a translation defined by schema in a file called autoexp.dat (depending on your VS version, the content therein can vary markedly). The file is located in your VS-InstallDir/Common7/Packages/Debugger folder (at least it is for VS2010 and VS2012).

Knowing this, a couple of ideas for you to try/consider:

Method One: Library Know-How

To access the actual address of the first element within the vector I ultimately just do this:

streets._Myfirst

if you know the number of elements you're going to view, you can use the array-expansion extension by:

streets._Myfirst,N

where N is the number of elements

Note: this only works as shown above with vectors. The practice is different depending on which container you are using. There are no-doubt simpler ways that are probably less dependent on the implementation of std::vector<>, but this is the simplest wasy I know how to get you up and debugging quickly.


Method Two: Scorched Earth

Under Tools/Options/Debugging/General is a list of features you can switch on and off. One of them you will find particularly useful to this question:

Show raw structure of objects in variable windows.

Turn this ON to see raw member variables of all structures and containers, including standard containers like std::vector<>. This effectively disables usage of the templates in autoexp.dat

这篇关于Visual Studio Debugger观察问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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