jingham added a comment.

In D112973#3101602 <https://reviews.llvm.org/D112973#3101602>, @JDevlieghere 
wrote:

> I feel like this puts too much Python specific logic in the driver compared 
> to the convenience it brings. Even though we already leak python details 
> (like `--python-path`), LLDB has always been designed to support several 
> scripting languages. I'm not convinced this use case is compelling enough to 
> make the situation worse.
>
> FWIW `crashlog.py` has a good example of how to import LLDB. It's complicated 
> slightly by us having to honor the `LLDB_DEFAULT_PYTHON_VERSION`, but 
> otherwise it's pretty simple:
>
>   try:
>       import lldb
>   except ImportError:
>       lldb_python_path = subprocess.check_output(['xcrun', 'lldb', 
> '-P']).decode("utf-8").strip()
>       if os.path.exists(lldb_python_path) and not 
> sys.path.__contains__(lldb_python_path):
>           sys.path.append(lldb_python_path)
>           import lldb
>
> A potential alternative to this could be an `lldb-python` (python) script 
> that reinvokes itself with the correct `PYTHONPATH` set?

I don't think that fits exactly with what Larry's patch is doing.  The lldb 
vrs. Python problem is two-fold, one problem is finding some lldb module 
somewhere, but the other is making sure that the python you pick (should you 
have multiple on your system) is the one that's going to work with the lldb 
module your lldb is going to find for you.

The solutions we have to this problem all assume you've ALREADY found the right 
python, now you just have to find some lldb module.  OTOH lldb-python uses the 
Python library that lldb loads to find the right python executable and match it 
to the right lldb module.

This isn't 100% necessary: once you've found your lldb, you could just continue 
to use lldb, employing the script command to feed the Python interpreter.  But 
I can see how you might want Python to be in control, and this solution makes 
that use case less error-prone.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112973/new/

https://reviews.llvm.org/D112973

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to