History Report a problem
Article Edit this page Discussion

Using gvim as frontend for dbx

From Vim Tips Wiki

Jump to: navigation, search

Tip 380 Previous TipNext Tip

Created: December 2, 2002 Complexity: basic Author: Dirk Volkmar Minimum version: 6.0 Karma: 25/10 Imported from: Tip#380


There is an easy way to use gvim as somewhat like a frontend for the solaris dbx debugger. Add the following to your .dbxrc:

alias sc=" gvim --remote +$vlineno $vfile"
when stop { gvim --remote +$vlineno $vfile ;}

Always the debugger stops it shows you the current positon in the gvim. My gvim doesn't take the focus, I don't know why, but so I just can walk through the code.

The sc alias shows the current position and is helpful after loading the executable to show the start (we haven't stopped at this point).

Unfortunately it doesn't work at the first stop after attaching to a process.

[edit] Alternate Implementation

In order to use console Vim with similar functionality, you can simply write a Vim command to a file, then source the command with Vim.

So, put this in your .dbxrc:

# Functions

# Write Current, this will write a line to ~/.dbx.vim
# which will cause vim to open the current file at the current location
function wc {
    echo :e +$vlineno $vfile > $HOME/.dbx.vim
}

# Write Variables, dumps the values of all variables local to current
# procedure into ~/.dbx.vars
function wv {
# dbx has a pretty bad parser, so pipes won't work within $(..), and
# you can forget about backticks, but at least it can call shell commands
    > ~/.dbx.dump dump
    > ~/.dbx.vars
    cat ~/.dbx.dump | sed 's/ .*$//' > ~/.dbx.varnames
    for var in $(cat ~/.dbx.varnames); do
# print only accepts one var at a time
        >> ~/.dbx.vars 2>&1 print -r $var
        if echo $(print $var) | grep "0x" > /dev/null; then
            >> ~/.dbx.vars 2>&1 print -r *$var
        fi
    done
}

# Vim Current, same thing, but will spawn vim
function vc {
    vim +$vlineno $vfile
}

# Whens
when stop { wc; }

# Aliases

# Whens
when stop { wc; }

# Aliases
alias sdb="source ~/.dbxrc"
alias w="where;wc"
alias u="up;wc"
alias d="down;wc"
alias he="help"
alias s="step;wc"
alias su="step up;wc" # cont to next stmt in parent function
alias n="next; wc" # cont to next stmt in same function

So, if you add the following lines to your .vimrc:

" Open current source file according to dbx
nmap <C-D> :source ~/.dbx.vim<CR>
" Open listing of active dbx variables
nmap ,v :e ~/.dbx.vars<CR>

Now, Ctrl-D will open the current dbx file and line (mnemonic: d for debug). ,v will open up a listing of variables (mnemonic: v for variables).

With only this, you can have a pretty good debugging setup with just vim and dbx.

[edit] Sending commands to dbx from Vim

If you wish to use Vim to execute dbx commands too, the easiest way I have found is to create an alias to source a file, then put the commands I want into the file, such as:

# Clear out breakpoints
delete all
# Clear out any displayed variables
undisplay 0

# Set breakpoint
stop at dbmulti.c:7043
stop at riintfn.c:4128

# Other commands

Then you just type in the alias, and the file is sourced, allowing you to more efficiently type in breakpoints and such using command completion/efficient editing in Vim.

The alias would look like

alias z="source ~/.dbx.comm"

It should go in your ~/.dbxrc file.

[edit] Comments

I think "when stop ........" should to executed in dbx after loading the program/Attaching a debugger to the process. Then only it works.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pushing Daisies
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Godzilla
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Using gvim as frontend for dbx"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation


.