" Mappings example for use with gdb
" Maintainer:
" Last Change: Mar 6 2006
if ! has("gdb")
finish
endif
let s:gdb_k = 1
nmap :call Toggle()
" Toggle between vim default and custom mappings
function! s:Toggle()
if s:gdb_k
let s:gdb_k = 0
map :call gdb("")
nmap :call gdb("\032")
nmap b :call gdb("info breakpoints")
nmap B :call gdb("info breakpoints")
nmap :call gdb("info locals")
nmap :call gdb("info args")
nmap S :call gdb("step")
nmap s :call gdb("step")
nmap :call gdb("stepi")
nmap :call gdb("next")
"nmap :call gdb("nexti")
nmap :call gdb("finish")
nmap :call gdb("run")
nmap q :call gdb("quit")
nmap Q :call gdb("quit")
nmap c :call gdb("continue")
nmap C :call gdb("continue")
nmap :call gdb("where")
nmap :call gdb("up")
nmap :call gdb("down")
" set/clear bp at current line
nmap :call Breakpoint("break")
nmap :call Breakpoint("clear")
" print value at cursor
nmap :call gdb("print " . expand(""))
" display Visual selected expression
"vmap y:call gdb("createvar " . """)
vmap y:call gdb("print " . """)
" print value referenced by word at cursor
nmap :call gdb("print *" . expand(""))
"vmap y:call gdb("createvar " . "*"" )
vmap y:call gdb("print " . "*"" )
nmap t :call gdb("ptype " . expand(""))
nmap T :call gdb("ptype " . expand(""))
nmap :call gdb("ptype (struct " . expand("") . "* )0")
echohl ErrorMsg
echo "gdb keys mapped"
echohl None
" Restore vim defaults
else
let s:gdb_k = 1
nunmap
nunmap
nunmap b
nunmap B
nunmap
nunmap
nunmap S
nunmap s
nunmap
nunmap
" nunmap
nunmap
nunmap
nunmap q
nunmap Q
nunmap c
nunmap C
nunmap
nunmap
nunmap
nunmap
nunmap
nunmap
vunmap
nunmap
vunmap
nunmap t
nunmap T
nunmap
echohl ErrorMsg
echo "gdb keys reset to default"
echohl None
endif
endfunction
" Run cmd on the current line in assembly or symbolic source code
" parameter cmd may be 'break' or 'clear'
function! s:Breakpoint(cmd)
" An asm buffer (a 'nofile')
if &buftype == "nofile"
" line start with address 0xhhhh...
let s = substitute(getline("."), "^\\s*\\(0x\\x\\+\\).*$", "*\\1", "")
if s != "*"
call gdb(a:cmd . " " . s)
endif
" A source file
else
let s = "\"" . fnamemodify(expand("%"), ":p") . ":" . line(".") . "\""
call gdb(a:cmd . " " . s)
endif
endfunction
" map vimGdb keys
" Zhao.rufei: disable gdb by default
" call s:Toggle()
阅读(1140) | 评论(0) | 转发(0) |