如何使用std :: string创建条件断点 [英] how to create conditional breakpoint with std::string

查看:294
本文介绍了如何使用std :: string创建条件断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有这个功能:

std::string Func1(std::string myString)
{
   //do some string processing 
   std::string newString = Func2(myString)
   return newString;  
}

如果 newString 具有特定的值? (不更改源)

how do I set a conditional break when newString has a specific value ? (without changing the source)

设置条件 newString ==我的价值

没有工作的断点被禁用,错误重载运算符未找到

didn't work the breakpoints got disabled with an error "overloaded operator not found"

推荐答案

有些搜索没有办法做到这一点。建议的替代方法是将测试放在代码中并添加标准断点:

Some searching has failed to turn up any way to do this. Suggested alternatives are to put the test in your code and add a standard breakpoint:

if (myStr == "xyz")
{
    // Set breakpoint here
}

或建立从个人角色比较中进行测试。即使看着字符串中的个人字符也有点骰子;在Visual Studio 2005中,我不得不挖掘成员变量,如

Or to build up your test from individual character comparisons. Even looking at individual characters in the string is a bit dicey; in Visual Studio 2005 I had to dig down into the member variables like

myStr._Bx._Buf[0] == 'x' && myStr._Bx._Buf[1] == 'y' && myStr._Bx._Buf[2] == 'z'

这两种方法都不是很令人满意。我们应该更好地访问标准库的无所不在的功能。

Neither of these approaches is very satisfactory. We should have better access to a ubiquitous feature of the Standard Library.

这篇关于如何使用std :: string创建条件断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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