在使用Eclipse/CDT调试c++代码时,可以更好地进行变量探索

时间:2023-01-17 19:26:10

Using Eclipse and CDT to debug C++ code the variable windows is cumbersome and not very informative for types defined in the standard template library or in boost (e.g. shared_ptr).

使用Eclipse和CDT调试c++代码,变量窗口很麻烦,而且对于标准模板库或boost(例如shared_ptr)中定义的类型没有太多的信息。

Just an example how this may look like for an std::vector:

举个例子,对于std::vector:

bar {...}   
    std::_Vector_base<TSample<MyTraits>, std::allocator<TSample<MyTraits> > >   
        _M_impl {...}   
            std::allocator<TSample<MyTraits> >  {...}   
            _M_start    0x00007ffff7fb5010  
            _M_finish   0x00007ffff7fd4410  
            _M_end_of_storage   0x00007ffff7fd5010  

Even if this information about the internals of those types may be useful, in almost any cases I would expect a clearer presentation here, i.e. a list of values for the std::vector. Are there any tools, plugins or other modifications around which can do this?

即使这些关于这些类型的内部信息可能有用,但在几乎任何情况下,我都希望这里有更清晰的表示,即std::vector的值列表。有没有什么工具,插件或者其他的修改可以做到这一点?

EDIT

编辑

The following solutions does not work for linux. I am using ubuntu 14.04, eclipse, g++, gdb.

以下解决方案不适用于linux。我正在使用ubuntu 14.04, eclipse, g++, gdb。

I cant find a package gdb-python and linux does not use mingw

我找不到一个gdb-python和linux不使用mingw的包

6 个解决方案

#1


26  

You need a version of GDB capable of using python to pretty print structures. I know at least on windows using mingw that this is not provided in the default install.

您需要一个GDB版本,它能够使用python实现漂亮的打印结构。我知道至少在使用mingw的windows上,默认安装中没有提供这个功能。

Pretty Printers are python modules which tell gdb how to display a given structure. You can write your own, but there are already printers for STL available for download.

漂亮的打印机是python模块,它告诉gdb如何显示给定的结构。您可以自己编写,但是已经有STL的打印机可以下载。

