#1 Le 04/02/2011, à 04:24
- ehmicky
[Vim]Pyclewn (intégration GDB dans Vim)
Salut à tous,
J'utilise Vim comme IDE, et Pyclewn est un plugin qui intègre GDB dans Vim (et qui utilise notamment Netbeans pour cela).
Cela marche impeccable : mon écran est partagée en deux fenêtres : une pour le source, une pour GDB. Seulement, je n'obtiens que l'output de GDB. La sortie standard (et l'entrée standard) du programme débuggué sont redirigés vers /dev/null et non vers la fenêtre Vim, parmi l'output de GDB. Je peux utiliser la commande GDB tty pour les rediriger vers un nouveau terminal, mais j'aimerais les rediriger directement dans Vim.
Quelqu'un saurait-il si c'est possible ? Merci !
Edit : pour info, Pyclewn est consitué seulement de deux wrappers :
- /usr/local/bin/pyclewn :
#!/usr/bin/python
import clewn.vim as vim
vim.main()
- ~/.vim/plugin/pyclewn.vim
" pyclewn run time file
" Maintainer: <xdegaye at users dot sourceforge dot net>
"
" Configure VIM to be used with pyclewn and netbeans
"
" pyclewn version
let g:pyclewn_version = "pyclewn-1.5"
" enable balloon_eval
if has("balloon_eval")
set ballooneval
set balloondelay=100
endif
" The 'Pyclewn' command starts pyclewn and vim netbeans interface.
command -nargs=* -complete=file Pyclewn call pyclewn#StartClewn(<f-args>)
de quelques fichiers de configuration de touches clavier (que j'utilise pas), et le plugin principal se trouve à ~/.vim/autoload/pyclewn.vim :
" pyclewn run time file
" Maintainer: <xdegaye at users dot sourceforge dot net>
"
" Configure VIM to be used with pyclewn and netbeans
"
if exists("s:did_pyclewn")
finish
endif
let s:did_pyclewn = 1
" The following variables define how pyclewn is started when
" the ':Pyclewn' vim command is run.
" They may be changed to match your preferences.
let s:pgm = "pyclewn"
if exists("pyclewn_args")
let s:args = pyclewn_args
else
let s:args = "--window=top --maxlines=10000 --background=Cyan,Green,Magenta"
endif
if exists("pyclewn_connection")
let s:connection = pyclewn_connection
else
let s:connection = "localhost:3219:changeme"
endif
" Uncomment the following line to print full traces in a file named 'logfile'
" for debugging purpose.
" let s:args .= " --level=nbdebug --file=logfile"
" The 'Pyclewn' command starts pyclewn and vim netbeans interface.
let s:fixed = "--daemon --editor= --netbeans=" . s:connection . " --cargs="
" Run the 'Cinterrupt' command to open the console
function s:start_pdb(args)
let argl = split(a:args)
if index(argl, "--pdb") != -1
" find the prefix
let prefix = "C"
let idx = index(argl, "-x")
if idx == -1
let idx = index(argl, "--prefix")
if idx == -1
for item in argl
if stridx(item, "--prefix") == 0
let pos = stridx(item, "=")
if pos != -1
let prefix = strpart(item, pos + 1)
endif
endif
endfor
endif
endif
if idx != -1 && len(argl) > idx + 1
let prefix = argl[idx + 1]
endif
" hack to prevent Vim being stuck in the command line with '--More--'
echohl WarningMsg
echo "About to run the 'interrupt' command."
call inputsave()
call input("Press the <Enter> key to continue.")
call inputrestore()
echohl None
exe prefix . "interrupt"
endif
endfunction
" Start pyclewn and vim netbeans interface.
function s:start(args)
if !exists(":nbstart")
throw "Error: the ':nbstart' vim command does not exist."
endif
if has("netbeans_enabled")
throw "Error: netbeans is already enabled and connected."
endif
if !executable(s:pgm)
throw "Error: '" . s:pgm . "' cannot be found or is not an executable."
endif
" the pyclewn generated vim script is sourced only once
if exists("s:tmpfile")
let s:tmpfile = ""
else
let s:tmpfile = tempname()
endif
" remove console and dbgvar buffers from previous session
if bufexists("(clewn)_console")
bwipeout (clewn)_console
endif
if bufexists("(clewn)_dbgvar")
bwipeout (clewn)_dbgvar
endif
" start pyclewn and netbeans
call s:info("Starting pyclewn, please wait...\n")
exe "silent !" . s:pgm . " " . a:args . " " . s:fixed . s:tmpfile . " &"
call s:info("'pyclewn' has been started.\n")
call s:info("Running nbstart, <C-C> to interrupt.\n")
" allow pyclewn to start its dispatch loop, otherwise we will have to
" wait 5 seconds for the second connection attempt by vim
sleep 500m
exe "nbstart :" . s:connection
" source vim script
if has("netbeans_enabled")
if s:tmpfile != ""
if !filereadable(s:tmpfile)
unlet s:tmpfile
nbclose
throw "Error: pyclewn failed to start."
endif
exe "source " . s:tmpfile
endif
call s:info("The netbeans socket is connected.\n")
call s:start_pdb(a:args)
else
throw "Error: the netbeans socket could not be connected."
endif
endfunction
function pyclewn#StartClewn(...)
" command to start pdb: Pyclewn pdb foo.py arg1 arg2 ....
let l:args = s:args
if a:0 != 0
if a:1 == "pdb"
if a:0 == 2 && filereadable(a:2) == 0
call s:error("File '" . a:2 . "' is not readable.")
return
endif
let l:args .= " --pdb"
if a:0 > 1
let l:args .= " --args \"" . join(a:000[1:], ' ') . "\""
endif
else
call s:error("Invalid optional first argument: must be 'pdb'.")
return
endif
endif
try
call s:start(l:args)
catch /.*/
if exists("s:tmpfile") && s:tmpfile != ""
unlet s:tmpfile
endif
call s:info("The 'Pyclewn' command has been aborted.\n")
call s:error(v:exception)
" vim console screen is garbled, redraw the screen
if !has("gui_running")
redraw!
endif
" clear the command line
echo "\n"
endtry
endfunction
function s:info(msg)
echohl WarningMsg
echo a:msg
echohl None
endfunction
function s:error(msg)
echohl ErrorMsg
echo a:msg
call inputsave()
call input("Press the <Enter> key to continue.")
call inputrestore()
echohl None
endfunction
Dernière modification par ehmicky (Le 04/02/2011, à 04:33)
Stego++, bibliothèque libre de stéganographie (avec cryptographie), à venir !
Besoin de votre aide :
Stats sur les compilateurs C++ les plus utilisés
Comment utiliser les archetypes C++ ?
Hors ligne