What is the proper syntax to add a condition to a breakpoint to break if a string matches a text. Same question to -break-insert. gdb) -break-condition 1 name.c_str() == "ernie" ^error,msg="No symbol \"ernie\" in current context." (gdb) -break-condition 1 $_streq(name.c_str(), "ernie") ^error,msg="Problem parsing arguments: break-condition 1 $_streq(name.c_str(), \"ernie\")" (gdb) $ more gdbmi_condition.cpp #include <iostream> #include <string> int main (int argc, char* argv[]) { std::string name = ""; name = "ernie"; // Create the breakpoint with a string condition. // // -break-insert -c 'name.c_str() == "ernie"' gdbmi_condition.cpp:16 // Failed parsing. // -break-insert -c '$_streq(name.c_str(), "ernie")' gdbmi_condition.cpp:16 // Failed parsing. // -break-insert -c 'strcmp("xxxxx", name.c_str() == 0' gdbmi_condition.cpp:16 // Is accepted but breaks eventhough strings are different. std::cout << "Name is: " << name << std::endl; return 0; }
I think it should work if you quote the whole condition, like this: -break-condition 1 "$_streq(name.c_str(), \"ernie\")"
Sweet! Yes, indeed. It does work after all the escape'isms. I can implement this in my Seergdb debugger. Thanks for your quick help.
Answered so closing. Thank you Hannes.