0

I would like to stop my execution when the content of the aux pointer to struct is "AAAAA".

typedef struct Matriz {
  string *usuario;
  string *produto;
  string nota;
  Matriz *proxima_linha, *proxima_coluna;
} Matriz;

Matriz *aux = new Matriz();

first i put a breakpoint after the aux declaration.

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

then I define a watchpoint.

watchpoint set variable aux

and then I add the stop condition.

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

but I get the following error:

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
            ^

1 Answers1

0

Conditions have to be valid C++ expressions. You can't pass a std::string to strcmp, you need to pass a char *. If you tried this in code you'd get an error as well.

Since you have a std::string, it's probably easiest to just use a std::string method like:

aux->usuario->compare("AAAAA") == 0
Jim Ingham
  • 25,260
  • 2
  • 55
  • 63