debugging 打印lldb中std::vector的内容< std::string>

ehxuflar  于 2023-01-26  发布在  其他
关注(0)|答案(1)|浏览(266)

我想把所有的字符串打印到一个向量中。当我这样做的时候

(lldb) p myVector
(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) $30 = size=65 {
  [0] = Summary Unavailable
  [1] = Summary Unavailable
  [2] = Summary Unavailable
  [3] = Summary Unavailable
  [4] = Summary Unavailable
  [5] = Summary Unavailable
  [6] = Summary Unavailable
  [7] = Summary Unavailable
  [8] = Summary Unavailable
  [9] = Summary Unavailable
  [10] = Summary Unavailable
  [11] = Summary Unavailable
...

然而,打印单独的元素起作用,

p myVector[5].c_str()
(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >::value_type *) $31 = 0x0000600000210280 "-D__STDC_CONSTANT_MACROS"

我想一次打印所有元素,因为有相当多。

wbgh16ku

wbgh16ku1#

-fstandalone-debug添加到编译器命令行。
我在cmake上为调试版本设置了以下内容:

set(CMAKE_CXX_FLAGS_DEBUG_INIT "-ggdb3 -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fstandalone-debug ${SANITIZE_OPTS}" CACHE STRING "Initial debug flags")

相关问题