Bug 1817094 - lldb is missing python modules in swift-lang
Summary: lldb is missing python modules in swift-lang
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: swift-lang
Version: 31
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Ron Olson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-03-25 14:56 UTC by Benjamin Kahn
Modified: 2020-04-12 02:08 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-12 02:08:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Benjamin Kahn 2020-03-25 14:56:42 UTC
Description of problem:
Trying to use Visual Studio Code to debug a swift program. The code extension CodeLLDB is trying to use LLDB's python to analyze the application state.

It uses the following command in LLDB to determine configuration:

/usr/libexec/swift-lldb/lldb  -b -O 'script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")'

The output from /usr/libexec/swift-lldb/lldb is:

(lldb) script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.7/site-packages/lldb/__init__.py", line 1081, in <module>
    eSectionTypeDWARFDebugTypesDwo = _lldb.eSectionTypeDWARFDebugTypesDwo
AttributeError: module '_lldb' has no attribute 'eSectionTypeDWARFDebugTypesDwo'
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
error: python failed attempting to evaluate 'print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")'

The system package lldb returns:
$ /usr/bin/lldb  -b -O 'script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")'
(lldb) script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")
<!/usr/lib64!>
<!/usr/bin!>

Version-Release number of selected component (if applicable):
swift-lang-5.1.5-0.3.20200305git30c042c.fc31.x86_64

How reproducible:
Every time

Steps to Reproduce:
1. Install swift-lang
2. Run: /usr/libexec/swift-lldb/lldb  -b -O 'script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")'

Actual results:
Error shown above

Expected results:
<!/usr/lib/swift!>
<!/usr/libexec/swift-lldb!>

Additional info:
I've filed this ticket against the VSCode extension here: https://github.com/vadimcn/vscode-lldb/issues/281 before realizing this was a problem with the Fedora package. More information may be there.

Comment 1 Ron Olson 2020-03-25 14:59:36 UTC
Hey Ben-

Do you know if this worked before 5.1.5?

Comment 2 Benjamin Kahn 2020-03-25 15:07:07 UTC
Sorry, I only tried this for the first time last week. If you want, I can try to download an old package and try.

Comment 3 Ron Olson 2020-03-25 15:10:38 UTC
Might be useful. FYI Apple released Swift 5.2 yesterday and I'm trying to get that working with Fedora (it has been surprisingly difficult); I'll look into this and see if it's a simple fix, otherwise are you okay waiting for 5.2?

Comment 4 Ron Olson 2020-03-25 20:24:54 UTC
So, as an update: I tested the line above using an official Ubuntu version and, yes, it does work. Funny enough, using the official Ubuntu 5.2 release it does *not* work; it gives the same error. Still looking into it.

Comment 5 Ron Olson 2020-03-25 20:36:21 UTC
As a *further* update, I see the issue; I am not packaging the "python2.7" directory which includes the lldb module that causes the error. This is currently hard-coded to live in /usr/lib so that's a problem. ;) Also, the reason why it doesn't work in 5.2 is because, surprise, they don't include the "python2.7" directory at all. This is all checked against the official Ubuntu versions downloaded from https://swift.org. 

They also started writing some header files to /usr/local/include for the IndexStore; I have to evaluate how this is going to work as a package going forward.

Comment 6 Benjamin Kahn 2020-03-25 21:23:30 UTC
Ugh. I'm shocked by a lot of this: the hard coded paths, the inability to scan the paths from a path search, and the reliance on python 2.7. I was hoping this was a simple fix! :)

Comment 7 Ron Olson 2020-04-06 21:30:10 UTC
FYI I asked the packaging committee about changing how Swift is packaged (https://pagure.io/packaging-committee/issue/966); hopefully it will make using Swift, even in VSCode, a lot easier. I've been testing my proposal and so far it's been working well. Just keeping you informed about what's going on.

Comment 8 Ron Olson 2020-04-10 14:10:35 UTC
Hey Ben-

FYI I submitted 5.2.1 for testing. I reorganized the package and Sourcekit-LSP worked with NeoVim right away; dunno what the plugin for VSCode will say about it, but in my testing everything has been working well and is a lot easier to maintain and don't have to deal with modifying code to look in *other* hard-coded places than the ones it's already looking for. ;)

Here's the links to the builds if you want to give it a go:

https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2020-42b57fbd27
https://bodhi.fedoraproject.org/updates/FEDORA-2020-aae36b1366
https://bodhi.fedoraproject.org/updates/FEDORA-2020-97a74de7d6
https://bodhi.fedoraproject.org/updates/FEDORA-2020-579503009b

Comment 9 Benjamin Kahn 2020-04-10 14:17:21 UTC
That's fantastic! I'll test them today.

Comment 10 Benjamin Kahn 2020-04-11 04:27:39 UTC
The test code still didn't work. I don't see the python2.7 directory in the swift-lang package.

$ /usr/libexec/swift/bin/lldb  -b -O 'script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")'(lldb) script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.7/site-packages/lldb/__init__.py", line 14097, in <module>
    target = SBTarget()
  File "/usr/lib64/python3.7/site-packages/lldb/__init__.py", line 9443, in __init__
    _lldb.SBTarget_swiginit(self, _lldb.new_SBTarget(*args))
AttributeError: module '_lldb' has no attribute 'SBTarget_swiginit'
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
error: python failed attempting to evaluate 'print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")'

Comment 11 Ron Olson 2020-04-11 14:05:18 UTC
Hey Ben-

Right, 5.2.1 doesn't include a Python runtime at all; I think the onus will be on the plugin author to update his code; I also checked the latest 5.3 build on Ubuntu and it seems a "python" directory within the Swift toolchain has been removed going forward. 

FWIW, NeoVim works great with the SourceKit LSP in 5.2.1.

Comment 12 Benjamin Kahn 2020-04-11 14:55:54 UTC
It works! I have these settings in vscode's settings.json file:

{
    "telemetry.enableTelemetry": false,
    "sde.languageServerMode": "sourcekit-lsp",
    "sourcekit-lsp.serverPath": "/usr/bin/sourcekit-lsp",
    "swift.languageServerPath": "/usr/bin/langserver-swift",
    "[swift]": {},
    "lldb.executable": "/usr/libexec/swift/bin/lldb",
    "lldb.libpython": "/lib64/libpython3.7m.so.1.0",
    "lldb.library": "/usr/libexec/swift/lib/liblldb.so.7.0.0svn",
    "lldb.adapterEnv": { "LLDB_DEBUGSERVER_PATH": "/usr/libexec/swift/bin/lldb-server" }
}

It looks like /usr/bin/langserver-swift no longer exists in the swift-lang package though it doesn't seem to cause any issues.

Comment 13 Ron Olson 2020-04-11 17:32:47 UTC
Awesome! Okay to close this bug?

Comment 14 Benjamin Kahn 2020-04-11 17:37:10 UTC
sure.


Note You need to log in before you can comment on or make changes to this bug.