今天主要了解了一下gdb的用法以及gdb的可視化工具insight。做個小結。總體上來說使用gvim和insight進行開發的過程還是比較舒服的。
1. 關於gdb的主要用法
感覺用到的命令不是特別的多。可以參考的文章是:
1) gdb十分鍾教程
http://blog.csdn.net/liigo/article/details/582231
特點:上手快,涵蓋了最基本的用法。
2) 詳細用法
http://fanqiang.chinaunix.net/program/other/2006-07-14/4834.shtml
特點:言簡意賅,涵蓋了一些高級功能。比如說處理信號,disable/enable端點等功能。
http://wiki.ubuntu.org.cn/%E7%94%A8GDB%E8%B0%83%E8%AF%95%E7%A8%8B%E5%BA%8F
特點:可以當做help的替代來看。
2. insight
insight是一款類似於VC的調試工具。用下來感覺還是可以的。
下面是我的編譯和安裝過程,其中解決了一些問題。(我的系統是Fedora Linux14,root權限)
1) 下載源代碼
我下載的是 insight-6.8a.tar.bz2
更新的版本在ftp://sourceware.org/pub/insight/releases(注意,我用chrome開是沒有打開成功,用ie或者火狐就行了)
2) 解壓縮
tar jvxf insight-6.8a.tar.bz2
3) 生成Makefile
./configure
4) 修改Makefile(注意是gdb目錄下的,否則編譯報錯)
cd gdb #(進入insight下的gdb目錄)
sudo gedit Makefile
找到WERROR_CFLAGS = -Werror,將其改為
WERROR_CFLAGS=#-Werror(這里也可以將‘=’后面的內容刪除掉變成 WERROR_CFLGAS= )
保存退出
仍然回到insight目錄
cd ..
5) 修改源碼
如果這里直接開始編譯,則會出現一個說tk.ctl文件找不到的錯誤:
Tk_Init failed: Can't find a usable tk.tcl in the following directories:
/usr/local/share/tk8.4 /usr/local/lib/tk8.4 /usr/lib/tk8.4 /usr/local/library /usr/library /usr/tk8.4.1/library /tk8.4.1/library
(1)修改insight-6.8/tk/generic/tk.h
將(line 653)
#define VirtualEvent (LASTEvent)
#define ActivateNotify (LASTEvent + 1)
#define DeactivateNotify (LASTEvent + 2)
#define MouseWheelEvent (LASTEvent + 3)
#define TK_LASTEVENT (LASTEvent + 4)
改為:
#define VirtualEvent (MappingNotify)
#define ActivateNotify (MappingNotify + 1)
#define DeactivateNotify (MappingNotify + 2)
#define MouseWheelEvent (MappingNotify + 3)
#define TK_LASTEVENT (MappingNotify + 4)
並將隨后的#define TK_LASTEVENT (LASTEvent + 4)刪除(line 661附近)
(2)修改insight-6.8/tk/generic/tkBind.c
在line 586和line 587之間增加
#ifdef GenericEvent
0,
#endif
6) 開始編譯
make
7) 編譯通過后安裝
make install
8) 運行時候遇到的問題
(1) 圖形界面打開二進制文件不成功
解決方法:使用 "insight ./xxxx"的方式從命令行打開。
(2) 啟動insight時候提示說”this is not a tk application, couldnot connect to DISPALY ‘0:0’ “
這是由於XServer權限不夠的關系。使用普通的用戶,在命令行下調用"xhost +"給予權限即可。
(3) insight中無法輸入
這是由於中文輸入法導致的。通過關閉iBus就可以解決這個問題。我一般都是在虛擬機里面跑的,所以不用中文輸入也無所謂。