Port from debugger.py (http://www.vim.org/scripts/script.php?script_id=2218)