我无法使用strcmp在GDB中创建条件断点:
break x if strcmp(str.c_str(), "foo") == 0你为什么要问?
因为:
print strcmp("hello", "hello")产量‘s
(int (*)(const char *, const char *)) 0x7ffff76ffe70 <__strcmp_sse2_unaligned> 即使在将其转换为整数时:
print (int)strcmp("hello", "hello")它返回一些荒谬的值,比如-143655312。
这里有一个不太优雅的方法来“解决”我的问题。我可以在自己的代码中定义一个函数:
int mystrcmp(const char *str1, const char* str2){
return strcmp(str1, str2);
} 现在我可以用这个函数来代替我的条件断点。但这并不是真正的调试,对吧?当您必须更改您的原始代码来调试它时,您已经输掉了游戏!
那我错过了什么?
发布于 2018-08-20 16:32:55
strcmp是特殊的--它是一个运行时函数选择器(IFUNC),它返回要在当前处理器上使用的strcmp的(几种可能的实现之一)的地址。
相反,您应该能够这样做:
break x if __strcmp_sse2_unaligned(str.c_str(), "foo") == 0https://stackoverflow.com/questions/51934903
复制相似问题