To Get Pretty Printers working on Windows (instructions should be similiar for other OS's):

要使漂亮的打印机在Windows上工作(指令应该与其他操作系统相似):

Prerequisites

先决条件

Installation:

安装:

  • Open a command Shell and type:

    打开命令Shell并输入:

    mingw-get install gdb-python
    
  • When its finished cd to a local directory and install the printers by typing:

    当完成cd到本地目录并通过输入安装打印机时:

    svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
    
  • Open the .gdbinit (create it in a text editor if need be) and type the following replaceing "C:/directory" with the folder that you checked the printers into.

    打开.gdbinit(如果需要,可以在文本编辑器中创建它),并使用检查打印机的文件夹键入下面的“C:/directory”替换。

    Python
    import sys
    sys.path.insert(0, 'C:/directory')
    from libstdcxx.v6.printers import register_libstdcxx_printers
    register_libstdcxx_printers (None)
    end

    Python导入sys sys.path。插入(0,“C:/目录”)从libstdcxx.v6。打印机导入register_libstdcxx_printers register_libstdcxx_printers (None)结束

Eclipse Setup

Eclipse设置

  • Go To Windows > Preferences > C/C++ > Debug > GDB
  • 转到Windows >首选项> C/ c++ >调试> GDB
  • Where it Says GDB Debugger put the path to the python enabled GDB it will most likely be in the mingw /bin folder with a name like gdb-python27.exe
  • 如果GDB调试器将路径放置到启用python的GDB,那么它很可能会位于mingw /bin文件夹中,文件夹的名称是GDB -python27.exe
  • Where it says GDB Command File put the path to the .gdb init file you made earlier.
  • 它说GDB命令文件将路径放到您之前创建的。GDB init文件中。

That's it, debug like normal, the stl structures should be much easier to read.

就是这样,像往常一样调试,stl结构应该更容易读。

#2


20  

Well, gdb don't natively support STL containers. You can't say this is incorrect, since it will expose the inner workings of the STL objects, but most of the time it is not what we want, right?

gdb本身并不支持STL容器。你不能说这是错误的,因为它会暴露STL对象的内部工作,但是大多数时候它不是我们想要的,对吧?

If you're using gdb 7.0 you can take advantage of the pretty printers. This website http://sourceware.org/gdb/wiki/STLSupport has a pretty simple tutorial on how to set them. I copied below the part that interests you:

如果你使用gdb 7.0,你可以利用漂亮的打印机。这个网站http://sourceware.org/gdb/wiki/STLSupport有一个关于如何设置它们的简单教程。我抄了以下你感兴趣的部分:

  1. Check-out the latest Python libstdc++ printers to a place on your machine. In a local directory, do:

    将最新的Python libstdc++打印机签出到您的机器上的某个位置。在本地目录中,请执行:

        svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
    
  2. Add the following to your ~/.gdbinit. The path needs to match where the python module above was checked-out. So if checked out to: /home/maude/gdb_printers/, the path would be as written in the example:

    将以下内容添加到您的~/.gdbinit中。路径需要匹配上面的python模块。因此,如果检出到:/home/maude/gdb_printers/,路径将如示例中所示:

        python
        import sys
        sys.path.insert(0, '/home/maude/gdb_printers/python')
        from libstdcxx.v6.printers import register_libstdcxx_printers
        register_libstdcxx_printers (None)
        end
    

The path should be the only element that needs to be adjusted in the example above. Once loaded, STL classes that the printers support should printed in a more human-readable format. To print the classes in the old style, use the /r (raw) switch in the print command (i.e., print /r foo). This will print the classes as if the Python pretty-printers were not loaded.

在上面的示例中,路径应该是唯一需要调整的元素。一旦加载,打印机支持的STL类应该以更易于阅读的格式打印。要以旧格式打印类,请在print命令(例如,、打印/ r foo)。这将打印类,就好像没有加载Python的漂亮的打印机一样。

Since you're using eclipse cdt, don't forget to point your debug configuration to your .gdbinit file. When creating a new Debug Configuration, go to the Debugger tab and put the path to the .gdbinit file in the "GDB command file" field.

由于您使用的是eclipse cdt,请不要忘记将调试配置指向.gdbinit文件。在创建新的调试配置时,转到Debugger选项卡,并将路径放到“GDB命令文件”字段中的.gdbinit文件中。

I hope that helps!

我希望会有帮助!

#3


9  

In debug view in variables list expand vector:

在调试视图中变量列表展开向量:

"vector_name" -> std::_Vector_base<"datatype"> -> _M_impl

"vector_name" -> std::_Vector_base<"datatype"> -> _M_impl。

then right click on _M_start and select "Display as array...", type its length and then click OK. Now you can expand each item of your vector.

然后右击_M_start,选择“显示为数组…”,输入它的长度,然后单击OK。现在你可以展开向量的每一项。

#4


8  

If you have gdb support for CDT (see, for example, GDB in Eclipse), you could try this: De-referencing STL containers

如果您对CDT有gdb支持(例如,在Eclipse中看到gdb),您可以尝试以下方法:取消引用STL容器。

Long ago I also stumbled upon your same problem. It was a pain to check the STL containers. Then I found that link and added to my .gdbinit file some of those definitions. Life was easier after that.

很久以前我也遇到过你的问题。检查STL容器是件痛苦的事。然后我找到了这个链接并将其添加到我的.gdbinit文件中。从那以后生活变得更容易了。

NOTE: My gdb version is 7.1 and adding those definitions work fine. I don't know if in newer versions of gdb they are already included.

注意:我的gdb版本是7.1,添加这些定义可以正常工作。我不知道新版本的gdb是否已经包含它们。

#5


5  

I would like to expand on the Windows 7 response because some key steps are left out:

我想扩展Windows 7响应,因为有些关键步骤被遗漏了:

This is for MinGW users with Eclipse CDT

0) If you don't have python GDB, open a shell/command and use MinGW-get.exe to 'install' Python-enabled GDB e.g.

0)如果没有python GDB,打开shell/命令并使用MinGW-get。exe to“install”启用python的GDB(例如)。

   MinGw-get.exe install gdb-python

1a) Get Python 2.7.x from http://python.org/download/ and install

1)获得Python 2.7。来自http://python.org/download/和install的x

1b) Make sure PYTHONPATH and PYTHONHOME are set in your environment:

1b)确保在您的环境中设置了PYTHONPATH和PYTHONHOME:

 PYTHONPATH should be C:\Python27\Lib   (or similar)
 PYTHONHOME should be C:\Python27

1c) Add PYTHONHOME to your PATH

将PYTHONHOME添加到你的路径中

 %PYTHONHOME%;...

2a) Open a text enter, enter the following statements. Notice the 3rd line is pointing to where the python scripts are located. See notes below about this!

