how to create conditional breakpoint with std::string

前端 未结 11 1001
粉色の甜心
粉色の甜心 2020-12-07 12:54

Suppose I have this function:

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


        
11条回答
  •  既然无缘
    2020-12-07 13:41

    Tried to use strcmp in gdb8.1 under ubuntu18.04, but it doesn't work:

    (ins)(gdb) p strcmp("a", "b")
    $20 = (int (*)(const char *, const char *)) 0x7ffff5179d60 <__strcmp_ssse3>
    

    According to this answer, strcmp, is a special IFUNC, one can setup condition like this:

    condition 1 __strcmp_ssse3(camera->_name.c_str(), "ping")==0
    

    It's pretty ugly, don't want to do it the second time.

    This answer gives a much better solution, it use std::string::compare :

    condition 1 camera->_name.compare("ping") == 0
    

提交回复
热议问题