-
Notifications
You must be signed in to change notification settings - Fork 11
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
Updating to support Python3 #1
base: master
Are you sure you want to change the base?
Conversation
* updating README * install notes, lldb help commands, configuration * using pyx to support python/python3 * removing pathogen dependency * updating error messages to use pyx * fixing path to python-vim-lldb * moving cursor binding to augroup * this allows targeted unbinding in the case that imports fail * adding bind/unbind ability to cursor * adding entrance guards * vim > v8 * check lldb exists before binding and allowing custom path to lldb * prevents vim lockup if lldb fails to import * fixing buffer append output * lldb output parsing - escaping ansi for cleaner output * adding async user option * updating vimrc customization naming * adding asci escaping to status line output * refactoring sign coloring and adding default hl groups * updating readme for custom overrides * updating lldb commands * bumping required vim down to 8.1.0 * updating error messaging
README.md
Outdated
vim-lldb | ||
======== | ||
|
||
LLDB debugging in Vim for Python2 and Python3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the common formatting is Python 2
and Python 3
.
README.md
Outdated
3.7.6 (default, ...) | ||
|
||
|
||
If python versions are mismatched, either recompile Vim to match the same version as LLDB or vice-versa. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could maybe point to https://lldb.llvm.org/resources/caveats.html for some more details.
if not os.path.exists(lldb_minus_p_path): | ||
# lldb -P returned invalid path, probably too old | ||
pass | ||
else: | ||
sys.path.append(lldb_minus_p_path) | ||
# print("DEBUG: importing from sys.path as lldb: %s"% lldb_minus_p_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this.
python-vim-lldb/import_lldb.py
Outdated
@@ -51,10 +60,12 @@ def import_lldb(): | |||
# Unable to import lldb module from path returned by `lldb -P` | |||
pass | |||
|
|||
# On Mac OS X, use the try the default path to XCode lldb module | |||
# On Mac OS X, try the default path to XCode lldb module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/XCode/Xcode/
python-vim-lldb/import_lldb.py
Outdated
if "darwin" in sys.platform: | ||
xcode_python_path = "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/Current/Resources/Python/" | ||
python_major_version = vim.eval("s:lldb_python_version") | ||
xcode_python_path = "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/Current/Resources/Python%s/"% python_major_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path for Python 2 is not /Python2/
but just Python
, so for Python 2 you'll want to append nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming of that variable is a bit misleading. In the case of Python 2 support, it resolves to an empty string. A better name like xcode_path_modifier
might make this more clear?
python-vim-lldb/lldb_controller.py
Outdated
@@ -93,6 +102,7 @@ def completeCommand(self, a, l, p): | |||
p = int(p) - 1 | |||
|
|||
result = lldb.SBStringList() | |||
# print("DEBUG: completeCommand result : %s"% result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
* updating README * correcting Python, Xcode naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried loading the plugin on macOS:
$ defaults write com.apple.dt.lldb DefaultPythonVersion 2 # Force lldb to use Python 2
$ /usr/bin/vim # System vim build against system Python 2
Vim would hang on launch. Have you seen something like this during development? I'll build an lldb against Python 3 (from Homebrew) to try out the Python 3 support.
README.md
Outdated
(lldb) script | ||
Python Interactive Interpreter | ||
>>> import sys | ||
>>> print(svs.version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/svs/sys/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also make this a one-liner:
lldb -b -o "script import sys; print(sys.version)"
* one liner test for lldb's python interpreter
What version of Vim are you running? I believe I used Python 2.7.16 when I tested support originally using Vim 8.2. I'll rebuild with a 2.x and see if I run into this. |
I wonder if setting the defaults to Python 2 as you have done in the bash snippet may be the issue. On your machine, are you able to import lldb as a module from the Python 2 interpreter? I tried recreating your env: set lldb defaults to Python 2 with lldb compiled against Python 3. I pulled the latest from the llvm repo to try building lldb fresh against Python 2. I used to set The only other cause I can think of for the plugin to hang on launching a debug session, is if an admin auth is needed for the lldb cert and the password prompt opens up in the background. Without admin rights, Vim would block until those were granted, i.e., typing in the admin pw. |
I'm using the system vim in
which is compiled with Python 2:
The configuration I'm testing is using only "system" tools, e.g. the
It did not, I just hung until I killed it after a few minutes. |
It might be the problem but that's one of the few scenario that we guarantee that should work. Yes, I can import lldb into the system Python 2 interpreter. As explained on https://lldb.llvm.org/resources/caveats.html it is not possible to import it into a third-party (e.g. Homebrew) Python 2 interpreter. T
This code is not available upstream and only applies to the LLDB shipped in Xcode. Rather than linking statically against one Python version, like the open source version does, it dlopen's a different script interpreter dylib that's build against the system Python 2 or the Xcode Python 3 respectively.
I hadn't reached that point yet but that sounds like a valid concern we should check. |
Anyway, the situations that should be guaranteed to work are:
I checked scenario (1) because it's the easiest to sanity check for users. |
Will do. I have only checked against open souce LLDB builds so I will get all these scenarios sorted then update this PR with any changes. |
I've been trying to use this PR, since the vim package on my distribution (debian stable) supports only python 3. I've not been able to get it to work. I'm using the lldb packages from the llvm repo directly and have verified that lldb is linked against the exact same python version. When I use the version from this PR, vim is somehow messed up. Syntax highlighing doesn't work, and in the bottom of the screen it shows Any guesses as to what is wrong here? |
Does Vim output any error messaging on startup? Also, does the syntax highlighting issue happen after you load a target file? |
* updating xcode path var * adding native package manager to installation notes
Vim uses 2 single quotes to escape a single quote for use by `echo`. This fixes a bug if LLDB's output contains a single quote, e.g., in a help menu
I don't see any error messages from vim. I have tried opening vim without opening a file, and when I do this, I get the usual startup message, but it's all on the last line (where you normally type commands and see line numbers. I get something like this:
The vim version used is 8.1 (2018 May 18, compiled Jun 15 2019 16:41:15), which is the version available in the debian stable repository. I have not installed any key mappings. The only entry in I don't think there's anything special about the j and k keys, or the way they are mapped. It's just that the whole console is somewhat garbled, and doing any kind of cursor movement changes how exactly it's messed up. I get the same thing if I use the arrow-up or arrow-down keys with |
I was able to recreate this with a Red Hat distro. It looks like the debugger hijacks the main Vim thread on initialization. My guess is this will affect any *nix distro. I will work on a patch for this and merge into the PR. |
Any Update on this? Would be great to have this working with Python3. |
I have a complete rewrite under development right now. This issue and a few other concurrency-related bugs dealing with targeted processes warranted an architectural shift, primarily, to a client/server model. I will post an update here once the plugin reaches a more functional level. |
Thanks for the update! Looking forward to trying the rewrite! |
@67hz Please let me know if I can help with anything. I'd be very happy to try things out on a variety of linux setups and with different lldb versions. |
@omartijn I could definitely use help on platform testing and portability. I will clean up the cruft and shoot over the repo link. It has not reached feature parity with the original, but it does play nice with Vim. |
I've submitted an alternative since I don't think we need to support python2 anymore #4 |
* install notes, lldb help commands, configuration
* prevents vim lockup if lldb fails to import