打开文本输入,输入以下语句。注意,第3行指向python脚本的位置。请看下面关于这一点的说明!

python
import sys
sys.path.insert(0, 'C:/MinGW/share/gcc-4.6.1/python')         
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

2b) Save as '.gdbinit' NOTE: Windows explorer will not let you name a file that starts with with a period from explorer. Most text edits (including Notepad) will let you. GDB init files are like 'scripts' of GDB commands that GBD will execute upon loading.

2 b)另存为”。注意:Windows资源管理器不允许您命名一个以资源管理器的句号开头的文件。大多数文本编辑(包括记事本)会让你。GDB init文件类似GDB命令的“脚本”,GBD将在加载时执行这些命令。

2c) The '.gdbinit' file needs to be in the working directory of GDB (most likely this is your projects root directory but your IDE can tell you.

2 c)”。gdbinit的文件需要放在GDB的工作目录中(很可能这是您的项目根目录,但是IDE可以告诉您。

3) Open your Eclipse (or other IDE) Preferences dialog. Go to the C++ Debugger sub-menu.

3)打开Eclipse(或其他IDE)首选项对话框。转到c++调试器子菜单。

4) Configure Eclipse to use C:\MinGW\bin\gdb-python27.exe as the debugger and your .gdbinit as the config file.

4)配置Eclipse使用C:\MinGW\bin\gdb-python27。作为调试器和.gdbinit作为配置文件。

5a) Re-create all your debug launch configurations (delete the old one and create a new one from scratch).

重新创建所有调试启动配置(删除旧配置并从头创建新配置)。

--OR--

5b) Edit each debug configuration and point it to the new gdb-python.exe AND point it to the.

编辑每个调试配置并将其指向新的gdb-python。把它指向。

If you run into issues:

--Don't forget to change the location to the python directory in the above python code! This directory is created by MinGW, so don't go looking to download the pretty printers, MinGW did it for you in step zero. Just goto your MinGW install director, the share folder, the GCC folder (has version number) and you will find python folder. This location is what should be in python script loaded by GDB.

——不要忘记在上面的python代码中将位置更改为python目录!这个目录是由MinGW创建的,所以不要去下载漂亮的打印机,MinGW在步骤0为您做了这个。只要打开您的MinGW安装管理器、共享文件夹、GCC文件夹(有版本号),您就会找到python文件夹。这个位置应该是由GDB加载的python脚本中的位置。

--Also, the .gdbinit is a PITA, make sure its named correctly and in the working folder of GDB which isn't necessarily where gdb-python.exe is located! Look at your GDB output when loading GDB to see if a) 'python-enabled' appears during load and that the statements in the .gdbinit are appearing.

另外,.gdbinit是一个PITA,请确保它的名称是正确的,并且在GDB的工作文件夹中,GDB -python不一定在这个文件夹中。exe位于!在加载GDB时查看GDB输出以查看a)“启用python”在加载期间出现,并显示.gdbinit中的语句。

--Finally, I had alot of issues with the system variables. If python gives you 'ImportError' then most likely you have not set PYTHONPATH or PYTHONHOME.

最后,系统变量有很多问题。如果python提供了“ImportError”,那么很可能没有设置PYTHONPATH或PYTHONHOME。

