Cannot view std::string when compiled with clang

前端 未结 4 909
深忆病人
深忆病人 2021-02-12 13:38

g++ (GCC) 5.2.0

clang version 3.7.1 (tags/RELEASE_371/final)

GNU gdb (GDB) 7.12

Gdb is unable to locate the definition of std::string when compiled with

4条回答
  •  暖寄归人
    2021-02-12 14:22

    The last workaround mentioned in bug 24202 as linked by ks1322 is worth having a look at:

    -fno-limit-debug-info will make your debug info larger, slow link (if you're not using -gsplit-dwarf) and debugger performance. But, yes, will address this.

    Using -fno-limit-debug-info forces Clang to emit debug information for e.g. std::string at the cost of a larger binary while preserving compatibility with other libraries and the rest of the system/SDK.

    As ks1322 and Kevin mentioned, one can instead use -D_GLIBCXX_DEBUG to switch libstdc++ into debug mode but this comes at a heavy price: any library you link against and with which you exchange STL containers (string, vector, etc.) must also be built with -D_GLIBCXX_DEBUG. Meaning: your system/SDK must either support this with a separate set of libraries or you will have to rebuild them yourself.

提交回复
热议问题