vim使用之程序调试-Vimgdb

1.下载vim

ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2

 

2.下载vimgdb

http://downloads.sourceforge.net/project/clewn/vimGdb/vimgdb72-1.14/vimgdb72-1.14.tar.gz?use_mirror=ncu&37740109

关于clewn和vimgdb

http://clewn.sourceforge.net/

 

3.阅读vimgdb中的README,给vim打补丁,并编译。

 

INSTALL.txt - VimGdb patch installation notes

This document describes how to install the patch for vimGdb.

 

 

a) You need:

 

    vim-7.2.tar.bz2         Vim 7.2 source tar ball (from www.vim.org)

    vimgdb72-1.14.tar.gz    this patch

 

 

b) Untar all files, apply the patch and make Vim:

 

    tar xjf vim-7.2.tar.bz2

    tar xzf vimgdb72-1.14.tar.gz

 

    patch -d vim72 --backup -p0 < vimgdb/vim72.diff

 

    cd vim72/src

        make            make vim

        make install        install vim (may require root privileges)

 

IMPORTANT NOTE: you must run make (not ./configure), and if you run

./configure then you must add the --enable-gdb command line argument

in order to include the gdb feature (vimgdb) in vim.

 

 

c) Install vimGdb runtime:

Copy the file vimgdb_runtime.tgz found in the vimgdb tarball, to your

runtime path. To find your runtime path location execute the vim

command (this is usually $HOME/.vim):

 

    :set runtimepath?

 

Untar vimgdb_runtime.tgz in your runtime path. After this step, you

should have the following files:

 

    doc/gdb.txt

    macros/gdb_mappings.vim

    syntax/gdb.vim

    syntax/gdbvim.vim

    syntax/gdbvar.vim

 

Change to the doc directory, start Vim and run the ":helptags ."

command to process the taglist help file. Without this step, you

cannot jump to the taglist help topics. You can now use the ":help

vimgdb" command to get the vimGdb documentation.

 

 

 

4、初识vim gdb

 

:help vimgdb阅读帮助文档,学习gdb使用。效果图如下:

 

b 10设置断点,窗口才出现出现源码?

 

5.vimgdb的使用方法及其常用快捷键

 

 

<<<<<<-- Mappings *gdb-mappings-->>>>>>

 

The gdb() function accepts a string as single argument which is sent to GDB as

a GDB command. This can be used to map any command to a key sequence. Examples

of such mappings are given in 'macros/gdb_mappings.vim'. To use those

mappings, source the script: >

 

    :run macros/gdb_mappings.vim

 

The key is used to toggle between the 'gdb_mappings.vim' mappings and the

default Vim mappings.

 

List of key mappings in 'gdb_mappings.vim':

 

launch the interactive gdb input-line window

CTRL-Z  send an interrupt to GDB and the program it is running

B info breakpoints

L info locals

A info args

S step

I stepi

CTRL-N next: next source line, skipping all function calls

X nexti

F finish

R run

Q quit

C continue

W where

CTRL-U up: go up one frame

CTRL-D down: go down one frame

CTRL-B set a breakpoint on the line where the cursor is located

CTRL-E clear all breakpoints on the line where the cursor is located

CTRL-P Normal mode: print value of word under cursor

Visual mode: GDB command "createvar" selected expression, see

|gdb-variables|

CTRL-X print value of data referenced by word under cursor

 

CTRL-B and CTRL-E operate both on source code and on disassembled code in

assembly buffers.

 

6.监控变量

:bel 25vsplit gdb-variables

space启动命令窗口,然后分别执行cr c.a, cr c.b(本例)

 

你可能感兴趣的:(linux)