[英]Cant debug `iostream` related code when using MSVC toolchain in clion
I am new to c++ development, and I find that I can't place breakpoints in iostream related class and if I force step into call of iostream functions like basic_streambuf::xsgetn
I will get a disassembly view which I have absolutely no interest to read.我是 c++ 开发的新手,我发现我无法在与 iostream 相关的 class 中放置断点,如果我强制步入调用basic_streambuf::xsgetn
之类的 iostream 函数,我将得到一个我完全没有兴趣阅读的反汇编视图.
I am using clion with Visual Studio
Toolchain.我正在使用带有Visual Studio
工具链的 clion。 Is there a way to debug normally with those classes?有没有办法用这些类进行正常调试?
By the way, how to use lldb to get actual value of unique_ptr
, now I am using ptr._Mypair._Myval2
which seems really ugly....顺便说一下,如何使用lldb来获取unique_ptr
的实际值,现在我用的是ptr._Mypair._Myval2
,看起来真的很难看....
After a few days of digging.经过几天的挖掘。 It turns out that adding the following to CMakeLists.txt fixed the problem事实证明,将以下内容添加到 CMakeLists.txt 解决了问题
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
message(STATUS " MSVC DEBUG RUNTIME")
# enable debugging of runtime library
set_property(TARGET archive_patcher_cpp PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
endif()
Note: this will link runtime statically so the executable size will be a lot bigger , and this requires cmake 3.15 or higher.注意:这将静态链接运行时,因此可执行文件大小会更大,这需要 cmake 3.15 或更高版本。
reference: https://cmake.org/cmake/help/v3.15/prop_tgt/MSVC_RUNTIME_LIBRARY.html参考: https://cmake.org/cmake/help/v3.15/prop_tgt/MSVC_RUNTIME_LIBRARY.html
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.