--The directory with 'gdb-python27' (e.g. C:\MinGW\bin') should also be on your path and if it is, it makes setting up eclipse a bit nicer because you don't need to put in absolute paths. But still, sometimes the .gbdinit needs an absoulte path. if it works you'll see output from gbd (console->gdb traces) like this on startup of debugger:

-带有“gdb-python27”(例如C:\MinGW\bin’)的目录也应该在您的路径上,如果是的话,它会使设置eclipse变得更好一些,因为您不需要放入绝对路径。但即便如此,有时.gbdinit也需要一个宽松的路径。如果它有效,您将会看到gbd(控制台->gdb跟踪)的输出,就像在调试器启动时一样:

835,059 4^done
835,059 (gdb) 
835,059 5-enable-pretty-printing
835,069 5^done
....
835,129 12^done
835,129 (gdb) 
835,129 13source C:\MinGW\bin\.gdbinit
835,139 &"source C:\\MinGW\\bin\\.gdbinit\n"
835,142 13^done
835,142 (gdb) 

#6


2  

I know that JDT (Java environment in eclipse) provides custom "formatters" to be applied when displaying variable values in debug views. A quick look at google for the same in CDT brings this page:

我知道JDT (eclipse中的Java环境)在调试视图中显示变量值时提供了要应用的自定义“格式化程序”。在CDT中快速查看谷歌,就会得到如下页面:

http://wiki.eclipse.org/CDT/Better_Debugging_%28GSoC_project%29

http://wiki.eclipse.org/CDT/Better_Debugging_%28GSoC_project%29

I don't know if this has been yet integrated in the main CDT line, may be you can try to right click on a variable while debugging (in the last CDT) and see if there is a custom formater entry. If not available I recomend you to add a new tracker entry in CDT tracker to ask this enhancement.

我不知道这是否已经集成到CDT主行中,您可以尝试在调试时右键单击一个变量(在上一个CDT中),看看是否有一个自定义格式器条目。如果没有可用,我建议您在CDT跟踪器中添加一个新的跟踪器条目来请求这个增强。

#1


26  

You need a version of GDB capable of using python to pretty print structures. I know at least on windows using mingw that this is not provided in the default install.

您需要一个GDB版本,它能够使用python实现漂亮的打印结构。我知道至少在使用mingw的windows上,默认安装中没有提供这个功能。

Pretty Printers are python modules which tell gdb how to display a given structure. You can write your own, but there are already printers for STL available for download.

漂亮的打印机是python模块,它告诉gdb如何显示给定的结构。您可以自己编写,但是已经有STL的打印机可以下载。

To Get Pretty Printers working on Windows (instructions should be similiar for other OS's):

要使漂亮的打印机在Windows上工作(指令应该与其他操作系统相似):

Prerequisites

先决条件

Installation:

安装:

  • Open a command Shell and type:

    打开命令Shell并输入:

    mingw-get install gdb-python
    
  • When its finished cd to a local directory and install the printers by typing:

    当完成cd到本地目录并通过输入安装打印机时:

    svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
    
  • Open the .gdbinit (create it in a text editor if need be) and type the following replaceing "C:/directory" with the folder that you checked the printers into.

    打开.gdbinit(如果需要,可以在文本编辑器中创建它),并使用检查打印机的文件夹键入下面的“C:/directory”替换。

    Python
    import sys
    sys.path.insert(0, 'C:/directory')
    from libstdcxx.v6.printers import register_libstdcxx_printers
    register_libstdcxx_printers (None)
    end

    Python导入sys sys.path。插入(0,“C:/目录”)从libstdcxx.v6。打印机导入register_libstdcxx_printers register_libstdcxx_printers (None)结束

Eclipse Setup

Eclipse设置

  • Go To Windows > Preferences > C/C++ > Debug > GDB
  • 转到Windows >首选项> C/ c++ >调试> GDB
  • Where it Says GDB Debugger put the path to the python enabled GDB it will most likely be in the mingw /bin folder with a name like gdb-python27.exe
  • 如果GDB调试器将路径放置到启用python的GDB,那么它很可能会位于mingw /bin文件夹中,文件夹的名称是GDB -python27.exe
  • Where it says GDB Command File put the path to the .gdb init file you made earlier.
  • 它说GDB命令文件将路径放到您之前创建的。GDB init文件中。

That's it, debug like normal, the stl structures should be much easier to read.

就是这样,像往常一样调试,stl结构应该更容易读。

#2


20  

Well, gdb don't natively support STL containers. You can't say this is incorrect, since it will expose the inner workings of the STL objects, but most of the time it is not what we want, right?

gdb本身并不支持STL容器。你不能说这是错误的,因为它会暴露STL对象的内部工作,但是大多数时候它不是我们想要的,对吧?

If you're using gdb 7.0 you can take advantage of the pretty printers. This website http://sourceware.org/gdb/wiki/STLSupport has a pretty simple tutorial on how to set them. I copied below the part that interests you:

如果你使用gdb 7.0,你可以利用漂亮的打印机。这个网站http://sourceware.org/gdb/wiki/STLSupport有一个关于如何设置它们的简单教程。我抄了以下你感兴趣的部分:

  1. Check-out the latest Python libstdc++ printers to a place on your machine. In a local directory, do:

    将最新的Python libstdc++打印机签出到您的机器上的某个位置。在本地目录中,请执行:

        svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
    
  2. Add the following to your ~/.gdbinit. The path needs to match where the python module above was checked-out. So if checked out to: /home/maude/gdb_printers/, the path would be as written in the example:

    将以下内容添加到您的~/.gdbinit中。路径需要匹配上面的python模块。因此,如果检出到:/home/maude/gdb_printers/,路径将如示例中所示:

        python
        import sys
        sys.path.insert(0, '/home/maude/gdb_printers/python')
        from libstdcxx.v6.printers import register_libstdcxx_printers
        register_libstdcxx_printers (None)
        end
    

The path should be the only element that needs to be adjusted in the example above. Once loaded, STL classes that the printers support should printed in a more human-readable format. To print the classes in the old style, use the /r (raw) switch in the print command (i.e., print /r foo). This will print the classes as if the Python pretty-printers were not loaded.

在上面的示例中,路径应该是唯一需要调整的元素。一旦加载,打印机支持的STL类应该以更易于阅读的格式打印。要以旧格式打印类,请在print命令(例如,、打印/ r foo)。这将打印类,就好像没有加载Python的漂亮的打印机一样。

Since you're using eclipse cdt, don't forget to point your debug configuration to your .gdbinit file. When creating a new Debug Configuration, go to the Debugger tab and put the path to the .gdbinit file in the "GDB command file" field.

由于您使用的是eclipse cdt,请不要忘记将调试配置指向.gdbinit文件。在创建新的调试配置时,转到Debugger选项卡,并将路径放到“GDB命令文件”字段中的.gdbinit文件中。

I hope that helps!

我希望会有帮助!

#3


9  

In debug view in variables list expand vector:

在调试视图中变量列表展开向量:

"vector_name" -> std::_Vector_base<"datatype"> -> _M_impl

"vector_name" -> std::_Vector_base<"datatype"> -> _M_impl。

then right click on _M_start and select "Display as array...", type its length and then click OK. Now you can expand each item of your vector.

然后右击_M_start,选择“显示为数组…”,输入它的长度,然后单击OK。现在你可以展开向量的每一项。

#4


8  

If you have gdb support for CDT (see, for example, GDB in Eclipse), you could try this: De-referencing STL containers

如果您对CDT有gdb支持(例如,在Eclipse中看到gdb),您可以尝试以下方法:取消引用STL容器。

Long ago I also stumbled upon your same problem. It was a pain to check the STL containers. Then I found that link and added to my .gdbinit file some of those definitions. Life was easier after that.

很久以前我也遇到过你的问题。检查STL容器是件痛苦的事。然后我找到了这个链接并将其添加到我的.gdbinit文件中。从那以后生活变得更容易了。

NOTE: My gdb version is 7.1 and adding those definitions work fine. I don't know if in newer versions of gdb they are already included.

注意:我的gdb版本是7.1,添加这些定义可以正常工作。我不知道新版本的gdb是否已经包含它们。

#5


5  

I would like to expand on the Windows 7 response because some key steps are left out:

我想扩展Windows 7响应,因为有些关键步骤被遗漏了:

This is for MinGW users with Eclipse CDT

0) If you don't have python GDB, open a shell/command and use MinGW-get.exe to 'install' Python-enabled GDB e.g.

0)如果没有python GDB,打开shell/命令并使用MinGW-get。exe to“install”启用python的GDB(例如)。

   MinGw-get.exe install gdb-python

