From 20045b29413203b3ef892161b8fedc967c1cd7bc Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 29 May 2018 01:48:37 +0100 Subject: [PATCH] Support the lldb debugger The advantage of this one is that it has globals and statics in the variables and runs directly in lldb. It can also show disassembly, though we don't yet support that. The disadvantage is that this is yet another plugin that plays fast and loose with the protocol, so we have to add a bunch more gets. --- .vimspector.json | 22 +++++++++++++++++++ python3/vimspector/code.py | 4 ++-- .../vimspector/debug_adapter_connection.py | 3 ++- python3/vimspector/output.py | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.vimspector.json b/.vimspector.json index a2fb97a..256a279 100644 --- a/.vimspector.json +++ b/.vimspector.json @@ -28,6 +28,17 @@ "node", "/Users/ben/.vscode/extensions/rogalmic.bash-debug-0.2.0/out/bashDebug.js" ] + }, + "lldb": { + "name": "lldb", + "command": [ + "lldb", + "-b", + "-O", + "command script import '/Users/ben/.vscode/extensions/vadimcn.vscode-lldb-0.8.7/adapter'", + "-O", + "script adapter.main.run_stdio_session()" + ] } }, "configurations": { @@ -97,6 +108,17 @@ "showDebugOutput": true, "trace": true } + }, + "lldb launch": { + "adapter": "lldb", + "configuration": { + "type": "lldb", + "request": "launch", + "name": "LLDB: Launch", + "program": "/Users/ben/Development/vim/src/vim", + "args": [], + "cwd": "/Users/ben/Development/vim" + } } } } diff --git a/python3/vimspector/code.py b/python3/vimspector/code.py index 2329c20..8d5908c 100644 --- a/python3/vimspector/code.py +++ b/python3/vimspector/code.py @@ -56,13 +56,13 @@ class CodeView( object ): vim.command( 'sign unplace {0}'.format( self._signs[ 'vimspectorPC' ] ) ) self._signs[ 'vimspectorPC' ] = None - if not frame or not frame[ 'source' ]: + if not frame or not frame.get( 'source' ): return False vim.current.window = self._window buffer_number = int( vim.eval( 'bufnr( "{0}", 1 )'.format( - frame[ 'source' ][ 'path' ] ) ) ) + frame[ 'source' ].get( 'path', '???' ) ) ) ) try: vim.command( 'bu {0}'.format( buffer_number ) ) diff --git a/python3/vimspector/debug_adapter_connection.py b/python3/vimspector/debug_adapter_connection.py index c4a137d..7489747 100644 --- a/python3/vimspector/debug_adapter_connection.py +++ b/python3/vimspector/debug_adapter_connection.py @@ -139,7 +139,8 @@ class DebugAdapterConnection( object ): handler( message ) else: self._logger.error( - 'Request failed: {0}'.format( message[ 'message' ] ) ) + 'Request failed: {0}'.format( + message.get( 'message' ) or '' ) ) utils.UserMessage( 'Request failed: {0}'.format( message[ 'message' ] ), persist = True ) elif message[ 'type' ] == 'event': diff --git a/python3/vimspector/output.py b/python3/vimspector/output.py index 5aa50ba..c74fe3e 100644 --- a/python3/vimspector/output.py +++ b/python3/vimspector/output.py @@ -27,7 +27,7 @@ class OutputView( object ): self.ShowOutput( 'stdout' ) def OnOutput( self, event ): - category = event[ 'category' ] + category = event.get( 'category' ) or 'output' if category not in self._buffers: self._CreateBuffer( category )