Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2315343
  • 博文数量: 527
  • 博客积分: 10343
  • 博客等级: 上将
  • 技术积分: 5565
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-26 23:05
文章分类

全部博文(527)

文章存档

2014年(4)

2012年(13)

2011年(19)

2010年(91)

2009年(136)

2008年(142)

2007年(80)

2006年(29)

2005年(13)

我的朋友

分类: LINUX

2010-06-25 21:30:51


" 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()

阅读(1110) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~