Wikia

Vim Tips Wiki

Changes: Using gvim as frontend for dbx

Edit

Back to page

(enhanced the implementation)
(Change <tt> to <code>, perhaps also minor tweak.)
Line 4: Line 4:
 
|previous=378
 
|previous=378
 
|next=381
 
|next=381
|created=December 2, 2002
+
|created=2002
 
|complexity=basic
 
|complexity=basic
 
|author=Dirk Volkmar
 
|author=Dirk Volkmar
Line 88: Line 88:
 
</pre>
 
</pre>
   
Now, Ctrl-D will open the current dbx file and line (mnemonic: d for debug). <tt>,v</tt> will open up a listing of variables (mnemonic: v for variables).
+
Now, Ctrl-D will open the current dbx file and line (mnemonic: d for debug). <code>,v</code> 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.
 
With only this, you can have a pretty good debugging setup with just vim and dbx.
Line 111: Line 111:
 
The alias would look like
 
The alias would look like
 
<pre>alias z="source ~/.dbx.comm"</pre>
 
<pre>alias z="source ~/.dbx.comm"</pre>
It should go in your <tt>~/.dbxrc</tt> file.
+
It should go in your <code>~/.dbxrc</code> file.
   
 
==Comments==
 
==Comments==

Revision as of 05:27, July 13, 2012

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

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.

Comments

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


Around Wikia's network

Random Wiki