Vim Tips Wiki

Using gvim as frontend for dbx

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 380 Printable Monobook Previous Next

created 2002 · complexity basic · author Dirk Volkmar · version 6.0

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 --servername DBX --remote-silent $vfile +$vlineno"
when stop { gvim --servername DBX --remote-silent $vfile +$vlineno ;}

When the debugger stops it shows you the current position in gvim. The first stop will open a new gvim window and then every other update will reuse the previously opened window. My gvim doesn't take the focus, I don't know why, 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).

It doesn't work at the first stop after attaching to a process. This is probably for the best though as this stop is typically in a system call with no source code.

Alternate ImplementationEdit

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
# 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.

Sending commands to dbx from VimEdit

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.


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

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki