GDB 无法调用函数

gdb can't call function

本文关键字:函数 调用 GDB      更新时间:2023-10-16

我有一些问题调试我的应用程序-当我尝试调用解析器::extractString(…)从gdb shell它返回

命名空间"parser"中没有"extractString"符号。

执行

info functions

我有这样的输出

所有匹配正则表达式"extractString"的函数:

文件/home/dmitriy/Sources/transceiver/解析器/json.cpp:std:: __cxx11:字符串解析器:extractString [abi: cxx11] (rapidjson:: GenericValue,解析器:MultithreadAllocator> const&);

非调试符号:0x0000000000506500解析器:extractString [abi: cxx11] (rapidjson:: GenericValue,解析器::MultithreadAllocator> const&)@plt 0x00007ffff77e3640解析器:extractString [abi: cxx11] (rapidjson:: GenericValue,解析器:MultithreadAllocator> const&) @plt

调用这个函数有什么问题?函数extractString定义在静态库中,从应用程序调用没有任何问题。

gdb还不支持gcc 5中引入的c++ 11 ABI标签。查看这些bug:

  • https://sourceware.org/bugzilla/show_bug.cgi?id=19436
  • https://sourceware.org/bugzilla/show_bug.cgi?id=18601

最简单的解决方法可能是通过定义宏_GLIBCXX_USE_CXX11_ABI到0来禁用新的gcc ABI,参见https://gcc.gnu.org/gcc-5/changes.html#libstdcxx。

或者您可以尝试从https://sourceware.org/bugzilla/show_bug.cgi?id=18601#c1应用变通方法,尽管它们看起来有点奇怪。