windows下eclipse中gdb調試輸出stl容器的內容(終極解決方案)

摸索了一天終於把這個問題搞定了


首先下載MinGw

地址:http://sourceforge.net/projects/mingw/?source=directory

下載完之後安裝G++,在安裝程序中步驟如下


之後利用CMD安裝gdb-python

MinGw-get.exe install gdb-python
同時安裝GDB


同時按照以下步驟安裝並配置Python 

1)從http://python.org/download/下載python 2.7.x

2)設置python環境變量

PYTHONPATH 應該是 C:\Python27\Lib   (或者類似的)
 PYTHONHOME 應該是 C:\Python27
3)把PYTHONHOME添加到PATH目錄中

 %PYTHONHOME%;...
4)打開文本編輯器,輸入以下你容,保存爲.gdbinit文件,並放置在gdb-python27.exe同一個路徑下,一般類似這樣:C:\MinGW\bin\gdb-python27.exe

python
import sys
sys.path.insert(0, 'C:/MinGW/share/gcc-4.6.1/python')   #此目錄是放置打印的python腳本的地方,一般在類似目錄下      
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
5)打開Eclipse按如下步驟配置MinGw(如果配置好了請忽略)

 http://jingyan.baidu.com/article/380abd0a5888211d90192cd6.html

6)配置GDB路徑與.gdbinit路徑

打開Window -> preferences -> C/C++ -> Debug -> GDB 改一下右邊的GDB Debugger與GDB command file
注意debugger一定要是gdb-python27.exe而不能是gdb.exe否則會不支持python
最後大功告成,顯示如下
參考:
http://wiki.eclipse.org/CDT/User/FAQ#CDT_does_not_recognize_C.2B.2B11_features
http://stackoverflow.com/questions/21376381/debugging-stl-containers-using-mingw-issue-with-python-script
http://stackoverflow.com/questions/148281/eclipse-c-pretty-printing/14266862#14266862


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章