Eclipse CDT Kepler 不允许"Display as array..."

Eclipse CDT Kepler does not allow "Display as array..."

本文关键字:Display array as 不允许 CDT Kepler Eclipse      更新时间:2023-10-16

我正在尝试使用Eclipse CDT:调试C++程序

#include <vector>
using namespace std;
int main() {
  vector<int> test (4,100);
  return 0;
}

如果我放置一个断点进行调试,并单击矢量变量的"显示为数组…",我会得到以下错误:

(*((test)+0)@4) Error: Multiple errors reported. Failed to execute MI command: -var-create - * (*((test)+0)@4) Error message from debugger back end: No symbol "operator+" in current context. Unable to create variable object

调试时如何查看数组的值?

我正在使用:

  • Eclipse 4.3(开普勒)
  • Ubuntu 13 64位
  • gcc 4.7.3(使用-g3-O0编译)
  • gdb 7.5.91
  • GDB(DSF)创建进程启动器

Eclipse可以在这里和这里查看快照和说明。这篇文章也帮助了我。

深入std::vector变量的结构,查找名为_M_start或类似的s.th(可能取决于实现)
将此类型转换为您知道并希望看到的最终类型数组。

原因是std::vector<T>只是在内部封装和管理T的数组,因此不能作为数组本身显示。