1a) Get Python 2.7.x from http://python.org/download/ and install

1)获得Python 2.7。来自http://python.org/download/和install的x

1b) Make sure PYTHONPATH and PYTHONHOME are set in your environment:

1b)确保在您的环境中设置了PYTHONPATH和PYTHONHOME:

 PYTHONPATH should be C:\Python27\Lib   (or similar)
 PYTHONHOME should be C:\Python27

1c) Add PYTHONHOME to your PATH

将PYTHONHOME添加到你的路径中

 %PYTHONHOME%;...

2a) Open a text enter, enter the following statements. Notice the 3rd line is pointing to where the python scripts are located. See notes below about this!

打开文本输入,输入以下语句。注意,第3行指向python脚本的位置。请看下面关于这一点的说明!

python
import sys
sys.path.insert(0, 'C:/MinGW/share/gcc-4.6.1/python')         
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

2b) Save as '.gdbinit' NOTE: Windows explorer will not let you name a file that starts with with a period from explorer. Most text edits (including Notepad) will let you. GDB init files are like 'scripts' of GDB commands that GBD will execute upon loading.

2 b)另存为”。注意:Windows资源管理器不允许您命名一个以资源管理器的句号开头的文件。大多数文本编辑(包括记事本)会让你。GDB init文件类似GDB命令的“脚本”,GBD将在加载时执行这些命令。

