vadimcn / codelldb

A native debugger extension for VSCode based on LLDB
https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
MIT License
2.43k stars 237 forks source link

Error when starting lldb.exe #913

Open Drllap opened 1 year ago

Drllap commented 1 year ago

OS: Windows VSCode version: 1.77.3 CodeLLDB version: v1.9.0 Compiler: N/A Debuggee: N/A

  1. Open up the lldb.exe from terminal
  2. A python error is thrown:
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:/Users/noob-destroyer/.vscode/extensions/vadimcn.vscode-lldb-1.9.0/lldb/lib/lldb-python\lldb\embedded_interprete
    r.py", line 29, in <module>
    if 'libedit' in readline.__doc__:
    TypeError: argument of type 'NoneType' is not iterable

    It seems that this error results in the python environment not being probably setup. When I try to run the script command in the lldb REPL I get the following error:

    (lldb) script
    Traceback (most recent call last):    
    File "<string>", line 1, in <module>
    NameError: name 'run_one_line' is not defined
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    NameError: name 'run_one_line' is not defined
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    NameError: name 'run_one_line' is not defined
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    NameError: name 'run_one_line' is not defined
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    NameError: name 'run_one_line' is not defined
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    NameError: name 'run_one_line' is not defined
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    NameError: name 'run_python_interpreter' is not defined
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    NameError: name 'lldb' is not defined
    (lldb)
Drllap commented 1 year ago

In lldb/lib/lldb-python/lldb/embedded_interpreter.py the imported readline module is from my installed python: print(type(readline)) gives C:\Users\<user>\AppData\Roaming\Python\Python39\site-packages\readline.py.

It appears that lldb is loading readline from a python outside the embedded one? Is this intended?

Drllap commented 1 year ago

BTW, I don't get this error when using the vanilla LLVM LLDB and I am able to use the script command when in the REPL

Drllap commented 1 year ago

I don't understand how lldb is finding my installed python. If I remove all python related things from my path, it still imports readline from my local installation.

vadimcn commented 1 year ago

Do you have Python-specific environment variables (like PYTHONPATH) set up?

Drllap commented 1 year ago

no, not that I can find. This is probably because I'm using miniconda and I don't have any environment active..

It is beyond me how lldb is still picking it up.

vadimcn commented 1 year ago

Actually, can you please clarify what did you mean by "Open up the lldb.exe from terminal"?

Drllap commented 1 year ago

Actually, can you please clarify what did you mean by "Open up the lldb.exe from terminal"?

So, I'm not using the "DEBUG CONSOLE" in vscode. When I did that I got some generic error about something not being right (basically don't remember what exactly it was). So I opened my terminal emulator (WezTerm) running PowerShell and cd to the lldb.exe file in the .~\vscode\extensions\valdimcn....

There I just run ./lldb.exe. There I can see the actual error where the "DEBUG CONSOLE" hides them.

vadimcn commented 1 year ago

Sorry, I don't think I'll be much help in diagnosing this. This issue seems to be specific to your machine configuration, so you will need to do the detective work to figure out how lldb ends up finding your external Python installation. Once we know how this happens, we can discuss possible fixes.