Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start process to debug from Vim #24

Closed
serebrov opened this issue Nov 16, 2012 · 2 comments
Closed

Start process to debug from Vim #24

serebrov opened this issue Nov 16, 2012 · 2 comments

Comments

@serebrov
Copy link

Now vdebug starts only listening process and process to debug should be started manually outside Vim.
For now I use following code in my vimrc to automate the process:

    function! Debug(url)
        let url = a:url
        " add 'http://' if it is not in url
        let http_pos = stridx(url, 'http')
        if http_pos != 0
            let url = 'http://'.url
        endif
        " add 'vim_debug' IDE key to url, this IDE key is also set in vdebug options
        let q_pos = stridx(url, '?')
        if q_pos == -1
            let url = url.'?XDEBUG_SESSION_START=vim_debug'
        else
            let url = url.'&XDEBUG_SESSION_START=vim_debug'
        endif
        " launch browser
        call OpenBrowser(url)
         " start debugging
        python debugger.run()
    endfunction
    command! -nargs=1 Debug call Debug('<args>')

This command allow to launch browser via OpenBrowser plugin and then start vdebug.
I use it like this:

: Debug http://myhost.com/xxx.php

Another one to debug currently edited python script:

    function! DebugPy(...)
        let str_args = join(a:000, ' ')
        " command to launch - uses local path to pydbgp, probably this can be done in a better way
        let last_cmd = '!python -S ~/pydbgp/bin/pydbgp -d localhost:9000 -k vim_debug ' . str_args
        " save last used args, command and its results to files (for debugging of this function)
        execute 'silent !echo "' . str_args . '" > ~/vim.last.arg.txt &'
        execute 'silent !echo "' . last_cmd . '" > ~/vim.last.cmd.txt &'
        " launch command in backgound
        execute 'silent ' . last_cmd . ' > ~/vim.last.out.txt 2> ~/vim.last.err.txt &'
        " start debugging
        python debugger.run()
    endfunction
    command! -nargs=* DebugPy call DebugPy('% <args>')

Now I can do this:

: DebugPy

And debug current python file.

Probably the same can be done in a better way inside the python code and maybe not only for php/python, but for other supported languages as well.

Also another python-based plugin for debugging, vim-debug, can do this

@joonty
Copy link
Collaborator

joonty commented Nov 23, 2012

Thanks for that, looks interesting. When I get a chance I'll start looking how to integrate something like this into Vdebug.

@BlackIkeEagle
Copy link
Member

I think this is somewhat out of the reach of what we can do with vim. It might work but will be very error prone for different browsers, if users use multiple profiles, multiple windows, there will be too many issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants