[ GDB ]php
gdb中查看源代碼執行路徑 html
tui就是 terminal UI的意思python
gdb -tui 代碼窗口相關命令: linux
info win 顯示窗口的大小 web
layout next 切換到下一個佈局模式 shell
layout prev 切換到上一個佈局模式 express
layout src 只顯示源代碼vim
layout asm 只顯示彙編代碼 windows
layout split 顯示源代碼和彙編代碼bash
layout regs 增長寄存器內容顯示
focus cmd/src/asm/regs/next/prev 切換當前窗口
refresh 刷新全部窗口
tui reg next 顯示下一組寄存器
tui reg system 顯示系統寄存器
update 更新源代碼窗口和當前執行點
winheight name +/- line 調整name窗口的高度
tabset nchar 設置tab爲nchar個字符
gdb在執行中,會自動跟蹤代碼
調用gdb編譯須要在cc後面加 -g參數再加-o;
[root@redhat home]#gdb 調試文件:啓動gdb
(gdb) l :(字母l)從第一行開始列出源碼
(gdb) break n :在第n行處設置斷點
(gdb) break func:在函數func()的入口處設置斷點
(gdb) info break: 查看斷點信息
(gdb) r:運行程序
(gdb) n:單步執行
(gdb) c:繼續運行
(gdb) p 變量 :打印變量的值
(gdb) bt:查看函數堆棧
(gdb) finish:退出函數
(gdb) shell 命令行:執行shell命令行
(gdb) set args 參數:指定運行時的參數
(gdb) show args:查看設置好的參數
(gdb) show paths:查看程序運行路徑;
set environment varname [=value] 設置環境變量。如:set env USER=hchen;
show environment [varname] 查看環境變量;
(gdb) cd 至關於shell的cd;
(gdb)pwd :顯示當前所在目錄
(gdb)info program: 來查看程序的是否在運行,進程號,被暫停的緣由。
(gdb)clear 行號n:清除第n行的斷點
(gdb)delete 斷點號n:刪除第n個斷點
(gdb)disable 斷點號n:暫停第n個斷點
(gdb)enable 斷點號n:開啓第n個斷點
(gdb)step:單步調試若是有函數調用,則進入函數;與命令n不一樣,n是不進入調用的函數的
注意 :若是運行list 命令獲得相似以下的打印,那是由於在編譯程序時沒有加入 -g 選項: (gdb) list 1 ../sysdeps/i386/elf/start.S: No such file or directory. in ../sysdeps/i386/elf/start.S |
固然,gdb的功能遠不止這些,包括多進程/多線程/信號/遠程調試等功能在這裏均沒有說起,有須要的讀者能夠參考其它信息。
#sudo apt-cache search vim
exuberant-ctags - build tag file indexes of source code definitions
linuxdoc-tools - convert LinuxDoc SGML source into other formats
vim - Vi IMproved - enhanced vi editor
vim-common - Vi IMproved - Common files
vim-dbg - Vi IMproved - enhanced vi editor (debugging symbols)
vim-doc - Vi IMproved - HTML documentation
vim-gnome - Vi IMproved - enhanced vi editor - with GNOME2 GUI
vim-gui-common - Vi IMproved - Common GUI files
vim-runtime - Vi IMproved - Runtime files
vim-tiny - Vi IMproved - enhanced vi editor - compact version
transcode-utils - Transcode utility programs
apvlv - PDF viewer with Vim-like behaviour
bicyclerepair - A refactoring tool for python
bleachbit - delete unnecessary files from the system
cernlib-base - CERNLIB data analysis suite - common files
colordiff - tool to colorize 'diff' output
cream - VIM macros that make the VIM easier to use for beginners
dmtcp - Checkpoint/Restart functionality for Linux processes
dmtcp-dbg - Debug package for dmtcp
editmoin - edit MoinMoin wiki pages with your favourite editor
elvis-tiny - Tiny vi compatible editor for the base system
fim - a scriptable frame buffer and ascii art image viewer
get-flash-videos - Video downloader for various Flash-based video hosting sites
global - Source code search and browse tools
glogg - A smart interactive log explorer using Qt4
gramadoir - Irish language grammar checker (integration scripts)
jvim-canna - Japanized VIM (Canna version)
jvim-doc - Documentation for jvim (Japanized VIM)
libdmtcpaware-dev - DMTCP programming interface -- developer package
libdmtcpaware1 - DMTCP programming interface
liblatex-table-perl - Perl extension for the automatic generation of LaTeX tables
libtext-findindent-perl - module to heuristically determine indentation style
libtext-vimcolor-perl - syntax color text in HTML or XML using Vim
libvi-quickfix-perl - Perl support for vim's QuickFix mode
netrik - text mode WWW browser with vi like keybindings
notmuch-vim - thread-based email index, search and tagging (vim interface)
nvi - 4.4BSD re-implementation of vi
nvi-doc - 4.4BSD re-implementation of vi - documentation files
nvi - 4.4BSD re-implementation of vi
nvi-doc - 4.4BSD re-implementation of vi - documentation files
ocaml-tools - tools for OCaml developers
openshot - Create and edit videos and movies
pms - Practical Music Search, an MPD client
ranger - File manager with an ncurses frontend written in Python
shorlfilter - Text filter to shorten long URLs using online redirection database
sisu - documents - structuring, publishing in multiple formats and search
tmux - terminal multiplexer
txt2regex - A Regular Expression "wizard", all written with bash2 builtins
uzbl - Lightweight Webkit browser following the UNIX philosophy
vim-addon-manager - manager of addons for the Vim editor
vim-athena - Vi IMproved - enhanced vi editor - with Athena GUI
vim-gtk - Vi IMproved - enhanced vi editor - with GTK2 GUI
vim-latexsuite - view, edit and compile LaTeX documents from within Vim
vim-lesstif - Vi IMproved - enhanced vi editor (transitional package)
vim-nox - Vi IMproved - enhanced vi editor
vim-rails - plugins for vim to allow easier editing of Rails Applications
vim-scripts - plugins for vim, adding bells and whistles
vim-syntax-go - Syntax files to highlight Go in the Vim editor
vim-syntax-gtk - Syntax files to highlight GTK+ keywords in vim
vim-vimoutliner - script for building an outline editor on top of Vim
vimhelp-de - Vi IMproved - Documentation files (German translation)
zathura - PDF viewer with a minimalistic interface
kdesdk-scripts - scripts and data files for development
vim-puppet - syntax highlighting for puppet manifests in vim
搜索發現apt源沒有什麼vim gdb整合的軟件,意外發現有一些有用的包,能夠根據我的需求安裝.
sudo apt-get install colordiff
google以後,發現能夠經過安裝vimgdb實線vim和gdb的整合
[ Useful Link ]
Vim How-to
http://users.skynet.be/antoine.mechelynck/vim/index.htm
Vim Org - Downloading Vim
http://www.vim.org/download.php
vimgdb : Emacs like gdb interface to cterm vim
http://www.vim.org/scripts/script.php?script_id=3039
This script provides an emacs like GDB interface to vim. Woks in cygwin and unix terminals (no need for +clientserver).
Start the program like this
vimgdb <gdb-params> <exe-file> <exe-params>
This will open vim with two windows. Type the gdb commands in bottom window. The top window will show the current file line and breakpoints highlighted.
You can also jump to top window and use the following keys
<F6> run
<F5> continue
<F7> step into
<F8> step over
<F9> toggle break point
Ctr-p Watch the variable under Cursor/Visual selection
watch the output/variables in bottom window.
Known Bugs:
Don't use the quit gdb command (that will hang the vim), instead quit the vim.
install details |
copy the vimgdb, vimgdb_msg to any directory in the system path
|
clewn gdb
Clewn implements full gdb support in the vim editor: breakpoints, watch variables, gdb command completion, assembly windows, etc.
This may be done with clewn or vimGdb. There is also a third way with pyclewn, a python program with more features than clewn and vimGdb, and a tight integration in Vim. See the pyclewn web site for a table listing the differences between all three programs.
Clewn is a program controlling vim through the netBeans socket interface, it runs concurrently with vim and talks to vim. Clewn can only be used with gvim, the graphical implementation of vim, as vim on a terminal does not support netBeans. VimGdb is a vim patch implemented as a vim optional feature.
Both alternatives use the same base source code to interface with gdb. Clewn, as a standalone process, needs its own terminal. This is not the case with vimGdb, but a drawback is that a different patch must be applied to each new Vim version.
They both share the same features set, except clewn supports some features that vimGdb does not have:
mainpage: http://clewn.sourceforge.net/
userguide: http://clewn.sourceforge.net/doc.html
http://blog.csdn.net/dduwayne/article/details/6595674
CGDB
CGDB is a curses (terminal-based) interface to the GNU Debugger (GDB). Its goal is to be lightweight and responsive; not encumbered with unnecessary features.
The primary feature of CGDB is the constant presence of a source display (screenshots), updated as the program executes, to help keep you focused while debugging. The interface is inspired by the classic Unix text editor, vi. Those familiar with vi (or vim) should feel right at home using CGDB.
The following table lists the differences between clewn, vimGdb and pyclewn.
vimGdb clewn pyclewn platform unix unix all unix platforms supported by python - requires GNU gdb from macports on Mac Os X
Windows (Python 3 only)
language C C Python 2.4 and above Python 3 vim mode vim in a terminal, gvim gvim vim in a terminal (vim 7.3 or above required), gvim vim interface a vim patch a standalone program connected to gvim with a netbeans socket a standalone program connected to vim with a netbeans socket
pyclewn may be started from within vim
vim version a different patch for each vim version vim 6.3 and above vim 7.0 and above debuggers gdb gdb gdb, pdb gdb features
- watched variables
- project file
- tight integration with vim
- gdb/mi interface
- asynchronous gdb commands
- watched variables
- project file
pdb features
- interrupt the debuggee
- attach to a running python process
- the threadstack command
[ Blog ]
gdb簡單入門教程
http://os.chinaunix.net/a2005/1211/967/000000967327.shtml
http://fanqiang.chinaunix.net/program/other/2006-07-14/4834.shtml
http://bzhang.iteye.com/blog/376214
gdb中彙編調試
http://blog.sina.com.cn/s/blog_535413540100a82y.html
vim gdb ddd xxgdb精彩的程序調試
http://easwy.com/blog/archives/advanced-vim-skills-vim-gdb-vimgdb/
[ Q&A ]
Q:
上網搜安裝教程,安裝vim7.2 + vimgdb補丁,那麼系統自帶的vim7.3怎麼辦?
A:
能夠安裝到其它目錄就行了,好比/opt或/home/xxx目錄裏面,而後編輯.bashrc,alias vi=安裝路徑/vim.
vim-dbg 和Vimgdb插件不要緊,Vimgdb能夠去 vim 網站下載
Link: http://www.vim.org/scripts/script.php?script_id=3039
集成gdb的vim插件有兩個,一個只須要編譯一個庫,另外一個須要先打補丁後編譯,樓主問的是須要先打補丁後編譯的那個。
www@linuxany.com:/tmp$ vim –version |grep -o ‘+clientserver\|+signs’
www@linuxany.com:/tmp$ vim –servername test
www@linuxany.com:/tmp$ vim –serverlist
www@linuxany.com:/tmp$ gdbvim –server=TEST
www@linuxany.com:~/source/soft_source$ tar xf pyclewn-1.1.tar.gz
www@linuxany.com:~/source/soft_source$ cd pyclewn-1.1/
www@linuxany.com:~/source/soft_source/pyclewn-1.1$ sudo python setup.py install –force
www@linuxany.com:~/source/soft_source/pyclewn-1.1$ vimdir=$HOME/.vim python setup.py install –force –home=$HOME