通过Visual Studio进行C ++调试-矢量大小更改的监视点 [英] C++ debugging by Visual Studio - Watchpoint on vector size change

查看:146
本文介绍了通过Visual Studio进行C ++调试-矢量大小更改的监视点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想探索矢量的变化.因此,我想在向量大小上设置一个小点.因此,每次更改大小后,Visual Studio都会让我查看向量中的内容.我该怎么办?

I want to explore the changes with my vector. Thus I want to set a whatchpoint on the vector size. Thereby, Visual Studio will let me to see what is in my vector after each size change. How I can do this?

在此链接中您可以找到如何设置条件断点.我试图设置这样的条件:Has changed事件上的my_vect.size()变量(根据8.条件断点),但是很糟糕.

Here in this link you can find how to set a conditional breakpoint. And I tried to set a condition like this: my_vect.size() variable on Has changed event (according to 8. Conditional breakpoints), but it sucks.

推荐答案

my_vect.size()不是变量,而是函数.看起来像这样:

my_vect.size() is not a variable, but a function. It looks like this:

size_type size() const _NOEXCEPT
    {   // return length of sequence
    return (this->_Mylast - this->_Myfirst);
    }

所以这是解决方案:使用调试器启动程序.在向量大小更改之前中断.添加新数据断点.假设您的向量称为myvec.然后在地址字段中分别输入&myvec._Mylast&myvec._Mylast.现在,只要指向向量中第一个或最后一个元素的指针发生更改,调试器就会停止.

So here is the solution: start your program with the debugger. Break before the vector size changes. Add a New Data Breakpoint. Suppose your vector is called myvec. Then in the address field put &myvec._Mylast and respectively &myvec._Mylast. Now, the debugger will stop whenever the pointers to the first or last elements in the vector change.

这篇关于通过Visual Studio进行C ++调试-矢量大小更改的监视点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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