首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >条件观察点监视lldb中指针的内容。

条件观察点监视lldb中指针的内容。
EN

Stack Overflow用户
提问于 2020-10-30 09:52:52
回答 1查看 31关注 0票数 0

当指向struct的aux指针的内容为"AAAAA“时,我想停止执行。

代码语言:javascript
复制
typedef struct Matriz {
  string *usuario;
  string *produto;
  string nota;
  Matriz *proxima_linha, *proxima_coluna;
} Matriz;

Matriz *aux = new Matriz();

首先,我在aux声明后面放了一个断点。

breakpoint set --file UsuariosSemelhantes.cpp --line 55

然后我定义了一个观察点。

watchpoint set variable aux

然后我添加了停止条件。

watchpoint modify -c '(int)strcmp(*aux->usuario,"AAAAA") == 0'

但我得到以下错误:

代码语言:javascript
复制
Process 398158 resuming
Stopped due to an error evaluating condition of watchpoint Watchpoint 1: addr = 0x7fffffffe620 size = 8 state = enabled type = w: "(int)strcmp(*aux->usuario,"AAAAA") == 0"
error: <user expression 0>:1:13: cannot pass object of non-trivial type 'std::string' (aka 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >') through variadic function; call will abort at runtime
(int)strcmp(*aux->usuario,"AAAAA") == 0
            ^
EN

回答 1

Stack Overflow用户

发布于 2020-10-31 02:45:13

条件必须是有效的C++表达式。不能将std::string传递给strcmp,需要传递char *。如果你在代码中尝试这样做,你也会得到一个错误。

因为您有一个std::string,所以使用std::string方法可能是最简单的方法:

代码语言:javascript
复制
aux->usuario->compare("AAAAA") == 0
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64601702

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档