2c) The '.gdbinit' file needs to be in the working directory of GDB (most likely this is your projects root directory but your IDE can tell you.

2 c)”。gdbinit的文件需要放在GDB的工作目录中(很可能这是您的项目根目录,但是IDE可以告诉您。

3) Open your Eclipse (or other IDE) Preferences dialog. Go to the C++ Debugger sub-menu.

3)打开Eclipse(或其他IDE)首选项对话框。转到c++调试器子菜单。

4) Configure Eclipse to use C:\MinGW\bin\gdb-python27.exe as the debugger and your .gdbinit as the config file.

4)配置Eclipse使用C:\MinGW\bin\gdb-python27。作为调试器和.gdbinit作为配置文件。

5a) Re-create all your debug launch configurations (delete the old one and create a new one from scratch).

重新创建所有调试启动配置(删除旧配置并从头创建新配置)。

--OR--

5b) Edit each debug configuration and point it to the new gdb-python.exe AND point it to the.

编辑每个调试配置并将其指向新的gdb-python。把它指向。

If you run into issues:

--Don't forget to change the location to the python directory in the above python code! This directory is created by MinGW, so don't go looking to download the pretty printers, MinGW did it for you in step zero. Just goto your MinGW install director, the share folder, the GCC folder (has version number) and you will find python folder. This location is what should be in python script loaded by GDB.

——不要忘记在上面的python代码中将位置更改为python目录!这个目录是由MinGW创建的,所以不要去下载漂亮的打印机,MinGW在步骤0为您做了这个。只要打开您的MinGW安装管理器、共享文件夹、GCC文件夹(有版本号),您就会找到python文件夹。这个位置应该是由GDB加载的python脚本中的位置。

--Also, the .gdbinit is a PITA, make sure its named correctly and in the working folder of GDB which isn't necessarily where gdb-python.exe is located! Look at your GDB output when loading GDB to see if a) 'python-enabled' appears during load and that the statements in the .gdbinit are appearing.

另外,.gdbinit是一个PITA,请确保它的名称是正确的,并且在GDB的工作文件夹中,GDB -python不一定在这个文件夹中。exe位于!在加载GDB时查看GDB输出以查看a)“启用python”在加载期间出现,并显示.gdbinit中的语句。

--Finally, I had alot of issues with the system variables. If python gives you 'ImportError' then most likely you have not set PYTHONPATH or PYTHONHOME.

最后,系统变量有很多问题。如果python提供了“ImportError”,那么很可能没有设置PYTHONPATH或PYTHONHOME。

--The directory with 'gdb-python27' (e.g. C:\MinGW\bin') should also be on your path and if it is, it makes setting up eclipse a bit nicer because you don't need to put in absolute paths. But still, sometimes the .gbdinit needs an absoulte path. if it works you'll see output from gbd (console->gdb traces) like this on startup of debugger:

-带有“gdb-python27”(例如C:\MinGW\bin’)的目录也应该在您的路径上,如果是的话,它会使设置eclipse变得更好一些,因为您不需要放入绝对路径。但即便如此,有时.gbdinit也需要一个宽松的路径。如果它有效,您将会看到gbd(控制台->gdb跟踪)的输出,就像在调试器启动时一样:

835,059 4^done
835,059 (gdb) 
835,059 5-enable-pretty-printing
835,069 5^done
....
835,129 12^done
835,129 (gdb) 
835,129 13source C:\MinGW\bin\.gdbinit
835,139 &"source C:\\MinGW\\bin\\.gdbinit\n"
835,142 13^done
835,142 (gdb) 

#6


2  

I know that JDT (Java environment in eclipse) provides custom "formatters" to be applied when displaying variable values in debug views. A quick look at google for the same in CDT brings this page:

我知道JDT (eclipse中的Java环境)在调试视图中显示变量值时提供了要应用的自定义“格式化程序”。在CDT中快速查看谷歌,就会得到如下页面:

http://wiki.eclipse.org/CDT/Better_Debugging_%28GSoC_project%29

http://wiki.eclipse.org/CDT/Better_Debugging_%28GSoC_project%29

I don't know if this has been yet integrated in the main CDT line, may be you can try to right click on a variable while debugging (in the last CDT) and see if there is a custom formater entry. If not available I recomend you to add a new tracker entry in CDT tracker to ask this enhancement.

我不知道这是否已经集成到CDT主行中,您可以尝试在调试时右键单击一个变量(在上一个CDT中),看看是否有一个自定义格式器条目。如果没有可用,我建议您在CDT跟踪器中添加一个新的跟踪器条目来请求这个增强。