【问题标题】:Clion debug: How to step into STLClion 调试:如何进入 STL
【发布时间】:2016-12-02 00:34:58
【问题描述】:

我想知道字符串是如何工作的,所以我在 basic_string.h 中添加了断点。 但是我调试的时候并没有进入这些断点。

当我在调试时添加断点时,GDB 控制台会显示: 文件“C:/Users/manch/Downloads/MinGW/lib/gcc/mingw32/4.8.1/include/c++/bits/basic_string.h”中没有第1008行。

enter image description here

这是我的测试代码

#include <iostream>
#include <string>

int main() {
    std::string *ps = new std::string("hello");
    ps->append(" world");
    return 0;
}

和 CMakeLists.txt

cmake_minimum_required(VERSION 3.6)
project(Stl)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp test.cpp  C:/Users/manch/Downloads/MinGW/lib/gcc/mingw32/4.8.1/include/c++/bits/stl_construct_copy.h)
add_executable(Stl ${SOURCE_FILES})

【问题讨论】:

    标签: c++ debugging stl clion


    【解决方案1】:

    您还需要有 libstdc++ 的源文件,MinGW 将标准 C++ 库链接到您的可执行文件。然后,根据this的问题,你需要在编译时添加-D_GLIBCXX_DEBUG标志,以便链接带有调试信息的库。

    【讨论】:

      猜你喜欢
      • 2023-04-05
      • 2016-10-20
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      • 2022-07-19
      • 1970-01-01
      • 2019-06-09
      • 1970-01-01
      相关资源
      最近更新 更多