GDB-strcmp无法正常工作:__strcmp_sse2_unaligned [英] GDB - strcmp not working: __strcmp_sse2_unaligned
问题描述
我无法使用strcmp在GDB中创建条件断点:
I'm unable to create conditional breakpoint in GDB using strcmp:
break x if strcmp(str.c_str(), "foo") == 0
你为什么问?
因为:
print strcmp("hello", "hello")
屈服的
(int (*)(const char *, const char *)) 0x7ffff76ffe70 <__strcmp_sse2_unaligned>
即使将其转换为整数:
print (int)strcmp("hello", "hello")
它返回一些无意义的值,如-143655312
It returns some nonsensical value like -143655312
这是解决"我的问题的一种不太优雅的方法.我可以在自己的代码中定义一个函数:
Here's a less graceful way to "solve" my problem. I can define a function in my own code:
int mystrcmp(const char *str1, const char* str2){
return strcmp(str1, str2);
}
现在我可以将其用作条件断点了.但这不是真的调试吗?当您不得不更改原始代码以对其进行调试时,您就迷失了游戏!
And now I'm able to use this function instead for my conditional breakpoint. But this isn't really debugging is it? When you have to change your original code to debug it you have lost the game!
那我想念什么?
推荐答案
The strcmp
is special -- it's a runtime function selector (IFUNC) which returns an address of (one of several possible) implementations of strcmp
to be used on the current processor.
您应该可以执行此操作:
You should be able to do this instead:
break x if __strcmp_sse2_unaligned(str.c_str(), "foo") == 0
这篇关于GDB-strcmp无法正常工作:__strcmp_sse2_unaligned的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!