LLDB module import paths

Hello,

We build Swift code in a location different from where sources live and
having a bunch of issues with LLDB in such a setup.

One of the problems is LLDB not being able to import the modules referenced
from binaries we build:
error: Error in auto-import:
failed to get module '<module name>' from AST context

It looks like LLDB gets module search paths from a few sources:

1. The compiler command line stored into DWARF. We could add a -I flag
here, like SPM does, but our paths are all relative. And Xcode starts LLDB
with CWD = /. This does not work in principle.

2. There's the target.swift-module-search-paths setting. But it does not
work in my experimentation, I suspect this is because it feeds into
framework search paths, as evidenced here
swift-lldb/SwiftASTContext.cpp at master · apple/swift-lldb · GitHub.
Is that a bug or intentional?

3. Anything else? Is there a flag similar to -compilation-dir flag on GDB
that would root all of the relative paths found in DWARF/modules to a
specific path?

Hm actually it looks like the code I mentioned in (2) is not even executed
in this case. The flow goes through if (module) {} block and does not care
about target.swift-module-search-paths.

···

On Mon, Aug 22, 2016 at 5:08 PM Dmitry Shevchenko <dmishe@google.com> wrote:

Hello,

We build Swift code in a location different from where sources live and
having a bunch of issues with LLDB in such a setup.

One of the problems is LLDB not being able to import the modules
referenced from binaries we build:
error: Error in auto-import:
failed to get module '<module name>' from AST context

It looks like LLDB gets module search paths from a few sources:

1. The compiler command line stored into DWARF. We could add a -I flag
here, like SPM does, but our paths are all relative. And Xcode starts LLDB
with CWD = /. This does not work in principle.

2. There's the target.swift-module-search-paths setting. But it does not
work in my experimentation, I suspect this is because it feeds into
framework search paths, as evidenced here
https://github.com/apple/swift-lldb/blob/master/source/Symbol/SwiftASTContext.cpp#L2009\.
Is that a bug or intentional?

3. Anything else? Is there a flag similar to -compilation-dir flag on GDB
that would root all of the relative paths found in DWARF/modules to a
specific path?