(Change <tt> to <code>, perhaps also minor tweak.) |
(Fixed spelling of 'servername') Tag: Visual edit |
||
Line 15: | Line 15: | ||
<pre> |
<pre> |
||
− | alias sc=" gvim -- |
+ | alias sc=" gvim --servername DBX --remote-silent $vfile +$vlineno" |
− | when stop { gvim -- |
+ | when stop { gvim --servername DBX --remote-silent $vfile +$vlineno ;} |
</pre> |
</pre> |
||
Line 32: | Line 32: | ||
<pre> |
<pre> |
||
# Functions |
# Functions |
||
− | |||
# Write Current, this will write a line to ~/.dbx.vim |
# Write Current, this will write a line to ~/.dbx.vim |
||
# which will cause vim to open the current file at the current location |
# which will cause vim to open the current file at the current location |
||
Line 38: | Line 37: | ||
echo :e +$vlineno $vfile > $HOME/.dbx.vim |
echo :e +$vlineno $vfile > $HOME/.dbx.vim |
||
} |
} |
||
− | |||
# Write Variables, dumps the values of all variables local to current |
# Write Variables, dumps the values of all variables local to current |
||
# procedure into ~/.dbx.vars |
# procedure into ~/.dbx.vars |
||
Line 55: | Line 53: | ||
done |
done |
||
} |
} |
||
− | |||
# Vim Current, same thing, but will spawn vim |
# Vim Current, same thing, but will spawn vim |
||
function vc { |
function vc { |
||
vim +$vlineno $vfile |
vim +$vlineno $vfile |
||
} |
} |
||
− | |||
# Whens |
# Whens |
||
when stop { wc; } |
when stop { wc; } |
||
− | |||
# Aliases |
# Aliases |
||
− | |||
# Whens |
# Whens |
||
when stop { wc; } |
when stop { wc; } |
||
− | |||
# Aliases |
# Aliases |
||
alias sdb="source ~/.dbxrc" |
alias sdb="source ~/.dbxrc" |
||
Line 99: | Line 92: | ||
# Clear out any displayed variables |
# Clear out any displayed variables |
||
undisplay 0 |
undisplay 0 |
||
− | |||
# Set breakpoint |
# Set breakpoint |
||
stop at dbmulti.c:7043 |
stop at dbmulti.c:7043 |
||
stop at riintfn.c:4128 |
stop at riintfn.c:4128 |
||
− | |||
# Other commands |
# Other commands |
||
</pre> |
</pre> |
Latest revision as of 21:43, 22 May 2014
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 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.