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

來源:互聯網
上載者:User

標籤:eclipse   c++   stl顯示   debug   

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


首先下載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

pythonimport syssys.path.insert(0, ‘C:/MinGW/share/gcc-4.6.1/python‘)   #此目錄是放置列印的python指令碼的地方,一般在類似目錄下      from libstdcxx.v6.printers import register_libstdcxx_printersregister_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


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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.