var-create无法创建变量对象 [英] var-create unable to create variable object
问题描述
当我调试c ++(clion)时,看不到全局字符串。我尝试检查其他类型,但效果很好。
此外,我尝试了 local 字符串,我也可以观看吗? >
以防万一,现在将问题跟踪为 CPP-8693 。
根本原因与libstdc ++ 双重ABI 。
std :: string
类型的全局符号以不同的方式处理,从而混淆了GDB。
在GCC 5.1版本中,libstdc ++引入了一个新的库ABI,其中包括
std :: string
和std ::的新实现。列表
。这些更改对于遵守2011 C ++标准是必要的,该标准禁止写时复制字符串,并要求列表跟踪其大小。
给出以下代码:
std :: string global_var =嗨!
static std :: string static_var = Hello;
以下是相关的 nm
输出:
0000000000602240 B _Z10global_varB5cxx11
0000000000602280 b _ZL10static_var
可能的解决方法是禁用C ++ 11 ABI。在CMakeLists.txt中,在 set(CMAKE_CXX_STANDARD 11)
行之后(如果有)添加以下行:
add_definitions(-D_GLIBCXX_USE_CXX11_ABI = 0)
这将使符号名称将以不同的方式进行处理,使GDB再次感到高兴:
0000000000602238 B global_var
0000000000602248 b _ZL10static_var
When I debug c++ (in clion), I can't watch global strings. I tried to check other types but it worked well.
Also, I tried local string and I can watch it too?!
Just in case, the issue is now tracked as CPP-8693.
The root cause is somehow related to libstdc++ dual ABI.
Global symbols of std::string
types are mangled differently, which in turn confuses GDB.
In the GCC 5.1 release libstdc++ introduced a new library ABI that includes new implementations of
std::string
andstd::list
. These changes were necessary to conform to the 2011 C++ standard which forbids Copy-On-Write strings and requires lists to keep track of their size.
Given the following code:
std::string global_var = "Hi there!";
static std::string static_var = "Hello";
Here's the related nm
output:
0000000000602240 B _Z10global_varB5cxx11
0000000000602280 b _ZL10static_var
A possible workaround is to disable C++11 ABI. In CMakeLists.txt, add the following line, right after the set(CMAKE_CXX_STANDARD 11)
line, if any:
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
This makes symbol names to be mangled differently, in a way GDB is happy again:
0000000000602238 B global_var
0000000000602248 b _ZL10static_var
这篇关于var-create无法创建变量对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!