https://stackoverflow.com/questions/253099/how-do-i-print-the-elements-of-a-c-vector-in-gdb
打印方法
With GCC 4.1.2, to print the whole of a std::vector<int> called myVector, do the following:
print *(myVector._M_impl._M_start)@myVector.size()To print only the first N elements, do:
print *(myVector._M_impl._M_start)@NExplanation
This is probably heavily dependent on your compiler version, but for GCC 4.1.2, the pointer to the internal array is:
myVector._M_impl._M_start And the GDB command to print N elements of an array starting at pointer P is:
print P@NOr, in a short form (for a standard .gdbinit):
p P@N其他解决方式:
使用clang++和lldb这一套工具,可以直接显示vector中的变量
使用vs自带的msvc及其调试工具,也可以直接显示vector中的变量
