summaryrefslogtreecommitdiffstats
path: root/lldb/utils/vim-lldb/python-vim-lldb/vim_signs.py
diff options
context:
space:
mode:
authorDaniel Malea <daniel.malea@intel.com>2013-02-11 17:18:14 +0000
committerDaniel Malea <daniel.malea@intel.com>2013-02-11 17:18:14 +0000
commitac4ce0cd4a5562faf71fd88d8c72dbb0edf312e8 (patch)
tree327008ce2d06c3bbee826bd5e3d31b8c260e3a52 /lldb/utils/vim-lldb/python-vim-lldb/vim_signs.py
parent09995ac0693adaa899015dec8fff528a278099c1 (diff)
downloadbcm5719-llvm-ac4ce0cd4a5562faf71fd88d8c72dbb0edf312e8.tar.gz
bcm5719-llvm-ac4ce0cd4a5562faf71fd88d8c72dbb0edf312e8.zip
Add Vim frontend to LLDB.
- Access any LLDB CLI command in Vim by typing ":L<command>". Tab-completion works too! - See source locations for breakpoints and the current PC with vim "marks" and highlights. - Examine backtraces, locals, disassembly, registers, and breakpoints in dedicated Vim windows. - See when in-scope variables and registers change by watching for (red) highlights. This plugin opens multiple Vim "windows" to display debugger information. To quit all windows at the same time use ":qa". The alternative would be ":q" to close each window separately. This plugin is known to work on Mac OS X (Mountain Lion) with MacVim and the system-provided terminal Vim, and on Linux (Ubuntu 12.04 and 12.10) with GVim and the terminal Vim from the "vim-gnome" package. llvm-svn: 174892
Diffstat (limited to 'lldb/utils/vim-lldb/python-vim-lldb/vim_signs.py')
-rw-r--r--lldb/utils/vim-lldb/python-vim-lldb/vim_signs.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/lldb/utils/vim-lldb/python-vim-lldb/vim_signs.py b/lldb/utils/vim-lldb/python-vim-lldb/vim_signs.py
new file mode 100644
index 00000000000..926cc29a7fc
--- /dev/null
+++ b/lldb/utils/vim-lldb/python-vim-lldb/vim_signs.py
@@ -0,0 +1,73 @@
+
+# Classes responsible for drawing signs in the Vim user interface.
+
+import vim
+
+class VimSign(object):
+ SIGN_TEXT_BREAKPOINT_RESOLVED = "B>"
+ SIGN_TEXT_BREAKPOINT_UNRESOLVED = "b>"
+ SIGN_TEXT_PC = "->"
+ SIGN_HIGHLIGHT_COLOUR_PC = 'darkblue'
+
+ # unique sign id (for ':[sign/highlight] define)
+ sign_id = 1
+
+ # unique name id (for ':sign place')
+ name_id = 1
+
+ # Map of {(sign_text, highlight_colour) --> sign_name}
+ defined_signs = {}
+
+ def __init__(self, sign_text, buffer, line_number, highlight_colour=None):
+ """ Define the sign and highlight (if applicable) and show the sign. """
+
+ # Get the sign name, either by defining it, or looking it up in the map of defined signs
+ key = (sign_text, highlight_colour)
+ if not key in VimSign.defined_signs:
+ name = self.define(sign_text, highlight_colour)
+ else:
+ name = VimSign.defined_signs[key]
+
+ self.show(name, buffer.number, line_number)
+ pass
+
+ def define(self, sign_text, highlight_colour):
+ """ Defines sign and highlight (if highlight_colour is not None). """
+ sign_name = "sign%d" % VimSign.name_id
+ if highlight_colour is None:
+ vim.command("sign define %s text=%s" % (sign_name, sign_text))
+ else:
+ self.highlight_name = "highlight%d" % VimSign.name_id
+ vim.command("highlight %s ctermbg=%s guibg=%s" % (self.highlight_name,
+ highlight_colour,
+ highlight_colour))
+ vim.command("sign define %s text=%s linehl=%s texthl=%s" % (sign_name,
+ sign_text,
+ self.highlight_name,
+ self.highlight_name))
+ VimSign.defined_signs[(sign_text, highlight_colour)] = sign_name
+ VimSign.name_id += 1
+ return sign_name
+
+
+ def show(self, name, buffer_number, line_number):
+ self.id = VimSign.sign_id
+ VimSign.sign_id += 1
+ vim.command("sign place %d name=%s line=%d buffer=%s" % (self.id, name, line_number, buffer_number))
+ pass
+
+ def hide(self):
+ vim.command("sign unplace %d" % self.id)
+ pass
+
+class BreakpointSign(VimSign):
+ def __init__(self, buffer, line_number, is_resolved):
+ txt = VimSign.SIGN_TEXT_BREAKPOINT_RESOLVED if is_resolved else VimSign.SIGN_TEXT_BREAKPOINT_UNRESOLVED
+ super(BreakpointSign, self).__init__(txt, buffer, line_number)
+
+class PCSign(VimSign):
+ def __init__(self, buffer, line_number, is_selected_thread):
+ super(PCSign, self).__init__(VimSign.SIGN_TEXT_PC,
+ buffer,
+ line_number,
+ VimSign.SIGN_HIGHLIGHT_COLOUR_PC if is_selected_thread else None)
OpenPOWER on IntegriCloud