我想在 VC++ Express 2005 中的代码中添加一个断点条件,以便仅当局部变量满足指定条件时才触发断点。例如
bool my_test(UIDList test_list) {
foo(test_list);
bar(test_list); // I have a breakpoint here, but only want it to trigger if test_list.Length() > 0
print(test_list);
}
右键单击我的断点并选择“条件...”后,我发现了一个对话框,它似乎可以执行我想要的操作,但是我尝试在文本字段中输入的任何内容都会导致以下错误:
Unable to evaluate the breakpoint condition: CX0052: Error: member function not present
我尝试了帮助文档,但找不到我的答案。我希望有 VC++ 经验的人能够为我指明正确的方向...
我之前曾尝试升级到更新版本的 VC++ Express,但项目没有完全导入。由于项目的复杂性和我当前的时间尺度,我目前不能考虑将升级作为解决方案。
最佳答案
VS 确实有一些微计算引擎——在可变监 window 口、即时窗口、断点条件等中。我永远找不到关于它们的合适文档。据我所知,他们对愿意调用的方法很挑剔,但他们对访问限制也不敏感。
所以,你可能可以改写你的条件从
test_list.Length() > 0
类似于
test_list.m_nLength > 0
(或者你的私有(private)长度变量是什么)。
(编辑)刚刚找到 this msdn page解释调试器可以处理和不能处理的表达式。所以首先,indeed -
'The debugger can access all class members regardless of access control. You can examine any class object member, including base classes and embedded member objects.'
其次,我对未能评估“Length()”的猜测 - 它可能是内联的:
'A debugger expression cannot call an intrinsic or inlined function unless the function appears at least once as a normal function.'
关于c++ - 如何在 Visual C++ 中添加条件断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/657724/